Device Tree support for RealView PB11MPCore
Subsystems (8)
cover Device Tree support for RealView PB11MPCore
This patch set gives an almost feature-complete device tree boot on the ARM PM11MPCore platform.
Remains to be done before deleting the board files:
- Flash protection: the board has flash protection through the system controller. Last time I tried to fix this I fried the flash on my PB1176 so I don't know if I dare to mess with this before I've recovered that board (which need to happen using JTAG and old Windows).
- CLCD: how the stuff merged for Vexpress device tree CLCD works is a mystery to me, and ideally the whole shebang should be rewritten to use DRM/KMS. But I guess I can fix it up some time.
The patches may have some rough edges but basically this is how I imagine we should make this work. Most of the code will be reusable for RealView PBx, EB and probably for tidying up some of the Vexpress stuff as well.
Linus Walleij (13):
ARM: add some L220 DT settings
ARM: add DT bindings for the ARM11MPCore CPU cluster
irqchips: fix ARM11MPCore GIC bindings irqchip/gic: support RealView variant setup irqchip/gic: assign irqchip dynamically
clk: versatile-icst: convert to use regmap
clk: versatile-icst: refactor to allocate regmap separately
clk: add ARM syscon ICST device tree bindings
clk: versatile-icst: add device tree support
soc: versatile: add support for the PB11MPCore
ARM: realview: select SP810 and ICST for the DT variant
ARM: realview: add an DT SMP boot method
ARM: realview: add device tree for PB11MPCore
Documentation/devicetree/bindings/arm/cpus.txt | 1 + Documentation/devicetree/bindings/arm/gic.txt | 3 +- Documentation/devicetree/bindings/arm/l2cc.txt | 10 +- Documentation/devicetree/bindings/arm/scu.txt | 3 + .../devicetree/bindings/clock/arm-syscon-icst.txt | 40 ++ arch/arm/boot/dts/Makefile | 3 +- arch/arm/boot/dts/arm-realview-pb11mp.dts | 681 +++++++++++++++++++++ arch/arm/mach-realview/Kconfig | 4 + arch/arm/mach-realview/Makefile | 2 +- arch/arm/mach-realview/platsmp-dt.c | 91 +++ arch/arm/mm/cache-l2x0.c | 15 + drivers/clk/versatile/Kconfig | 1 + drivers/clk/versatile/clk-icst.c | 191 +++++- drivers/irqchip/Makefile | 1 + drivers/irqchip/irq-gic-realview.c | 39 ++ drivers/irqchip/irq-gic-realview.h | 5 + drivers/irqchip/irq-gic.c | 43 +- drivers/soc/versatile/soc-realview.c | 4 + 18 files changed, 1082 insertions(+), 55 deletions(-) create mode 100644 Documentation/devicetree/bindings/clock/arm-syscon-icst.txt create mode 100644 arch/arm/boot/dts/arm-realview-pb11mp.dts create mode 100644 arch/arm/mach-realview/platsmp-dt.c create mode 100644 drivers/irqchip/irq-gic-realview.c create mode 100644 drivers/irqchip/irq-gic-realview.h
Signature · 1 line
2.4.3
PATCH 1/13 ARM: add some L220 DT settings
The RealView ARM11MPCore enables parity, eventmon and shared override in the cache controller through its current boardfile, but the code and DT bindings for the ARM L220 is currently lacking the ability to set this up from DT. Add the required bool parameters.
---
I know this patch mixes code and DT changes but it is silly to split such a small patch. Will submit this to Russell's patch tracker if it looks OK to the DT people. (Or if they are quiet.)
--- Documentation/devicetree/bindings/arm/l2cc.txt | 10 ++++++---- arch/arm/mm/cache-l2x0.c | 15 +++++++++++++++ 2 files changed, 21 insertions(+), 4 deletions(-)
Documentation/devicetree/bindings/arm/l2cc.txt +6 -4
@@ -67,12 +67,14 @@ Optional properties: disable if zero. - arm,prefetch-offset : Override prefetch offset value. Valid values are 0-7, 15, 23, and 31. -- arm,shared-override : The default behavior of the pl310 cache controller with - respect to the shareable attribute is to transform "normal memory - non-cacheable transactions" into "cacheable no allocate" (for reads) or - "write through no write allocate" (for writes). +- arm,shared-override : The default behavior of the PL220 or PL310 cache + controllers with respect to the shareable attribute is to transform "normal + memory non-cacheable transactions" into "cacheable no allocate" (for reads) + or "write through no write allocate" (for writes). On systems where this may cause DMA buffer corruption, this property must be specified to indicate that such transforms are precluded. +- arm,parity-enable : enable parity checking on the L2 cache (PL220 only). +- arm,eventmon-enable : enable the event monitor on the L2 cache (PL220 only). - prefetch-data : Data prefetch. Value: <0> (forcibly disable), <1> (forcibly enable), property absent (retain settings set by firmware) - prefetch-instr : Instruction prefetch. Value: <0> (forcibly disable),
arch/arm/mm/cache-l2x0.c +15 -0
@@ -1060,6 +1060,21 @@ static void __init l2x0_of_parse(const struct device_node *np, val |= (dirty -1 ) <<L2X0_AUX_CTRL_DIRTY_LATENCY_SHIFT ; } +if (of_property_read_bool (np,"arm,parity-enable" )) { + mask &= ~L2C_AUX_CTRL_PARITY_ENABLE ; + val |=L2C_AUX_CTRL_PARITY_ENABLE ; + } + +if (of_property_read_bool (np,"arm,eventmon-enable" )) { + mask &= ~L2C_AUX_CTRL_EVTMON_ENABLE ; + val |=L2C_AUX_CTRL_EVTMON_ENABLE ; + } + +if (of_property_read_bool (np,"arm,shared-override" )) { + mask &= ~L2C_AUX_CTRL_SHARED_OVERRIDE ; + val |=L2C_AUX_CTRL_SHARED_OVERRIDE ; + } + ret =l2x0_cache_size_of_parse (np, aux_val, aux_mask, &assoc,SZ_256K );if (ret)return ;
Signature · 1 line
2.4.3
PATCH 1/13 ARM: add some L220 DT settings
Quoted 27 lines · Linus Walleij
The RealView ARM11MPCore enables parity, eventmon and shared override in the cache controller through its current boardfile, but the code and DT bindings for the ARM L220 is currently lacking the ability to set this up from DT. Add the required bool parameters.
Cc devicetree at vger.kernel.orgSigned-off-by Linus Walleij <[email protected]>---
I know this patch mixes code and DT changes but it is silly to split such a small patch. Will submit this to Russell's patch tracker if it looks OK to the DT people. (Or if they are quiet.)--- Documentation/devicetree/bindings/arm/l2cc.txt | 10 ++++++---- arch/arm/mm/cache-l2x0.c | 15 +++++++++++++++ 2 files changed, 21 insertions(+), 4 deletions(-)Documentation/devicetree/bindings/arm/l2cc.txt +0
-2@@ -67,12 +67,14 @@ Optional properties: disable if zero. - arm,prefetch-offset : Override prefetch offset value. Valid values are 0-7, 15, 23, and 31. -- arm,shared-override : The default behavior of the pl310 cache controller with - respect to the shareable attribute is to transform "normal memory
Documentation/devicetree/bindings/arm/l2cc.txt Optional properties: · line 77
Quoted 10 lines
Documentation/devicetree/bindings/arm/l2cc.txt +6
-2- non-cacheable transactions" into "cacheable no allocate" (for reads) or - "write through no write allocate" (for writes). +- arm,shared-override : The default behavior of the PL220 or PL310 cache + controllers with respect to the shareable attribute is to transform "normal + memory non-cacheable transactions" into "cacheable no allocate" (for reads) + or "write through no write allocate" (for writes). On systems where this may cause DMA buffer corruption, this property must be specified to indicate that such transforms are precluded. +- arm,parity-enable : enable parity checking on the L2 cache (PL220 only). +- arm,eventmon-enable : enable the event monitor on the L2 cache (PL220 only).
I don't think we should introduce a DT property for this: if we support the event monitor, then the event monitor support code should be controlling this bit.
Signature · 2 lines
FTTC broadband for 0.8mile line: currently at 9.6Mbps down 400kbps up according to speedtest.net.
PATCH 1/13 ARM: add some L220 DT settings
Quoted 7 lines · Russell King - ARM Linux
Quoted 1 line · Linus Walleij
+- arm,eventmon-enable : enable the event monitor on the L2 cache (PL220 only).
I don't think we should introduce a DT property for this: if we support the event monitor, then the event monitor support code should be controlling this bit.
OK that's reasonable. I'll make a patch for the parity enable and think about how to implement eventmonitor bit setting.
Yours,
Linus Walleij
Rob Herring
maintainerPATCH 1/13 ARM: add some L220 DT settings
In reply to Linus WalleijQuoted 22 lines · Linus Walleij
The RealView ARM11MPCore enables parity, eventmon and shared override in the cache controller through its current boardfile, but the code and DT bindings for the ARM L220 is currently lacking the ability to set this up from DT. Add the required bool parameters.
Cc devicetree at vger.kernel.orgSigned-off-by Linus Walleij <[email protected]>---
I know this patch mixes code and DT changes but it is silly to split such a small patch. Will submit this to Russell's patch tracker if it looks OK to the DT people. (Or if they are quiet.)--- Documentation/devicetree/bindings/arm/l2cc.txt | 10 ++++++---- arch/arm/mm/cache-l2x0.c | 15 +++++++++++++++ 2 files changed, 21 insertions(+), 4 deletions(-)Documentation/devicetree/bindings/arm/l2cc.txt +0
-0
Documentation/devicetree/bindings/arm/l2cc.txt Optional properties: · line 70
Quoted 8 lines
Documentation/devicetree/bindings/arm/l2cc.txt +1
-4@@ -67,12 +67,14 @@ Optional properties: disable if zero. - arm,prefetch-offset : Override prefetch offset value. Valid values are 0-7, 15, 23, and 31. -- arm,shared-override : The default behavior of the pl310 cache controller with - respect to the shareable attribute is to transform "normal memory - non-cacheable transactions" into "cacheable no allocate" (for reads) or - "write through no write allocate" (for writes). +- arm,shared-override : The default behavior of the PL220 or PL310 cache
PL220 is something else:
http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.ddi0249b/CHDIIEAD.html
Documentation/devicetree/bindings/arm/l2cc.txt Optional properties: · line 73
Quoted 3 lines
Documentation/devicetree/bindings/arm/l2cc.txt +3
-0+ controllers with respect to the shareable attribute is to transform "normal + memory non-cacheable transactions" into "cacheable no allocate" (for reads) + or "write through no write allocate" (for writes).
I seem to recall the PL310 TRM says this bit is different from the L220 or the default is.
Documentation/devicetree/bindings/arm/l2cc.txt Optional properties: · line 76
Quoted 3 lines
Documentation/devicetree/bindings/arm/l2cc.txt +1
-0On systems where this may cause DMA buffer corruption, this property must be specified to indicate that such transforms are precluded. +- arm,parity-enable : enable parity checking on the L2 cache (PL220 only).
PL310 has parity.
Documentation/devicetree/bindings/arm/l2cc.txt Optional properties: · line 77
Quoted 1 line
Documentation/devicetree/bindings/arm/l2cc.txt +1
-0+- arm,eventmon-enable : enable the event monitor on the L2 cache (PL220 only).
and eventmon.
There's a slight problem here in that you can turn on these with DT, but you can't turn them off as absence means don't touch. Maybe a value of 0 should be allowed for disabling.
Quoted 32 lines
Documentation/devicetree/bindings/arm/l2cc.txt +0
-0- prefetch-data : Data prefetch. Value: <0> (forcibly disable), <1> (forcibly enable), property absent (retain settings set by firmware) - prefetch-instr : Instruction prefetch. Value: <0> (forcibly disable),arch/arm/mm/cache-l2x0.c +15
-1@@ -1060,6 +1060,21 @@ static void __init l2x0_of_parse(const struct device_node *np, val |= (dirty -1 ) <<L2X0_AUX_CTRL_DIRTY_LATENCY_SHIFT ; } +if (of_property_read_bool (np,"arm,parity-enable" )) { + mask &= ~L2C_AUX_CTRL_PARITY_ENABLE ; + val |=L2C_AUX_CTRL_PARITY_ENABLE ; + } + +if (of_property_read_bool (np,"arm,eventmon-enable" )) { + mask &= ~L2C_AUX_CTRL_EVTMON_ENABLE ; + val |=L2C_AUX_CTRL_EVTMON_ENABLE ; + } + +if (of_property_read_bool (np,"arm,shared-override" )) { + mask &= ~L2C_AUX_CTRL_SHARED_OVERRIDE ; + val |=L2C_AUX_CTRL_SHARED_OVERRIDE ; + } + ret =l2x0_cache_size_of_parse (np, aux_val, aux_mask, &assoc,SZ_256K );if (ret)return ; --2.4.3
PATCH 2/13 ARM: add DT bindings for the ARM11MPCore CPU cluster
In reply to Linus WalleijThe ARM11MPCore has a Snoop Control Unit, but references to it were missing from the DT specification. Define a compatible string for this unit.
--- Documentation/devicetree/bindings/arm/scu.txt | 3 +++ 1 file changed, 3 insertions(+)
Documentation/devicetree/bindings/arm/scu.txt +3 -0
@@ -10,10 +10,13 @@ References: Revision r2p0 - Cortex-A5: see DDI0434B Cortex-A5 MPCore Technical Reference Manual Revision r0p1 +- ARM11 MPCore: see DDI0360F ARM 11 MPCore Processor Technical Reference + Manial Revision r2p0 - compatible : Should be: "arm,cortex-a9-scu" "arm,cortex-a5-scu" + "arm,arm11mp-scu" - reg : Specify the base address and the size of the SCU register window.
Signature · 1 line
2.4.3
PATCH 3/13 irqchips: fix ARM11MPCore GIC bindings
In reply to Linus WalleijThe GIC bindings for the ARM11MPCore need to differentiate between the GIC on the Test Chip and the one on the evaluation baseboard. Split the binding in two and define new compatible-strings.
--- Documentation/devicetree/bindings/arm/gic.txt | 3 ++- drivers/irqchip/irq-gic.c | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-)
Documentation/devicetree/bindings/arm/gic.txt +2 -1
@@ -15,7 +15,8 @@ Main node required properties: "arm,cortex-a15-gic" "arm,cortex-a9-gic" "arm,cortex-a7-gic" - "arm,arm11mp-gic" + "arm,tc11mp-gic" + "arm,pb11mp-gic" "brcm,brahma-b15-gic" "arm,arm1176jzf-devchip-gic" "qcom,msm-8660-qgic"
drivers/irqchip/irq-gic.c +2 -1
@@ -1184,7 +1184,8 @@ gic_of_init(struct device_node *node, struct device_node *parent)return 0 ; }IRQCHIP_DECLARE (gic_400,"arm,gic-400" , gic_of_init); -IRQCHIP_DECLARE (arm11mp_gic,"arm,arm11mp-gic" , gic_of_init); +IRQCHIP_DECLARE (armtc11mp_gic,"arm,tc11mp-gic" , gic_of_init); +IRQCHIP_DECLARE (armpb11mp_gic,"arm,pb11mp-gic" , gic_of_init);IRQCHIP_DECLARE (arm1176jzf_dc_gic,"arm,arm1176jzf-devchip-gic" , gic_of_init);IRQCHIP_DECLARE (cortex_a15_gic,"arm,cortex-a15-gic" , gic_of_init);IRQCHIP_DECLARE (cortex_a9_gic,"arm,cortex-a9-gic" , gic_of_init);
Signature · 1 line
2.4.3
Rob Herring
maintainerPATCH 3/13 irqchips: fix ARM11MPCore GIC bindings
Quoted 6 lines · Linus Walleij
The GIC bindings for the ARM11MPCore need to differentiate between the GIC on the Test Chip and the one on the evaluation baseboard. Split the binding in two and define new compatible-strings.
Cc devicetree at vger.kernel.orgSigned-off-by Linus Walleij <[email protected]>
Quoted 36 lines
--- Documentation/devicetree/bindings/arm/gic.txt | 3 ++- drivers/irqchip/irq-gic.c | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-)Documentation/devicetree/bindings/arm/gic.txt +2
-1@@ -15,7 +15,8 @@ Main node required properties: "arm,cortex-a15-gic" "arm,cortex-a9-gic" "arm,cortex-a7-gic" - "arm,arm11mp-gic" + "arm,tc11mp-gic" + "arm,pb11mp-gic" "brcm,brahma-b15-gic" "arm,arm1176jzf-devchip-gic" "qcom,msm-8660-qgic"drivers/irqchip/irq-gic.c +2
-2@@ -1184,7 +1184,8 @@ gic_of_init(struct device_node *node, struct device_node *parent)return 0 ; }IRQCHIP_DECLARE (gic_400,"arm,gic-400" , gic_of_init); -IRQCHIP_DECLARE (arm11mp_gic,"arm,arm11mp-gic" , gic_of_init); +IRQCHIP_DECLARE (armtc11mp_gic,"arm,tc11mp-gic" , gic_of_init); +IRQCHIP_DECLARE (armpb11mp_gic,"arm,pb11mp-gic" , gic_of_init);IRQCHIP_DECLARE (arm1176jzf_dc_gic,"arm,arm1176jzf-devchip-gic" , gic_of_init);IRQCHIP_DECLARE (cortex_a15_gic,"arm,cortex-a15-gic" , gic_of_init);IRQCHIP_DECLARE (cortex_a9_gic,"arm,cortex-a9-gic" , gic_of_init); --2.4.3
PATCH 4/13 irqchip/gic: support RealView variant setup
In reply to Linus WalleijThe ARM RealView PB11MPCore reference design has some special bits in a system controller register to set up the GIC in one of three modes: legacy, new with DCC, new without DCC. The register is also used to enable FIQ.
Since the platform will not boot unless this register is set up to "new with DCC" mode, we need a special quirk to be compiled-in for the RealView platforms.
If we find the right compatible string on the GIC TestChip, we enable this quirk by looking up the system controller and enabling the special bits.
We depend on the CONFIG_REALVIEW_DT Kconfig symbol as the old boardfile code has the same fix hardcoded, and this is only needed for the attempts to modernize the RealView code using device tree.
After fixing this, the PB11MPCore boots with device tree only.
---
Looking for an ACK for this (unless the irqchip maintainers barf at it) so I can take it through the ARM SoC tree.
--- drivers/irqchip/Makefile | 1 + drivers/irqchip/irq-gic-realview.c | 39 ++++++++++++++++++++++++++++++++++++++ drivers/irqchip/irq-gic-realview.h | 5 +++++ drivers/irqchip/irq-gic.c | 4 ++++ 4 files changed, 49 insertions(+) create mode 100644 drivers/irqchip/irq-gic-realview.c create mode 100644 drivers/irqchip/irq-gic-realview.h
drivers/irqchip/Makefile +1 -0
@@ -21,6 +21,7 @@ obj-$(CONFIG_ARCH_SUNXI) += irq-sun4i.o obj-$(CONFIG_ARCH_SUNXI) += irq-sunxi-nmi.o obj-$(CONFIG_ARCH_SPEAR3XX) += spear-shirq.o obj-$(CONFIG_ARM_GIC) += irq-gic.o irq-gic-common.o +obj-$(CONFIG_REALVIEW_DT) += irq-gic-realview.o obj-$(CONFIG_ARM_GIC_V2M) += irq-gic-v2m.o obj-$(CONFIG_ARM_GIC_V3) += irq-gic-v3.o irq-gic-common.o obj-$(CONFIG_ARM_GIC_V3_ITS) += irq-gic-v3-its.o irq-gic-v3-its-pci-msi.o irq-gic-v3-its-platform-msi.o
drivers/irqchip/irq-gic-realview.c new file +39 -0
@@ -0,0 +1,39 @@ +/* +* Special GIC quirks for the ARM RealView +* Copyright (C) 2015 Linus Walleij +*/ +#include <linux/of.h> +#include <linux/regmap.h> +#include <linux/mfd/syscon.h> +#include <linux/bitops.h> + +#define REALVIEW_SYS_LOCK_OFFSET 0x20 +#define REALVIEW_PB11MP_SYS_PLD_CTRL1 0x74 +#define VERSATILE_LOCK_VAL 0xA05F +#define PLD_INTMODE_MASK BIT(22)|BIT(23)|BIT(24) +#define PLD_INTMODE_LEGACY 0x0 +#define PLD_INTMODE_NEW_DCC BIT(22) +#define PLD_INTMODE_NEW_NO_DCC BIT(23) +#define PLD_INTMODE_FIQ_ENABLE BIT(24) + +void __init realview_gic_init (struct device_node *np) +{ +static struct regmap *map; + +/* The PB11MPCore GIC needs to be configured in the syscon */ +if (of_device_is_compatible (np,"arm,tc11mp-gic" )) { + map =syscon_regmap_lookup_by_compatible ("arm,realview-pb11mp-syscon" ); +if (!IS_ERR (map)) { +/* new irq mode with no DCC */ +regmap_write (map,REALVIEW_SYS_LOCK_OFFSET , +VERSATILE_LOCK_VAL ); +regmap_update_bits (map,REALVIEW_PB11MP_SYS_PLD_CTRL1 , +PLD_INTMODE_NEW_NO_DCC , +PLD_INTMODE_MASK ); +regmap_write (map,REALVIEW_SYS_LOCK_OFFSET ,0x0000 ); +pr_info ("TC11MP GIC: set up interrupt controller to NEW mode, no DCC\n" ); + }else { +pr_err ("TC11MP GIC setup: could not find syscon\n" ); + } + } +}
drivers/irqchip/irq-gic-realview.h new file +5 -0
@@ -0,0 +1,5 @@ +#ifdef CONFIG_REALVIEW_DT +void realview_gic_init (struct device_node *np); +#else +static void realview_gic_init (struct device_node *np) {} +#endif
drivers/irqchip/irq-gic.c +4 -0
@@ -50,6 +50,7 @@#include <asm/virt.h> #include "irq-gic-common.h" +#include "irq-gic-realview.h" union gic_base {void __iomem *common_base;
@@ -1158,6 +1159,9 @@ gic_of_init(struct device_node *node, struct device_node *parent) cpu_base =of_iomap (node,1 );WARN (!cpu_base,"unable to map gic cpu registers\n" ); +/* Special quirk for ARM RealView */ +realview_gic_init (node); +/* * Disable split EOI/Deactivate if either HYP is not available * or the CPU interface is too small.
Signature · 1 line
2.4.3
PATCH 4/13 irqchip/gic: support RealView variant setup
Quoted 118 lines · Linus Walleij
The ARM RealView PB11MPCore reference design has some special bits in a system controller register to set up the GIC in one of three modes: legacy, new with DCC, new without DCC. The register is also used to enable FIQ.
Since the platform will not boot unless this register is set up to "new with DCC" mode, we need a special quirk to be compiled-in for the RealView platforms.
If we find the right compatible string on the GIC TestChip, we enable this quirk by looking up the system controller and enabling the special bits.
We depend on the
CONFIG_REALVIEW_DTKconfigsymbol as the old boardfile code has the same fix hardcoded, and this is only needed for the attempts to modernize the RealView code using device tree.After fixing this, the PB11MPCore boots with device tree only.
Cc Thomas Gleixner <[email protected]>Cc Jason Cooper <[email protected]>Cc Marc Zyngier <[email protected]>Signed-off-by Linus Walleij <[email protected]>---
Looking for an ACK for this (unless the irqchip maintainers barf at it) so I can take it through the ARM SoC tree.--- drivers/irqchip/Makefile | 1 + drivers/irqchip/irq-gic-realview.c | 39 ++++++++++++++++++++++++++++++++++++++ drivers/irqchip/irq-gic-realview.h | 5 +++++ drivers/irqchip/irq-gic.c | 4 ++++ 4 files changed, 49 insertions(+) create mode 100644 drivers/irqchip/irq-gic-realview.c create mode 100644 drivers/irqchip/irq-gic-realview.hdrivers/irqchip/Makefile +1
-0@@ -21,6 +21,7 @@ obj-$(CONFIG_ARCH_SUNXI) += irq-sun4i.o obj-$(CONFIG_ARCH_SUNXI) += irq-sunxi-nmi.o obj-$(CONFIG_ARCH_SPEAR3XX) += spear-shirq.o obj-$(CONFIG_ARM_GIC) += irq-gic.o irq-gic-common.o +obj-$(CONFIG_REALVIEW_DT) += irq-gic-realview.o obj-$(CONFIG_ARM_GIC_V2M) += irq-gic-v2m.o obj-$(CONFIG_ARM_GIC_V3) += irq-gic-v3.o irq-gic-common.o obj-$(CONFIG_ARM_GIC_V3_ITS) += irq-gic-v3-its.o irq-gic-v3-its-pci-msi.o irq-gic-v3-its-platform-msi.odrivers/irqchip/irq-gic-realview.c new file +39
-0@@ -0,0 +1,39 @@ +/* +* Special GIC quirks for the ARM RealView +* Copyright (C) 2015 Linus Walleij +*/ +#include <linux/of.h> +#include <linux/regmap.h> +#include <linux/mfd/syscon.h> +#include <linux/bitops.h> + +#define REALVIEW_SYS_LOCK_OFFSET 0x20 +#define REALVIEW_PB11MP_SYS_PLD_CTRL1 0x74 +#define VERSATILE_LOCK_VAL 0xA05F +#define PLD_INTMODE_MASK BIT(22)|BIT(23)|BIT(24) +#define PLD_INTMODE_LEGACY 0x0 +#define PLD_INTMODE_NEW_DCC BIT(22) +#define PLD_INTMODE_NEW_NO_DCC BIT(23) +#define PLD_INTMODE_FIQ_ENABLE BIT(24) + +void __init realview_gic_init (struct device_node *np) +{ +static struct regmap *map; + +/* The PB11MPCore GIC needs to be configured in the syscon */ +if (of_device_is_compatible (np,"arm,tc11mp-gic" )) { + map =syscon_regmap_lookup_by_compatible ("arm,realview-pb11mp-syscon" ); +if (!IS_ERR (map)) { +/* new irq mode with no DCC */ +regmap_write (map,REALVIEW_SYS_LOCK_OFFSET , +VERSATILE_LOCK_VAL ); +regmap_update_bits (map,REALVIEW_PB11MP_SYS_PLD_CTRL1 , +PLD_INTMODE_NEW_NO_DCC , +PLD_INTMODE_MASK ); +regmap_write (map,REALVIEW_SYS_LOCK_OFFSET ,0x0000 ); +pr_info ("TC11MP GIC: set up interrupt controller to NEW mode, no DCC\n" ); + }else { +pr_err ("TC11MP GIC setup: could not find syscon\n" ); + } + } +}drivers/irqchip/irq-gic-realview.h new file +5
-0@@ -0,0 +1,5 @@ +#ifdef CONFIG_REALVIEW_DT +void realview_gic_init (struct device_node *np); +#else +static void realview_gic_init (struct device_node *np) {} +#endif drivers/irqchip/irq-gic.c +1
-0@@ -50,6 +50,7 @@#include <asm/virt.h> #include "irq-gic-common.h" +#include "irq-gic-realview.h" union gic_base {void __iomem *common_base;
drivers/irqchip/irq-gic.c gic_of_init(struct device_node *node, struct device_node *parent) · line 1164
Quoted 6 lines
drivers/irqchip/irq-gic.c +3
-0@@ -1158,6 +1159,9 @@ gic_of_init(struct device_node *node, struct device_node *parent) cpu_base =of_iomap (node,1 );WARN (!cpu_base,"unable to map gic cpu registers\n" ); +/* Special quirk for ARM RealView */ +realview_gic_init (node); +
How about having a special entry in the IRQCHIP_OF_DECLARE section, which would call this, and then gic_of_init? It would look slightly nicer, and you could from the check in realview_gic_init...
Thoughts?
M.
Signature · 1 line
Jazz is not dead. It just smells funny...
PATCH 4/13 irqchip/gic: support RealView variant setup
In reply to Linus WalleijOn Thu, 15 Oct 2015, Linus Walleij wrote:
PATCH 5/13 irqchip/gic: assign irqchip dynamically
In reply to Linus WalleijInstead of having the irqchip being a static struct, make it part of the per-instance data so we can assign it a dynamic name. This has the usable side effect of displaying the GIC with an instance number as GIC0, GIC1 ... GICn in /proc/interrupts, which is helpful when debugging cascaded GICs, such as on the ARM PB11MPCore.
---
Fellas please say what you think about this:
Yes / No / Linus is an idiot
This can be applied directly to the irqchip tree if you like it, AFAIK it has no dependencies.
--- drivers/irqchip/irq-gic.c | 36 +++++++++++++++++++----------------- 1 file changed, 19 insertions(+), 17 deletions(-)
drivers/irqchip/irq-gic.c +19 -17
@@ -58,6 +58,7 @@ union gic_base { };struct gic_chip_data { +struct irq_chip chip;union gic_base dist_base;union gic_base cpu_base;#ifdef CONFIG_CPU_PM
@@ -369,22 +370,6 @@ static void gic_handle_cascade_irq(struct irq_desc *desc)chained_irq_exit (chip, desc); } -static struct irq_chip gic_chip = { - .name ="GIC" , - .irq_mask = gic_mask_irq, - .irq_unmask = gic_unmask_irq, - .irq_eoi = gic_eoi_irq, - .irq_set_type = gic_set_type, -#ifdef CONFIG_SMP - .irq_set_affinity = gic_set_affinity, -#endif - .irq_get_irqchip_state = gic_irq_get_irqchip_state, - .irq_set_irqchip_state = gic_irq_set_irqchip_state, - .flags =IRQCHIP_SET_TYPE_MASKED | -IRQCHIP_SKIP_SET_WAKE | -IRQCHIP_MASK_ON_SUSPEND , -}; -static struct irq_chip gic_eoimode1_chip = { .name ="GICv2" , .irq_mask = gic_eoimode1_mask_irq,
@@ -880,7 +865,8 @@ void __init gic_init_physaddr(struct device_node *node)static int gic_irq_domain_map (struct irq_domain *d,unsigned int irq,irq_hw_number_t hw) { -struct irq_chip *chip = &gic_chip; +struct gic_chip_data *gic = d->host_data; +struct irq_chip *chip = &gic->chip;if (static_key_true (&supports_deactivate)) {if (d->host_data == (void *)&gic_data[0 ])
@@ -989,6 +975,22 @@ static void __init __gic_init_bases(unsigned int gic_nr, int irq_start,BUG_ON (gic_nr >=MAX_GIC_NR ); gic = &gic_data[gic_nr]; + +/* Initialize irq_chip */ + gic->chip.name =kasprintf (GFP_KERNEL ,"GIC%d" , gic_nr); + gic->chip.irq_mask = gic_mask_irq; + gic->chip.irq_unmask = gic_unmask_irq; + gic->chip.irq_eoi = gic_eoi_irq; + gic->chip.irq_set_type = gic_set_type; +#ifdef CONFIG_SMP + gic->chip.irq_set_affinity = gic_set_affinity; +#endif + gic->chip.irq_get_irqchip_state = gic_irq_get_irqchip_state; + gic->chip.irq_set_irqchip_state = gic_irq_set_irqchip_state; + gic->chip.flags =IRQCHIP_SET_TYPE_MASKED | +IRQCHIP_SKIP_SET_WAKE | +IRQCHIP_MASK_ON_SUSPEND ; +#ifdef CONFIG_GIC_NON_BANKED if (percpu_offset) {/* Frankein-GIC without banked registers... */ unsigned int cpu;
Signature · 1 line
2.4.3
PATCH 5/13 irqchip/gic: assign irqchip dynamically
Hi Linus,
Quoted 74 lines · Linus Walleij
Instead of having the irqchip being a static struct, make it part of the per-instance data so we can assign it a dynamic name. This has the usable side effect of displaying the GIC with an instance number as GIC0, GIC1 ... GICn in
/proc/interrupts, which is helpful when debugging cascaded GICs, such as on the ARM PB11MPCore.Cc Thomas Gleixner <[email protected]>Cc Jason Cooper <[email protected]>Cc Marc Zyngier <[email protected]>Signed-off-by Linus Walleij <[email protected]>---
Fellas please say what you think about this:
Yes / No / Linus is an idiot
This can be applied directly to the irqchip tree if you like it, AFAIK it has no dependencies.--- drivers/irqchip/irq-gic.c | 36 +++++++++++++++++++----------------- 1 file changed, 19 insertions(+), 17 deletions(-)drivers/irqchip/irq-gic.c +9
-17@@ -58,6 +58,7 @@ union gic_base { };struct gic_chip_data { +struct irq_chip chip;union gic_base dist_base;union gic_base cpu_base;#ifdef CONFIG_CPU_PM @@ -369,22 +370,6 @@ static void gic_handle_cascade_irq(struct irq_desc *desc)chained_irq_exit (chip, desc); } -static struct irq_chip gic_chip = { - .name ="GIC" , - .irq_mask = gic_mask_irq, - .irq_unmask = gic_unmask_irq, - .irq_eoi = gic_eoi_irq, - .irq_set_type = gic_set_type, -#ifdef CONFIG_SMP - .irq_set_affinity = gic_set_affinity, -#endif - .irq_get_irqchip_state = gic_irq_get_irqchip_state, - .irq_set_irqchip_state = gic_irq_set_irqchip_state, - .flags =IRQCHIP_SET_TYPE_MASKED | -IRQCHIP_SKIP_SET_WAKE | -IRQCHIP_MASK_ON_SUSPEND , -}; -static struct irq_chip gic_eoimode1_chip = { .name ="GICv2" , .irq_mask = gic_eoimode1_mask_irq,@@ -880,7 +865,8 @@ void __init gic_init_physaddr(struct device_node *node)static int gic_irq_domain_map (struct irq_domain *d,unsigned int irq,irq_hw_number_t hw) { -struct irq_chip *chip = &gic_chip; +struct gic_chip_data *gic = d->host_data; +struct irq_chip *chip = &gic->chip;if (static_key_true (&supports_deactivate)) {if (d->host_data == (void *)&gic_data[0 ])@@ -989,6 +975,22 @@ static void __init __gic_init_bases(unsigned int gic_nr, int irq_start,BUG_ON (gic_nr >=MAX_GIC_NR ); gic = &gic_data[gic_nr]; + +/* Initialize irq_chip */ + gic->chip.name =kasprintf (GFP_KERNEL ,"GIC%d" , gic_nr); + gic->chip.irq_mask = gic_mask_irq; + gic->chip.irq_unmask = gic_unmask_irq; + gic->chip.irq_eoi = gic_eoi_irq;
drivers/irqchip/irq-gic.c static void __init __gic_init_bases(unsigned int gic_nr, int irq_start, · line 993
Quoted 10 lines
drivers/irqchip/irq-gic.c +10
-0+ gic->chip.irq_set_type = gic_set_type; +#ifdef CONFIG_SMP + gic->chip.irq_set_affinity = gic_set_affinity; +#endif + gic->chip.irq_get_irqchip_state = gic_irq_get_irqchip_state; + gic->chip.irq_set_irqchip_state = gic_irq_set_irqchip_state; + gic->chip.flags =IRQCHIP_SET_TYPE_MASKED | +IRQCHIP_SKIP_SET_WAKE | +IRQCHIP_MASK_ON_SUSPEND ; +
How does it work when we want to use the ops from gic_eoimode1_chip? I don't think it breaks, but it is a bit weird.
You could also replace this sequence by keeping the original structure and assigning it to the embedded one (I don't think you save much by replacing this with discreet field assignment).
Thanks,
M.
Signature · 1 line
Jazz is not dead. It just smells funny...
PATCH 6/13 clk: versatile-icst: convert to use regmap
In reply to Linus WalleijInstead of passing around register bases, pass around a regmap in this driver. This refactoring make things so much easier when we later want to manage an ICST that is part of a syscon.
---
I'm looking for an ACK from the CLK maintainers to take this through the ARM SoC tree once the series stabilize.
--- drivers/clk/versatile/Kconfig | 1 + drivers/clk/versatile/clk-icst.c | 88 +++++++++++++++++++++++++++------------- 2 files changed, 61 insertions(+), 28 deletions(-)
drivers/clk/versatile/Kconfig +1 -0
@@ -1,6 +1,7 @@ config COMMON_CLK_VERSATILE bool "Clock driver for ARM Reference designs" depends on ARCH_INTEGRATOR || ARCH_REALVIEW || ARCH_VEXPRESS || ARM64 + select REGMAP_MMIO ---help--- Supports clocking on ARM Reference designs: - Integrator/AP and Integrator/CP
drivers/clk/versatile/clk-icst.c +60 -28
154 lines not on this page · raw message
Signature · 1 line
2.4.3
PATCH 6/13 clk: versatile-icst: convert to use regmap
drivers/clk/versatile/clk-icst.c struct clk *icst_clk_register(struct device *dev, · line 183
Quoted 11 lines · Linus Walleij
drivers/clk/versatile/clk-icst.c +7
-0@@ -151,10 +174,19 @@ struct clk *icst_clk_register(struct device *dev, init.flags =CLK_IS_ROOT ; init.parent_names = (parent_name ? &parent_name :NULL ); init.num_parents = (parent_name ?1 :0 ); + icst->map =regmap_init_mmio (NULL , base, &icst_regmap_conf); +if (IS_ERR (icst->map)) { +int ret; + +pr_err ("could not initialize ICST regmap\n" ); +kfree (icst); + ret =PTR_ERR (icst->map);
drivers/clk/versatile/clk-icst.c:183 icst_clk_register() error: dereferencing freed memory 'icst' drivers/clk/versatile/clk-icst.c:184 icst_clk_register() warn: possible memory leak of 'pclone'
Quoted 1 line
drivers/clk/versatile/clk-icst.c +1
-0+return ERR_PTR (ret);
Signature · 2 lines
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project
PATCH 6/13 clk: versatile-icst: convert to use regmap
Quoted 17 lines · Stephen Boyd
drivers/clk/versatile/clk-icst.c struct clk *icst_clk_register(struct device *dev, · line 183
Quoted 11 lines · Linus Walleij
drivers/clk/versatile/clk-icst.c +7
-0@@ -151,10 +174,19 @@ struct clk *icst_clk_register(struct device *dev, init.flags =CLK_IS_ROOT ; init.parent_names = (parent_name ? &parent_name :NULL ); init.num_parents = (parent_name ?1 :0 ); + icst->map =regmap_init_mmio (NULL , base, &icst_regmap_conf); +if (IS_ERR (icst->map)) { +int ret; + +pr_err ("could not initialize ICST regmap\n" ); +kfree (icst); + ret =PTR_ERR (icst->map);
drivers/clk/versatile/clk-icst.c:183icst_clk_register()error: dereferencing freed memory 'icst'drivers/clk/versatile/clk-icst.c:184icst_clk_register()warn: possible memory leak of 'pclone'
The pclone warning is correct, nice catch. (Fixing it.)
But for the second warning, whatever static checker you're using for this is unable to handle error pointers:
clk = clk_register(dev, &icst->hw);
if (IS_ERR(clk))
kfree(icst);
return clk;It is quite obvious that returning clk (which may be an error code) is OK here.
If you want, I may need to add some specific annotation to shut up the static checker, any hints?
Yours,
Linus Walleij
PATCH 6/13 clk: versatile-icst: convert to use regmap
Quoted 19 lines · Linus Walleij
Quoted 17 lines · Stephen Boyd
drivers/clk/versatile/clk-icst.c struct clk *icst_clk_register(struct device *dev, · line 183
Quoted 11 lines · Linus Walleij
drivers/clk/versatile/clk-icst.c +7
-0@@ -151,10 +174,19 @@ struct clk *icst_clk_register(struct device *dev, init.flags =CLK_IS_ROOT ; init.parent_names = (parent_name ? &parent_name :NULL ); init.num_parents = (parent_name ?1 :0 ); + icst->map =regmap_init_mmio (NULL , base, &icst_regmap_conf); +if (IS_ERR (icst->map)) { +int ret; + +pr_err ("could not initialize ICST regmap\n" ); +kfree (icst); + ret =PTR_ERR (icst->map);
drivers/clk/versatile/clk-icst.c:183icst_clk_register()error: dereferencing freed memory 'icst'drivers/clk/versatile/clk-icst.c:184icst_clk_register()warn: possible memory leak of 'pclone'
Quoted 1 line
The pclone warning is correct, nice catch. (Fixing it.)
Turns out that this was around for ages, so sent a separate fix for -stable.
Yours,
Linus Walleij
PATCH 6/13 clk: versatile-icst: convert to use regmap
In reply to Linus WalleijQuoted 30 lines · Linus Walleij
Quoted 17 lines · Stephen Boyd
drivers/clk/versatile/clk-icst.c struct clk *icst_clk_register(struct device *dev, · line 183
Quoted 11 lines · Linus Walleij
drivers/clk/versatile/clk-icst.c +7
-0@@ -151,10 +174,19 @@ struct clk *icst_clk_register(struct device *dev, init.flags =CLK_IS_ROOT ; init.parent_names = (parent_name ? &parent_name :NULL ); init.num_parents = (parent_name ?1 :0 ); + icst->map =regmap_init_mmio (NULL , base, &icst_regmap_conf); +if (IS_ERR (icst->map)) { +int ret; + +pr_err ("could not initialize ICST regmap\n" ); +kfree (icst); + ret =PTR_ERR (icst->map);
drivers/clk/versatile/clk-icst.c:183icst_clk_register()error: dereferencing freed memory 'icst'drivers/clk/versatile/clk-icst.c:184icst_clk_register()warn: possible memory leak of 'pclone'The pclone warning is correct, nice catch. (Fixing it.)
But for the second warning, whatever static checker you're using for this is unable to handle error pointers:
clk = clk_register(dev, &icst->hw); if (IS_ERR(clk)) kfree(icst); return clk;
Quoted 6 lines
It is quite obvious that returning clk (which may be an error code) is OK here.
If you want, I may need to add some specific annotation to shut up the static checker, any hints?
Huh? I'm totally lost. I use sparse and smatch.
Quoted 2 lines
Quoted 2 lines
drivers/clk/versatile/clk-icst.c struct clk *icst_clk_register(struct device *dev, · line 183
Quoted 2 lines
drivers/clk/versatile/clk-icst.c +2
-0+kfree (icst); + ret =PTR_ERR (icst->map);
We just freed icst, and then we dereferenced it in the next line. What does that have to do with error pointers?
Signature · 2 lines
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project
PATCH 6/13 clk: versatile-icst: convert to use regmap
Quoted 38 lines · Stephen Boyd
Quoted 30 lines · Linus Walleij
Quoted 17 lines · Stephen Boyd
drivers/clk/versatile/clk-icst.c struct clk *icst_clk_register(struct device *dev, · line 183
Quoted 11 lines · Linus Walleij
drivers/clk/versatile/clk-icst.c +7
-0@@ -151,10 +174,19 @@ struct clk *icst_clk_register(struct device *dev, init.flags =CLK_IS_ROOT ; init.parent_names = (parent_name ? &parent_name :NULL ); init.num_parents = (parent_name ?1 :0 ); + icst->map =regmap_init_mmio (NULL , base, &icst_regmap_conf); +if (IS_ERR (icst->map)) { +int ret; + +pr_err ("could not initialize ICST regmap\n" ); +kfree (icst); + ret =PTR_ERR (icst->map);
drivers/clk/versatile/clk-icst.c:183icst_clk_register()error: dereferencing freed memory 'icst'drivers/clk/versatile/clk-icst.c:184icst_clk_register()warn: possible memory leak of 'pclone'The pclone warning is correct, nice catch. (Fixing it.)
But for the second warning, whatever static checker you're using for this is unable to handle error pointers:
clk = clk_register(dev, &icst->hw); if (IS_ERR(clk)) kfree(icst); return clk;Quoted 6 lines
It is quite obvious that returning clk (which may be an error code) is OK here.
If you want, I may need to add some specific annotation to shut up the static checker, any hints?
Quoted 7 lines
Huh? I'm totally lost. I use sparse and smatch.
Quoted 2 lines
Quoted 2 lines
drivers/clk/versatile/clk-icst.c struct clk *icst_clk_register(struct device *dev, · line 183
Quoted 2 lines
drivers/clk/versatile/clk-icst.c +2
-0+kfree (icst); + ret =PTR_ERR (icst->map);We just freed icst, and then we dereferenced it in the next line. What does that have to do with error pointers?
Sorry I must have confused patch versions. :(
I see the real problem now, so will make a v3 of this.
Yours,
Linus Walleij
PATCH 7/13 clk: versatile-icst: refactor to allocate regmap separately
In reply to Linus WalleijBreak out the registration function so it creates a regmap and pass to the setup function, so the latter can be shared with a device tree probe function that already has a regmap.
---
I'm looking for an ACK from the CLK maintainers to take this through the ARM SoC tree once the series stabilize.
--- drivers/clk/versatile/clk-icst.c | 44 +++++++++++++++++++++++++--------------- 1 file changed, 28 insertions(+), 16 deletions(-)
drivers/clk/versatile/clk-icst.c +28 -16
@@ -20,6 +20,7 @@#include <linux/clk-provider.h> #include <linux/io.h> #include <linux/regmap.h> +#include <linux/mfd/syscon.h> #include "clk-icst.h"
@@ -140,21 +141,16 @@ static const struct clk_ops icst_ops = { .set_rate = icst_set_rate, }; -struct clk *icst_clk_register (struct device *dev, +struct clk *icst_clk_setup (struct device *dev,const struct clk_icst_desc *desc,const char *name,const char *parent_name, -void __iomem *base) +struct regmap *map) {struct clk *clk;struct clk_icst *icst;struct clk_init_data init;struct icst_params *pclone; -struct regmap_config icst_regmap_conf = { - .reg_bits =32 , - .val_bits =32 , - .reg_stride =4 , - }; icst =kzalloc (sizeof (struct clk_icst ),GFP_KERNEL );if (!icst) {
@@ -174,15 +170,7 @@ struct clk *icst_clk_register(struct device *dev, init.flags =CLK_IS_ROOT ; init.parent_names = (parent_name ? &parent_name :NULL ); init.num_parents = (parent_name ?1 :0 ); - icst->map =regmap_init_mmio (NULL , base, &icst_regmap_conf); -if (IS_ERR (icst->map)) { -int ret; - -pr_err ("could not initialize ICST regmap\n" ); -kfree (icst); - ret =PTR_ERR (icst->map); -return ERR_PTR (ret); - } + icst->map = map; icst->hw.init = &init; icst->params = pclone; icst->vcoreg_off = desc->vco_offset;
@@ -194,4 +182,28 @@ struct clk *icst_clk_register(struct device *dev,return clk; } + +struct clk *icst_clk_register (struct device *dev, +const struct clk_icst_desc *desc, +const char *name, +const char *parent_name, +void __iomem *base) +{ +struct regmap_config icst_regmap_conf = { + .reg_bits =32 , + .val_bits =32 , + .reg_stride =4 , + }; +struct regmap *map; + + map =regmap_init_mmio (NULL , base, &icst_regmap_conf); +if (IS_ERR (map)) { +int ret; + +pr_err ("could not initialize ICST regmap\n" ); + ret =PTR_ERR (map); +return ERR_PTR (ret); + } +return icst_clk_setup (dev, desc, name, parent_name, map); +}EXPORT_SYMBOL_GPL (icst_clk_register);
Signature · 1 line
2.4.3
PATCH 7/13 clk: versatile-icst: refactor to allocate regmap separately
drivers/clk/versatile/clk-icst.c struct clk *icst_clk_register(struct device *dev, · line 184
Quoted 12 lines · Linus Walleij
drivers/clk/versatile/clk-icst.c +0
-8@@ -174,15 +170,7 @@ struct clk *icst_clk_register(struct device *dev, init.flags =CLK_IS_ROOT ; init.parent_names = (parent_name ? &parent_name :NULL ); init.num_parents = (parent_name ?1 :0 ); - icst->map =regmap_init_mmio (NULL , base, &icst_regmap_conf); -if (IS_ERR (icst->map)) { -int ret; - -pr_err ("could not initialize ICST regmap\n" ); -kfree (icst); - ret =PTR_ERR (icst->map); -return ERR_PTR (ret);
Oh now it gets moved.
Quoted 14 lines
drivers/clk/versatile/clk-icst.c +6
-1- } + icst->map = map; icst->hw.init = &init; icst->params = pclone; icst->vcoreg_off = desc->vco_offset;@@ -194,4 +182,28 @@ struct clk *icst_clk_register(struct device *dev,return clk; } + +struct clk *icst_clk_register(struct device *dev, + const struct clk_icst_desc *desc, + const char *name, + const char *parent_name,
drivers/clk/versatile/clk-icst.c struct clk *icst_clk_register(struct device *dev, · line 199
Quoted 10 lines
drivers/clk/versatile/clk-icst.c +10
-0+ void __iomem *base) +{ +struct regmap_config icst_regmap_conf = { + .reg_bits =32 , + .val_bits =32 , + .reg_stride =4 , + }; +struct regmap *map; + + map =regmap_init_mmio (NULL , base, &icst_regmap_conf);
Any reason we aren't passing dev as the first argument? Same comment applies to patch 6.
drivers/clk/versatile/clk-icst.c struct clk *icst_clk_register(struct device *dev, · line 205
Quoted 6 lines
drivers/clk/versatile/clk-icst.c +6
-0+if (IS_ERR (map)) { +int ret; + +pr_err ("could not initialize ICST regmap\n" ); + ret =PTR_ERR (map); +return ERR_PTR (ret);
Use ERR_CAST(map) instead.
Quoted 2 lines
drivers/clk/versatile/clk-icst.c +2
-0+ } +return icst_clk_setup (dev, desc, name, parent_name, map);
Signature · 2 lines
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project
PATCH 7/13 clk: versatile-icst: refactor to allocate regmap separately
In reply to Linus Walleijdrivers/clk/versatile/clk-icst.c static const struct clk_ops icst_ops = { · line 144
Quoted 6 lines · Linus Walleij
drivers/clk/versatile/clk-icst.c +1
-1@@ -140,21 +141,16 @@ static const struct clk_ops icst_ops = { .set_rate = icst_set_rate, }; -struct clk *icst_clk_register(struct device *dev, +struct clk *icst_clk_setup(struct device *dev,
This needs static now.
Quoted 4 lines
drivers/clk/versatile/clk-icst.c +0
-1const struct clk_icst_desc *desc, const char *name, const char *parent_name, - void __iomem *base)
Signature · 2 lines
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project
PATCH 8/13 clk: add ARM syscon ICST device tree bindings
In reply to Linus WalleijThis adds the device tree bindings for the ARM Syscon ICST oscillators, which is a register-level interface to the Integrated Device Technology (IDT) ICS525 and ICS307 serially programmable oscillators.
---
I'm looking for an ACK from the CLK maintainers to take this through the ARM SoC tree once the series stabilize.
--- .../devicetree/bindings/clock/arm-syscon-icst.txt | 40 ++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 Documentation/devicetree/bindings/clock/arm-syscon-icst.txt
Documentation/devicetree/bindings/clock/arm-syscon-icst.txt new file +40 -0
@@ -0,0 +1,40 @@ +ARM System Controller ICST clocks + +The ICS525 and ICS307 oscillators are produced by Integrated Devices +Technology (IDT). ARM integrated these oscillators deeply into their +reference designs by adding special control registers that manage such +oscillators to their system controllers. + +The ARM system controller contains logic to serialized and initialize +an ICST clock request after a write to the 32 bit register at an offset +into the system controller. Further, to even be able to alter one of +these frequencies, the system controller must first be unlocked by +writing a special token to another offset in the system controller. + +The ICST oscillator must be provided inside a system controller node. + +Required properties: +- lock-offset: the offset address into the system controller where the + unlocking register is located +- vco-offset: the offset address into the system controller where the + ICST control register is located (even 32 bit address) +- compatible: must be one of "arm,syscon-icst525" or "arm,syscon-icst307" +- #clock-cells: must be <0> +- clocks: parent clock, since the ICST needs a parent clock to derive its + frequency from, this attribute is compulsory. + +Example: + +syscon: syscon at 10000000 { + compatible = "syscon"; + reg = <0x10000000 0x1000>; + + oscclk0: osc0 at 0c { + compatible = "arm,syscon-icst307"; + #clock-cells = <0>; + lock-offset = <0x20>; + vco-offset = <0x0C>; + clocks = <&xtal24mhz>; + }; + (...) +};
Signature · 1 line
2.4.3
PATCH 8/13 clk: add ARM syscon ICST device tree bindings
Quoted 6 lines · Linus Walleij
Documentation/devicetree/bindings/clock/arm-syscon-icst.txt new file +0
-0
Documentation/devicetree/bindings/clock/arm-syscon-icst.txt line 8
Quoted 8 lines
Documentation/devicetree/bindings/clock/arm-syscon-icst.txt new file +8
-0@@ -0,0 +1,40 @@ +ARM System Controller ICST clocks + +The ICS525 and ICS307 oscillators are produced by Integrated Devices +Technology (IDT). ARM integrated these oscillators deeply into their +reference designs by adding special control registers that manage such +oscillators to their system controllers. + +The ARM system controller contains logic to serialized and initialize
serialize ?
Documentation/devicetree/bindings/clock/arm-syscon-icst.txt line 10
Quoted 2 lines
Documentation/devicetree/bindings/clock/arm-syscon-icst.txt new file +2
-0+an ICST clock request after a write to the 32 bit register at an offset +into the system controller. Further, to even be able to alter one of
Furthermore?
Documentation/devicetree/bindings/clock/arm-syscon-icst.txt line 12
Quoted 2 lines
Documentation/devicetree/bindings/clock/arm-syscon-icst.txt new file +2
-0+these frequencies, the system controller must first be unlocked by +writing a special token to another offset in the system controller.
Sounds like a great design!
Documentation/devicetree/bindings/clock/arm-syscon-icst.txt line 20
Quoted 8 lines
Documentation/devicetree/bindings/clock/arm-syscon-icst.txt new file +8
-0+ +The ICST oscillator must be provided inside a system controller node. + +Required properties: +- lock-offset: the offset address into the system controller where the + unlocking register is located +- vco-offset: the offset address into the system controller where the + ICST control register is located (even 32 bit address)
Is there any reason why we don't use a reg property for this?
Quoted 6 lines
Documentation/devicetree/bindings/clock/arm-syscon-icst.txt new file +6
-0+- compatible: must be one of "arm,syscon-icst525" or "arm,syscon-icst307" +- #clock-cells: must be <0> +- clocks: parent clock, since the ICST needs a parent clock to derive its + frequency from, this attribute is compulsory. + +Example:
Documentation/devicetree/bindings/clock/arm-syscon-icst.txt line 36
Quoted 10 lines
Documentation/devicetree/bindings/clock/arm-syscon-icst.txt new file +10
-0+ +syscon: syscon at 10000000 { + compatible = "syscon"; + reg = <0x10000000 0x1000>; + + oscclk0: osc0 at 0c { + compatible = "arm,syscon-icst307"; + #clock-cells = <0>; + lock-offset = <0x20>; + vco-offset = <0x0C>;
lowercase the C?
Quoted 4 lines
Documentation/devicetree/bindings/clock/arm-syscon-icst.txt new file +4
-0+ clocks = <&xtal24mhz>; + }; + (...) +};
Signature · 2 lines
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project
PATCH 8/13 clk: add ARM syscon ICST device tree bindings
Quoted 9 lines · Stephen Boyd
Documentation/devicetree/bindings/clock/arm-syscon-icst.txt line 20
Quoted 5 lines · Linus Walleij
Documentation/devicetree/bindings/clock/arm-syscon-icst.txt new file +5
-0+Required properties: +- lock-offset: the offset address into the system controller where the + unlocking register is located +- vco-offset: the offset address into the system controller where the + ICST control register is located (even 32 bit address)Is there any reason why we don't use a reg property for this?
Usually reg = <> is used with two (or more) tokens:
reg = <phys_addr size>;
The exception being things like I2C addresses which are just one token.
Since in this case, there is a "mother" reg property in the syscon-compatible node, which we are indexing into, it is confusing to use the same name for subnodes.
Also there is a bunch of precedents doing it like this for sybdevices to system controllers, just git grep offset Documentation/devicetree/bindings will give you a bunch of them.
(Fixing the spelling comments.)
Yours,
Linus Walleij
PATCH 8/13 clk: add ARM syscon ICST device tree bindings
Quoted 18 lines · Linus Walleij
Quoted 9 lines · Stephen Boyd
Documentation/devicetree/bindings/clock/arm-syscon-icst.txt line 20
Quoted 5 lines · Linus Walleij
Documentation/devicetree/bindings/clock/arm-syscon-icst.txt new file +5
-0+Required properties: +- lock-offset: the offset address into the system controller where the + unlocking register is located +- vco-offset: the offset address into the system controller where the + ICST control register is located (even 32 bit address)Is there any reason why we don't use a reg property for this?
Usually reg = <> is used with two (or more) tokens:
reg = <
phys_addrsize>;The exception being things like I2C addresses which are just one token.
Quoted 9 lines
Since in this case, there is a "mother" reg property in the syscon-compatible node, which we are indexing into, it is confusing to use the same name for subnodes.
Also there is a bunch of precedents doing it like this for sybdevices to system controllers, just git grep offset
Documentation/devicetree/bindingswill give you a bunch of them.
Ok. I'm no DT expert, but it seems odd to have subnodes without a reg property.
Signature · 2 lines
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project
PATCH 9/13 clk: versatile-icst: add device tree support
In reply to Linus WalleijThis adds support for the ARM syscon ICST clocks to initialized directly from the device tree syscon node on ARM Integrator, Versatile and RealView reference designs.
---
I'm looking for an ACK from the CLK maintainers to take this through the ARM SoC tree once the series stabilize.
--- drivers/clk/versatile/clk-icst.c | 89 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 88 insertions(+), 1 deletion(-)
drivers/clk/versatile/clk-icst.c +88 -1
@@ -3,7 +3,7 @@* We wrap the custom interface from <asm/hardware/icst.h> into the generic * clock framework. * -* Copyright (C) 2012 Linus Walleij +* Copyright (C) 2012-2015 Linus Walleij * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as
@@ -207,3 +207,90 @@ struct clk *icst_clk_register(struct device *dev,return icst_clk_setup (dev, desc, name, parent_name, map); }EXPORT_SYMBOL_GPL (icst_clk_register); + +#ifdef CONFIG_OF +/* +* In a device tree, an memory-mapped ICST clock appear as a child +* of a syscon node. Assume this and probe it only as a child of a +* syscon. +*/ + +static const struct icst_params icst525_params = { + .vco_max =ICST525_VCO_MAX_5V , + .vco_min =ICST525_VCO_MIN , + .vd_min =8 , + .vd_max =263 , + .rd_min =3 , + .rd_max =65 , + .s2div = icst525_s2div, + .idx2s = icst525_idx2s, +}; + +static const struct icst_params icst307_params = { + .vco_max =ICST307_VCO_MAX , + .vco_min =ICST307_VCO_MIN , + .vd_min =4 +8 , + .vd_max =511 +8 , + .rd_min =1 +2 , + .rd_max =127 +2 , + .s2div = icst307_s2div, + .idx2s = icst307_idx2s, +}; + +static void __init of_syscon_icst_setup (struct device_node *np) +{ +struct device_node *parent; +struct regmap *map; +struct clk_icst_desc icst_desc; +const char *name = np->name; +const char *parent_name; +struct clk *regclk; + +/* We do not release this reference, we are using it perpetually */ + parent =of_get_parent (np); +if (!parent) { +pr_err ("no parent node for syscon ICST clock\n" ); +return ; + } + map =syscon_node_to_regmap (parent); +if (IS_ERR (map)) { +pr_err ("no regmap for syscon ICST clock parent\n" ); +return ; + } + +if (of_property_read_u32 (np,"vco-offset" , &icst_desc.vco_offset)) { +pr_err ("no VCO register offset for ICST clock\n" ); +return ; + } +if (of_property_read_u32 (np,"lock-offset" , &icst_desc.lock_offset)) { +pr_err ("no lock register offset for ICST clock\n" ); +return ; + } + +if (of_device_is_compatible (np,"arm,syscon-icst525" )) + icst_desc.params = &icst525_params; +else if (of_device_is_compatible (np,"arm,syscon-icst307" )) + icst_desc.params = &icst307_params; +else { +pr_info ("unknown ICST clock %s\n" , name); +return ; + } + +/* Parent clock name is not the same as node parent */ + parent_name =of_clk_get_parent_name (np,0 ); + + regclk =icst_clk_setup (NULL , &icst_desc, name, parent_name, map); +if (IS_ERR (regclk)) { +pr_err ("error setting up syscon ICST clock %s\n" , name); +return ; + } +of_clk_add_provider (np, of_clk_src_simple_get, regclk); +pr_info ("registered syscon ICST clock %s\n" , name); +} + +CLK_OF_DECLARE (arm_syscon_icst525_clk, +"arm,syscon-icst525" , of_syscon_icst_setup); +CLK_OF_DECLARE (arm_syscon_icst307_clk, +"arm,syscon-icst307" , of_syscon_icst_setup); + +#endif
Signature · 1 line
2.4.3
PATCH 9/13 clk: versatile-icst: add device tree support
drivers/clk/versatile/clk-icst.c struct clk *icst_clk_register(struct device *dev, · line 273
Quoted 5 lines · Linus Walleij
drivers/clk/versatile/clk-icst.c +5
-0+ +if (of_device_is_compatible (np,"arm,syscon-icst525" )) + icst_desc.params = &icst525_params; +else if (of_device_is_compatible (np,"arm,syscon-icst307" )) + icst_desc.params = &icst307_params;
I guess if we add anymore here we should use an of_device_id array instead.
drivers/clk/versatile/clk-icst.c struct clk *icst_clk_register(struct device *dev, · line 275
Quoted 2 lines
drivers/clk/versatile/clk-icst.c +2
-0+else { +pr_info ("unknown ICST clock %s\n" , name);
pr_warn? pr_err?
drivers/clk/versatile/clk-icst.c struct clk *icst_clk_register(struct device *dev, · line 288
Quoted 13 lines
drivers/clk/versatile/clk-icst.c +13
-0+return ; + } + +/* Parent clock name is not the same as node parent */ + parent_name =of_clk_get_parent_name (np,0 ); + + regclk =icst_clk_setup (NULL , &icst_desc, name, parent_name, map); +if (IS_ERR (regclk)) { +pr_err ("error setting up syscon ICST clock %s\n" , name); +return ; + } +of_clk_add_provider (np, of_clk_src_simple_get, regclk); +pr_info ("registered syscon ICST clock %s\n" , name);
debug print? Please remove debug noise.
Signature · 2 lines
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project
PATCH 9/13 clk: versatile-icst: add device tree support
Quoted 9 lines · Stephen Boyd
drivers/clk/versatile/clk-icst.c struct clk *icst_clk_register(struct device *dev, · line 273
Quoted 5 lines · Linus Walleij
drivers/clk/versatile/clk-icst.c +5
-0+ +if (of_device_is_compatible (np,"arm,syscon-icst525" )) + icst_desc.params = &icst525_params; +else if (of_device_is_compatible (np,"arm,syscon-icst307" )) + icst_desc.params = &icst307_params;I guess if we add anymore here we should use an
of_device_idarray instead.
As it happens those two are gonna be it.
ARM never created any more integrated ICST devices, and they stopped using them since. Those two are the required ones.
(Fixing all other comments.)
Yours,
Linus Walleij
PATCH 9/13 clk: versatile-icst: add device tree support
Quoted 8 lines · Linus Walleij
Quoted 7 lines · Stephen Boyd
Quoted 5 lines · Linus Walleij
drivers/clk/versatile/clk-icst.c +5
-0+ +if (of_device_is_compatible (np,"arm,syscon-icst525" )) + icst_desc.params = &icst525_params; +else if (of_device_is_compatible (np,"arm,syscon-icst307" )) + icst_desc.params = &icst307_params;
Quoted 8 lines
Quoted 2 lines
I guess if we add anymore here we should use an
of_device_idarray instead.As it happens those two are gonna be it.
ARM never created any more integrated ICST devices, and they stopped using them since. Those two are the required ones.
As ARM didn't create any ICST devices at all, that's hardly surprising. These devices are created by Integrated Circuit Systems, Inc. The 525 is a parallel-loaded clock generator, the 307 is a serial-loaded clock generator.
However, they have no "standard" software interface - indeed, the 525 is marketed as a device that needs no processor or software to be used, so it doesn't have a "software" interface as such.
ARM Ltd's hardware on these boards provides interfaces to these, however the underlying ICST support I wrote was factored to separate out the interface from the chip support - I haven't been tracking what's been going on with these, but I hope that separation has been kept as it's entirely logical, and describing these things in DT as an ARM Ltd device, combining the ICST device itself with its interface would be wrong.
Signature · 2 lines
FTTC broadband for 0.8mile line: currently at 9.6Mbps down 400kbps up according to speedtest.net.
PATCH 9/13 clk: versatile-icst: add device tree support
Quoted 5 lines · Russell King - ARM Linux
[Me]
Quoted 3 lines
ARM never created any more integrated ICST devices, and they stopped using them since. Those two are the required ones.
Quoted 8 lines
As ARM didn't create any ICST devices at all, that's hardly surprising. These devices are created by Integrated Circuit Systems, Inc. The 525 is a parallel-loaded clock generator, the 307 is a serial-loaded clock generator.
However, they have no "standard" software interface - indeed, the 525 is marketed as a device that needs no processor or software to be used, so it doesn't have a "software" interface as such.
RIght, I wrote a blurb with the more elaborate and correct story for the device tree bindings. I get sloppy sometimes.
Quoted 6 lines
ARM Ltd's hardware on these boards provides interfaces to these, however the underlying ICST support I wrote was factored to separate out the interface from the chip support - I haven't been tracking what's been going on with these, but I hope that separation has been kept as it's entirely logical, and describing these things in DT as an ARM Ltd device, combining the ICST device itself with its interface would be wrong.
So the device tree bindings does say that, and the compatible strings are "arm,syscon-icst525" or "arm,syscon-icst307" indicating that it is indeed the ARM syscon register-mapped thing, and the ICST sits on the back of that register.
The logical separation is indeed kept, if someone ever decides to interface the ICST clocks in some other way, the code is reusable.
Yours,
Linus Walleij
PATCH 9/13 clk: versatile-icst: add device tree support
In reply to Linus WalleijQuoted 9 lines · Linus Walleij
This adds support for the ARM syscon ICST clocks to initialized directly from the device tree syscon node on ARM Integrator, Versatile and RealView reference designs.
Cc Michael Turquette <[email protected]>Cc Stephen Boyd <[email protected]>Cc linux-clk at vger.kernel.orgSigned-off-by Linus Walleij <[email protected]>---
Also:
WARNING: please, no space before tabs
#47: FILE: drivers/clk/versatile/clk-icst.c:221:
+^I.vd_min ^I= 8,$
WARNING: please, no space before tabs
#48: FILE: drivers/clk/versatile/clk-icst.c:222:
+^I.vd_max ^I= 263,$
WARNING: please, no space before tabs
#49: FILE: drivers/clk/versatile/clk-icst.c:223:
+^I.rd_min ^I= 3,$
WARNING: please, no space before tabs
#50: FILE: drivers/clk/versatile/clk-icst.c:224:
+^I.rd_max ^I= 65,$
total: 0 errors, 4 warnings, 98 lines checked
Signature · 2 lines
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project
PATCH 10/13 soc: versatile: add support for the PB11MPCore
In reply to Linus WalleijThe SoC driver needs a minor update to display the correct sysfs information for the PB11MPCore.
---
I wonder if I should Cc: arm at kernel.org on patches like this. They seem to be the default drivers/soc maintainers.
--- drivers/soc/versatile/soc-realview.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/soc/versatile/soc-realview.c +4 -0
@@ -36,6 +36,8 @@ static const char *realview_board_str(u32 id)switch ((id >>16 ) &0xfff ) {case 0x0147 :return "HBI-0147" ; +case 0x0159 : +return "HBI-0159" ;default :return "Unknown" ; }
@@ -44,6 +46,8 @@ static const char *realview_board_str(u32 id)static const char *realview_arch_str (u32 id) {switch ((id >>8 ) &0xf ) { +case 0x04 : +return "AHB" ;case 0x05 :return "Multi-layer AXI" ;default :
Signature · 1 line
2.4.3
PATCH 11/13 ARM: realview: select SP810 and ICST for the DT variant
In reply to Linus WalleijThe device tree boot for RealView need the SP810 system controller (same as found on the Versatile Express) to set up the timers on the board so the machine can tick. It further utilize the ICST307 through its system controller for 6 other oscillators. We have to select these from Kconfig or the machine does not boot.
--- arch/arm/mach-realview/Kconfig | 2 ++ 1 file changed, 2 insertions(+)
arch/arm/mach-realview/Kconfig +2 -0
@@ -4,6 +4,8 @@ menu "RealView platform type" config REALVIEW_DT bool "Support RealView(R) Device Tree based boot" select ARM_GIC + select CLK_SP810 + select ICST select MFD_SYSCON select POWER_RESET select POWER_RESET_VERSATILE
Signature · 1 line
2.4.3
PATCH 12/13 ARM: realview: add an DT SMP boot method
In reply to Linus WalleijThis adds an SMP boot method for the ARM RealView reference designs. We also select HAVE_SMP by default and make it use SMP_ON_UP so we only need to support one single kernel across the RealView reference designs when using DT.
The RealViews need to have the SCU (Snoop Control Unit) activated on boot, and this is now done by looking up its address from the device tree and initializing it and counting the available cores.
The RealViews boot by using a magic address register in the system controller (SYS_FLAGS) to store the boot address, the ROM will then read this register to the PC when the CPUs are taken out of WFI. This code uses a handle to the syscon regmap to access this register.
--- Documentation/devicetree/bindings/arm/cpus.txt | 1 + arch/arm/mach-realview/Kconfig | 2 + arch/arm/mach-realview/Makefile | 2 +- arch/arm/mach-realview/platsmp-dt.c | 91 ++++++++++++++++++++++++++ 4 files changed, 95 insertions(+), 1 deletion(-) create mode 100644 arch/arm/mach-realview/platsmp-dt.c
Documentation/devicetree/bindings/arm/cpus.txt +1 -0
@@ -190,6 +190,7 @@ nodes to be present and contain the properties described below. "allwinner,sun6i-a31" "allwinner,sun8i-a23" "arm,psci" + "arm,realview-smp" "brcm,brahma-b15" "marvell,armada-375-smp" "marvell,armada-380-smp"
arch/arm/mach-realview/Kconfig +2 -0
@@ -5,11 +5,13 @@ config REALVIEW_DT bool "Support RealView(R) Device Tree based boot" select ARM_GIC select CLK_SP810 + select HAVE_SMP select ICST select MFD_SYSCON select POWER_RESET select POWER_RESET_VERSATILE select POWER_SUPPLY + select SMP_ON_UP select SOC_REALVIEW select USE_OF help
arch/arm/mach-realview/Makefile +1 -1
@@ -3,7 +3,7 @@ # obj-y := core.o -obj-$(CONFIG_REALVIEW_DT) += realview-dt.o +obj-$(CONFIG_REALVIEW_DT) += realview-dt.o platsmp-dt.o obj-$(CONFIG_MACH_REALVIEW_EB) += realview_eb.o obj-$(CONFIG_MACH_REALVIEW_PB11MP) += realview_pb11mp.o obj-$(CONFIG_MACH_REALVIEW_PB1176) += realview_pb1176.o
arch/arm/mach-realview/platsmp-dt.c new file +91 -0
91 lines not on this page · raw message
Signature · 1 line
2.4.3
PATCH 13/13 ARM: realview: add device tree for PB11MPCore
In reply to Linus WalleijThis adds a device tree for the ARM RealView ARM11MPCore reference design.
--- arch/arm/boot/dts/Makefile | 3 +- arch/arm/boot/dts/arm-realview-pb11mp.dts | 681 ++++++++++++++++++++++++++++++ 2 files changed, 683 insertions(+), 1 deletion(-) create mode 100644 arch/arm/boot/dts/arm-realview-pb11mp.dts
arch/arm/boot/dts/Makefile +2 -1
@@ -496,7 +496,8 @@ dtb-$(CONFIG_ARCH_QCOM) += \ qcom-msm8960-cdp.dtb \ qcom-msm8974-sony-xperia-honami.dtb dtb-$(CONFIG_ARCH_REALVIEW) += \ - arm-realview-pb1176.dtb + arm-realview-pb1176.dtb \ + arm-realview-pb11mp.dtb dtb-$(CONFIG_ARCH_ROCKCHIP) += \ rk3066a-bqcurie2.dtb \ rk3066a-marsboard.dtb \
arch/arm/boot/dts/arm-realview-pb11mp.dts new file +681 -0
681 lines not on this page · raw message
Signature · 1 line
2.4.3