ARM Versatile multi-platform support
Subsystems (9)
cover ARM Versatile multi-platform support
From: Rob Herring <[email protected]>
This series converts ARM Versatile platform to multi-platform. I started this some time ago and some pieces were already merged. The primary piece remaining is converting the PCI host to DT which I was waiting for the common PCI DT parsing to get settled. Now that that is in place as well as a few other pieces are in place like multi-platform fixes for CLCD, we can fully convert Versatile to DT and multi-platform.
There's still a few things that need DT support which can be done later:
- MMC card detect and write protect. Should be able to use VExpress support
- Reboot support. Should be able to re-use Realview reboot code.
- flash phys-map support. Binding exists, but specifically Vpp control is needed.
- CLCD support. Not sure where this is at.
This has been tested on QEMU. A previous version was tested on Versatile/AB by Linus Walleij. Linus reported a problem with the display panel detection. Investigation on h/w is needed still as I have not been able to identify the issue by inspection and the display detection seems to work correctly on QEMU.
Linus had also mentioned to me that QEMU users may have some issue with removing non-DT code as the work flow has to change somewhat. Copying Peter Maydell here for comment (and there's rumors he may have actual PB h/w with PCI as well).
This series is available here:
git://git.kernel.org/pub/scm/linux/kernel/git/robh/linux.git versatile-multiplatform
Rob
Rob Herring (9):
dt/bindings: add versatile PCI binding
dts: versatile: add PCI controller binding
ARM: versatile: add DT based PCI detection
pci: add DT based ARM Versatile PCI host driver
dts: versatile: add sysregs nodes
ARM: versatile: switch to DT only booting and remove legacy code
ARM: versatile: move mach includes into mach directory
ARM: versatile: convert to multi-platform
ARM: versatile: consolidate code to single file
.../devicetree/bindings/pci/versatile.txt | 59 ++
arch/arm/Kconfig | 17 -
arch/arm/boot/dts/versatile-ab.dts | 23 +
arch/arm/boot/dts/versatile-pb.dts | 37 +
arch/arm/mach-versatile/Kconfig | 39 +-
arch/arm/mach-versatile/Makefile | 6 +-
arch/arm/mach-versatile/Makefile.boot | 4 -
arch/arm/mach-versatile/core.c | 845 ---------------------
arch/arm/mach-versatile/core.h | 46 --
arch/arm/mach-versatile/include/mach/clkdev.h | 16 -
arch/arm/mach-versatile/include/mach/hardware.h | 38 -
arch/arm/mach-versatile/include/mach/irqs.h | 134 ----
arch/arm/mach-versatile/include/mach/uncompress.h | 45 --
arch/arm/mach-versatile/pci.c | 368 ---------
.../mach-versatile/{include/mach => }/platform.h | 179 +----
arch/arm/mach-versatile/versatile_ab.c | 44 --
arch/arm/mach-versatile/versatile_dt.c | 338 ++++++++-
arch/arm/mach-versatile/versatile_pb.c | 91 ---
drivers/clk/versatile/Kconfig | 3 +-
drivers/pci/host/Kconfig | 4 +
drivers/pci/host/Makefile | 1 +
drivers/pci/host/pci-versatile.c | 305 ++++++++
22 files changed, 784 insertions(+), 1858 deletions(-)
create mode 100644 Documentation/devicetree/bindings/pci/versatile.txt
delete mode 100644 arch/arm/mach-versatile/Makefile.boot
delete mode 100644 arch/arm/mach-versatile/core.c
delete mode 100644 arch/arm/mach-versatile/core.h
delete mode 100644 arch/arm/mach-versatile/include/mach/clkdev.h
delete mode 100644 arch/arm/mach-versatile/include/mach/hardware.h
delete mode 100644 arch/arm/mach-versatile/include/mach/irqs.h
delete mode 100644 arch/arm/mach-versatile/include/mach/uncompress.h
delete mode 100644 arch/arm/mach-versatile/pci.c
rename arch/arm/mach-versatile/{include/mach => }/platform.h (54%)
delete mode 100644 arch/arm/mach-versatile/versatile_ab.c
delete mode 100644 arch/arm/mach-versatile/versatile_pb.c
create mode 100644 drivers/pci/host/pci-versatile.cSignature · 1 line
2.1.0
PATCH 1/9 dt/bindings: add versatile PCI binding
From: Rob Herring <[email protected]>
Add binding documentation for the PCI controller found on Versatile PB boards.
--- .../devicetree/bindings/pci/versatile.txt | 59 ++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 Documentation/devicetree/bindings/pci/versatile.txt
Documentation/devicetree/bindings/pci/versatile.txt new file +59 -0
@@ -0,0 +1,59 @@ +* ARM Versatile Platform Baseboard PCI interface + +PCI host controller found on the ARM Versatile PB board's FPGA. + +Required properties: +- compatible: should contain "arm,versatile-pci" to identify the Versatile PCI + controller. +- reg: base addresses and lengths of the pci controller. There must be 3 + entries: + - Versatile specific registers + - Self Config space + - Config space +- #address-cells: set to <3> +- #size-cells: set to <2> +- device_type: set to "pci" +- bus-range: set to <0 0xff> +- ranges: ranges for the PCI memory and I/O regions +- #interrupt-cells: set to <1> +- interrupt-map-mask and interrupt-map: standard PCI properties to define + the mapping of the PCI interface to interrupt numbers. + +Example: + +pci-controller at 10001000 { + compatible = "arm,versatile-pci"; + device_type = "pci"; + reg = <0x10001000 0x1000 + 0x41000000 0x10000 + 0x42000000 0x100000>; + bus-range = <0 0xff>; + #address-cells = <3>; + #size-cells = <2>; + #interrupt-cells = <1>; + + ranges = <0x01000000 0 0x00000000 0x43000000 0 0x00010000 /* downstream I/O */ + 0x02000000 0 0x50000000 0x50000000 0 0x10000000 /* non-prefetchable memory */ + 0x42000000 0 0x60000000 0x60000000 0 0x10000000>; /* prefetchable memory */ + + interrupt-map-mask = <0x1800 0 0 7>; + interrupt-map = <0x1800 0 0 1 &sic 28 + 0x1800 0 0 2 &sic 29 + 0x1800 0 0 3 &sic 30 + 0x1800 0 0 4 &sic 27 + + 0x1000 0 0 1 &sic 27 + 0x1000 0 0 2 &sic 28 + 0x1000 0 0 3 &sic 29 + 0x1000 0 0 4 &sic 30 + + 0x0800 0 0 1 &sic 30 + 0x0800 0 0 2 &sic 27 + 0x0800 0 0 3 &sic 28 + 0x0800 0 0 4 &sic 29 + + 0x0000 0 0 1 &sic 29 + 0x0000 0 0 2 &sic 30 + 0x0000 0 0 3 &sic 27 + 0x0000 0 0 4 &sic 28>; +};
Signature · 1 line
2.1.0
PATCH 2/9 dts: versatile: add PCI controller binding
In reply to Rob HerringFrom: Rob Herring <[email protected]>
Add the PCI controller node for the Versatile/PB board.
--- arch/arm/boot/dts/versatile-pb.dts | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+)
arch/arm/boot/dts/versatile-pb.dts +37 -0
@@ -29,6 +29,43 @@ clock-names = "apb_pclk"; }; + pci-controller at 10001000 { + compatible = "arm,versatile-pci"; + device_type = "pci"; + reg = <0x10001000 0x1000 + 0x41000000 0x10000 + 0x42000000 0x100000>; + bus-range = <0 0xff>; + #address-cells = <3>; + #size-cells = <2>; + #interrupt-cells = <1>; + + ranges = <0x01000000 0 0x00000000 0x43000000 0 0x00010000 /* downstream I/O */ + 0x02000000 0 0x50000000 0x50000000 0 0x10000000 /* non-prefetchable memory */ + 0x42000000 0 0x60000000 0x60000000 0 0x10000000>; /* prefetchable memory */ + + interrupt-map-mask = <0x1800 0 0 7>; + interrupt-map = <0x1800 0 0 1 &sic 28 + 0x1800 0 0 2 &sic 29 + 0x1800 0 0 3 &sic 30 + 0x1800 0 0 4 &sic 27 + + 0x1000 0 0 1 &sic 27 + 0x1000 0 0 2 &sic 28 + 0x1000 0 0 3 &sic 29 + 0x1000 0 0 4 &sic 30 + + 0x0800 0 0 1 &sic 30 + 0x0800 0 0 2 &sic 27 + 0x0800 0 0 3 &sic 28 + 0x0800 0 0 4 &sic 29 + + 0x0000 0 0 1 &sic 29 + 0x0000 0 0 2 &sic 30 + 0x0000 0 0 3 &sic 27 + 0x0000 0 0 4 &sic 28>; + }; + fpga { uart at 9000 { compatible = "arm,pl011", "arm,primecell";
Signature · 1 line
2.1.0
PATCH 3/9 ARM: versatile: add DT based PCI detection
In reply to Rob HerringFrom: Rob Herring <[email protected]>
Disable the Versatile PCI DT node when no PCI backplane is detected. This will prevent the Versatile PCI driver from probing when PCI is not populated.
--- arch/arm/mach-versatile/versatile_dt.c | 46 ++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+)
arch/arm/mach-versatile/versatile_dt.c +46 -0
@@ -22,15 +22,61 @@*/ #include <linux/init.h> +#include <linux/io.h> +#include <linux/of.h> +#include <linux/of_address.h> #include <linux/of_irq.h> #include <linux/of_platform.h> +#include <linux/slab.h> #include <asm/mach-types.h> #include <asm/mach/arch.h> #include "core.h" +#define VERSATILE_SYS_PCICTL_OFFSET 0x44 + +static void __init versatile_dt_pci_init (void ) +{ +u32 val; +void __iomem *base; +struct device_node *np; +struct property *newprop; + + np =of_find_compatible_node (NULL ,NULL ,"arm,core-module-versatile" ); +if (!np) +return ; + + base =of_iomap (np,0 ); +if (!base) +return ; + +/* Check if PCI backplane is detected */ + val =__raw_readl (base +VERSATILE_SYS_PCICTL_OFFSET ); +if (val &1 ) + goto err; + + np =of_find_compatible_node (NULL ,NULL ,"arm,versatile-pci" ); +if (!np) + goto err; + + newprop =kzalloc (sizeof (*newprop),GFP_KERNEL ); +if (!newprop) + goto err; + + newprop->name =kstrdup ("status" ,GFP_KERNEL ); + newprop->value =kstrdup ("disabled" ,GFP_KERNEL ); + newprop->length =sizeof ("disabled" ); +of_update_property (np, newprop); + +pr_info ("Not plugged into PCI backplane!\n" ); +err: +iounmap (base); +} +static void __init versatile_dt_init (void ) { +versatile_dt_pci_init (); +of_platform_populate (NULL , of_default_bus_match_table, versatile_auxdata_lookup,NULL ); }
Signature · 1 line
2.1.0
PATCH 3/9 ARM: versatile: add DT based PCI detection
Quoted 5 lines · On Tuesday 30 December 2014 13:28:32 Rob Herring wrote:
From: Rob Herring <[email protected]>
Disable the Versatile PCI DT node when no PCI backplane is detected. This will prevent the Versatile PCI driver from probing when PCI is not populated.
Can you explain why the check is done in platform code instead of the PCI driver probe function itself?
arch/arm/mach-versatile/versatile_dt.c line 56
Quoted 4 lines
arch/arm/mach-versatile/versatile_dt.c +4
-0+/* Check if PCI backplane is detected */ + val =__raw_readl (base +VERSATILE_SYS_PCICTL_OFFSET ); +if (val &1 ) + goto err;
Using __raw_readl prevents this from working with big-endian kernels, so just use readl here.
Arnd
PATCH 3/9 ARM: versatile: add DT based PCI detection
Quoted 9 lines · Arnd Bergmann
Quoted 5 lines · On Tuesday 30 December 2014 13:28:32 Rob Herring wrote:
From: Rob Herring <[email protected]>
Disable the Versatile PCI DT node when no PCI backplane is detected. This will prevent the Versatile PCI driver from probing when PCI is not populated.
Can you explain why the check is done in platform code instead of the PCI driver probe function itself?
Because the register to check is not part of the PCI controller, but part of the system registers. There was no infrastructure for the system registers when I originally wrote this, but there's some syscon support now for VExpress that may be able to be used. I think it is cleaner if we can avoid syscon dependencies in drivers in general, but it is pretty much zero chance the Versatile PCI driver will ever be used on another platform.
Quoted 7 lines
arch/arm/mach-versatile/versatile_dt.c line 56
Quoted 4 lines
arch/arm/mach-versatile/versatile_dt.c +4
-0+/* Check if PCI backplane is detected */ + val =__raw_readl (base +VERSATILE_SYS_PCICTL_OFFSET ); +if (val &1 ) + goto err;Using
__raw_readlprevents this from working with big-endian kernels, so just use readl here.
So does the fact that this is an ARM926, but yes there's not really any reason not to use readl.
Rob
PATCH 3/9 ARM: versatile: add DT based PCI detection
Quoted 11 lines · On Tuesday 30 December 2014 17:05:16 Rob Herring wrote:
Quoted 9 lines · Arnd Bergmann
Quoted 5 lines · On Tuesday 30 December 2014 13:28:32 Rob Herring wrote:
From: Rob Herring <[email protected]>
Disable the Versatile PCI DT node when no PCI backplane is detected. This will prevent the Versatile PCI driver from probing when PCI is not populated.
Can you explain why the check is done in platform code instead of the PCI driver probe function itself?
Quoted 7 lines
Because the register to check is not part of the PCI controller, but part of the system registers. There was no infrastructure for the system registers when I originally wrote this, but there's some syscon support now for VExpress that may be able to be used. I think it is cleaner if we can avoid syscon dependencies in drivers in general, but it is pretty much zero chance the Versatile PCI driver will ever be used on another platform.
Ok, I see. I guess ideally we would get a correct DTB file from the boot loader, but that is of course completely unrealistic on versatile, both on hardware and qemu.
Maybe we can just take your current approach for now, and add a comment about the possibility of using syscon in the future to the function.
I'm also not completely sure if your code gets it right: the existing driver writes '1' into this register in .preinit() and then reads the same register back in .setup(). Your driver just reads the value but never writes it.
I suspect that either the existing behavior is completely bogus because the driver always reads what it write before, and then you can skip the logic completely, or your new driver is broken because reading the register without writing it first will result in undefined behavior on real hardware.
Quoted 10 lines
Quoted 7 lines
arch/arm/mach-versatile/versatile_dt.c line 56
Quoted 4 lines
arch/arm/mach-versatile/versatile_dt.c +4
-0+/* Check if PCI backplane is detected */ + val =__raw_readl (base +VERSATILE_SYS_PCICTL_OFFSET ); +if (val &1 ) + goto err;Using
__raw_readlprevents this from working with big-endian kernels, so just use readl here.So does the fact that this is an ARM926, but yes there's not really any reason not to use readl.
Ok. I don't think there is anything preventing you from setting big-endian mode on arm926 though, it's just that nobody ever has the need in practice, and a lot of drivers are broken.
Arnd
PATCH 3/9 ARM: versatile: add DT based PCI detection
Quoted 9 lines · Arnd Bergmann
Quoted 7 lines · On Tuesday 30 December 2014 17:05:16 Rob Herring wrote:
Because the register to check is not part of the PCI controller, but part of the system registers. There was no infrastructure for the system registers when I originally wrote this, but there's some syscon support now for VExpress that may be able to be used. I think it is cleaner if we can avoid syscon dependencies in drivers in general, but it is pretty much zero chance the Versatile PCI driver will ever be used on another platform.
Quoted 3 lines
Ok, I see. I guess ideally we would get a correct DTB file from the boot loader, but that is of course completely unrealistic on versatile, both on hardware and qemu.
Why would you want to get the bootloader to do this for you when the hardware provides a perfectly good mechanism for probing for the existence of the hardware? "Ask the hardware" is always going to be a more reliable and foolproof way to get the answer if you can do it -- device tree should just be for the cases where there is no way to probe. In any case the only way for the boot loader to determine the correct value to put into the device tree would be to read the register itself.
Quoted 5 lines
I suspect that either the existing behavior is completely bogus because the driver always reads what it write before, and then you can skip the logic completely, or your new driver is broken because reading the register without writing it first will result in undefined behavior on real hardware.
The documentation describes this register as:
# The SYS_PCICTL register at 0x10000044 enables the bridge to the PCI bus:
#
# * Setting bit 0 HIGH enables PCI bus accesses.
# * Read returns a HIGH in bit 0 if a PCI board is present
# in the expansion backplane.
ie the read and write behaviour is independent. So I suspect that this new driver's failure to write 1 means that it will break PCI on real hardware. (QEMU doesn't attempt to model this behaviour: SYS_PCICTL will always read-as-one, writes-ignored.)
thanks
-- PMM
PATCH 3/9 ARM: versatile: add DT based PCI detection
Quoted 14 lines · Peter Maydell
Quoted 9 lines · Arnd Bergmann
Quoted 7 lines · On Tuesday 30 December 2014 17:05:16 Rob Herring wrote:
Because the register to check is not part of the PCI controller, but part of the system registers. There was no infrastructure for the system registers when I originally wrote this, but there's some syscon support now for VExpress that may be able to be used. I think it is cleaner if we can avoid syscon dependencies in drivers in general, but it is pretty much zero chance the Versatile PCI driver will ever be used on another platform.
Quoted 3 lines
Ok, I see. I guess ideally we would get a correct DTB file from the boot loader, but that is of course completely unrealistic on versatile, both on hardware and qemu.
Quoted 8 lines
Why would you want to get the bootloader to do this for you when the hardware provides a perfectly good mechanism for probing for the existence of the hardware? "Ask the hardware" is always going to be a more reliable and foolproof way to get the answer if you can do it -- device tree should just be for the cases where there is no way to probe. In any case the only way for the boot loader to determine the correct value to put into the device tree would be to read the register itself.
Only that it is nice to hide all the ugly bits in the bootloader/firmware and DT already provides a standard way to enable or disable h/w. This h/w is not probeable in any sort of standard way.
Quoted 14 lines
Quoted 5 lines
I suspect that either the existing behavior is completely bogus because the driver always reads what it write before, and then you can skip the logic completely, or your new driver is broken because reading the register without writing it first will result in undefined behavior on real hardware.
The documentation describes this register as:
# The
SYS_PCICTLregister at0x10000044enables the bridge to the PCI bus:
#
# * Setting bit 0 HIGH enables PCI bus accesses.
# * Read returns a HIGH in bit 0 if a PCI board is present
# in the expansion backplane.
Quoted 7 lines
ie the read and write behaviour is independent. So I suspect that this new driver's failure to write 1 means that it will break PCI on real hardware. (QEMU doesn't attempt to model this behaviour:
SYS_PCICTLwill always read-as-one, writes-ignored.)From Table 4.4, I came to the conclusion that the write wasn't really necessary:
SYS_PCICTL 0x10000044 Read only -Read returns a HIGH in bit [0] if a PCI board is present in the expansion backplane.
I'll add it back.
Rob
PATCH 3/9 ARM: versatile: add DT based PCI detection
Quoted 11 lines · Rob Herring
Quoted 8 lines · Peter Maydell
Why would you want to get the bootloader to do this for you when the hardware provides a perfectly good mechanism for probing for the existence of the hardware? "Ask the hardware" is always going to be a more reliable and foolproof way to get the answer if you can do it -- device tree should just be for the cases where there is no way to probe. In any case the only way for the boot loader to determine the correct value to put into the device tree would be to read the register itself.
Quoted 3 lines
Only that it is nice to hide all the ugly bits in the bootloader/firmware and DT already provides a standard way to enable or disable h/w. This h/w is not probeable in any sort of standard way.
This is an embedded system, you were expecting some kind of standard? :-) I believe that SYS_PCICTL tells you whether you're going to find the PCI controller or a decode error at the addresses in the memory map where the PCI controller usually lives, so robustness suggests it's worth retaining the check in the kernel. [I'd want to check this on hardware but my current belief is that if there's no backplane attached then the register will read zero and the PCI controller register space will abort with decode errors.]
Quoted 6 lines
From Table 4.4, I came to the conclusion that the write wasn't really necessary:
SYS_PCICTL0x10000044Read only -Read returns a HIGH in bit [0] if a PCI board is present in the expansion backplane.I'll add it back.
The self-contradictory VersatilePB docs strike again, I see. Interestingly, in the PB1176 docs this register is documented as definitely read/only:
# [1]Read only: Reserved.
#
# Note
#
# On the RealView Platform Baseboard for ARM926EJ-S, this bit
# was PCICONTROLIN signal and indicated that 66MHz mode was # enabled. The PB1176JZF-S only supports 33MHz operation. # # [0]Read only: Status of P_DETECT pin.
...and in passing provides some info about the 926 board that isn't in the docs for the 926!
A little digging suggests that it may in fact be the case that the 1176 docs are correct and the write to bit 0 does nothing. However the safest thing here is to keep doing what the old kernel did, I think.
thanks
-- PMM
PATCH 3/9 ARM: versatile: add DT based PCI detection
Quoted 12 lines · On Wednesday 31 December 2014 21:07:25 Peter Maydell wrote:
Quoted 11 lines · Rob Herring
Quoted 8 lines · Peter Maydell
Why would you want to get the bootloader to do this for you when the hardware provides a perfectly good mechanism for probing for the existence of the hardware? "Ask the hardware" is always going to be a more reliable and foolproof way to get the answer if you can do it -- device tree should just be for the cases where there is no way to probe. In any case the only way for the boot loader to determine the correct value to put into the device tree would be to read the register itself.
Quoted 6 lines
Quoted 3 lines
Only that it is nice to hide all the ugly bits in the bootloader/firmware and DT already provides a standard way to enable or disable h/w. This h/w is not probeable in any sort of standard way.
This is an embedded system, you were expecting some kind of standard?
But that is exactly the point: While we try to ask the hardware about anything that can be reasonably queried through an in-kernel interface that talks to the hardware, it works less well when that hardware interface is rather obscure and (like this one) only used on a few special machines.
Similar examples are Marvell's SoC ID register, which you have to read by powering on the PCI host bridge and reading the Vendor/Device ID registers for the root bus, or the 'nvram' on Broadcom's wifi router chips that is in reality a partition on either NOR or NAND flash. Accessing those at early boot from a random device driver is a real pain, and it would be much nicer to have the boot loader read them and put the data into the DT for us if we had the option. Unfortunately we have to deal with legacy boot loaders that don't change the DTB.
Quoted 21 lines
Quoted 6 lines
From Table 4.4, I came to the conclusion that the write wasn't really necessary:
SYS_PCICTL0x10000044Read only -Read returns a HIGH in bit [0] if a PCI board is present in the expansion backplane.I'll add it back.
The self-contradictory VersatilePB docs strike again, I see. Interestingly, in the PB1176 docs this register is documented as definitely read/only:
# [1]Read only: Reserved.
#
# Note
#
# On the RealView Platform Baseboard for ARM926EJ-S, this bit# was PCICONTROLIN signal and indicated that 66MHz mode was # enabled. The PB1176JZF-S only supports 33MHz operation. # # [0]Read only: Status of P_DETECT pin.
Quoted 7 lines
...and in passing provides some info about the 926 board that isn't in the docs for the 926!
A little digging suggests that it may in fact be the case that the 1176 docs are correct and the write to bit 0 does nothing. However the safest thing here is to keep doing what the old kernel did, I think.
Agreed. This also means that we need a way to access that register anyway, and any discussion about finding a way to move the read access for probing the device elsewhere is moot. A syscon device node would probably be best, but the current approach also works.
Arnd
PATCH 3/9 ARM: versatile: add DT based PCI detection
Quoted 4 lines · Arnd Bergmann
But that is exactly the point: While we try to ask the hardware about anything that can be reasonably queried through an in-kernel interface that talks to the hardware, it works less well when that hardware interface is rather obscure and (like this one) only used on a few special machines.
"We put this random collection of status bits in to a register somewhere because it was convenient for the h/w engineers" is pretty common, I think.
Quoted 8 lines
Similar examples are Marvell's SoC ID register, which you have to read by powering on the PCI host bridge and reading the Vendor/Device ID registers for the root bus, or the 'nvram' on Broadcom's wifi router chips that is in reality a partition on either NOR or NAND flash. Accessing those at early boot from a random device driver is a real pain, and it would be much nicer to have the boot loader read them and put the data into the DT for us if we had the option. Unfortunately we have to deal with legacy boot loaders that don't change the DTB.
I don't think it's going to be any easier for the boot loader, which is quite possibly totally uninterested in PCI and would have no reason to need to prod this location on the versatilepb. I also trust the kernel much more to get bugfixes and be easily updatable. I appreciate that it's more work for you if you can't just say "punt this nastiness to the bootloader", but I think it's also the better (more robust and self-contained) design.
-- PMM
PATCH 3/9 ARM: versatile: add DT based PCI detection
In reply to Rob HerringQuoted 9 lines · Rob Herring
From: Rob Herring <[email protected]>
Disable the Versatile PCI DT node when no PCI backplane is detected. This will prevent the Versatile PCI driver from probing when PCI is not populated.
Signed-off-by Rob Herring <[email protected]>Cc Russell King <[email protected]>Cc Linus Walleij <[email protected]>
(...)
arch/arm/mach-versatile/versatile_dt.c line 54
Quoted 2 lines
arch/arm/mach-versatile/versatile_dt.c +2
-0+/* Check if PCI backplane is detected */ + val =__raw_readl (base +VERSATILE_SYS_PCICTL_OFFSET );
I think this kind of random syscon register access should be handled using the mfd/syscon.c hub and looked up in some way to be used by the driver.
I'm thinking along the pattern of adding code in drivers/* by the pattern of e.g. drivers/video/fbdev/amba-clcd-versatile.c
i.e. an add-on that gets compiled-in only for those platform but still married to the main driver.
Yours,
Linus Walleij
PATCH 3/9 ARM: versatile: add DT based PCI detection
Quoted 12 lines · Linus Walleij
Quoted 9 lines · Rob Herring
From: Rob Herring <[email protected]>
Disable the Versatile PCI DT node when no PCI backplane is detected. This will prevent the Versatile PCI driver from probing when PCI is not populated.
Signed-off-by Rob Herring <[email protected]>Cc Russell King <[email protected]>Cc Linus Walleij <[email protected]>
Quoted 7 lines
(...)
arch/arm/mach-versatile/versatile_dt.c line 54
Quoted 2 lines
arch/arm/mach-versatile/versatile_dt.c +2
-0+/* Check if PCI backplane is detected */ + val =__raw_readl (base +VERSATILE_SYS_PCICTL_OFFSET );I think this kind of random syscon register access should be handled using the
mfd/syscon.chub and looked up in some way to be used by the driver.
Perhaps, but I've not figured out how much of VExpress syscon can be used for Versatile. I looked at it briefly, but it appeared to be more work that I have time for ATM. We still have other accesses to system registers in Versatile as well. So if we want to merge all this anytime soon, the options are:
- this patch
- Create a versatilepb-pci.dts which includes versatilepb.dts and enables PCI
- Default to PCI enabled (for QEMU) in the dts and users have to disable in their dts if they don't have a PCI backplane.
Quoted 5 lines
I'm thinking along the pattern of adding code in
drivers/*by the pattern of e.g.drivers/video/fbdev/amba-clcd-versatile.c
i.e. an add-on that gets compiled-in only for those platform but still married to the main driver.
One difference here is the PCI driver is pretty much only ever going to be for a single platform.
Rob
PATCH 4/9 pci: add DT based ARM Versatile PCI host driver
In reply to Rob HerringFrom: Rob Herring <[email protected]>
This converts the Versatile PCI host code to a platform driver using the commom DT parsing and setup. The driver uses only an empty ARM pci_sys_data struct and does not use pci_common_init_dev init function. The old host code will be removed in a subsequent commit when Versatile is completely converted to DT.
I've tested this on QEMU with the sym53c8xx driver in both i/o and memory mapped modes.
--- drivers/pci/host/Kconfig | 4 + drivers/pci/host/Makefile | 1 + drivers/pci/host/pci-versatile.c | 305 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 310 insertions(+) create mode 100644 drivers/pci/host/pci-versatile.c
drivers/pci/host/Kconfig +4 -0
@@ -102,4 +102,8 @@ config PCI_LAYERSCAPE help Say Y here if you want PCIe controller support on Layerscape SoCs. +config PCI_VERSATILE + bool "ARM Versatile PB PCI controller" + depends on ARCH_VERSATILE + endmenu
drivers/pci/host/Makefile +1 -0
@@ -12,3 +12,4 @@ obj-$(CONFIG_PCI_KEYSTONE) += pci-keystone-dw.o pci-keystone.o obj-$(CONFIG_PCIE_XILINX) += pcie-xilinx.o obj-$(CONFIG_PCI_XGENE) += pci-xgene.o obj-$(CONFIG_PCI_LAYERSCAPE) += pci-layerscape.o +obj-$(CONFIG_PCI_VERSATILE) += pci-versatile.o
drivers/pci/host/pci-versatile.c new file +305 -0
305 lines not on this page · raw message
Signature · 1 line
2.1.0
PATCH 4/9 pci: add DT based ARM Versatile PCI host driver
Quoted 10 lines · On Tuesday 30 December 2014 13:28:33 Rob Herring wrote:
From: Rob Herring <[email protected]>
This converts the Versatile PCI host code to a platform driver using the commom DT parsing and setup. The driver uses only an empty ARM
pci_sys_datastruct and does not usepci_common_init_devinit function. The old host code will be removed in a subsequent commit when Versatile is completely converted to DT.I've tested this on QEMU with the sym53c8xx driver in both i/o and memory mapped modes.
Ah, this is quite clever, I think you tried to explain to me what you did with the pci_sys_data before, but I didn't get it then.
drivers/pci/host/pci-versatile.c line 64
Quoted 12 lines
drivers/pci/host/pci-versatile.c new file +12
-0+ +static void __iomem *__pci_addr (struct pci_bus *bus, +unsigned int devfn,int offset) +{ +unsigned int busnr = bus->number; + +/* +* Trap out illegal values +*/ +BUG_ON (offset >255 ); +BUG_ON (busnr >255 ); +BUG_ON (devfn >255 );
Isn't an offset>255 something that can be triggered by a non-broken driver or even user space?
Maybe just return PCIBIOS_BAD_REGISTER_NUMBER in this case?
Quoted 33 lines
drivers/pci/host/pci-versatile.c new file +33
-0+static int versatile_pci_parse_request_of_pci_ranges (struct device *dev, +struct list_head *res) +{ +int err, mem =1 , res_valid =0 ; +struct device_node *np = dev->of_node; +resource_size_t iobase; +struct pci_host_bridge_window *win; + + err =of_pci_get_host_bridge_resources (np,0 ,0xff , res, &iobase); +if (err) +return err; + +list_for_each_entry (win, res, list) { +struct resource *parent, *res = win->res; + +switch (resource_type (res)) { +case IORESOURCE_IO : + parent = &ioport_resource; + err =pci_remap_iospace (res, iobase); +if (err) { +dev_warn (dev,"error %d: failed to map resource %pR\n" , + err, res); +continue ; + } +break ; +case IORESOURCE_MEM : + parent = &iomem_resource; + res_valid |= !(res->flags &IORESOURCE_PREFETCH ); + +writel (res->start >>28 ,PCI_IMAP (mem)); +writel (PHYS_OFFSET >>28 ,PCI_SMAP (mem)); + mem++; +
drivers/pci/host/pci-versatile.c line 181
Quoted 10 lines
drivers/pci/host/pci-versatile.c new file +10
-0+break ; +case IORESOURCE_BUS : +default : +continue ; + } + + err =devm_request_resource (dev, parent, res); +if (err) + goto out_release_res; + }
I wonder if we should also request the physical resource for the I/O space window to have it show up in /proc/iomem. We are rather inconsistent in this regard between drivers.
drivers/pci/host/pci-versatile.c line 286
Quoted 11 lines
drivers/pci/host/pci-versatile.c new file +11
-0+pci_add_flags (PCI_ENABLE_PROC_DOMAINS ); +pci_add_flags (PCI_REASSIGN_ALL_BUS |PCI_REASSIGN_ALL_RSRC ); + + bus =pci_scan_root_bus (&pdev->dev,0 , &pci_versatile_ops, &sys, &pci_res); +if (!bus) +return -ENOMEM ; + +pci_fixup_irqs (pci_common_swizzle, of_irq_parse_and_map_pci); +pci_assign_unassigned_bus_resources (bus); + +return 0 ;
One general question, mainly for Bjorn: pci_scan_root_bus adds all the devices at the Linux driver level by calling pci_bus_add_devices(), but then we call pci_fixup_irqs and pci_assign_unassigned_bus_resources after that, which will change the devices again. Is this how it's meant to work? How do we ensure that we have the correct irq number and resources by the time we enter the probe() function of the PCI device driver that gets bound to a device here?
Arnd
PATCH 4/9 pci: add DT based ARM Versatile PCI host driver
Quoted 15 lines · Arnd Bergmann
Quoted 10 lines · On Tuesday 30 December 2014 13:28:33 Rob Herring wrote:
From: Rob Herring <[email protected]>
This converts the Versatile PCI host code to a platform driver using the commom DT parsing and setup. The driver uses only an empty ARM
pci_sys_datastruct and does not usepci_common_init_devinit function. The old host code will be removed in a subsequent commit when Versatile is completely converted to DT.I've tested this on QEMU with the sym53c8xx driver in both i/o and memory mapped modes.
Ah, this is quite clever, I think you tried to explain to me what you did with the
pci_sys_databefore, but I didn't get it then.
Quoted 15 lines
drivers/pci/host/pci-versatile.c line 64
Quoted 12 lines
drivers/pci/host/pci-versatile.c new file +12
-0+ +static void __iomem *__pci_addr (struct pci_bus *bus, +unsigned int devfn,int offset) +{ +unsigned int busnr = bus->number; + +/* +* Trap out illegal values +*/ +BUG_ON (offset >255 ); +BUG_ON (busnr >255 ); +BUG_ON (devfn >255 );Isn't an offset>255 something that can be triggered by a non-broken driver or even user space?
I don't know. I just copied what the old driver did. Are these checks even host controller specific?
Quoted 1 line
Maybe just return
PCIBIOS_BAD_REGISTER_NUMBERin this case?
Perhaps. We could probably simplify the config space read/write functions and just provide the PCI core a bus/devfn/offset to config address translation function. That would not work in all cases, but propably most that have memory mapped config space.
Quoted 39 lines
Quoted 39 lines
drivers/pci/host/pci-versatile.c new file +39
-0+static int versatile_pci_parse_request_of_pci_ranges (struct device *dev, +struct list_head *res) +{ +int err, mem =1 , res_valid =0 ; +struct device_node *np = dev->of_node; +resource_size_t iobase; +struct pci_host_bridge_window *win; + + err =of_pci_get_host_bridge_resources (np,0 ,0xff , res, &iobase); +if (err) +return err; + +list_for_each_entry (win, res, list) { +struct resource *parent, *res = win->res; + +switch (resource_type (res)) { +case IORESOURCE_IO : + parent = &ioport_resource; + err =pci_remap_iospace (res, iobase); +if (err) { +dev_warn (dev,"error %d: failed to map resource %pR\n" , + err, res); +continue ; + } +break ; +case IORESOURCE_MEM : + parent = &iomem_resource; + res_valid |= !(res->flags &IORESOURCE_PREFETCH ); + +writel (res->start >>28 ,PCI_IMAP (mem)); +writel (PHYS_OFFSET >>28 ,PCI_SMAP (mem)); + mem++; + +break ; +case IORESOURCE_BUS : +default : +continue ; + } +
Quoted 8 lines
drivers/pci/host/pci-versatile.c line 181
Quoted 4 lines
drivers/pci/host/pci-versatile.c new file +4
-0+ err =devm_request_resource (dev, parent, res); +if (err) + goto out_release_res; + }I wonder if we should also request the physical resource for the I/O space window to have it show up in
/proc/iomem. We are rather inconsistent in this regard between drivers.
It's a little complicated now because we don't have that as a struct resource any more. We could reconstruct it from iobase and the i/o resource size.
Quoted 11 lines
Quoted 11 lines
drivers/pci/host/pci-versatile.c new file +10
-0+pci_add_flags (PCI_ENABLE_PROC_DOMAINS ); +pci_add_flags (PCI_REASSIGN_ALL_BUS |PCI_REASSIGN_ALL_RSRC ); + + bus =pci_scan_root_bus (&pdev->dev,0 , &pci_versatile_ops, &sys, &pci_res); +if (!bus) +return -ENOMEM ; + +pci_fixup_irqs (pci_common_swizzle, of_irq_parse_and_map_pci); +pci_assign_unassigned_bus_resources (bus); +
Quoted 8 lines
Quoted 1 line
+ return 0;
One general question, mainly for Bjorn:
pci_scan_root_busadds all the devices at the Linux driver level by callingpci_bus_add_devices(), but then we callpci_fixup_irqsandpci_assign_unassigned_bus_resourcesafter that, which will change the devices again. Is this how it's meant to work? How do we ensure that we have the correct irq number and resources by the time we enter theprobe()function of the PCI device driver that gets bound to a device here?
I'm a bit puzzled myself. I think that the devices are not probed until after pci_assign_unassigned_bus_resources. It certainly doesn't work without that call. Really, I think of_irq_parse_and_map_pci should be the default if no one else has set the device's irq (and the host has a device node of course).
It also seems to be a bit of random set of pci functions that are called here. It would be nice to simplify this chunk of code.
Rob
PATCH 4/9 pci: add DT based ARM Versatile PCI host driver
Quoted 32 lines · On Friday 02 January 2015 12:14:43 Rob Herring wrote:
Quoted 15 lines · Arnd Bergmann
Quoted 10 lines · On Tuesday 30 December 2014 13:28:33 Rob Herring wrote:
From: Rob Herring <[email protected]>
This converts the Versatile PCI host code to a platform driver using the commom DT parsing and setup. The driver uses only an empty ARM
pci_sys_datastruct and does not usepci_common_init_devinit function. The old host code will be removed in a subsequent commit when Versatile is completely converted to DT.I've tested this on QEMU with the sym53c8xx driver in both i/o and memory mapped modes.
Ah, this is quite clever, I think you tried to explain to me what you did with the
pci_sys_databefore, but I didn't get it then.Quoted 15 lines
drivers/pci/host/pci-versatile.c line 64
Quoted 12 lines
drivers/pci/host/pci-versatile.c new file +12
-0+ +static void __iomem *__pci_addr (struct pci_bus *bus, +unsigned int devfn,int offset) +{ +unsigned int busnr = bus->number; + +/* +* Trap out illegal values +*/ +BUG_ON (offset >255 ); +BUG_ON (busnr >255 ); +BUG_ON (devfn >255 );Isn't an offset>255 something that can be triggered by a non-broken driver or even user space?
Quoted 2 lines
I don't know. I just copied what the old driver did. Are these checks even host controller specific?
A busnr or devfn larger than 255 would be a serious bug on any host controller, those just don't exist. A BUG_ON check here is not a problem, but if we want to have it, I'd prefer to put it into the core code.
offset values between 256 and 4095 can be valid on some devices, but apparently this host controller does not support them.
Quoted 6 lines
Quoted 1 line
Maybe just return
PCIBIOS_BAD_REGISTER_NUMBERin this case?Perhaps. We could probably simplify the config space read/write functions and just provide the PCI core a bus/devfn/offset to config address translation function. That would not work in all cases, but propably most that have memory mapped config space.
Actually, thinking about this some more, the implementation seems to be "CAM" compliant, and we could share the confic space accessors with the ones from drivers/pci/host/pci-host-generic.c.
Quoted 73 lines
Quoted 39 lines
Quoted 39 lines
drivers/pci/host/pci-versatile.c new file +39
-0+static int versatile_pci_parse_request_of_pci_ranges (struct device *dev, +struct list_head *res) +{ +int err, mem =1 , res_valid =0 ; +struct device_node *np = dev->of_node; +resource_size_t iobase; +struct pci_host_bridge_window *win; + + err =of_pci_get_host_bridge_resources (np,0 ,0xff , res, &iobase); +if (err) +return err; + +list_for_each_entry (win, res, list) { +struct resource *parent, *res = win->res; + +switch (resource_type (res)) { +case IORESOURCE_IO : + parent = &ioport_resource; + err =pci_remap_iospace (res, iobase); +if (err) { +dev_warn (dev,"error %d: failed to map resource %pR\n" , + err, res); +continue ; + } +break ; +case IORESOURCE_MEM : + parent = &iomem_resource; + res_valid |= !(res->flags &IORESOURCE_PREFETCH ); + +writel (res->start >>28 ,PCI_IMAP (mem)); +writel (PHYS_OFFSET >>28 ,PCI_SMAP (mem)); + mem++; + +break ; +case IORESOURCE_BUS : +default : +continue ; + } +Quoted 8 lines
drivers/pci/host/pci-versatile.c line 181
Quoted 4 lines
drivers/pci/host/pci-versatile.c new file +4
-0+ err =devm_request_resource (dev, parent, res); +if (err) + goto out_release_res; + }I wonder if we should also request the physical resource for the I/O space window to have it show up in
/proc/iomem. We are rather inconsistent in this regard between drivers.It's a little complicated now because we don't have that as a struct resource any more. We could reconstruct it from iobase and the i/o resource size.
Quoted 10 lines
Quoted 10 lines
drivers/pci/host/pci-versatile.c new file +10
-0+pci_add_flags (PCI_ENABLE_PROC_DOMAINS ); +pci_add_flags (PCI_REASSIGN_ALL_BUS |PCI_REASSIGN_ALL_RSRC ); + + bus =pci_scan_root_bus (&pdev->dev,0 , &pci_versatile_ops, &sys, &pci_res); +if (!bus) +return -ENOMEM ; + +pci_fixup_irqs (pci_common_swizzle, of_irq_parse_and_map_pci); +pci_assign_unassigned_bus_resources (bus); +Quoted 8 lines
Quoted 1 line
+ return 0;
One general question, mainly for Bjorn:
pci_scan_root_busadds all the devices at the Linux driver level by callingpci_bus_add_devices(), but then we callpci_fixup_irqsandpci_assign_unassigned_bus_resourcesafter that, which will change the devices again. Is this how it's meant to work? How do we ensure that we have the correct irq number and resources by the time we enter theprobe()function of the PCI device driver that gets bound to a device here?
Quoted 8 lines
I'm a bit puzzled myself. I think that the devices are not probed until after
pci_assign_unassigned_bus_resources. It certainly doesn't work without that call. Really, I thinkof_irq_parse_and_map_pcishould be the default if no one else has set the device's irq (and the host has a device node of course).It also seems to be a bit of random set of pci functions that are called here. It would be nice to simplify this chunk of code.
Yes, and we recently had some attempts at creating a better interface posted on the mailing list, not sure what the latest status on it is. I think we want to end up with a two-stage interface along the lines of:
/* allocate a pci_host_bridge, scan DT, set default operations, map I/O space if necessary, request all resources ... */ phb = pci_host_bridge_create(parent, ..., sizeof(struct my_pci_private)); if (IS_ERR(phb)) return PTR_ERR(phb); /* any host specific customization */ phb->bus->ops = my_pci_ops; /* for nonstandard config space access */ phb->foo = my_pci_foo; /* some other optional function pointers, replacing pcibios_* */ my_pci = &phb->priv; /* extra allocated data */ my_pci->clk = devm_clk_get(parent, "pci"); my_pci->regs = devm_ioremap_resource(parent, platform_get_resource(pdev, IORESOURCE_MEM, 0); /* scan everything */ return pci_scan_child_bus_and_add_devices(phb->bus); Arnd
PATCH 4/9 pci: add DT based ARM Versatile PCI host driver
Quoted 33 lines · Arnd Bergmann
Quoted 32 lines · On Friday 02 January 2015 12:14:43 Rob Herring wrote:
Quoted 30 lines · Arnd Bergmann
Quoted 10 lines · On Tuesday 30 December 2014 13:28:33 Rob Herring wrote:
From: Rob Herring <[email protected]>
This converts the Versatile PCI host code to a platform driver using the commom DT parsing and setup. The driver uses only an empty ARM
pci_sys_datastruct and does not usepci_common_init_devinit function. The old host code will be removed in a subsequent commit when Versatile is completely converted to DT.I've tested this on QEMU with the sym53c8xx driver in both i/o and memory mapped modes.
Ah, this is quite clever, I think you tried to explain to me what you did with the
pci_sys_databefore, but I didn't get it then.drivers/pci/host/pci-versatile.c line 64
Quoted 12 lines
drivers/pci/host/pci-versatile.c new file +12
-0+ +static void __iomem *__pci_addr (struct pci_bus *bus, +unsigned int devfn,int offset) +{ +unsigned int busnr = bus->number; + +/* +* Trap out illegal values +*/ +BUG_ON (offset >255 ); +BUG_ON (busnr >255 ); +BUG_ON (devfn >255 );Isn't an offset>255 something that can be triggered by a non-broken driver or even user space?
Quoted 6 lines
Quoted 2 lines
I don't know. I just copied what the old driver did. Are these checks even host controller specific?
A busnr or devfn larger than 255 would be a serious bug on any host controller, those just don't exist. A
BUG_ONcheck here is not a problem, but if we want to have it, I'd prefer to put it into the core code.
Agreed.
Quoted 2 lines
offset values between 256 and 4095 can be valid on some devices, but apparently this host controller does not support them.
I'm going to drop the checks. The only checks I see in other drivers are for the bus number to match the root bus which I'm not convinced are needed either.
Quoted 10 lines
Quoted 6 lines
Quoted 1 line
Maybe just return
PCIBIOS_BAD_REGISTER_NUMBERin this case?Perhaps. We could probably simplify the config space read/write functions and just provide the PCI core a bus/devfn/offset to config address translation function. That would not work in all cases, but propably most that have memory mapped config space.
Actually, thinking about this some more, the implementation seems to be "CAM" compliant, and we could share the confic space accessors with the ones from
drivers/pci/host/pci-host-generic.c.
Almost. It uses readl for all size accesses. Yet writes support different access sizes. I would guess that the h/w can support byte and word reads if writes are supported, but I can't really verify. Dword-only sized reads or reads and writes seem to be the main variations for config space accesses. There's a few hosts with more complex config space access setup, but quite a few only vary in address decode.
Quoted 82 lines
Quoted 73 lines
Quoted 39 lines
Quoted 39 lines
drivers/pci/host/pci-versatile.c new file +39
-0+static int versatile_pci_parse_request_of_pci_ranges (struct device *dev, +struct list_head *res) +{ +int err, mem =1 , res_valid =0 ; +struct device_node *np = dev->of_node; +resource_size_t iobase; +struct pci_host_bridge_window *win; + + err =of_pci_get_host_bridge_resources (np,0 ,0xff , res, &iobase); +if (err) +return err; + +list_for_each_entry (win, res, list) { +struct resource *parent, *res = win->res; + +switch (resource_type (res)) { +case IORESOURCE_IO : + parent = &ioport_resource; + err =pci_remap_iospace (res, iobase); +if (err) { +dev_warn (dev,"error %d: failed to map resource %pR\n" , + err, res); +continue ; + } +break ; +case IORESOURCE_MEM : + parent = &iomem_resource; + res_valid |= !(res->flags &IORESOURCE_PREFETCH ); + +writel (res->start >>28 ,PCI_IMAP (mem)); +writel (PHYS_OFFSET >>28 ,PCI_SMAP (mem)); + mem++; + +break ; +case IORESOURCE_BUS : +default : +continue ; + } +Quoted 8 lines
drivers/pci/host/pci-versatile.c line 181
Quoted 4 lines
drivers/pci/host/pci-versatile.c new file +4
-0+ err =devm_request_resource (dev, parent, res); +if (err) + goto out_release_res; + }I wonder if we should also request the physical resource for the I/O space window to have it show up in
/proc/iomem. We are rather inconsistent in this regard between drivers.It's a little complicated now because we don't have that as a struct resource any more. We could reconstruct it from iobase and the i/o resource size.
Quoted 10 lines
Quoted 10 lines
drivers/pci/host/pci-versatile.c new file +10
-0+pci_add_flags (PCI_ENABLE_PROC_DOMAINS ); +pci_add_flags (PCI_REASSIGN_ALL_BUS |PCI_REASSIGN_ALL_RSRC ); + + bus =pci_scan_root_bus (&pdev->dev,0 , &pci_versatile_ops, &sys, &pci_res); +if (!bus) +return -ENOMEM ; + +pci_fixup_irqs (pci_common_swizzle, of_irq_parse_and_map_pci); +pci_assign_unassigned_bus_resources (bus); +Quoted 8 lines
Quoted 1 line
+ return 0;
One general question, mainly for Bjorn:
pci_scan_root_busadds all the devices at the Linux driver level by callingpci_bus_add_devices(), but then we callpci_fixup_irqsandpci_assign_unassigned_bus_resourcesafter that, which will change the devices again. Is this how it's meant to work? How do we ensure that we have the correct irq number and resources by the time we enter theprobe()function of the PCI device driver that gets bound to a device here?Quoted 8 lines
I'm a bit puzzled myself. I think that the devices are not probed until after
pci_assign_unassigned_bus_resources. It certainly doesn't work without that call. Really, I thinkof_irq_parse_and_map_pcishould be the default if no one else has set the device's irq (and the host has a device node of course).It also seems to be a bit of random set of pci functions that are called here. It would be nice to simplify this chunk of code.
Quoted 7 lines
Yes, and we recently had some attempts at creating a better interface posted on the mailing list, not sure what the latest status on it is. I think we want to end up with a two-stage interface along the lines of:
/* allocate a pci_host_bridge, scan DT, set default operations, map I/O space if necessary, request all resources ... */ phb = pci_host_bridge_create(parent, ..., sizeof(struct my_pci_private));
Humm, I wondered what happened to pci_host_bridge_create and thought we had abandoned it. It wasn't too clear reading thru the threads. The host drivers generally still have to walk thru the resources anyway to setup inbound and outbound windows, so we don't gain too much moving that out. And the error clean-up gets complicated too.
Rob
PATCH 4/9 pci: add DT based ARM Versatile PCI host driver
Quoted 16 lines · On Friday 02 January 2015 17:13:19 Rob Herring wrote:
Quoted 6 lines · Arnd Bergmann
Quoted 5 lines · On Friday 02 January 2015 12:14:43 Rob Herring wrote:
Quoted 3 lines · Arnd Bergmann
On Tuesday 30 December 2014 13:28:33 Rob Herring wrote:
Maybe just return
PCIBIOS_BAD_REGISTER_NUMBERin this case?Quoted 8 lines
Quoted 4 lines
Perhaps. We could probably simplify the config space read/write functions and just provide the PCI core a bus/devfn/offset to config address translation function. That would not work in all cases, but propably most that have memory mapped config space.
Actually, thinking about this some more, the implementation seems to be "CAM" compliant, and we could share the confic space accessors with the ones from
drivers/pci/host/pci-host-generic.c.
Quoted 7 lines
Almost. It uses readl for all size accesses. Yet writes support different access sizes. I would guess that the h/w can support byte and word reads if writes are supported, but I can't really verify. Dword-only sized reads or reads and writes seem to be the main variations for config space accesses. There's a few hosts with more complex config space access setup, but quite a few only vary in address decode.
It was probably just done the current way because it seemed simpler at the time, but I agree that we can just keep it like this if there is any chance it's required as a workaround for a hardware glitch.
With your other patch you just posted, it really becomes trivial to do.
Quoted 17 lines
Quoted 9 lines
Quoted 8 lines
I'm a bit puzzled myself. I think that the devices are not probed until after
pci_assign_unassigned_bus_resources. It certainly doesn't work without that call. Really, I thinkof_irq_parse_and_map_pcishould be the default if no one else has set the device's irq (and the host has a device node of course).It also seems to be a bit of random set of pci functions that are called here. It would be nice to simplify this chunk of code.
Quoted 7 lines
Yes, and we recently had some attempts at creating a better interface posted on the mailing list, not sure what the latest status on it is. I think we want to end up with a two-stage interface along the lines of:
/* allocate a pci_host_bridge, scan DT, set default operations, map I/O space if necessary, request all resources ... */ phb = pci_host_bridge_create(parent, ..., sizeof(struct my_pci_private));
Quoted 5 lines
Humm, I wondered what happened to
pci_host_bridge_createand thought we had abandoned it. It wasn't too clear reading thru the threads. The host drivers generally still have to walk thru the resources anyway to setup inbound and outbound windows, so we don't gain too much moving that out.
I think the discussion has not ended yet, I'm still in favor of doing it like that. The current of_pci_get_host_bridge_resources() function is indeed lacking a bit because it just returns the resources that are needed for setting up the PCI side, but it doesn't provide a list of the host side windows that may need to get programmed into hardware registers on machines without a firmware that has set them up in advance (i.e. most ARM32 and MIPS32 machines).
We could add another exported function to return those, or we could find a way to pass those back through the pci_host_bridge pointer from the common function.
Setting up the PCI side by itself does seem useful to me though, mainly to prevent host controller drivers from getting it wrong.
Quoted 1 line
And the error clean-up gets complicated too.
In what way? I would hope that we could come up with a way to make pci_host_bridge_create() able to roll-back, so it does nothing in case of an error, and allocate all resources using devm_* so it all gets undone if probe() fails for another reason.
Arnd
Bjorn Helgaas
maintainerPATCH 4/9 pci: add DT based ARM Versatile PCI host driver
In reply to Arnd BergmannQuoted 28 lines · Arnd Bergmann
Quoted 27 lines · On Tuesday 30 December 2014 13:28:33 Rob Herring wrote:
drivers/pci/host/pci-versatile.c new file +27
-0+list_for_each_entry (win, res, list) { +struct resource *parent, *res = win->res; + +switch (resource_type (res)) { +case IORESOURCE_IO : + parent = &ioport_resource; + err =pci_remap_iospace (res, iobase); +if (err) { +dev_warn (dev,"error %d: failed to map resource %pR\n" , + err, res); +continue ; + } +break ; +case IORESOURCE_MEM : + parent = &iomem_resource; + res_valid |= !(res->flags &IORESOURCE_PREFETCH ); + +writel (res->start >>28 ,PCI_IMAP (mem)); +writel (PHYS_OFFSET >>28 ,PCI_SMAP (mem)); + mem++; + +break ; +case IORESOURCE_BUS : +default : +continue ; + } +
Quoted 8 lines
drivers/pci/host/pci-versatile.c line 181
Quoted 4 lines
drivers/pci/host/pci-versatile.c new file +4
-0+ err =devm_request_resource (dev, parent, res); +if (err) + goto out_release_res; + }I wonder if we should also request the physical resource for the I/O space window to have it show up in
/proc/iomem. We are rather inconsistent in this regard between drivers.
I'd like that. We are inconsistent, but I think it's useful to have this information in /proc/iomem. After all, it is physical address space that we can't use for anything else, so I guess you could argue that it's actually a bug to omit it.
Quoted 10 lines
Quoted 10 lines
drivers/pci/host/pci-versatile.c new file +10
-0+pci_add_flags (PCI_ENABLE_PROC_DOMAINS ); +pci_add_flags (PCI_REASSIGN_ALL_BUS |PCI_REASSIGN_ALL_RSRC ); + + bus =pci_scan_root_bus (&pdev->dev,0 , &pci_versatile_ops, &sys, &pci_res); +if (!bus) +return -ENOMEM ; + +pci_fixup_irqs (pci_common_swizzle, of_irq_parse_and_map_pci); +pci_assign_unassigned_bus_resources (bus); +
Quoted 8 lines
Review
Quoted 1 line
(quoted diff) +1
-0+ return 0;One general question, mainly for Bjorn:
pci_scan_root_busadds all the devices at the Linux driver level by callingpci_bus_add_devices(), but then we callpci_fixup_irqsandpci_assign_unassigned_bus_resourcesafter that, which will change the devices again. Is this how it's meant to work? How do we ensure that we have the correct irq number and resources by the time we enter theprobe()function of the PCI device driver that gets bound to a device here?
Nope, that isn't how it's meant to work. After pci_bus_add_devices() completes, drivers can be already bound to the device, and the PCI core should keep its mitts off things the driver could be using. But I think we've had this problem for a long time, and I haven't looked at it recently to see how hard it would be to fix.
Bjorn
Bjorn Helgaas
maintainerPATCH 4/9 pci: add DT based ARM Versatile PCI host driver
In reply to Rob HerringSorry for the late reply; maybe this has already been queued up somewhere, so this might be moot.
I usually capitalize the "PCI" and first letter of the subject, like:
PCI: Add DT based ARM Versatile PCI host driver
And I try to ask for MAINTAINER updates since these drivers are under drivers/pci, but I can't maintain them all myself.
Quoted 11 lines · Rob Herring
From: Rob Herring <[email protected]>
This converts the Versatile PCI host code to a platform driver using the commom DT parsing and setup. The driver uses only an empty ARM
pci_sys_datastruct and does not usepci_common_init_devinit function. The old host code will be removed in a subsequent commit when Versatile is completely converted to DT.I've tested this on QEMU with the sym53c8xx driver in both i/o and memory mapped modes.
Quoted 6 lines
Signed-off-by Rob Herring <[email protected]>Cc Bjorn Helgaas <[email protected]>Cc linux-pci at vger.kernel.orgCc Russell King <[email protected]>Cc Linus Walleij <[email protected]>Cc Peter Maydell <[email protected]>
Looks fine to me.
drivers/pci/host/pci-versatile.c line 229
Quoted 6 lines
+++
b/drivers/pci/host/pci-versatile.c
...drivers/pci/host/pci-versatile.c new file +3
-0+/* +* We need to discover the PCI core first to configure itself +* before the main PCI probing is performed
Unusual to have two spaces between the "*" and the comments here.
Quoted 1 line
+MODULE_LICENSE("GPLv2");
This needs to be "GPL v2" per license_is_gpl_compatible().
PATCH 5/9 dts: versatile: add sysregs nodes
In reply to Rob HerringFrom: Rob Herring <[email protected]>
The Versatile boards have the same sysregs as other ARM Ltd boards. Add the nodes in preparation to enable support for 24MHz counter as sched_clock and MMC card detect and write protect support.
--- arch/arm/boot/dts/versatile-ab.dts | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+)
arch/arm/boot/dts/versatile-ab.dts +23 -0
@@ -252,6 +252,29 @@ #size-cells = <1>; ranges = <0 0x10000000 0x10000>; + sysreg at 0 { + compatible = "arm,vexpress-sysreg"; + reg = <0x00000 0x1000>; + + v2m_led_gpios: sys_led at 08 { + compatible = "arm,vexpress-sysreg,sys_led"; + gpio-controller; + #gpio-cells = <2>; + }; + + v2m_mmc_gpios: sys_mci at 48 { + compatible = "arm,vexpress-sysreg,sys_mci"; + gpio-controller; + #gpio-cells = <2>; + }; + + v2m_flash_gpios: sys_flash at 4c { + compatible = "arm,vexpress-sysreg,sys_flash"; + gpio-controller; + #gpio-cells = <2>; + }; + }; + aaci at 4000 { compatible = "arm,primecell"; reg = <0x4000 0x1000>;
Signature · 1 line
2.1.0
PATCH 5/9 dts: versatile: add sysregs nodes
Quoted 18 lines · Rob Herring
From: Rob Herring <[email protected]>
The Versatile boards have the same sysregs as other ARM Ltd boards. Add the nodes in preparation to enable support for 24MHz counter as
sched_clockand MMC card detect and write protect support.Signed-off-by Rob Herring <[email protected]>Cc Russell King <[email protected]>Cc Linus Walleij <[email protected]>--- arch/arm/boot/dts/versatile-ab.dts | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+)arch/arm/boot/dts/versatile-ab.dts +0
-0
arch/arm/boot/dts/versatile-ab.dts line 256
Quoted 5 lines
arch/arm/boot/dts/versatile-ab.dts +2
-0@@ -252,6 +252,29 @@ #size-cells = <1>; ranges = <0 0x10000000 0x10000>; + sysreg at 0 { + compatible = "arm,vexpress-sysreg";
vexpress? No...
compatible = "syscon";
arch/arm/boot/dts/versatile-ab.dts line 263
Quoted 7 lines
arch/arm/boot/dts/versatile-ab.dts +7
-0+ reg = <0x00000 0x1000>; + + v2m_led_gpios: sys_led at 08 { + compatible = "arm,vexpress-sysreg,sys_led"; + gpio-controller; + #gpio-cells = <2>; + };
These are not GPIOs. These are LED registers really. see how to use LEDs from drivers/leds/leds-syscon.c and bindings. example in:arch/arm/boot/dts/integrator.dtsi
Very straight-forward I think.
arch/arm/boot/dts/versatile-ab.dts line 275
Quoted 12 lines
arch/arm/boot/dts/versatile-ab.dts +12
-0+ + v2m_mmc_gpios: sys_mci at 48 { + compatible = "arm,vexpress-sysreg,sys_mci"; + gpio-controller; + #gpio-cells = <2>; + }; + + v2m_flash_gpios: sys_flash at 4c { + compatible = "arm,vexpress-sysreg,sys_flash"; + gpio-controller; + #gpio-cells = <2>; + };
I don't have drivers for these "gpio controllers" and I don't think they are GPIOs either, since they are not general purpose at all.
For the latter I have some code boiling for the Integrators:
https://git.kernel.org/cgit/linux/kernel/git/linusw/linux-integrator.git/commit/?h=multiplatform&id=9c28e114ec957fadf1dade382d8e8b8aa43c8426
https://git.kernel.org/cgit/linux/kernel/git/linusw/linux-integrator.git/commit/?h=multiplatform&id=a3d4512abb85de290cdca0586bcff9147833917f
Yours,
Linus Walleij
PATCH 5/9 dts: versatile: add sysregs nodes
Adding VExpress maintainers...
Quoted 23 lines · Linus Walleij
Quoted 21 lines · Rob Herring
From: Rob Herring <[email protected]>
The Versatile boards have the same sysregs as other ARM Ltd boards. Add the nodes in preparation to enable support for 24MHz counter as
sched_clockand MMC card detect and write protect support.Signed-off-by Rob Herring <[email protected]>Cc Russell King <[email protected]>Cc Linus Walleij <[email protected]>--- arch/arm/boot/dts/versatile-ab.dts | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+)arch/arm/boot/dts/versatile-ab.dts +0
-0@@ -252,6 +252,29 @@ #size-cells = <1>; ranges = <0 0x10000000 0x10000>;
Quoted 4 lines
arch/arm/boot/dts/versatile-ab.dts line 256
Quoted 2 lines
arch/arm/boot/dts/versatile-ab.dts +2
-0+ sysreg at 0 { + compatible = "arm,vexpress-sysreg";vexpress? No...
Compatible with yes. Should perhaps be '"arm,versatile-sysreg", "arm,vexpress-sysreg"' instead. Kind of backwards, as really the versatile came first, but it would work. Or we just need another match entry in the kernel.
I copied this whole chunk as is from VExpress and verified these sub nodes are all the same hence why it is here.
Quoted 1 line
compatible = "syscon";
maybe? VExpress is missing that then...
Quoted 9 lines
arch/arm/boot/dts/versatile-ab.dts line 263
Quoted 7 lines
arch/arm/boot/dts/versatile-ab.dts +7
-0+ reg = <0x00000 0x1000>; + + v2m_led_gpios: sys_led at 08 { + compatible = "arm,vexpress-sysreg,sys_led"; + gpio-controller; + #gpio-cells = <2>; + };These are not GPIOs. These are LED registers really.
A register bit that controls an i/o signal sounds like a GPIO to me.
Quoted 5 lines
see how to use LEDs from
drivers/leds/leds-syscon.cand bindings. example in:arch/arm/boot/dts/integrator.dtsiVery straight-forward I think.
So we have 2 implementations and bindings for roughly the same hardware? Great!
Quoted 12 lines
arch/arm/boot/dts/versatile-ab.dts line 275
Quoted 11 lines
arch/arm/boot/dts/versatile-ab.dts +11
-0+ v2m_mmc_gpios: sys_mci at 48 { + compatible = "arm,vexpress-sysreg,sys_mci"; + gpio-controller; + #gpio-cells = <2>; + }; + + v2m_flash_gpios: sys_flash at 4c { + compatible = "arm,vexpress-sysreg,sys_flash"; + gpio-controller; + #gpio-cells = <2>; + };
Quoted 2 lines
I don't have drivers for these "gpio controllers" and I don't think they are GPIOs either, since they are not general purpose at all.
They are only general purpose until you connect the i/o lines to something. But yes, if we went around making every misc internal control line in SOCs a 1-bit GPIO controller that would be pretty crazy.
Anyway, most of this is not actually used ATM on Versatile, but it is present in VExpress. I added it only for sched_clock. We need to resolve this with VExpress platforms, but it's already in use for MMC and LEDs.
Rob
Quoted 6 lines
For the latter I have some code boiling for the Integrators:
https://git.kernel.org/cgit/linux/kernel/git/linusw/linux-integrator.git/commit/?h=multiplatform&id=9c28e114ec957fadf1dade382d8e8b8aa43c8426
https://git.kernel.org/cgit/linux/kernel/git/linusw/linux-integrator.git/commit/?h=multiplatform&id=a3d4512abb85de290cdca0586bcff9147833917fYours,
Linus Walleij
PATCH 5/9 dts: versatile: add sysregs nodes
Quoted 6 lines · Rob Herring
Quoted 2 lines · Linus Walleij
On Tue, Dec 30, 2014 at 8:28 PM, Rob Herring <[email protected]> wrote:
compatible = "syscon";maybe? VExpress is missing that then...
I don't like the way some vexpress stuff has been done I think, just not enough reviewing power :(
I've tried to make an as clean separation as possible in the Integrator as it has been refactored with a minimum of time pressure and I tried to make it as reusable as possible. But it doesn't necessarily mean I did the right thing all the time ...
Quoted 11 lines
Quoted 9 lines
arch/arm/boot/dts/versatile-ab.dts line 263
Quoted 7 lines
arch/arm/boot/dts/versatile-ab.dts +7
-0+ reg = <0x00000 0x1000>; + + v2m_led_gpios: sys_led at 08 { + compatible = "arm,vexpress-sysreg,sys_led"; + gpio-controller; + #gpio-cells = <2>; + };These are not GPIOs. These are LED registers really.
A register bit that controls an i/o signal sounds like a GPIO to me.
Are they described as general purpose in the manual for the board?
In the ARM reference design manuals I've seen these bits are described as for one purpose only. I mean you can claim the memory RE signal is "a bit that controls an I/O signal" as well, but we have to think about the abstraction here.
Quoted 7 lines
Quoted 5 lines
see how to use LEDs from
drivers/leds/leds-syscon.cand bindings. example in:arch/arm/boot/dts/integrator.dtsiVery straight-forward I think.
So we have 2 implementations and bindings for roughly the same hardware? Great!
The syscon stuff is designed to be reusable for machines outside the Versatile and ARM reference families.
Yours,
Linus Walleij
PATCH 5/9 dts: versatile: add sysregs nodes
Cc'ing Pawel since he wrote the sysreg code
Quoted 10 lines · Linus Walleij
Quoted 6 lines · Rob Herring
Quoted 2 lines · Linus Walleij
On Tue, Dec 30, 2014 at 8:28 PM, Rob Herring <[email protected]> wrote:
compatible = "syscon";maybe? VExpress is missing that then...
I don't like the way some vexpress stuff has been done I think, just not enough reviewing power :(
I think that "syscon" is not meant to be there in the first place and it was done on purpose for vexpress but I need Pawel to confirm and shed light on this.
Quoted 17 lines
I've tried to make an as clean separation as possible in the Integrator as it has been refactored with a minimum of time pressure and I tried to make it as reusable as possible. But it doesn't necessarily mean I did the right thing all the time ...
Quoted 11 lines
Quoted 9 lines
arch/arm/boot/dts/versatile-ab.dts line 263
Quoted 7 lines
arch/arm/boot/dts/versatile-ab.dts +7
-0+ reg = <0x00000 0x1000>; + + v2m_led_gpios: sys_led at 08 { + compatible = "arm,vexpress-sysreg,sys_led"; + gpio-controller; + #gpio-cells = <2>; + };These are not GPIOs. These are LED registers really.
A register bit that controls an i/o signal sounds like a GPIO to me.
Quoted 7 lines
Are they described as general purpose in the manual for the board?
In the ARM reference design manuals I've seen these bits are described as for one purpose only. I mean you can claim the memory RE signal is "a bit that controls an I/O signal" as well, but we have to think about the abstraction here.
I will have a look into this.
Thanks,
Lorenzo
PATCH 5/9 dts: versatile: add sysregs nodes
In reply to Rob HerringQuoted 31 lines · Rob Herring
Adding VExpress maintainers...
Quoted 23 lines · Linus Walleij
Quoted 21 lines · Rob Herring
From: Rob Herring <[email protected]>
The Versatile boards have the same sysregs as other ARM Ltd boards. Add the nodes in preparation to enable support for 24MHz counter as
sched_clockand MMC card detect and write protect support.Signed-off-by Rob Herring <[email protected]>Cc Russell King <[email protected]>Cc Linus Walleij <[email protected]>--- arch/arm/boot/dts/versatile-ab.dts | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+)arch/arm/boot/dts/versatile-ab.dts +0
-0@@ -252,6 +252,29 @@ #size-cells = <1>; ranges = <0 0x10000000 0x10000>;Quoted 4 lines
arch/arm/boot/dts/versatile-ab.dts line 256
Quoted 2 lines
arch/arm/boot/dts/versatile-ab.dts +2
-0+ sysreg at 0 { + compatible = "arm,vexpress-sysreg";vexpress? No...
Quoted 4 lines
Compatible with yes. Should perhaps be '"arm,versatile-sysreg", "arm,vexpress-sysreg"' instead. Kind of backwards, as really the versatile came first, but it would work. Or we just need another match entry in the kernel.
versatile and vexpress sys registers are not compatible, so they should not be treated as such.
Actually, versatile regs are not managed by a single entity driver in the kernel, so basically I really think you should not leave
"arm,vexpress-sysreg"
in the compatible list.
Quoted 6 lines
I copied this whole chunk as is from VExpress and verified these sub nodes are all the same hence why it is here.
Quoted 1 line
compatible = "syscon";
maybe? VExpress is missing that then...
vexpress-sysreg is more than a "syscon" interface, so we can't match on it, it would be wrong.
Quoted 9 lines
Quoted 9 lines
Quoted 8 lines
arch/arm/boot/dts/versatile-ab.dts +7
-0+ reg = <0x00000 0x1000>; + + v2m_led_gpios: sys_led at 08 { + compatible = "arm,vexpress-sysreg,sys_led"; + gpio-controller; + #gpio-cells = <2>; + };
Quoted 3 lines
Quoted 1 line
These are not GPIOs. These are LED registers really.
A register bit that controls an i/o signal sounds like a GPIO to me.
To me too. I agree that definining a gpio-controller for every possible gpio pin would soon get unwieldy, but hey, the choice made for vexpress leds makes perfect sense to me, after all they are gpio signals connected to leds, and there is a driver for that in the kernel:
drivers/leds/leds-gpio.c
we could move this stuff to syscon-leds, but honestly I think is one of those things we could argue forever about that.
Quoted 7 lines
Quoted 5 lines
see how to use LEDs from
drivers/leds/leds-syscon.cand bindings. example in:arch/arm/boot/dts/integrator.dtsiVery straight-forward I think.
So we have 2 implementations and bindings for roughly the same hardware? Great!
See above.
Quoted 20 lines
Quoted 12 lines
arch/arm/boot/dts/versatile-ab.dts line 275
Quoted 11 lines
arch/arm/boot/dts/versatile-ab.dts +11
-0+ v2m_mmc_gpios: sys_mci at 48 { + compatible = "arm,vexpress-sysreg,sys_mci"; + gpio-controller; + #gpio-cells = <2>; + }; + + v2m_flash_gpios: sys_flash at 4c { + compatible = "arm,vexpress-sysreg,sys_flash"; + gpio-controller; + #gpio-cells = <2>; + };Quoted 2 lines
I don't have drivers for these "gpio controllers" and I don't think they are GPIOs either, since they are not general purpose at all.
They are only general purpose until you connect the i/o lines to something. But yes, if we went around making every misc internal control line in SOCs a 1-bit GPIO controller that would be pretty crazy.
Quoted 4 lines
Anyway, most of this is not actually used ATM on Versatile, but it is present in VExpress. I added it only for
sched_clock. We need to resolve this with VExpress platforms, but it's already in use for MMC and LEDs.
I did not get what you meant here, in particular which bits you want us to fix/change/update on vexpress.
Thanks,
Lorenzo
Linus Walleij
NAKPATCH 5/9 dts: versatile: add sysregs nodes
Quoted 21 lines · Lorenzo Pieralisi
Quoted 11 lines · Rob Herring
Quoted 10 lines · Linus Walleij
Quoted 7 lines · Rob Herring
arch/arm/boot/dts/versatile-ab.dts +7
-0+ reg = <0x00000 0x1000>; + + v2m_led_gpios: sys_led at 08 { + compatible = "arm,vexpress-sysreg,sys_led"; + gpio-controller; + #gpio-cells = <2>; + };Quoted 3 lines
Quoted 1 line
These are not GPIOs. These are LED registers really.
A register bit that controls an i/o signal sounds like a GPIO to me.
To me too. I agree that definining a gpio-controller for every possible gpio pin would soon get unwieldy, but hey, the choice made for vexpress leds makes perfect sense to me, after all they are gpio signals connected to leds, and there is a driver for that in the kernel:
Quoted 4 lines
drivers/leds/leds-gpio.cwe could move this stuff to syscon-leds, but honestly I think is one of those things we could argue forever about that.
OK it's just so that the GPIO maintainer disagrees with the way gpio-controller is being used here, and I consequently NACK it so for the record add my:
To this patch if/when merging it through ARM SoC.
If the DT people think it is a good way to describe the hardware and override this then I will live with it I guess...
Yours,
Linus Walleij
PATCH 6/9 ARM: versatile: switch to DT only booting and remove legacy code
In reply to Rob HerringFrom: Rob Herring <[email protected]>
With DT support for clocks, irqchips, timers, and PCI now in place, DT based booting has feature parity with non-DT legacy boot. The final piece is actually enabling common clock support on Versatile. Enabling full DT support requires either removing the old Versatile clock code, updating the legacy boot to use the common clock code, or making DT and legacy boot mutually exclusive. Given that removing legacy boot code is the goal anyway, I am going with the 1st option.
Tested on QEMU. Earlier versions of this patch have been tested on h/w by Linus Walleij.
--- arch/arm/Kconfig | 14 +- arch/arm/mach-versatile/Kconfig | 33 -- arch/arm/mach-versatile/Makefile | 6 +- arch/arm/mach-versatile/core.c | 540 +----------------------- arch/arm/mach-versatile/core.h | 9 +- arch/arm/mach-versatile/include/mach/clkdev.h | 16 - arch/arm/mach-versatile/include/mach/hardware.h | 6 - arch/arm/mach-versatile/include/mach/irqs.h | 134 ------ arch/arm/mach-versatile/include/mach/platform.h | 174 -------- arch/arm/mach-versatile/pci.c | 368 ---------------- arch/arm/mach-versatile/versatile_ab.c | 44 -- arch/arm/mach-versatile/versatile_dt.c | 1 + arch/arm/mach-versatile/versatile_pb.c | 91 ---- drivers/clk/versatile/Kconfig | 3 +- 14 files changed, 23 insertions(+), 1416 deletions(-) delete mode 100644 arch/arm/mach-versatile/Kconfig delete mode 100644 arch/arm/mach-versatile/include/mach/clkdev.h delete mode 100644 arch/arm/mach-versatile/include/mach/irqs.h delete mode 100644 arch/arm/mach-versatile/pci.c delete mode 100644 arch/arm/mach-versatile/versatile_ab.c delete mode 100644 arch/arm/mach-versatile/versatile_pb.c
arch/arm/Kconfig +7 -7
@@ -343,13 +343,15 @@ config ARCH_VERSATILE select ARM_AMBA select ARM_TIMER_SP804 select ARM_VIC - select CLKDEV_LOOKUP + select CLKSRC_VERSATILE + select COMMON_CLK + select COMMON_CLK_VERSATILE + select CPU_ARM926T select GENERIC_CLOCKEVENTS - select HAVE_MACH_CLKDEV select ICST - select PLAT_VERSATILE - select PLAT_VERSATILE_CLOCK - select PLAT_VERSATILE_SCHED_CLOCK + select MIGHT_HAVE_PCI + select SPARSE_IRQ + select USE_OF select VERSATILE_FPGA_IRQ help This enables support for ARM Ltd Versatile board.
@@ -954,8 +956,6 @@ source "arch/arm/mach-u300/Kconfig" source "arch/arm/mach-ux500/Kconfig" -source "arch/arm/mach-versatile/Kconfig" - source "arch/arm/mach-vexpress/Kconfig" source "arch/arm/plat-versatile/Kconfig"
arch/arm/mach-versatile/Kconfig deleted +0 -33
@@ -1,33 +0,0 @@ -menu "Versatile platform type" - depends on ARCH_VERSATILE - -config ARCH_VERSATILE_PB - bool "Support Versatile Platform Baseboard for ARM926EJ-S" - default y - select CPU_ARM926T - select MIGHT_HAVE_PCI - help - Include support for the ARM(R) Versatile Platform Baseboard - for the ARM926EJ-S. - -config MACH_VERSATILE_AB - bool "Support Versatile Application Baseboard for ARM926EJ-S" - select CPU_ARM926T - help - Include support for the ARM(R) Versatile Application Baseboard - for the ARM926EJ-S. - -config MACH_VERSATILE_DT - bool "Support Versatile platform from device tree" - select CPU_ARM926T - select USE_OF - help - Include support for the ARM(R) Versatile/PB platform, - using the device tree for discovery - -config MACH_VERSATILE_AUTO - def_bool y - depends on !ARCH_VERSATILE_PB && !MACH_VERSATILE_AB - select MACH_VERSATILE_DT - -endmenu
arch/arm/mach-versatile/Makefile +1 -5
@@ -2,8 +2,4 @@ # Makefile for the linux kernel. # -obj-y := core.o -obj-$(CONFIG_ARCH_VERSATILE_PB) += versatile_pb.o -obj-$(CONFIG_MACH_VERSATILE_AB) += versatile_ab.o -obj-$(CONFIG_MACH_VERSATILE_DT) += versatile_dt.o -obj-$(CONFIG_PCI) += pci.o +obj-y := core.o versatile_dt.o
arch/arm/mach-versatile/core.c +10 -530
651 lines not on this page · raw message
arch/arm/mach-versatile/core.h +2 -7
@@ -26,7 +26,8 @@#include <linux/of_platform.h> #include <linux/reboot.h> -extern void __init versatile_init (void ); +extern struct platform_device versatile_flash_device; +extern void __init versatile_init_early (void );extern void __init versatile_init_irq (void );extern void __init versatile_map_io (void );
@@ -37,10 +38,4 @@ extern unsigned int mmc_status(struct device *dev);extern struct of_dev_auxdata versatile_auxdata_lookup[];#endif -#define APB_DEVICE (name, busid, base, plat) \ -static AMBA_APB_DEVICE(name, busid, 0, VERSATILE_##base##_BASE, base##_IRQ, plat) - -#define AHB_DEVICE (name, busid, base, plat) \ -static AMBA_AHB_DEVICE(name, busid, 0, VERSATILE_##base##_BASE, base##_IRQ, plat) -#endif
arch/arm/mach-versatile/include/mach/clkdev.h deleted +0 -16
@@ -1,16 +0,0 @@ -#ifndef __ASM_MACH_CLKDEV_H -#define __ASM_MACH_CLKDEV_H - -#include <plat/clock.h> - -struct clk { -unsigned long rate; -const struct clk_ops *ops; -const struct icst_params *params; -void __iomem *vcoreg; -}; - -#define __clk_get (clk) ({ 1; }) -#define __clk_put (clk) do { } while (0) - -#endif
arch/arm/mach-versatile/include/mach/hardware.h +0 -6
@@ -24,12 +24,6 @@#include <asm/sizes.h> -/* -* PCI space virtual addresses -*/ -#define VERSATILE_PCI_VIRT_BASE (void __iomem *)0xe8000000ul -#define VERSATILE_PCI_CFG_VIRT_BASE (void __iomem *)0xe9000000ul -/* macro to get at MMIO space when running virtually */ #define IO_ADDRESS (x) (((x) & 0x0fffffff) + (((x) >> 4) & 0x0f000000) + 0xf0000000)
arch/arm/mach-versatile/include/mach/irqs.h deleted +0 -134
134 lines not on this page · raw message
arch/arm/mach-versatile/include/mach/platform.h +0 -174
207 lines not on this page · raw message
arch/arm/mach-versatile/pci.c deleted +0 -368
368 lines not on this page · raw message
arch/arm/mach-versatile/versatile_ab.c deleted +0 -44
44 lines not on this page · raw message
arch/arm/mach-versatile/versatile_dt.c +1 -0
@@ -77,6 +77,7 @@ static void __init versatile_dt_init(void) {versatile_dt_pci_init (); +platform_device_register (&versatile_flash_device);of_platform_populate (NULL , of_default_bus_match_table, versatile_auxdata_lookup,NULL ); }
arch/arm/mach-versatile/versatile_pb.c deleted +0 -91
91 lines not on this page · raw message
drivers/clk/versatile/Kconfig +2 -1
@@ -1,6 +1,7 @@ config COMMON_CLK_VERSATILE bool "Clock driver for ARM Reference designs" - depends on ARCH_INTEGRATOR || ARCH_REALVIEW || ARCH_VEXPRESS || ARM64 + depends on ARCH_INTEGRATOR || ARCH_REALVIEW || \ + ARCH_VERSATILE || ARCH_VEXPRESS || ARM64 ---help--- Supports clocking on ARM Reference designs: - Integrator/AP and Integrator/CP
Signature · 1 line
2.1.0
PATCH 7/9 ARM: versatile: move mach includes into mach directory
In reply to Rob HerringFrom: Rob Herring <[email protected]>
In preparation for multi-platform support, move platform.h and hardware.h into mach-versatile directory. Combine them into a single file in the process.
---
arch/arm/mach-versatile/core.c | 3 +-
arch/arm/mach-versatile/include/mach/hardware.h | 32 ----------------------
.../mach-versatile/{include/mach => }/platform.h | 5 ++++
3 files changed, 6 insertions(+), 34 deletions(-)
delete mode 100644 arch/arm/mach-versatile/include/mach/hardware.h
rename arch/arm/mach-versatile/{include/mach => }/platform.h (98%)arch/arm/mach-versatile/core.c +1 -2
@@ -34,8 +34,7 @@#include <asm/mach/arch.h> #include <asm/mach/map.h> -#include <mach/hardware.h> -#include <mach/platform.h> +#include "platform.h" #include "core.h"
arch/arm/mach-versatile/include/mach/hardware.h deleted +0 -32
@@ -1,32 +0,0 @@ -/* -* arch/arm/mach-versatile/include/mach/hardware.h -* -* This file contains the hardware definitions of the Versatile boards. -* -* Copyright (C) 2003 ARM Limited. -* -* This program is free software; you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation; either version 2 of the License, or -* (at your option) any later version. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software -* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ -#ifndef __ASM_ARCH_HARDWARE_H -#define __ASM_ARCH_HARDWARE_H - -#include <asm/sizes.h> - -/* macro to get at MMIO space when running virtually */ -#define IO_ADDRESS (x) (((x) & 0x0fffffff) + (((x) >> 4) & 0x0f000000) + 0xf0000000) - -#define __io_address (n) ((void __iomem __force *)IO_ADDRESS(n)) - -#endif
arch/arm/mach-versatile/platform.h renamed from arch/arm/mach-versatile/include/mach/platform.h +5 -0
@@ -21,6 +21,11 @@#ifndef __address_h#define __address_h 1 +/* macro to get at MMIO space when running virtually */ +#define IO_ADDRESS (x) (((x) & 0x0fffffff) + (((x) >> 4) & 0x0f000000) + 0xf0000000) + +#define __io_address (n) ((void __iomem __force *)IO_ADDRESS(n)) +/* * Memory definitions */
Signature · 1 line
2.1.0
PATCH 7/9 ARM: versatile: move mach includes into mach directory
Quoted 6 lines · On Tuesday 30 December 2014 13:28:36 Rob Herring wrote:
From: Rob Herring <[email protected]>
In preparation for multi-platform support, move
platform.handhardware.hinto mach-versatile directory. Combine them into a single file in the process.
Quoted 9 lines
Signed-off-by Rob Herring <[email protected]>Cc Russell King <[email protected]>Cc Linus Walleij <[email protected]>--- arch/arm/mach-versatile/core.c | 3 +- arch/arm/mach-versatile/include/mach/hardware.h | 32 ---------------------- .../mach-versatile/{include/mach => }/platform.h | 5 ++++ 3 files changed, 6 insertions(+), 34 deletions(-)
If I read this right, there is only one file left that includes this header after patch 9, so how about moving the contents into versatile_dt.c directly?
Arnd
PATCH 8/9 ARM: versatile: convert to multi-platform
In reply to Rob HerringFrom: Rob Herring <[email protected]>
Now that all the prerequisites are in place, we can enable Versatile boards for multi-platform kernels.
--- arch/arm/Kconfig | 21 +---------- arch/arm/mach-versatile/Kconfig | 14 +++++++ arch/arm/mach-versatile/Makefile.boot | 4 -- arch/arm/mach-versatile/include/mach/uncompress.h | 45 ----------------------- 4 files changed, 16 insertions(+), 68 deletions(-) create mode 100644 arch/arm/mach-versatile/Kconfig delete mode 100644 arch/arm/mach-versatile/Makefile.boot delete mode 100644 arch/arm/mach-versatile/include/mach/uncompress.h
arch/arm/Kconfig +2 -19
@@ -337,25 +337,6 @@ config ARCH_REALVIEW help This enables support for ARM Ltd RealView boards. -config ARCH_VERSATILE - bool "ARM Ltd. Versatile family" - select ARCH_WANT_OPTIONAL_GPIOLIB - select ARM_AMBA - select ARM_TIMER_SP804 - select ARM_VIC - select CLKSRC_VERSATILE - select COMMON_CLK - select COMMON_CLK_VERSATILE - select CPU_ARM926T - select GENERIC_CLOCKEVENTS - select ICST - select MIGHT_HAVE_PCI - select SPARSE_IRQ - select USE_OF - select VERSATILE_FPGA_IRQ - help - This enables support for ARM Ltd Versatile board. - config ARCH_AT91 bool "Atmel AT91" select ARCH_REQUIRE_GPIOLIB
@@ -956,6 +937,8 @@ source "arch/arm/mach-u300/Kconfig" source "arch/arm/mach-ux500/Kconfig" +source "arch/arm/mach-versatile/Kconfig" + source "arch/arm/mach-vexpress/Kconfig" source "arch/arm/plat-versatile/Kconfig"
arch/arm/mach-versatile/Kconfig new file +14 -0
@@ -0,0 +1,14 @@ +config ARCH_VERSATILE + bool "ARM Ltd. Versatile family" if ARCH_MULTI_V5 + select ARM_AMBA + select ARM_TIMER_SP804 + select ARM_VIC + select CLKSRC_VERSATILE + select COMMON_CLK_VERSATILE + select CPU_ARM926T + select ICST + select MIGHT_HAVE_PCI + select VERSATILE_FPGA_IRQ + help + This enables support for ARM Ltd Versatile board. +
arch/arm/mach-versatile/Makefile.boot deleted +0 -4
@@ -1,4 +0,0 @@ - zreladdr-y += 0x00008000 -params_phys-y := 0x00000100 -initrd_phys-y := 0x00800000 -
arch/arm/mach-versatile/include/mach/uncompress.h deleted +0 -45
45 lines not on this page · raw message
Signature · 1 line
2.1.0
PATCH 9/9 ARM: versatile: consolidate code to single file
In reply to Rob HerringFrom: Rob Herring <[email protected]>
The split of core.c and versatile_dt.c now makes little sense, so move all of core.c into versatile_dt.c.
--- arch/arm/mach-versatile/Makefile | 2 +- arch/arm/mach-versatile/core.c | 324 --------------------------------- arch/arm/mach-versatile/core.h | 41 ----- arch/arm/mach-versatile/versatile_dt.c | 291 ++++++++++++++++++++++++++++- 4 files changed, 291 insertions(+), 367 deletions(-) delete mode 100644 arch/arm/mach-versatile/core.c delete mode 100644 arch/arm/mach-versatile/core.h
arch/arm/mach-versatile/Makefile +1 -1
@@ -2,4 +2,4 @@ # Makefile for the linux kernel. # -obj-y := core.o versatile_dt.o +obj-y := versatile_dt.o
arch/arm/mach-versatile/core.c deleted +0 -324
324 lines not on this page · raw message
arch/arm/mach-versatile/core.h deleted +0 -41
41 lines not on this page · raw message
arch/arm/mach-versatile/versatile_dt.c +290 -1
303 lines not on this page · raw message
Signature · 1 line
2.1.0
cover ARM Versatile multi-platform support
In reply to Rob HerringQuoted 8 lines · On Tuesday 30 December 2014 13:28:29 Rob Herring wrote:
From: Rob Herring <[email protected]>
This series converts ARM Versatile platform to multi-platform. I started this some time ago and some pieces were already merged. The primary piece remaining is converting the PCI host to DT which I was waiting for the common PCI DT parsing to get settled. Now that that is in place as well as a few other pieces are in place like multi-platform fixes for CLCD, we can fully convert Versatile to DT and multi-platform.
Hi Rob, thanks for picking this up again, looks great overall!
I've replied to a few individual patches with minor questions, but none of them are show-stoppers.
Arnd
cover ARM Versatile multi-platform support
In reply to Rob HerringQuoted 8 lines · Rob Herring
This has been tested on QEMU. A previous version was tested on Versatile/AB by Linus Walleij. Linus reported a problem with the display panel detection. Investigation on h/w is needed still as I have not been able to identify the issue by inspection and the display detection seems to work correctly on QEMU.
Linus had also mentioned to me that QEMU users may have some issue with removing non-DT code as the work flow has to change somewhat.
As long as you call out the requirement for a DT now in whatever your equivalent of release notes is that should be fine. (Does the kernel provide a useful message to serial in the absence of a DT or does it now not have enough platform knowledge to do that?)
Quoted 3 lines
Copying
Peter Maydell here for comment (and there's rumors he may have actual PB h/w with PCI as well).
Will Deacon and Marc Zyngier are currently in possession of that h/w. I'm sure they'd be delighted to pull it out of the cupboard and give it a spin :-)
-- PMM
cover ARM Versatile multi-platform support
Quoted 15 lines · Peter Maydell
Quoted 8 lines · Rob Herring
This has been tested on QEMU. A previous version was tested on Versatile/AB by Linus Walleij. Linus reported a problem with the display panel detection. Investigation on h/w is needed still as I have not been able to identify the issue by inspection and the display detection seems to work correctly on QEMU.
Linus had also mentioned to me that QEMU users may have some issue with removing non-DT code as the work flow has to change somewhat.
As long as you call out the requirement for a DT now in whatever your equivalent of release notes is that should be fine. (Does the kernel provide a useful message to serial in the absence of a DT or does it now not have enough platform knowledge to do that?)
Quoted 7 lines
Quoted 3 lines
Copying
Peter Maydell here for comment (and there's rumors he may have actual PB h/w with PCI as well).Will Deacon and Marc Zyngier are currently in possession of that h/w. I'm sure they'd be delighted to pull it out of the cupboard and give it a spin :-)
I'll try to find some time (or a victim to do the testing... ;-). To those interested, I have a few extra PCI backplanes (just the PCB, not the huge noisy carrier rack) I could be convinced to part with...
Thanks,
M.
Signature · 1 line
Jazz is not dead. It just smells funny...
cover ARM Versatile multi-platform support
Quoted 6 lines · Marc Zyngier
Quoted 3 lines · Peter Maydell
Will Deacon and Marc Zyngier are currently in possession of that h/w. I'm sure they'd be delighted to pull it out of the cupboard and give it a spin :-)
I'll try to find some time (or a victim to do the testing... ;-)
To save you some time in trying to debug things which didn't work before this patchset, the status last time I tested on h/w was:
* PCI MMIO accesses work
* PCI IO accesses work
* PCI bus-master (DMA) doesn't work
with the failure symptom for DMA being that the card wrote to the correct area of memory but only every other word, so you got strings like "HellXXXXrld" with the Xs being garbage. This feels to me like a h/w issue rather than a driver problem.
-- PMM
cover ARM Versatile multi-platform support
Quoted 14 lines · Peter Maydell
Quoted 6 lines · Marc Zyngier
Quoted 3 lines · Peter Maydell
Will Deacon and Marc Zyngier are currently in possession of that h/w. I'm sure they'd be delighted to pull it out of the cupboard and give it a spin :-)
I'll try to find some time (or a victim to do the testing... ;-)
To save you some time in trying to debug things which didn't work before this patchset, the status last time I tested on h/w was:
* PCI MMIO accesses work
* PCI IO accesses work
* PCI bus-master (DMA) doesn't work
Quoted 4 lines
with the failure symptom for DMA being that the card wrote to the correct area of memory but only every other word, so you got strings like "HellXXXXrld" with the Xs being garbage. This feels to me like a h/w issue rather than a driver problem.
Looks like some 64bit address decoding getting in the way. Or something.... Do you remember the exact platform you tried this on (I have PB926, PB1176, and a bunch of RealViews with an odd mix of tiles...)?
M.
Signature · 1 line
Jazz is not dead. It just smells funny.
cover ARM Versatile multi-platform support
Quoted 20 lines · Marc Zyngier
Quoted 14 lines · Peter Maydell
Quoted 6 lines · Marc Zyngier
Quoted 3 lines · Peter Maydell
Will Deacon and Marc Zyngier are currently in possession of that h/w. I'm sure they'd be delighted to pull it out of the cupboard and give it a spin :-)
I'll try to find some time (or a victim to do the testing... ;-)
To save you some time in trying to debug things which didn't work before this patchset, the status last time I tested on h/w was:
* PCI MMIO accesses work
* PCI IO accesses work
* PCI bus-master (DMA) doesn't workQuoted 4 lines
with the failure symptom for DMA being that the card wrote to the correct area of memory but only every other word, so you got strings like "HellXXXXrld" with the Xs being garbage. This feels to me like a h/w issue rather than a driver problem.
Quoted 4 lines
Looks like some 64bit address decoding getting in the way. Or something.... Do you remember the exact platform you tried this on (I have PB926, PB1176, and a bunch of RealViews with an odd mix of tiles...)?
According to my coverletter email from the last time I did anything with versatile PCI:
http://lists.infradead.org/pipermail/linux-arm-kernel/2013-August/193990.html
it was a PB926 (and an rtl8139 network card). I'm pretty sure I flashed the board with the latest IO FPGA image too.
thanks
-- PMM
cover ARM Versatile multi-platform support
In reply to Rob HerringQuoted 9 lines · Rob Herring
From: Rob Herring <[email protected]>
This series converts ARM Versatile platform to multi-platform. I started this some time ago and some pieces were already merged. The primary piece remaining is converting the PCI host to DT which I was waiting for the common PCI DT parsing to get settled. Now that that is in place as well as a few other pieces are in place like multi-platform fixes for CLCD, we can fully convert Versatile to DT and multi-platform.
Quoted 8 lines
There's still a few things that need DT support which can be done later:
- MMC card detect and write protect. Should be able to use VExpress support
- Reboot support. Should be able to re-use Realview reboot code.
- flash phys-map support. Binding exists, but specifically Vpp control is needed.
- CLCD support. Not sure where this is at.
I like it overall but would like to see some use of the syscon pattern to access random registers in syscon, and specifically not to refer to these registers as some "gpio" because they aren't.
Yours,
Linus Walleij
cover ARM Versatile multi-platform support
Quoted 20 lines · Linus Walleij
Quoted 9 lines · Rob Herring
From: Rob Herring <[email protected]>
This series converts ARM Versatile platform to multi-platform. I started this some time ago and some pieces were already merged. The primary piece remaining is converting the PCI host to DT which I was waiting for the common PCI DT parsing to get settled. Now that that is in place as well as a few other pieces are in place like multi-platform fixes for CLCD, we can fully convert Versatile to DT and multi-platform.
Quoted 8 lines
There's still a few things that need DT support which can be done later:
- MMC card detect and write protect. Should be able to use VExpress support
- Reboot support. Should be able to re-use Realview reboot code.
- flash phys-map support. Binding exists, but specifically Vpp control is needed.
- CLCD support. Not sure where this is at.
Quoted 3 lines
I like it overall but would like to see some use of the syscon pattern to access random registers in syscon, and specifically not to refer to these registers as some "gpio" because they aren't.
I'm not sure I follow. Creating GPIO lines for SD card detect and write protect is exactly how VExpress syscon was implemented.
Rob
cover ARM Versatile multi-platform support
Quoted 21 lines · Rob Herring
Quoted 20 lines · Linus Walleij
Quoted 17 lines · Rob Herring
From: Rob Herring <[email protected]>
This series converts ARM Versatile platform to multi-platform. I started this some time ago and some pieces were already merged. The primary piece remaining is converting the PCI host to DT which I was waiting for the common PCI DT parsing to get settled. Now that that is in place as well as a few other pieces are in place like multi-platform fixes for CLCD, we can fully convert Versatile to DT and multi-platform.
There's still a few things that need DT support which can be done later:
- MMC card detect and write protect. Should be able to use VExpress support
- Reboot support. Should be able to re-use Realview reboot code.
- flash phys-map support. Binding exists, but specifically Vpp control is needed.
- CLCD support. Not sure where this is at.
Quoted 6 lines
Quoted 3 lines
I like it overall but would like to see some use of the syscon pattern to access random registers in syscon, and specifically not to refer to these registers as some "gpio" because they aren't.
I'm not sure I follow. Creating GPIO lines for SD card detect and write protect is exactly how VExpress syscon was implemented.
Hm it all boils down to this mfd/vexpress-sysreg.c driver that spawns some MFD devices.
Quoted 1 line
From there a LED, card detect and flash protection are modeled as
"basic-mmio-gpio" instantiating the drivers/gpio/gpio-generic.c driver to drive/read various bits.
Specifically commit 974cc7b93441a0e78f030495436d1be7eb7c208d that makes a layered MFD->gpio->gpio LED cake. Needless to say neither the GPIO maintainers or the GPIO mailing list was included in review of this patch and it was merged on its MFD merits :(
It is sort of elegant in a way, but I don't like it when we describe registers that are not general purpose as "general purpose input output" it is simply ontologically wrong and a misleading hardware description. These bits are not general purpose *at* *all* they are special purpose.
It is Linux GPIO implementation details leaking into the hardware description basically: it just happened to be very convenient to describe these register bits as "gpios" as the drivers etc were already in place.
I prefer syscon->syscon LED as a two layer cake
instead of a three layer cake involving GPIO and it's more to the point, describing the hardware properly, so I say let's go for that instead.
For card detect and flash protection I suspect we can use syscon as well, avoiding shoehorning a GPIO abstraction between it.
Yours,
Linus Walleij