ARM: i.MX: allow disabling supervisor protect via DT
Subsystems (3)
PATCH v3 1/2 ARM: i.MX: allow disabling supervisor protect via DT
The i.MX SoCs allow to setup fine grained access rights to peripherals on the AIPS bus.
This is done via the Peripheral Access Register (PAR) in e.g. the i.MX21 or in later SoC versions the Off-Platform Peripheral Access Control Register (OPACR), e.g. i.MX53.
Under certain circumstances this leads to problems in which bus masters are not granted their access rights to peripherals.
To be able to disable these restrictions on DT platforms, add a helper function that looks for AIPS nodes in the DT and disables them for every match it finds. The match table has to be declared in the mach-specific entry file, where this helper function should then be called.
--- arch/arm/mach-imx/common.h | 2 ++ arch/arm/mach-imx/cpu.c | 13 +++++++++++++ 2 files changed, 15 insertions(+)
arch/arm/mach-imx/common.h +2 -0
@@ -19,6 +19,7 @@ struct pt_regs;struct clk ;struct device_node ;enum mxc_cpu_pwr_mode ; +struct of_device_id ;void mx1_map_io (void );void mx21_map_io (void );
@@ -77,6 +78,7 @@ void mxc_arch_reset_init(void __iomem *);void mxc_arch_reset_init_dt (void );int mx53_revision (void );void imx_set_aips (void __iomem *); +void imx_aips_allow_unprivileged_access (const struct of_device_id *of_matches);int mxc_device_init (void );void imx_set_soc_revision (unsigned int rev);unsigned int imx_get_soc_revision (void );
arch/arm/mach-imx/cpu.c +13 -0
@@ -2,6 +2,7 @@#include <linux/module.h> #include <linux/io.h> #include <linux/of.h> +#include <linux/of_address.h> #include <linux/slab.h> #include <linux/sys_soc.h>
@@ -60,6 +61,18 @@ void __init imx_set_aips(void __iomem *base)__raw_writel (reg, base +0x50 ); } +void __init imx_aips_allow_unprivileged_access ( +const struct of_device_id *of_matches) +{ +void __iomem *aips_base_addr; +struct device_node *np; + +for_each_matching_node (np, of_matches) { + aips_base_addr =of_iomap (np,0 ); +imx_set_aips (aips_base_addr); + } +} +struct device *__init imx_soc_device_init (void ) {struct soc_device_attribute *soc_dev_attr;
Signature · 1 line
2.0.0
PATCH v3 2/2 ARM: i.MX53: globally disable supervisor protect
Most peripherals on the i.MX53 have an
Off-Platform Peripheral Access Control Register (OPACR)
in which the access rights (together with the MPROT registers) can be declared. However, this does not seem to work for example for SSI1+SDMA, because the supervisor bit is not set for the SDMA unit.
It does work for SSI2, the QSB for example uses SSI2 for its audio. But SSI2 only works because it does NOT have an OPACR.
The right solution would be to fix the access rights for the SDMA, but the unit responsible for this is the Central Security Unit (CSU), which of course is NOT documented. So, until documentation for this is openly available, turn off the supervisor protection because it cripples the hardware.
---
Changes in v3:
- move code pattern to helper function in cpu.c
arch/arm/mach-imx/mach-imx53.c | 7 +++++++ 1 file changed, 7 insertions(+)
arch/arm/mach-imx/mach-imx53.c +7 -0
@@ -24,11 +24,18 @@#include "hardware.h" #include "mx53.h" +static const struct of_device_id aips_of_matches[]__initconst = { + { .compatible ="fsl,imx53-aipstz" }, + {/*sentinel*/ } +}; +static void __init imx53_dt_init (void ) {mxc_arch_reset_init_dt ();of_platform_populate (NULL , of_default_bus_match_table,NULL ,NULL ); + +imx_aips_allow_unprivileged_access (aips_of_matches); }static const char *imx53_dt_board_compat[]__initconst = {
Signature · 1 line
2.0.0
PATCH v3 1/2 ARM: i.MX: allow disabling supervisor protect via DT
In reply to Steffen TrumtrarQuoted 51 lines · Steffen Trumtrar
The i.MX SoCs allow to setup fine grained access rights to peripherals on the AIPS bus.
This is done via the Peripheral Access Register (PAR) in e.g. the i.MX21 or in later SoC versions the Off-Platform Peripheral Access Control Register (OPACR), e.g. i.MX53.
Under certain circumstances this leads to problems in which bus masters are not granted their access rights to peripherals.
To be able to disable these restrictions on DT platforms, add a helper function that looks for AIPS nodes in the DT and disables them for every match it finds. The match table has to be declared in the mach-specific entry file, where this helper function should then be called.Signed-off-by Steffen Trumtrar <[email protected]>--- arch/arm/mach-imx/common.h | 2 ++ arch/arm/mach-imx/cpu.c | 13 +++++++++++++ 2 files changed, 15 insertions(+)arch/arm/mach-imx/common.h +2
-0@@ -19,6 +19,7 @@ struct pt_regs;struct clk ;struct device_node ;enum mxc_cpu_pwr_mode ; +struct of_device_id ;void mx1_map_io (void );void mx21_map_io (void );@@ -77,6 +78,7 @@ void mxc_arch_reset_init(void __iomem *);void mxc_arch_reset_init_dt (void );int mx53_revision (void );void imx_set_aips (void __iomem *); +void imx_aips_allow_unprivileged_access (const struct of_device_id *of_matches);int mxc_device_init (void );void imx_set_soc_revision (unsigned int rev);unsigned int imx_get_soc_revision (void );arch/arm/mach-imx/cpu.c +1
-0@@ -2,6 +2,7 @@#include <linux/module.h> #include <linux/io.h> #include <linux/of.h> +#include <linux/of_address.h> #include <linux/slab.h> #include <linux/sys_soc.h>
arch/arm/mach-imx/cpu.c void __init imx_set_aips(void __iomem *base) · line 70
Quoted 10 lines
arch/arm/mach-imx/cpu.c +7
-0@@ -60,6 +61,18 @@ void __init imx_set_aips(void __iomem *base)__raw_writel (reg, base +0x50 ); } +void __init imx_aips_allow_unprivileged_access ( +const struct of_device_id *of_matches) +{ +void __iomem *aips_base_addr; +struct device_node *np; + +for_each_matching_node (np, of_matches) {
Can we use for_each_compatible_node() here, so that the caller only needs to pass a compatible string instead of a match table?
Shawn
Quoted 11 lines
arch/arm/mach-imx/cpu.c +5
-0+ aips_base_addr =of_iomap (np,0 ); +imx_set_aips (aips_base_addr); + } +} +struct device *__init imx_soc_device_init (void ) {struct soc_device_attribute *soc_dev_attr;Signature · 1 line
2.0.0