Commit graph

11 commits

Author SHA1 Message Date
Alex Elder ed24f446ab ARM: bcm: rewrite commentary for bcm_kona_do_smc()
The block of comments in bcm_kona_do_smc() are somewhat confusing.
This patch attempts to clarify what's going on.

Signed-off-by: Alex Elder <elder@linaro.org>
Reviewed-by: Tim Kryger <tim.kryger@linaro.org>
Reviewed-by: Markus Mayer <markus.mayer@linaro.org>
Reviewed-by: Matt Porter <mporter@linaro.org>
Signed-off-by: Matt Porter <mporter@linaro.org>
2014-04-25 08:51:37 -04:00
Alex Elder 8b9c550e37 ARM: bcm: use inline assembly for "smc" request
Move the code that implements the "smc" call into a C function that
uses inline assembly.  This allows us to make that function private,
and enables us to get rid of "arch/arm/mach-bcm/bcm_kona_smc_asm.S".
Rename what had been the "buffer_addr" argument to be "buffer_phys"
so it's consistent with other usage in this file.

Since it's now easy to do, verify that r12 contains SEC_EXIT_NORMAL
upon completion of the SMC.  There really isn't a good way to handle
the abnormal completion of a secure monitor request.

Since "bcm_kona_smc.h" is now only included from C files, eliminate
the #ifndef __ASSEMBLY__.

Signed-off-by: Alex Elder <elder@linaro.org>
Reviewed-by: Tim Kryger <tim.kryger@linaro.org>
Reviewed-by: Markus Mayer <markus.mayer@linaro.org>
Reviewed-by: Matt Porter <mporter@linaro.org>
Signed-off-by: Matt Porter <mporter@linaro.org>
2014-04-25 08:51:36 -04:00
Alex Elder 35138d52f1 ARM: bcm: don't special-case CPU 0 in bcm_kona_smc()
There's logic in bcm_kona_smc() to ensure __bcm_kona_smc() gets
called on CPU 0; if already executing on CPU 0, that function is
called directly.  The direct call is not protected from interrupts,
however, which is not safe.

Note that smp_call_function_single() is designed to handle the case
where the target cpu is the current one.  It also gets a reference
to the CPU and disables IRQs across the call.

So we can simplify things and at the same time be protected against
interrupts by calling smp_call_function_single() unconditionally.

Signed-off-by: Alex Elder <elder@linaro.org>
Reviewed-by: Tim Kryger <tim.kryger@linaro.org>
Reviewed-by: Markus Mayer <markus.mayer@linaro.org>
Reviewed-by: Matt Porter <mporter@linaro.org>
Signed-off-by: Matt Porter <mporter@linaro.org>
2014-04-25 08:51:34 -04:00
Alex Elder 6c90f10864 ARM: bcm: have bcm_kona_smc() return request result
Currently it is assumed that SEC_ROM_RET_OK is the only valid "good"
result of a secure monitor request.  However the values that can be
returned by a secure monitor request are dependent on which service
id was provided.

We therefore should handle the result in a request-dependent way.
The most natural way to do that is to have the initiator of the
request--where bcm_kona_smc() is called--handle the result in a way
appropriate to the request.

An "smc" operation must be performed only on core 0, while the
request can be initiated from any core.  To pass back the request
result, we add a new field to the bcm_kona_smc_data structure, and
have bcm_kona_smc() return that value rather than 0.

There's only one caller right now.  Move the existing check of the
result out of __bcm_kona_smc() and into the kona_l2_cache_init()
where the SSAPI_ENABLE_L2_CACHE request is initiated.

Signed-off-by: Alex Elder <elder@linaro.org>
Reviewed-by: Tim Kryger <tim.kryger@linaro.org>
Reviewed-by: Markus Mayer <markus.mayer@linaro.org>
Reviewed-by: Matt Porter <mporter@linaro.org>
Signed-off-by: Matt Porter <mporter@linaro.org>
2014-04-25 08:51:33 -04:00
Alex Elder c64756cca2 ARM: bcm: clean up SMC code
This patch just does some simple cleanup in "bcm_kona_smc.c":
    - Get rid of the secure_bridge_data structure.  Instead, just
      define two globals that record the physical and virtual
      addresses of the SMC arguments buffer.  Use "buffer" instead
      of "bounce" in their names.  Drop of the erroneous __iomem
      annotation for the physical address.
    - Get rid of the initialized flag and just use a non-null buffer
      address to indicate that.
    - Get the size of the memory region when fetching the SMC
      arguments buffer location from the device tree.  Use it to
      call ioremap() directly rather than requiring of_iomap() to
      go look it up again.
    - Do some additional validation on that memory region size.
    - Flush caches unconditionally in __bcm_kona_smc(); nothing
      supplies SSAPI_BRCM_START_VC_CORE as a service id.
    - Drop a needless initialization of "rc" in __bcm_kona_smc().

It also deletes most of the content of "bcm_kona_smc.h" because it's
never actually used and is of questionable value anyway.

Signed-off-by: Alex Elder <elder@linaro.org>
Reviewed-by: Tim Kryger <tim.kryger@linaro.org>
Reviewed-by: Markus Mayer <markus.mayer@linaro.org>
Reviewed-by: Matt Porter <mporter@linaro.org>
Signed-off-by: Matt Porter <mporter@linaro.org>
2014-04-25 08:51:32 -04:00
Alex Elder 5c4cee2fe8 ARM: bcm: err, don't BUG() on SMC init failures
Several conditions in bcm_kona_smc_init() are handled with BUG_ON().
That function is capable of returning an error, so do that instead.

Also, don't assume of_get_address() returns a valid pointer.

Signed-off-by: Alex Elder <elder@linaro.org>
Reviewed-by: Tim Kryger <tim.kryger@linaro.org>
Reviewed-by: Markus Mayer <markus.mayer@linaro.org>
Reviewed-by: Matt Porter <mporter@linaro.org>
Signed-off-by: Matt Porter <mporter@linaro.org>
2014-04-25 08:51:32 -04:00
Alex Elder e80eef33f4 ARM: bcm: use memory accessors for ioremapped area
The pointer used to pass parameters to an "smc" call is produced
through a call to ioremap().  As such, we should be using functions
like writel() to access it.

Signed-off-by: Alex Elder <elder@linaro.org>
Reviewed-by: Tim Kryger <tim.kryger@linaro.org>
Reviewed-by: Markus Mayer <markus.mayer@linaro.org>
Reviewed-by: Matt Porter <mporter@linaro.org>
Signed-off-by: Matt Porter <mporter@linaro.org>
2014-04-25 08:51:31 -04:00
Christian Daudt 3a76b35186 ARM: bcm: Make secure API call optional
The current bcm_kona_smc_init function throws a BUG_ON if there's no SMC
device node defined in the device tree.

Since secure API access is optional depending the chip configuration,
fix this by allowing the rest of the code to run even if there's no SMC
device node defined

Signed-off-by: Christian Daudt <csd@broadcom.com>
Reviewed-by: Markus Mayer <markus.mayer@linaro.org>
2013-08-20 10:51:39 -07:00
Christian Daudt aea237bfa0 ARM: DT: binding fixup to align with vendor-prefixes.txt (drivers)
[ this is a follow-up to this discussion:
http://archive.arm.linux.org.uk/lurker/message/20130730.230827.a1ceb12a.en.html ]
This patchset renames all uses of "bcm," name bindings to
"brcm," as they were done prior to knowing that brcm had
already been standardized as Broadcom vendor prefix
(in Documentation/devicetree/bindings/vendor-prefixes.txt).
This will not cause any churn on devices because none of
these bindings have made it into production yet.

Signed-off-by: Christian Daudt <csd@broadcom.com>
Acked-by: Stephen Warren <swarren@nvidia.com>
2013-08-20 10:51:38 -07:00
Arnd Bergmann 721e0205b0 ARM: bcm: mark bcm_kona_smc_init as __init
The bcm_kona_smc_init function references the bcm_kona_smc_ids variable
that is marked __initconst, so the function itself has to be __init
to avoid this build error:

WARNING: arch/arm/mach-bcm/built-in.o(.text+0x12c): Section mismatch in reference from the function bcm_kona_smc_init() to the (unknown reference) .init.rodata:(unknown)

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Cc: Christian Daudt <csd@broadcom.com>
2013-04-23 17:43:32 +02:00
Christian Daudt b8eb35fd59 ARM: bcm281xx: Add L2 cache enable code
- Adds a module to provide calls into secure monitor mode
- Uses this module to make secure monitor calls to enable L2 cache.

Updates from V1:
- Split DT portion into separate patch
- replace #ifdef-ed L2 code with "if".
- move init call to board init

Signed-off-by: Christian Daudt <csd@broadcom.com>
Acked-by: Arnd Bergmann <arnd@arndb.de>
2013-04-09 09:18:13 -07:00