ARM: ixp4xx: Modernize and DT support
Subsystems (11)
cover ARM: ixp4xx: Modernize and DT support
This modernizes the IXP4xx platform and adds initial Device Tree Support. We migrate to MULTI_IRQ_HANDLER, bumps the IRQs to offset 16, converts to SPARSE_IRQ, then we add proper subsystem drivers in each subsystem for irqchip, GPIO and clocksource and switch over to using these new drivers.
Then we add DT bindings to all of these aforementioned drivers, add add support for probing each from device tree (keeping the boardfile path).
Then we add Device Tree boot support.
The last patch shows how some basic (working) device trees will look.
We will not delete any boardfiles until we support the corresponding board fully with a device tree, which requires things like PCI support which we can work on using this as a base.
A working set of base patches that boots to prompto from initramfs on NSLU2 and GW2358-4 is provided on this branch:
https://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-nomadik.git/log/?h=ixp4
I am now collecting feedback and ACKs for the patches. I aim to create a branch in the GPIO tree and ask the ARM SoC tree to pull it in. It will be best to keep all patches in one branch since I mess with MAINTAINERS after each commit (as requested by checkpatch!).
Obviously I am looking for the IXP4xx maintainers to review and consent to this change or I cannot move ahead. I think it is best that I queue up a branch and send to ARM SoC but if you IXP4xx folks want to do it in some other way I am happy to hear.
Linus Walleij (17):
ARM: ixp4xx: Convert to MULTI_IRQ_HANDLER
ARM: ixp4xx: Pass IRQ resource to beeper
ARM: ixp4xx: Convert to SPARSE_IRQ
irqchip: Add driver for IXP4xx
gpio: ixp4xx: Add driver for the IXP4xx GPIO
ARM: ixp4xx: Switch to use new IRQ+GPIO drivers clocksource/drivers/ixp4xx: Add driver
ARM: ixp4xx: Switch to use new timer driver
irqchip: ixp4xx: Add DT bindings
irqchip: ixp4xx: Add OF initialization support clocksource/drivers/ixp4xx: Add DT bindings clocksource/drivers/ixp4xx: Add OF initialization support
gpio: ixp4xx: Add DT bindings
gpio: ixp4xx: Add OF probing support
ARM: ixp4xx: Add DT bindings
ARM: ixp4xx: Add device tree boot support
RFC: ARM: dts: Add some initial IXP4xx device trees
.../devicetree/bindings/arm/intel-ixp4xx.yaml | 22 + .../bindings/gpio/intel,ixp4xx-gpio.txt | 38 ++ .../intel,ixp4xx-interrupt.txt | 33 ++ .../bindings/timer/intel,ixp4xx-timer.txt | 18 + MAINTAINERS | 9 + arch/arm/Kconfig | 5 +- arch/arm/boot/dts/Makefile | 3 + .../boot/dts/intel-ixp42x-linksys-nslu2.dts | 111 ++++ arch/arm/boot/dts/intel-ixp42x.dtsi | 25 + .../dts/intel-ixp43x-gateworks-gw2358-4.dts | 96 ++++ arch/arm/boot/dts/intel-ixp43x.dtsi | 15 + arch/arm/boot/dts/intel-ixp45x-ixp46x.dtsi | 34 ++ arch/arm/boot/dts/intel-ixp4xx.dtsi | 58 +++ arch/arm/mach-ixp4xx/Kconfig | 14 + arch/arm/mach-ixp4xx/Makefile | 3 + arch/arm/mach-ixp4xx/avila-pci.c | 2 + arch/arm/mach-ixp4xx/avila-setup.c | 2 + arch/arm/mach-ixp4xx/common.c | 426 ++-------------- arch/arm/mach-ixp4xx/coyote-pci.c | 2 + arch/arm/mach-ixp4xx/coyote-setup.c | 2 + arch/arm/mach-ixp4xx/dsmg600-pci.c | 2 + arch/arm/mach-ixp4xx/dsmg600-setup.c | 5 +- arch/arm/mach-ixp4xx/fsg-pci.c | 2 + arch/arm/mach-ixp4xx/fsg-setup.c | 2 + arch/arm/mach-ixp4xx/gateway7001-pci.c | 2 + arch/arm/mach-ixp4xx/gateway7001-setup.c | 2 + arch/arm/mach-ixp4xx/gtwx5715-pci.c | 2 + arch/arm/mach-ixp4xx/gtwx5715-setup.c | 2 + .../mach-ixp4xx/include/mach/entry-macro.S | 41 -- arch/arm/mach-ixp4xx/include/mach/irqs.h | 75 --- .../mach-ixp4xx/include/mach/ixp4xx-regs.h | 89 ---- arch/arm/mach-ixp4xx/irqs.h | 68 +++ arch/arm/mach-ixp4xx/ixdp425-pci.c | 2 + arch/arm/mach-ixp4xx/ixdp425-setup.c | 2 + arch/arm/mach-ixp4xx/ixdpg425-pci.c | 2 + arch/arm/mach-ixp4xx/ixp4xx-of.c | 49 ++ arch/arm/mach-ixp4xx/ixp4xx_npe.c | 5 + arch/arm/mach-ixp4xx/ixp4xx_qmgr.c | 7 + arch/arm/mach-ixp4xx/nas100d-pci.c | 2 + arch/arm/mach-ixp4xx/nas100d-setup.c | 5 +- arch/arm/mach-ixp4xx/nslu2-pci.c | 2 + arch/arm/mach-ixp4xx/nslu2-setup.c | 12 +- arch/arm/mach-ixp4xx/wg302v2-pci.c | 2 + arch/arm/mach-ixp4xx/wg302v2-setup.c | 2 + drivers/clocksource/Kconfig | 7 + drivers/clocksource/Makefile | 1 + drivers/clocksource/timer-ixp4xx.c | 284 +++++++++++ drivers/gpio/Kconfig | 12 + drivers/gpio/Makefile | 1 + drivers/gpio/gpio-ixp4xx.c | 473 ++++++++++++++++++ drivers/input/misc/ixp4xx-beeper.c | 20 +- drivers/irqchip/Kconfig | 6 + drivers/irqchip/Makefile | 1 + drivers/irqchip/irq-ixp4xx.c | 405 +++++++++++++++ drivers/net/ethernet/xscale/ixp4xx_eth.c | 10 + drivers/watchdog/ixp4xx_wdt.c | 9 + include/linux/irqchip/irq-ixp4xx.h | 12 + include/linux/platform_data/timer-ixp4xx.h | 11 + 58 files changed, 1940 insertions(+), 614 deletions(-) create mode 100644 Documentation/devicetree/bindings/arm/intel-ixp4xx.yaml create mode 100644 Documentation/devicetree/bindings/gpio/intel,ixp4xx-gpio.txt create mode 100644 Documentation/devicetree/bindings/interrupt-controller/intel,ixp4xx-interrupt.txt create mode 100644 Documentation/devicetree/bindings/timer/intel,ixp4xx-timer.txt create mode 100644 arch/arm/boot/dts/intel-ixp42x-linksys-nslu2.dts create mode 100644 arch/arm/boot/dts/intel-ixp42x.dtsi create mode 100644 arch/arm/boot/dts/intel-ixp43x-gateworks-gw2358-4.dts create mode 100644 arch/arm/boot/dts/intel-ixp43x.dtsi create mode 100644 arch/arm/boot/dts/intel-ixp45x-ixp46x.dtsi create mode 100644 arch/arm/boot/dts/intel-ixp4xx.dtsi delete mode 100644 arch/arm/mach-ixp4xx/include/mach/entry-macro.S delete mode 100644 arch/arm/mach-ixp4xx/include/mach/irqs.h create mode 100644 arch/arm/mach-ixp4xx/irqs.h create mode 100644 arch/arm/mach-ixp4xx/ixp4xx-of.c create mode 100644 drivers/clocksource/timer-ixp4xx.c create mode 100644 drivers/gpio/gpio-ixp4xx.c create mode 100644 drivers/irqchip/irq-ixp4xx.c create mode 100644 include/linux/irqchip/irq-ixp4xx.h create mode 100644 include/linux/platform_data/timer-ixp4xx.h
Signature · 7 lines
2.20.1 _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
PATCH 1/17 ARM: ixp4xx: Convert to MULTI_IRQ_HANDLER
This rewrites the IXP4xx to use MULTI_IRQ_HANDLER and create an irqdomain for the irqchip in the platform. We convert the timer to request the interrupt like any other driver in the process.
We bump all IRQs to 16+offset to avoid using IRQ 0 and set NR_IRQS to 512 (the default for most systems). This conveniently fits with the first 16 IRQs being pre-allocated when using SPARSE_IRQ.
This is a prerequisite for SPARSE_IRQ and DT boot.
--- arch/arm/Kconfig | 1 + arch/arm/mach-ixp4xx/common.c | 109 +++++++++++++----- .../mach-ixp4xx/include/mach/entry-macro.S | 41 ------- arch/arm/mach-ixp4xx/include/mach/irqs.h | 95 ++++++++------- 4 files changed, 126 insertions(+), 120 deletions(-) delete mode 100644 arch/arm/mach-ixp4xx/include/mach/entry-macro.S
arch/arm/Kconfig +1 -0
@@ -431,6 +431,7 @@ config ARCH_IXP4XX select CPU_XSCALE select DMABOUNCE if PCI select GENERIC_CLOCKEVENTS + select GENERIC_IRQ_MULTI_HANDLER select GPIOLIB select HAVE_PCI select NEED_MACH_IO_H
arch/arm/mach-ixp4xx/common.c +80 -29
210 lines not on this page · raw message
arch/arm/mach-ixp4xx/include/mach/entry-macro.S deleted +0 -41
41 lines not on this page · raw message
arch/arm/mach-ixp4xx/include/mach/irqs.h +45 -50
105 lines not on this page · raw message
Signature · 7 lines
2.20.1 _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
PATCH 2/17 ARM: ixp4xx: Pass IRQ resource to beeper
In reply to Linus WalleijAll IXP4xx devices except the beeper passes the IRQ as a resource, augment the NSLU2 beeper to do the same.
This is a prerequisite for SPARSE_IRQ.
--- arch/arm/mach-ixp4xx/nslu2-setup.c | 10 +++++++++- drivers/input/misc/ixp4xx-beeper.c | 20 +++++++++++++++----- 2 files changed, 24 insertions(+), 6 deletions(-)
arch/arm/mach-ixp4xx/nslu2-setup.c +9 -1
@@ -125,10 +125,18 @@ static struct platform_device nslu2_i2c_gpio = { }, }; +static struct resource nslu2_beeper_resources[] = { + { + .start =IRQ_IXP4XX_TIMER2 , + .flags =IORESOURCE_IRQ , + }, +}; +static struct platform_device nslu2_beeper = { .name ="ixp4xx-beeper" , .id =NSLU2_GPIO_BUZZ , - .num_resources =0 , + .resource = nslu2_beeper_resources, + .num_resources =ARRAY_SIZE (nslu2_beeper_resources), };static struct resource nslu2_uart_resources[] = {
drivers/input/misc/ixp4xx-beeper.c +15 -5
@@ -30,6 +30,8 @@ MODULE_ALIAS("platform:ixp4xx-beeper");static DEFINE_SPINLOCK (beep_lock); +static int ixp4xx_timer2_irq; +static void ixp4xx_spkr_control (unsigned int pin,unsigned int count) {unsigned long flags;
@@ -90,6 +92,7 @@ static irqreturn_t ixp4xx_spkr_interrupt(int irq, void *dev_id)static int ixp4xx_spkr_probe (struct platform_device *dev) {struct input_dev *input_dev; +int irq;int err; input_dev =input_allocate_device ();
@@ -110,15 +113,22 @@ static int ixp4xx_spkr_probe(struct platform_device *dev) input_dev->sndbit[0 ] =BIT_MASK (SND_BELL ) |BIT_MASK (SND_TONE ); input_dev->event = ixp4xx_spkr_event; + irq =platform_get_irq (dev,0 ); +if (irq <0 ) { + err = irq; + goto err_free_device; + } + err =gpio_request (dev->id,"ixp4-beeper" );if (err) goto err_free_device; - err =request_irq (IRQ_IXP4XX_TIMER2 , &ixp4xx_spkr_interrupt, + err =request_irq (irq, &ixp4xx_spkr_interrupt,IRQF_NO_SUSPEND ,"ixp4xx-beeper" , (void *) dev->id);if (err) goto err_free_gpio; + ixp4xx_timer2_irq = irq; err =input_register_device (input_dev);if (err)
@@ -129,7 +139,7 @@ static int ixp4xx_spkr_probe(struct platform_device *dev)return 0 ; err_free_irq: -free_irq (IRQ_IXP4XX_TIMER2 , (void *)dev->id); +free_irq (irq, (void *)dev->id); err_free_gpio:gpio_free (dev->id); err_free_device:
@@ -146,10 +156,10 @@ static int ixp4xx_spkr_remove(struct platform_device *dev)input_unregister_device (input_dev);/* turn the speaker off */ -disable_irq (IRQ_IXP4XX_TIMER2 ); +disable_irq (ixp4xx_timer2_irq);ixp4xx_spkr_control (pin,0 ); -free_irq (IRQ_IXP4XX_TIMER2 , (void *)dev->id); +free_irq (ixp4xx_timer2_irq, (void *)dev->id);gpio_free (dev->id);return 0 ;
@@ -161,7 +171,7 @@ static void ixp4xx_spkr_shutdown(struct platform_device *dev)unsigned int pin = (unsigned int )input_get_drvdata (input_dev);/* turn off the speaker */ -disable_irq (IRQ_IXP4XX_TIMER2 ); +disable_irq (ixp4xx_timer2_irq);ixp4xx_spkr_control (pin,0 ); }
Signature · 7 lines
2.20.1 _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
PATCH 3/17 ARM: ixp4xx: Convert to SPARSE_IRQ
In reply to Linus WalleijThis localizes the <mach/irqs.h> header to the mach-ixp4xx directory, removes NR_IRQS and switches IXP4xx over to using SPARSE_IRQ.
This is a prerequisite for DT support.
---
arch/arm/Kconfig | 1 +
arch/arm/mach-ixp4xx/avila-pci.c | 2 ++
arch/arm/mach-ixp4xx/avila-setup.c | 2 ++
arch/arm/mach-ixp4xx/common.c | 2 ++
arch/arm/mach-ixp4xx/coyote-pci.c | 2 ++
arch/arm/mach-ixp4xx/coyote-setup.c | 2 ++
arch/arm/mach-ixp4xx/dsmg600-pci.c | 2 ++
arch/arm/mach-ixp4xx/dsmg600-setup.c | 2 ++
arch/arm/mach-ixp4xx/fsg-pci.c | 2 ++
arch/arm/mach-ixp4xx/fsg-setup.c | 2 ++
arch/arm/mach-ixp4xx/gateway7001-pci.c | 2 ++
arch/arm/mach-ixp4xx/gateway7001-setup.c | 2 ++
arch/arm/mach-ixp4xx/gtwx5715-pci.c | 2 ++
arch/arm/mach-ixp4xx/gtwx5715-setup.c | 2 ++
arch/arm/mach-ixp4xx/{include/mach => }/irqs.h | 2 --
arch/arm/mach-ixp4xx/ixdp425-pci.c | 2 ++
arch/arm/mach-ixp4xx/ixdp425-setup.c | 2 ++
arch/arm/mach-ixp4xx/ixdpg425-pci.c | 2 ++
arch/arm/mach-ixp4xx/ixp4xx_qmgr.c | 2 ++
arch/arm/mach-ixp4xx/nas100d-pci.c | 2 ++
arch/arm/mach-ixp4xx/nas100d-setup.c | 2 ++
arch/arm/mach-ixp4xx/nslu2-pci.c | 2 ++
arch/arm/mach-ixp4xx/nslu2-setup.c | 2 ++
arch/arm/mach-ixp4xx/wg302v2-pci.c | 2 ++
arch/arm/mach-ixp4xx/wg302v2-setup.c | 2 ++
25 files changed, 47 insertions(+), 2 deletions(-)
rename arch/arm/mach-ixp4xx/{include/mach => }/irqs.h (99%)arch/arm/Kconfig +1 -0
@@ -435,6 +435,7 @@ config ARCH_IXP4XX select GPIOLIB select HAVE_PCI select NEED_MACH_IO_H + select SPARSE_IRQ select USB_EHCI_BIG_ENDIAN_DESC select USB_EHCI_BIG_ENDIAN_MMIO help
arch/arm/mach-ixp4xx/avila-pci.c +2 -0
@@ -27,6 +27,8 @@#include <mach/hardware.h> #include <asm/mach-types.h> +#include "irqs.h" +#define AVILA_MAX_DEV 4#define LOFT_MAX_DEV 6#define IRQ_LINES 4
arch/arm/mach-ixp4xx/avila-setup.c +2 -0
@@ -28,6 +28,8 @@#include <asm/mach/arch.h> #include <asm/mach/flash.h> +#include "irqs.h" +#define AVILA_SDA_PIN 7#define AVILA_SCL_PIN 6
arch/arm/mach-ixp4xx/common.c +2 -0
@@ -45,6 +45,8 @@#include <asm/mach/irq.h> #include <asm/mach/time.h> +#include "irqs.h" +#define IXP4XX_TIMER_FREQ 66666000/*
arch/arm/mach-ixp4xx/coyote-pci.c +2 -0
@@ -23,6 +23,8 @@#include <asm/irq.h> #include <asm/mach/pci.h> +#include "irqs.h" +#define SLOT0_DEVID 14#define SLOT1_DEVID 15
arch/arm/mach-ixp4xx/coyote-setup.c +2 -0
@@ -25,6 +25,8 @@#include <asm/mach/arch.h> #include <asm/mach/flash.h> +#include "irqs.h" +#define COYOTE_IDE_BASE_PHYS IXP4XX_EXP_BUS_BASE(3)#define COYOTE_IDE_BASE_VIRT 0xFFFE1000#define COYOTE_IDE_REGION_SIZE 0x1000
arch/arm/mach-ixp4xx/dsmg600-pci.c +2 -0
@@ -22,6 +22,8 @@#include <asm/mach/pci.h> #include <asm/mach-types.h> +#include "irqs.h" +#define MAX_DEV 4#define IRQ_LINES 3
arch/arm/mach-ixp4xx/dsmg600-setup.c +2 -0
@@ -35,6 +35,8 @@#include <asm/mach/flash.h> #include <asm/mach/time.h> +#include "irqs.h" +#define DSMG600_SDA_PIN 5#define DSMG600_SCL_PIN 4
arch/arm/mach-ixp4xx/fsg-pci.c +2 -0
@@ -22,6 +22,8 @@#include <asm/mach/pci.h> #include <asm/mach-types.h> +#include "irqs.h" +#define MAX_DEV 3#define IRQ_LINES 3
arch/arm/mach-ixp4xx/fsg-setup.c +2 -0
@@ -29,6 +29,8 @@#include <asm/mach/arch.h> #include <asm/mach/flash.h> +#include "irqs.h" +#define FSG_SDA_PIN 12#define FSG_SCL_PIN 13
arch/arm/mach-ixp4xx/gateway7001-pci.c +2 -0
@@ -27,6 +27,8 @@#include <asm/mach/pci.h> +#include "irqs.h" +void __init gateway7001_pci_preinit (void ) {irq_set_irq_type (IRQ_IXP4XX_GPIO10 ,IRQ_TYPE_LEVEL_LOW );
arch/arm/mach-ixp4xx/gateway7001-setup.c +2 -0
@@ -28,6 +28,8 @@#include <asm/mach/arch.h> #include <asm/mach/flash.h> +#include "irqs.h" +static struct flash_platform_data gateway7001_flash_data = { .map_name ="cfi_probe" , .width =2 ,
arch/arm/mach-ixp4xx/gtwx5715-pci.c +2 -0
@@ -30,6 +30,8 @@#include <mach/hardware.h> #include <asm/mach/pci.h> +#include "irqs.h" +#define SLOT0_DEVID 0#define SLOT1_DEVID 1#define INTA 10/* slot 1 has INTA and INTB crossed */
arch/arm/mach-ixp4xx/gtwx5715-setup.c +2 -0
@@ -36,6 +36,8 @@#include <asm/mach/arch.h> #include <asm/mach/flash.h> +#include "irqs.h" +/* GPIO 5,6,7 and 12 are hard wired to the Kendin KS8995M Switch and operate as an SPI type interface. The details of the interface are available on Kendin/Micrel's web site. */
arch/arm/mach-ixp4xx/irqs.h renamed from arch/arm/mach-ixp4xx/include/mach/irqs.h +0 -2
@@ -63,8 +63,6 @@#define _IXP4XX_GPIO_IRQ (n) (IRQ_IXP4XX_GPIO ## n)#define IXP4XX_GPIO_IRQ (n) _IXP4XX_GPIO_IRQ(n) -#define NR_IRQS 512 -#define XSCALE_PMU_IRQ (IRQ_IXP4XX_XSCALE_PMU)#endif
arch/arm/mach-ixp4xx/ixdp425-pci.c +2 -0
@@ -24,6 +24,8 @@#include <mach/hardware.h> #include <asm/mach-types.h> +#include "irqs.h" +#define MAX_DEV 4#define IRQ_LINES 4
arch/arm/mach-ixp4xx/ixdp425-setup.c +2 -0
@@ -32,6 +32,8 @@#include <asm/mach/arch.h> #include <asm/mach/flash.h> +#include "irqs.h" +#define IXDP425_SDA_PIN 7#define IXDP425_SCL_PIN 6
arch/arm/mach-ixp4xx/ixdpg425-pci.c +2 -0
@@ -23,6 +23,8 @@#include <asm/mach/pci.h> +#include "irqs.h" +void __init ixdpg425_pci_preinit (void ) {irq_set_irq_type (IRQ_IXP4XX_GPIO6 ,IRQ_TYPE_LEVEL_LOW );
arch/arm/mach-ixp4xx/ixp4xx_qmgr.c +2 -0
@@ -14,6 +14,8 @@#include <linux/module.h> #include <mach/qmgr.h> +#include "irqs.h" +static struct qmgr_regs __iomem *qmgr_regs =IXP4XX_QMGR_BASE_VIRT ;static struct resource *mem_res;static spinlock_t qmgr_lock;
arch/arm/mach-ixp4xx/nas100d-pci.c +2 -0
@@ -21,6 +21,8 @@#include <asm/mach/pci.h> #include <asm/mach-types.h> +#include "irqs.h" +#define MAX_DEV 3#define IRQ_LINES 3
arch/arm/mach-ixp4xx/nas100d-setup.c +2 -0
@@ -34,6 +34,8 @@#include <asm/mach/arch.h> #include <asm/mach/flash.h> +#include "irqs.h" +#define NAS100D_SDA_PIN 5#define NAS100D_SCL_PIN 6
arch/arm/mach-ixp4xx/nslu2-pci.c +2 -0
@@ -21,6 +21,8 @@#include <asm/mach/pci.h> #include <asm/mach-types.h> +#include "irqs.h" +#define MAX_DEV 3#define IRQ_LINES 3
arch/arm/mach-ixp4xx/nslu2-setup.c +2 -0
@@ -32,6 +32,8 @@#include <asm/mach/flash.h> #include <asm/mach/time.h> +#include "irqs.h" +#define NSLU2_SDA_PIN 7#define NSLU2_SCL_PIN 6
arch/arm/mach-ixp4xx/wg302v2-pci.c +2 -0
@@ -27,6 +27,8 @@#include <asm/mach/pci.h> +#include "irqs.h" +void __init wg302v2_pci_preinit (void ) {irq_set_irq_type (IRQ_IXP4XX_GPIO8 ,IRQ_TYPE_LEVEL_LOW );
arch/arm/mach-ixp4xx/wg302v2-setup.c +2 -0
@@ -29,6 +29,8 @@#include <asm/mach/arch.h> #include <asm/mach/flash.h> +#include "irqs.h" +static struct flash_platform_data wg302v2_flash_data = { .map_name ="cfi_probe" , .width =2 ,
Signature · 7 lines
2.20.1 _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
PATCH 4/17 irqchip: Add driver for IXP4xx
In reply to Linus WalleijThe IXP4xx (arch/arm/mach-ixp4xx) is an old Intel XScale platform that has very wide deployment and use.
As part of modernizing the platform, we need to implement a proper irqchip in the irqchip subsystem.
The IXP4xx irqchip is tightly jotted together with the GPIO controller, and wheras in the past we would deal with this complex logic by adding necessarily different code, we can nowadays modernize it using a hierarchical irqchip.
The actual IXP4 irqchip is a simple active low level IRQ controller, whereas the GPIO functionality resides in a different memory area and adds edge trigger support for the interrupts.
The interrupts from GPIO lines 0..12 are 1:1 mapped to a fixed set of hardware IRQs on this IRQchip, so we expect the child GPIO interrupt controller to go in and allocate descriptors for these interrupts.
For the other interrupts, as we do not yet have DT support for this platform, we create a linear irqdomain and then go in and allocate the IRQs that the legacy boards use. This code will be removed on the DT probe path when we add DT support to the platform.
We add some translation code for supporting DT translations for the fwnodes, but we leave most of that for later.
---
irqchip maintainers: I am requesting an ACK for this once you're happy with the driver, as I intend to merge all of this IXP4xx rework through ARM SoC.
--- MAINTAINERS | 2 + drivers/irqchip/Kconfig | 6 + drivers/irqchip/Makefile | 1 + drivers/irqchip/irq-ixp4xx.c | 360 +++++++++++++++++++++++++++++ include/linux/irqchip/irq-ixp4xx.h | 12 + 5 files changed, 381 insertions(+) create mode 100644 drivers/irqchip/irq-ixp4xx.c create mode 100644 include/linux/irqchip/irq-ixp4xx.h
MAINTAINERS +2 -0
@@ -1651,6 +1651,8 @@ M: Krzysztof Halasa <[email protected]> L: [email protected] (moderated for non-subscribers) S: Maintained F: arch/arm/mach-ixp4xx/ +F: drivers/irqchip/irq-ixp4xx.c +F: include/linux/irqchip/irq-ixp4xx.h ARM/INTEL RESEARCH IMOTE/STARGATE 2 MACHINE SUPPORT M: Jonathan Cameron <[email protected]>
drivers/irqchip/Kconfig +6 -0
@@ -150,6 +150,12 @@ config IMGPDC_IRQ select GENERIC_IRQ_CHIP select IRQ_DOMAIN +config IXP4XX_IRQ + bool + select IRQ_DOMAIN + select GENERIC_IRQ_MULTI_HANDLER + select SPARSE_IRQ + config MADERA_IRQ tristate
drivers/irqchip/Makefile +1 -0
@@ -41,6 +41,7 @@ obj-$(CONFIG_ATMEL_AIC5_IRQ) += irq-atmel-aic-common.o irq-atmel-aic5.o obj-$(CONFIG_I8259) += irq-i8259.o obj-$(CONFIG_IMGPDC_IRQ) += irq-imgpdc.o obj-$(CONFIG_IRQ_MIPS_CPU) += irq-mips-cpu.o +obj-$(CONFIG_IXP4XX_IRQ) += irq-ixp4xx.o obj-$(CONFIG_SIRF_IRQ) += irq-sirfsoc.o obj-$(CONFIG_JCORE_AIC) += irq-jcore-aic.o obj-$(CONFIG_RDA_INTC) += irq-rda-intc.o
drivers/irqchip/irq-ixp4xx.c new file +360 -0
360 lines not on this page · raw message
include/linux/irqchip/irq-ixp4xx.h new file +12 -0
@@ -0,0 +1,12 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef __IRQ_IXP4XX_H +#define __IRQ_IXP4XX_H + +#include <linux/ioport.h> +struct irq_domain ; + +void ixp4xx_irq_init (resource_size_t irqbase, +bool is_356); +struct irq_domain *ixp4xx_get_irq_domain (void ); + +#endif /* __IRQ_IXP4XX_H */
Signature · 7 lines
2.20.1 _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Re: [PATCH 04/17 v1] irqchip: Add driver for IXP4xx
Hi Linus,
Quoted 8 lines · Linus Walleij
The IXP4xx (
arch/arm/mach-ixp4xx) is an old Intel XScale platform that has very wide deployment and use.As part of modernizing the platform, we need to implement a proper irqchip in the irqchip subsystem.
The IXP4xx irqchip is tightly jotted together with the GPIO controller, and wheras in the past we would deal with this
nit: whereas
Quoted 143 lines
complex logic by adding necessarily different code, we can nowadays modernize it using a hierarchical irqchip.
The actual IXP4 irqchip is a simple active low level IRQ controller, whereas the GPIO functionality resides in a different memory area and adds edge trigger support for the interrupts.
The interrupts from GPIO lines 0..12 are 1:1 mapped to a fixed set of hardware IRQs on this IRQchip, so we expect the child GPIO interrupt controller to go in and allocate descriptors for these interrupts.
For the other interrupts, as we do not yet have DT support for this platform, we create a linear irqdomain and then go in and allocate the IRQs that the legacy boards use. This code will be removed on the DT probe path when we add DT support to the platform.
We add some translation code for supporting DT translations for the fwnodes, but we leave most of that for later.
Cc Marc Zyngier <[email protected]>Cc Jason Cooper <[email protected]>Cc Thomas Gleixner <[email protected]>Signed-off-by Linus Walleij <[email protected]>---
irqchip maintainers: I am requesting an ACK for this once you're happy with the driver, as I intend to merge all of this IXP4xx rework through ARM SoC.--- MAINTAINERS | 2 + drivers/irqchip/Kconfig | 6 + drivers/irqchip/Makefile | 1 + drivers/irqchip/irq-ixp4xx.c | 360 +++++++++++++++++++++++++++++ include/linux/irqchip/irq-ixp4xx.h | 12 + 5 files changed, 381 insertions(+) create mode 100644 drivers/irqchip/irq-ixp4xx.c create mode 100644 include/linux/irqchip/irq-ixp4xx.hMAINTAINERS +2
-0@@ -1651,6 +1651,8 @@ M: Krzysztof Halasa <[email protected]> L: [email protected] (moderated for non-subscribers) S: Maintained F: arch/arm/mach-ixp4xx/ +F: drivers/irqchip/irq-ixp4xx.c +F: include/linux/irqchip/irq-ixp4xx.h ARM/INTEL RESEARCH IMOTE/STARGATE 2 MACHINE SUPPORT M: Jonathan Cameron <[email protected]>drivers/irqchip/Kconfig +6
-0@@ -150,6 +150,12 @@ config IMGPDC_IRQ select GENERIC_IRQ_CHIP select IRQ_DOMAIN +config IXP4XX_IRQ + bool + select IRQ_DOMAIN + select GENERIC_IRQ_MULTI_HANDLER + select SPARSE_IRQ + config MADERA_IRQ tristatedrivers/irqchip/Makefile +1
-0@@ -41,6 +41,7 @@ obj-$(CONFIG_ATMEL_AIC5_IRQ) += irq-atmel-aic-common.o irq-atmel-aic5.o obj-$(CONFIG_I8259) += irq-i8259.o obj-$(CONFIG_IMGPDC_IRQ) += irq-imgpdc.o obj-$(CONFIG_IRQ_MIPS_CPU) += irq-mips-cpu.o +obj-$(CONFIG_IXP4XX_IRQ) += irq-ixp4xx.o obj-$(CONFIG_SIRF_IRQ) += irq-sirfsoc.o obj-$(CONFIG_JCORE_AIC) += irq-jcore-aic.o obj-$(CONFIG_RDA_INTC) += irq-rda-intc.odrivers/irqchip/irq-ixp4xx.c new file +54
-0@@ -0,0 +1,360 @@ +// SPDX-License-Identifier: GPL-2.0 +/* +* irqchip for the IXP4xx interrupt controller +* Copyright (C) 2019 Linus Walleij <[email protected]> +* +* Based on arch/arm/mach-ixp4xx/common.c +* Copyright 2002 (C) Intel Corporation +* Copyright 2003-2004 (C) MontaVista, Software, Inc. +* Copyright (C) Deepak Saxena <[email protected]> +*/ +#include <linux/bitops.h> +#include <linux/gpio/driver.h> +#include <linux/irq.h> +#include <linux/io.h> +#include <linux/irqchip.h> +#include <linux/irqchip/irq-ixp4xx.h> +#include <linux/irqdomain.h> +#include <linux/platform_device.h> +#include <linux/cpu.h> + +#include <asm/exception.h> +#include <asm/mach/irq.h> + +#define IXP4XX_ICPR 0x00/* Interrupt Status */ +#define IXP4XX_ICMR 0x04/* Interrupt Enable */ +#define IXP4XX_ICLR 0x08/* Interrupt IRQ/FIQ Select */ +#define IXP4XX_ICIP 0x0C/* IRQ Status */ +#define IXP4XX_ICFP 0x10/* FIQ Status */ +#define IXP4XX_ICHR 0x14/* Interrupt Priority */ +#define IXP4XX_ICIH 0x18/* IRQ Highest Pri Int */ +#define IXP4XX_ICFH 0x1C/* FIQ Highest Pri Int */ + +/* IXP43x and IXP46x-only */ +#define IXP4XX_ICPR2 0x20/* Interrupt Status 2 */ +#define IXP4XX_ICMR2 0x24/* Interrupt Enable 2 */ +#define IXP4XX_ICLR2 0x28/* Interrupt IRQ/FIQ Select 2 */ +#define IXP4XX_ICIP2 0x2C/* IRQ Status */ +#define IXP4XX_ICFP2 0x30/* FIQ Status */ +#define IXP4XX_ICEEN 0x34/* Error High Pri Enable */ + +/** +* struct ixp4xx_irq - state container for the Faraday IRQ controller +* @irqbase: IRQ controller memory base in virtual memory +* @is_356: if this is an IXP43x, IXP45x or IX46x SoC (with 64 IRQs) +* @irqchip: irqchip for this instance +* @domain: IRQ domain for this instance +*/ +struct ixp4xx_irq { +void __iomem *irqbase; +bool is_356; +struct irq_chip irqchip; +struct irq_domain *domain; +}; +
drivers/irqchip/irq-ixp4xx.c line 64
Quoted 10 lines
drivers/irqchip/irq-ixp4xx.c new file +10
-0+/* Local static state container */ +static struct ixp4xx_irq ixirq; + +/* GPIO Clocks */ +#define IXP4XX_GPIO_CLK_0 14 +#define IXP4XX_GPIO_CLK_1 15 + +static int ixp4xx_set_irq_type (struct irq_data *d,unsigned int type) +{ +/* All are level active high (asserted) here */
It'd be good to return an error if type isn't LEVEL_HIGH.
Quoted 8 lines
drivers/irqchip/irq-ixp4xx.c new file +8
-0+return 0 ; +} + +static void ixp4xx_irq_mask (struct irq_data *d) +{ +struct ixp4xx_irq *ixi =irq_data_get_irq_chip_data (d); +u32 val; +
drivers/irqchip/irq-ixp4xx.c line 82
Quoted 10 lines
drivers/irqchip/irq-ixp4xx.c new file +10
-0+if (ixi->is_356 && d->hwirq >=32 ) { + val =__raw_readl (ixi->irqbase +IXP4XX_ICMR2 ); + val &= ~BIT (d->hwirq -32 ); +__raw_writel (val, ixi->irqbase +IXP4XX_ICMR2 ); + }else { + val =__raw_readl (ixi->irqbase +IXP4XX_ICMR ); + val &= ~BIT (d->hwirq); +__raw_writel (val, ixi->irqbase +IXP4XX_ICMR ); + } +}
This probably comes from the original code, but I'd like to be able to use a LE kernel on this HW (full disclosure: I have some of this crap stashed somewhere in the basement... ;-).
How about using something that enforces the endianness of the accesses, as I suspect the bus is hardcoded to BE? ioread32be/iowrite32be springs to mind, and I can see the current IXP4xx code provides such an implementation in its own io.h (which you may have to make private).
Quoted 10 lines
drivers/irqchip/irq-ixp4xx.c new file +10
-0+ +/* +* Level triggered interrupts on GPIO lines can only be cleared when the +* interrupt condition disappears. +*/ +static void ixp4xx_irq_unmask (struct irq_data *d) +{ +struct ixp4xx_irq *ixi =irq_data_get_irq_chip_data (d); +u32 val; +
drivers/irqchip/irq-ixp4xx.c line 102
Quoted 10 lines
drivers/irqchip/irq-ixp4xx.c new file +10
-0+if (ixi->is_356 && d->hwirq >=32 ) { + val =__raw_readl (ixi->irqbase +IXP4XX_ICMR2 ); + val |=BIT (d->hwirq -32 ); +__raw_writel (val, ixi->irqbase +IXP4XX_ICMR2 ); + }else { + val =__raw_readl (ixi->irqbase +IXP4XX_ICMR ); + val |=BIT (d->hwirq); +__raw_writel (val, ixi->irqbase +IXP4XX_ICMR ); + } +}
Same here, as well as all the other places sporting a __raw_ accessor.
Quoted 169 lines
drivers/irqchip/irq-ixp4xx.c new file +169
-0+ +asmlinkage void __exception_irq_entry ixp4xx_handle_irq(struct pt_regs *regs) +{ +struct ixp4xx_irq *ixi = &ixirq; +unsigned long status; +int i; + + status =__raw_readl (ixi->irqbase +IXP4XX_ICIP ); +for_each_set_bit (i, &status,32 ) +handle_domain_irq (ixi->domain, i, regs); + +/* +* IXP465/IXP435 has an upper IRQ status register +*/ +if (ixi->is_356) { + status =__raw_readl (ixi->irqbase +IXP4XX_ICIP2 ); +for_each_set_bit (i, &status,32 ) +handle_domain_irq (ixi->domain, i +32 , regs); + } +} + +static int ixp4xx_irq_domain_translate (struct irq_domain *domain, +struct irq_fwspec *fwspec, +unsigned long *hwirq, +unsigned int *type) +{ +/* We support standard DT translation */ +if (is_of_node (fwspec->fwnode) && fwspec->param_count ==2 ) { + *hwirq = fwspec->param[0 ]; + *type = fwspec->param[1 ]; +return 0 ; + } + +if (is_fwnode_irqchip (fwspec->fwnode)) { +if (fwspec->param_count !=2 ) +return -EINVAL ; + *hwirq = fwspec->param[0 ]; + *type = fwspec->param[1 ]; +WARN_ON (*type ==IRQ_TYPE_NONE ); +return 0 ; + } + +return -EINVAL ; +} + +static int ixp4xx_irq_domain_alloc (struct irq_domain *d, +unsigned int irq,unsigned int nr_irqs, +void *data) +{ +struct ixp4xx_irq *ixi = d->host_data; +irq_hw_number_t hwirq; +unsigned int type =IRQ_TYPE_NONE ; +struct irq_fwspec *fwspec = data; +int ret; +int i; + + ret =ixp4xx_irq_domain_translate (d, fwspec, &hwirq, &type); +if (ret) +return ret; + +for (i =0 ; i < nr_irqs; i++) { +/* +* TODO: after converting IXP4xx to only device tree, set +* handle_bad_irq as default handler and assume all consumers +* call .set_type() as this is provided in the second cell in +* the device tree phandle. +*/ +irq_domain_set_info (d, + irq + i, + hwirq + i, + &ixi->irqchip, + ixi, + handle_level_irq, +NULL ,NULL ); +irq_set_probe (irq + i); + } + +return 0 ; +} + +/* +* This needs to be a hierarchical irqdomain to work well with the +* GPIO irqchip (which is lower in the hierarchy) +*/ +static const struct irq_domain_ops ixp4xx_irqdomain_ops = { + .translate = ixp4xx_irq_domain_translate, + .alloc = ixp4xx_irq_domain_alloc, + .free = irq_domain_free_irqs_common, +}; + +/** +* ixp4xx_get_irq_domain() - retrieve the ixp4xx irq domain +* +* This function will go away when we transition to DT probing. +*/ +struct irq_domain *ixp4xx_get_irq_domain (void ) +{ +struct ixp4xx_irq *ixi = &ixirq; + +return ixi->domain; +} +EXPORT_SYMBOL_GPL (ixp4xx_get_irq_domain); + +/* +* This is the Linux IRQ to hwirq mapping table. This goes away when +* we have DT support as all IRQ resources are defined in the device +* tree. It will register all the IRQs that are not used by the hierarchical +* GPIO IRQ chip. The "holes" inbetween these IRQs will be requested by +* the GPIO driver using . This is a step-gap solution. +*/ +struct ixp4xx_irq_chunk { +int irq; +int hwirq; +int nr_irqs; +}; + +static const struct ixp4xx_irq_chunk ixp4xx_irq_chunks[] = { + { + .irq =16 , + .hwirq =0 , + .nr_irqs =6 , + }, + { + .irq =24 , + .hwirq =8 , + .nr_irqs =11 , + }, + { + .irq =46 , + .hwirq =30 , + .nr_irqs =2 , + }, +/* Only on the 436 variants */ + { + .irq =48 , + .hwirq =32 , + .nr_irqs =10 , + }, +}; + +/** +* ixp4x_irq_setup() - Common setup code for the IXP4xx interrupt controller +* @ixi: State container +* @irqbase: Virtual memory base for the interrupt controller +* @fwnode: Corresponding fwnode abstraction for this controller +* @is_356: if this is an IXP43x, IXP45x or IXP46x SoC variant +*/ +static int ixp4xx_irq_setup (struct ixp4xx_irq *ixi, +void __iomem *irqbase, +struct fwnode_handle *fwnode, +bool is_356) +{ +int nr_irqs; + + ixi->irqbase = irqbase; + ixi->is_356 = is_356; + +/* Route all sources to IRQ instead of FIQ */ +__raw_writel (0x0 , ixi->irqbase +IXP4XX_ICLR ); + +/* Disable all interrupts */ +__raw_writel (0x0 , ixi->irqbase +IXP4XX_ICMR ); + +if (is_356) { +/* Route upper 32 sources to IRQ instead of FIQ */ +__raw_writel (0x0 , ixi->irqbase +IXP4XX_ICLR2 ); + +/* Disable upper 32 interrupts */ +__raw_writel (0x0 , ixi->irqbase +IXP4XX_ICMR2 );
drivers/irqchip/irq-ixp4xx.c line 281
Quoted 10 lines
drivers/irqchip/irq-ixp4xx.c new file +10
-0+ + nr_irqs =64 ; + }else { + nr_irqs =32 ; + } + + ixi->irqchip.name ="IXP4xx" ; + ixi->irqchip.irq_mask = ixp4xx_irq_mask; + ixi->irqchip.irq_unmask = ixp4xx_irq_unmask; + ixi->irqchip.irq_set_type = ixp4xx_set_irq_type;
Aren't you guaranteed to only have one such irqchip? If so, this could become a static const object, instead of allocating it dynamically. Not a big deal though.
Quoted 26 lines
drivers/irqchip/irq-ixp4xx.c new file +26
-0+ + ixi->domain =irq_domain_create_linear (fwnode, nr_irqs, + &ixp4xx_irqdomain_ops, + ixi); +if (!ixi->domain) { +pr_crit ("IXP4XX: can not add primary irqdomain\n" ); +return -ENODEV ; + } + +set_handle_irq (ixp4xx_handle_irq); + +return 0 ; +} + +/** +* ixp4xx_irq_init() - Function to initialize the irqchip from boardfiles +* @irqbase: physical base for the irq controller +* @is_356: if this is an IXP43x, IXP45x or IXP46x SoC variant +*/ +void __init ixp4xx_irq_init (resource_size_t irqbase, +bool is_356) +{ +struct ixp4xx_irq *ixi = &ixirq; +void __iomem *base; +struct fwnode_handle *fwnode; +struct irq_fwspec fwspec;
drivers/irqchip/irq-ixp4xx.c line 317
Quoted 10 lines
drivers/irqchip/irq-ixp4xx.c new file +10
-0+int nr_chunks; +int ret; +int i; + + base =ioremap (irqbase,0x100 ); +if (!base) { +pr_crit ("IXP4XX: could not ioremap interrupt controller\n" ); +return ; + } + fwnode =irq_domain_alloc_fwnode (base);
I assume this is a temporary solution until the SoC gains a DT port (and the irqchip a DT node)?
Quoted 52 lines
drivers/irqchip/irq-ixp4xx.c new file +43
-0+if (!fwnode) { +pr_crit ("IXP4XX: no domain handle\n" ); +return ; + } + ret =ixp4xx_irq_setup (ixi, base, fwnode, is_356); +if (ret) { +pr_crit ("IXP4XX: failed to set up irqchip\n" ); +irq_domain_free_fwnode (fwnode); + } + + nr_chunks =ARRAY_SIZE (ixp4xx_irq_chunks); +if (!is_356) + nr_chunks--; + +/* +* After adding OF support, this is no longer needed: irqs +* will be allocated for the respective fwnodes. +*/ +for (i =0 ; i < nr_chunks; i++) { +const struct ixp4xx_irq_chunk *chunk = &ixp4xx_irq_chunks[i]; + +pr_info ("Allocate Linux IRQs %d..%d HW IRQs %d..%d\n" , + chunk->irq, chunk->irq + chunk->nr_irqs -1 , + chunk->hwirq, chunk->hwirq + chunk->nr_irqs -1 ); + fwspec.fwnode = fwnode; + fwspec.param[0 ] = chunk->hwirq; + fwspec.param[1 ] =IRQ_TYPE_LEVEL_HIGH ; + fwspec.param_count =2 ; + ret =__irq_domain_alloc_irqs (ixi->domain, + chunk->irq, + chunk->nr_irqs, +NUMA_NO_NODE , + &fwspec, + false, +NULL ); +if (ret <0 ) { +pr_crit ("IXP4XX: can not allocate irqs in hierarchy %d\n" , + ret); +return ; + } + } +} +EXPORT_SYMBOL_GPL (ixp4xx_irq_init);include/linux/irqchip/irq-ixp4xx.h new file +2
-0@@ -0,0 +1,12 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef __IRQ_IXP4XX_H
include/linux/irqchip/irq-ixp4xx.h line 12
Quoted 10 lines
include/linux/irqchip/irq-ixp4xx.h new file +10
-0+#define __IRQ_IXP4XX_H + +#include <linux/ioport.h> +struct irq_domain ; + +void ixp4xx_irq_init (resource_size_t irqbase, +bool is_356); +struct irq_domain *ixp4xx_get_irq_domain (void ); + +#endif /* __IRQ_IXP4XX_H */
Thanks,
M.
Signature · 6 lines
Jazz is not dead. It just smells funny... _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Re: [PATCH 04/17 v1] irqchip: Add driver for IXP4xx
Quoted 5 lines · Marc Zyngier
drivers/irqchip/irq-ixp4xx.c line 64
Quoted 3 lines
drivers/irqchip/irq-ixp4xx.c new file +3
-0+static int ixp4xx_set_irq_type (struct irq_data *d,unsigned int type) +{ +/* All are level active high (asserted) here */ It'd be good to return an error if type isn't
LEVEL_HIGH.
OK
Quoted 11 lines
drivers/irqchip/irq-ixp4xx.c line 82
Quoted 10 lines
drivers/irqchip/irq-ixp4xx.c new file +10
-0+if (ixi->is_356 && d->hwirq >=32 ) { + val =__raw_readl (ixi->irqbase +IXP4XX_ICMR2 ); + val &= ~BIT (d->hwirq -32 ); +__raw_writel (val, ixi->irqbase +IXP4XX_ICMR2 ); + }else { + val =__raw_readl (ixi->irqbase +IXP4XX_ICMR ); + val &= ~BIT (d->hwirq); +__raw_writel (val, ixi->irqbase +IXP4XX_ICMR ); + } +}
Quoted 3 lines
This probably comes from the original code, but I'd like to be able to use a LE kernel on this HW (full disclosure: I have some of this crap stashed somewhere in the basement... ;-).
It will work. One reason I am refactoring and preserving IXP4xx is this stuff from the datasheet:
Ambient Air Temperature (Extended) -40° C to 85° C Ambient Air Temperature (Commercial) 0° C to 70° C
MTBF: 60 Years at 55°C
And I don't think there is any big difference between the "extended" and "commercial" version of this SoC, they all come in the same sturdy packaging too. Diamonds and IXP4xx are forever.
Quoted 2 lines
How about using something that enforces the endianness of the accesses, as I suspect the bus is hardcoded to BE?
So, IIUC (Krzysztof can confirm) IXP4xx works like this that when the CPU is brought up in LE mode, all bytes on the address bus are swizzled so that the access can always use the CPU native endianness.
Isn't it crazy :D
This means __raw_writel() will always do the right thing, because that uses native endianness, and that is why it is used quite a lot in IXP4xx drivers.
If you want full control you need to define local helpers for everything that change behaviour at compile-time such as:
static void foo_writel(u32 val, __iomem void *addr) {
#if defined(CONFIG_CPU_BIG_ENDIAN)
iowrite32be(val, addr);
#else
writel(val, addr);#endif
}
Which will have the same effect as __raw_writel().
So that is why we use the (ugly) macro __raw_writel() a lot in IXP4xx drivers.
Quoted 3 lines
ioread32be/iowrite32be springs
to mind, and I can see the current IXP4xx code provides such an implementation in its ownio.h(which you may have to make private).
The stuf in <mach/io.h> is there for indirect PCI, which is another unrelated oddity. PCI devices are always LE (as is proper). It is there because the PCI host on the IXP4xx can only access > 64MB PCI memory space with certain quirks that no other PCI host controller needs.
I will get to this when I try to move that driver to drivers/pci ... It's unrelated to this business however.
Quoted 8 lines
drivers/irqchip/irq-ixp4xx.c line 281
Quoted 4 lines
drivers/irqchip/irq-ixp4xx.c new file +4
-0+ ixi->irqchip.name ="IXP4xx" ; + ixi->irqchip.irq_mask = ixp4xx_irq_mask; + ixi->irqchip.irq_unmask = ixp4xx_irq_unmask; + ixi->irqchip.irq_set_type = ixp4xx_set_irq_type;Aren't you guaranteed to only have one such irqchip? If so, this could become a static const object, instead of allocating it dynamically. Not a big deal though.
Force of habit. Comes from the GPIO side of things where we never know how many instances there are of stuff, if it's OK I'd like to keep it.
Quoted 4 lines
Quoted 1 line
+ fwnode =
irq_domain_alloc_fwnode(base);I assume this is a temporary solution until the SoC gains a DT port (and the irqchip a DT node)?
Yes, see the later DT patch that passes the parent as fwnode, once all boards are converted we can drop this.
BTW here is how I then use the hierarchical parent in the GPIO chip:
https://marc.info/?l=linux-arm-kernel&m=154923023907623&w=2
https://marc.info/?l=linux-arm-kernel&m=154923038707686&w=2
Yours,
Linus Walleij
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Re: [PATCH 04/17 v1] irqchip: Add driver for IXP4xx
Quoted 1 line · On Mon, 11 Feb 2019 21:58:41 +0100 Linus Walleij <[email protected]>…
On Mon, Feb 11, 2019 at 4:30 PM Marc Zyngier <[email protected]> wrote:
[...]
Quoted 9 lines
Quoted 2 lines
How about using something that enforces the endianness of the accesses, as I suspect the bus is hardcoded to BE?
So, IIUC (Krzysztof can confirm) IXP4xx works like this that when the CPU is brought up in LE mode, all bytes on the address bus are swizzled so that the access can always use the CPU native endianness.
Isn't it crazy :D
It's spelled BE32! ;-) I vaguely remember doing some of that on vulcan, but that's a decade ago, and I've paged it out... ;-)
Quoted 3 lines
This means
__raw_writel()will always do the right thing, because that uses native endianness, and that is why it is used quite a lot in IXP4xx drivers.
OK, it now makes some sense. Maybe a comment somewhere will help if someone tries to reverse engineer it again in the next decade!
Quoted 7 lines
Quoted 3 lines
Aren't you guaranteed to only have one such irqchip? If so, this could become a static const object, instead of allocating it dynamically. Not a big deal though.
Force of habit. Comes from the GPIO side of things where we never know how many instances there are of stuff, if it's OK I'd like to keep it.
No problem.
Quoted 6 lines
Quoted 5 lines
Quoted 2 lines
+ fwnode =
irq_domain_alloc_fwnode(base);I assume this is a temporary solution until the SoC gains a DT port (and the irqchip a DT node)?
Quoted 7 lines
Yes, see the later DT patch that passes the parent as fwnode, once all boards are converted we can drop this.
BTW here is how I then use the hierarchical parent in the GPIO chip:
https://marc.info/?l=linux-arm-kernel&m=154923023907623&w=2
https://marc.info/?l=linux-arm-kernel&m=154923038707686&w=2
Looks pretty cool, and surely even better once entirely converted to DT (I'm sure I can revive this FSG-3 that has been collecting dust on the shelf for a number of years).
Please CC me on the whole series next time you respin it!
Thanks,
M.
Signature · 6 lines
Without deviation from the norm, progress is not possible. _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Re: [PATCH 04/17 v1] irqchip: Add driver for IXP4xx
Quoted 2 lines · Marc Zyngier
It's spelled BE32! ;-) I vaguely remember doing some of that on vulcan, but that's a decade ago, and I've paged it out... ;-)
Right. It's also called value-preserving (where the "value" must 32-bit and aligned on 32-bit boundary) or (double) word invariant.
Since most of these accesses are natural 32-bit registers and (almost) none are ASCII/byte-style, it makes sense. IIRC the PCI has its own rules, though.
Signature · 9 lines
Krzysztof Halasa Industrial Research Institute for Automation and Measurements PIAP Al. Jerozolimskie 202, 02-486 Warsaw, Poland _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Re: [PATCH 04/17 v1] irqchip: Add driver for IXP4xx
Quoted 11 lines · Krzysztof Hałasa
Quoted 2 lines · Marc Zyngier
It's spelled BE32! ;-) I vaguely remember doing some of that on vulcan, but that's a decade ago, and I've paged it out... ;-)
Right. It's also called value-preserving (where the "value" must 32-bit and aligned on 32-bit boundary) or (double) word invariant.
Since most of these accesses are natural 32-bit registers and (almost) none are ASCII/byte-style, it makes sense. IIRC the PCI has its own rules, though.
IIUC PCI should always be LE and readl() writel() always read/write in LE. But I see PCI on the IXP4xx is a special history so I am going to experience it in all its glory now that I start looking at it.
Thanks,
Linus Walleij
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Re: [PATCH 04/17 v1] irqchip: Add driver for IXP4xx
Quoted 3 lines · Linus Walleij
IIUC PCI should always be LE and
readl()writel()always read/write in LE. But I see PCI on the IXP4xx is a special history so I am going to experience it in all its glory now that I start looking at it.
Oh yeah. BTW obviously readl() and writel() do the right thing on IXP4xx (otherwise the drivers wouldn't work) and the byte operations work as well. That's why the internal stuff uses __raw_{readl,writel}() and the PCI uses readl/writel() and so on (which corrects for endianness on BE).
Signature · 9 lines
Krzysztof Halasa Industrial Research Institute for Automation and Measurements PIAP Al. Jerozolimskie 202, 02-486 Warsaw, Poland _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Arnd Bergmann
maintainerRe: [PATCH 04/17 v1] irqchip: Add driver for IXP4xx
In reply to Linus WalleijQuoted 10 lines · Linus Walleij
Quoted 8 lines · Krzysztof Hałasa
Quoted 2 lines · Marc Zyngier
It's spelled BE32! ;-) I vaguely remember doing some of that on vulcan, but that's a decade ago, and I've paged it out... ;-)
Right. It's also called value-preserving (where the "value" must 32-bit and aligned on 32-bit boundary) or (double) word invariant.
Quoted 7 lines
Quoted 3 lines
Since most of these accesses are natural 32-bit registers and (almost) none are ASCII/byte-style, it makes sense. IIRC the PCI has its own rules, though.
IIUC PCI should always be LE and
readl()writel()always read/write in LE. But I see PCI on the IXP4xx is a special history so I am going to experience it in all its glory now that I start looking at it.
I found a document that explains some of the more obscure details of this chip (among a lot of the general concepts), in particular how you can configure memory regions as either BE, LE-data-coherent or LE-address-coherent, and the byte swap on PCI depending on that:
Arnd
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Re: [PATCH 04/17 v1] irqchip: Add driver for IXP4xx
Quoted 4 lines · Arnd Bergmann
I found a document that explains some of the more obscure details of this chip (among a lot of the general concepts), in particular how you can configure memory regions as either BE, LE-data-coherent or LE-address-coherent, and the byte swap on PCI depending on that:
There is also a problem with certain devices (certain old US Robotics access servers?) using IXP425 rev. A0. Those first chips don't have the LE data coherent mode.
We (= the official Linux kernel) don't use LE data coherent mode at all, though I have had a patch (not very clean) which could do that.
Signature · 9 lines
Krzysztof Halasa Industrial Research Institute for Automation and Measurements PIAP Al. Jerozolimskie 202, 02-486 Warsaw, Poland _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Arnd Bergmann
maintainerRe: [PATCH 04/17 v1] irqchip: Add driver for IXP4xx
Quoted 8 lines · Krzysztof Hałasa
Quoted 4 lines · Arnd Bergmann
I found a document that explains some of the more obscure details of this chip (among a lot of the general concepts), in particular how you can configure memory regions as either BE, LE-data-coherent or LE-address-coherent, and the byte swap on PCI depending on that:
Quoted 5 lines
There is also a problem with certain devices (certain old US Robotics access servers?) using IXP425 rev. A0. Those first chips don't have the LE data coherent mode.
We (= the official Linux kernel) don't use LE data coherent mode at all, though I have had a patch (not very clean) which could do that.
It does sound appealing to move to data coherent mode, since that is closer to what we have elsewhere. Maybe we can finally work that out and then allow a little-endian multiplatform configuration to include ixp4xx.
I have two questions about this:
- I have a vague memory that only specific revisions actually require the PCI indirect mode. Is it the same chip revision A0 of IXP425 that requires both pci-indirect and address-coherent mode, or are there other combinations?
- How much would it hurt actual users to drop support for both features? I.e. do we know of anyone using the affected chips (and still doing updates), or are the remaining ixp4xx systems generally using the later chip revision?
Arnd
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Re: [PATCH 04/17 v1] irqchip: Add driver for IXP4xx
Quoted 4 lines · Arnd Bergmann
- I have a vague memory that only specific revisions actually require the PCI indirect mode. Is it the same chip revision A0 of IXP425 that requires both pci-indirect and address-coherent mode, or are there other combinations?
IIRC, all chips support indirect PCI. Perhaps there are some changes about LE mode on the PCI, but that's it.
Most boards don't need indirect PCI. It's only needed when there is more than 64 MB of PCI address space to be used - IIRC IXP4xx have 4 direct PCI memory access windows, and each is 16 MB in size.
I remember I needed indirect PCI for use with a (SiS?) VGA card, it had (I guess) 128 MB of RAM. I think indirect PCI means the memory can't be really mapped, it can only be accessed using readl() and friends (which are then converted into register accesses resulting in the actual MMIO). Even with indirect PCI, 64 MB can be accessed directly (though I think we don't support it).
This is different from the bus mastering access to the main RAM - I think only the first 64 MB can be used for PCI BM DMA. This limitation, IIRC, doesn't apply to internal devices (Ethernet etc).
Quoted 4 lines
- How much would it hurt actual users to drop support for both features? I.e. do we know of anyone using the affected chips (and still doing updates), or are the remaining ixp4xx systems generally using the later chip revision?
Most chips are B0+, though there are (were) certain A0 platforms. I don't have any idea about their current use.
Signature · 9 lines
Krzysztof Halasa Industrial Research Institute for Automation and Measurements PIAP Al. Jerozolimskie 202, 02-486 Warsaw, Poland _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Arnd Bergmann
maintainerRe: [PATCH 04/17 v1] irqchip: Add driver for IXP4xx
Quoted 19 lines · Krzysztof Hałasa
Quoted 4 lines · Arnd Bergmann
- I have a vague memory that only specific revisions actually require the PCI indirect mode. Is it the same chip revision A0 of IXP425 that requires both pci-indirect and address-coherent mode, or are there other combinations?
IIRC, all chips support indirect PCI. Perhaps there are some changes about LE mode on the PCI, but that's it.
Most boards don't need indirect PCI. It's only needed when there is more than 64 MB of PCI address space to be used - IIRC IXP4xx have 4 direct PCI memory access windows, and each is 16 MB in size.
I remember I needed indirect PCI for use with a (SiS?) VGA card, it had (I guess) 128 MB of RAM. I think indirect PCI means the memory can't be really mapped, it can only be accessed usingreadl()and friends (which are then converted into register accesses resulting in the actual MMIO). Even with indirect PCI, 64 MB can be accessed directly (though I think we don't support it).
Quoted 3 lines
This is different from the bus mastering access to the main RAM - I think only the first 64 MB can be used for PCI BM DMA. This limitation, IIRC, doesn't apply to internal devices (Ethernet etc).
Thanks a lot for this background, that helps a lot. We actually have a more general implementation of this (indirect mmio and pio) in arch/powerpc/kernel/io-workarounds.c, and I was considering whether we can make that architecture independent code and reuse it here as well.
Looking at the powerpc implementation however, I see two other problems:
- the way it is implemented requires using some spare address bits on a 64-bit pointer, so that would have to be change a lot to work on a 32-bit architecture
- the MMIO workarounds don't really work for a VGA card
in general since you cannot map the frame buffer into user space, so the application of that is still a bit limited. I suspect you would have had the same problem with the existing ixp4xx code as well, depending on how the driver implements user space graphics.
We could still consider using it on Allwinner H6, which is a 64-bit chip that is even more limited (only 64 /KB/ can be mapped at a time).
Quoted 7 lines
Quoted 4 lines
- How much would it hurt actual users to drop support for both features? I.e. do we know of anyone using the affected chips (and still doing updates), or are the remaining ixp4xx systems generally using the later chip revision?
Most chips are B0+, though there are (were) certain A0 platforms. I don't have any idea about their current use.
Ok, fair enough.
Arnd
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Re: [PATCH 04/17 v1] irqchip: Add driver for IXP4xx
Quoted 6 lines · Arnd Bergmann
- the MMIO workarounds don't really work for a VGA card
in general since you cannot map the frame buffer into user space, so the application of that is still a bit limited. I suspect you would have had the same problem with the existing ixp4xx code as well, depending on how the driver implements user space graphics.
Right. Now I remember I put the VGA FB in the first 64 MB of PCI address space (this means it was a 64 MB VGA, and that I could actually do direct and indirect accesses at the same time). The rest of PCI address space was used indirectly for (I guess) VGA registers and other hardware (SATA controller and similar stuff - nothing which would require mapped PCI memory).
The PCI bus mastering limitation was far worse - there are boards with 128 and 256 MB (maximum possible on IXP42x) of RAM and double SKB buffering with e.g. dual gigabit Ethernet wasn't nice. I ended up with a hack which allocated network buffers from the first 64 MB of RAM only.
Signature · 9 lines
Krzysztof Halasa Industrial Research Institute for Automation and Measurements PIAP Al. Jerozolimskie 202, 02-486 Warsaw, Poland _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Arnd Bergmann
maintainerRe: [PATCH 04/17 v1] irqchip: Add driver for IXP4xx
In reply to Marc ZyngierQuoted 21 lines · Marc Zyngier
Quoted 1 line · On Mon, 11 Feb 2019 21:58:41 +0100 Linus Walleij <[email protected]>…
On Mon, Feb 11, 2019 at 4:30 PM Marc Zyngier <[email protected]> wrote:
[...]
Quoted 9 lines
Quoted 2 lines
How about using something that enforces the endianness of the accesses, as I suspect the bus is hardcoded to BE?
So, IIUC (Krzysztof can confirm) IXP4xx works like this that when the CPU is brought up in LE mode, all bytes on the address bus are swizzled so that the access can always use the CPU native endianness.
Isn't it crazy :D
It's spelled BE32! ;-) I vaguely remember doing some of that on vulcan, but that's a decade ago, and I've paged it out... ;-)
Quoted 6 lines
Quoted 3 lines
This means
__raw_writel()will always do the right thing, because that uses native endianness, and that is why it is used quite a lot in IXP4xx drivers.OK, it now makes some sense. Maybe a comment somewhere will help if someone tries to reverse engineer it again in the next decade!
I think the best way forward would be to change all the __raw_readl()/__raw_writel() in ixp4xx specific drivers to a new accessor that is defined as a trivial wrapper around __raw_readl()/ __raw_writel() but that is explicitly defined as
- always accessing a 32-bit word in native endianess
- only valid on ixp4xx on-chip registers (not PCI)
- containing the required barriers (if any)
In my mental model of the I/O accessors, readl/writel are used for (little-endian) MMIO register accesses, while __raw_readl()/__raw_writel() can only be used in portable code on byte streams in memory behind a bus, not on registers. The way ixp4xx works fits into neither of those two, so we should not use them here. I also think it's a bug to use 8-bit or 16-bit accessors for internal registers on ixp4xx, so having a pair of special helpers makes it impossible to do so.
Arnd
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
PATCH 5/17 gpio: ixp4xx: Add driver for the IXP4xx GPIO
In reply to Linus WalleijThis adds a driver for the IXP4xx GPIO block found in the Intel XScale IXP4xx systems.
The GPIO part of this block is pretty straight-forward and just uses the generic MMIO GPIO library.
The irqchip side of this driver is hierarchical where the main irqchip will receive a processed level trigger in response to the edge detector of the GPIO block, so for this reason the v2 version of the irqdomain API is used (as well as in the parent IXP4xx irqchip) and masking, unmasking and setting up the type on IRQ happens on several levels.
Currently this GPIO controller will grab the parent irqdomain using a special function, but as the platform move toward device tree probing, this will not be needed:
we can just look up the parent irqdomain from the device tree.
---
Bartosz: looking for your ACK on this, it'd be good if the other GPIO maintainer is aligned with my ideas here. I intend to merge this through the ARM SoC tree.
--- MAINTAINERS | 1 + drivers/gpio/Kconfig | 12 + drivers/gpio/Makefile | 1 + drivers/gpio/gpio-ixp4xx.c | 443 +++++++++++++++++++++++++++++++++++++ 4 files changed, 457 insertions(+) create mode 100644 drivers/gpio/gpio-ixp4xx.c
MAINTAINERS +1 -0
@@ -1651,6 +1651,7 @@ M: Krzysztof Halasa <[email protected]> L: [email protected] (moderated for non-subscribers) S: Maintained F: arch/arm/mach-ixp4xx/ +F: drivers/gpio/gpio-ixp4xx.c F: drivers/irqchip/irq-ixp4xx.c F: include/linux/irqchip/irq-ixp4xx.h
drivers/gpio/Kconfig +12 -0
@@ -286,6 +286,18 @@ config GPIO_IOP If unsure, say N. +config GPIO_IXP4XX + bool "Intel IXP4xx GPIO" + depends on ARCH_IXP4XX || COMPILE_TEST + select GPIO_GENERIC + select IRQ_DOMAIN + select IRQ_DOMAIN_HIERARCHY + help + Say yes here to support the GPIO functionality of a number of Intel + IXP4xx series of chips. + + If unsure, say N. + config GPIO_LOONGSON bool "Loongson-2/3 GPIO support" depends on CPU_LOONGSON2 || CPU_LOONGSON3
drivers/gpio/Makefile +1 -0
@@ -60,6 +60,7 @@ obj-$(CONFIG_GPIO_HLWD) += gpio-hlwd.o obj-$(CONFIG_HTC_EGPIO) += gpio-htc-egpio.o obj-$(CONFIG_GPIO_ICH) += gpio-ich.o obj-$(CONFIG_GPIO_IOP) += gpio-iop.o +obj-$(CONFIG_GPIO_IXP4XX) += gpio-ixp4xx.o obj-$(CONFIG_GPIO_IT87) += gpio-it87.o obj-$(CONFIG_GPIO_JANZ_TTL) += gpio-janz-ttl.o obj-$(CONFIG_GPIO_KEMPLD) += gpio-kempld.o
drivers/gpio/gpio-ixp4xx.c new file +443 -0
443 lines not on this page · raw message
Signature · 7 lines
2.20.1 _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Re: [PATCH 05/17 v1] gpio: ixp4xx: Add driver for the IXP4xx GPIO
niedz., 3 lut 2019 o 22:42 Linus Walleij <[email protected]> napisał(a):
Quoted 21 lines
This adds a driver for the IXP4xx GPIO block found in the Intel XScale IXP4xx systems.
The GPIO part of this block is pretty straight-forward and just uses the generic MMIO GPIO library.
The irqchip side of this driver is hierarchical where the main irqchip will receive a processed level trigger in response to the edge detector of the GPIO block, so for this reason the v2 version of the irqdomain API is used (as well as in the parent IXP4xx irqchip) and masking, unmasking and setting up the type on IRQ happens on several levels.
Currently this GPIO controller will grab the parent irqdomain using a special function, but as the platform move toward device tree probing, this will not be needed:
we can just look up the parent irqdomain from the device tree.
Quoted 7 lines
Cc Bartosz Golaszewski <[email protected]>Signed-off-by Linus Walleij <[email protected]>---
Bartosz: looking for your ACK on this, it'd be good if the other GPIO maintainer is aligned with my ideas here. I intend to merge this through the ARM SoC tree.
---
Linus,
My remarks are below. Mostly just nits (feel free to ignore) or questions that I'd like clarified.
Quoted 60 lines
MAINTAINERS | 1 + drivers/gpio/Kconfig | 12 + drivers/gpio/Makefile | 1 + drivers/gpio/gpio-ixp4xx.c | 443 +++++++++++++++++++++++++++++++++++++ 4 files changed, 457 insertions(+) create mode 100644 drivers/gpio/gpio-ixp4xx.cMAINTAINERS +1
-0@@ -1651,6 +1651,7 @@ M: Krzysztof Halasa <[email protected]> L: [email protected] (moderated for non-subscribers) S: Maintained F: arch/arm/mach-ixp4xx/ +F: drivers/gpio/gpio-ixp4xx.c F: drivers/irqchip/irq-ixp4xx.c F: include/linux/irqchip/irq-ixp4xx.hdrivers/gpio/Kconfig +12
-0@@ -286,6 +286,18 @@ config GPIO_IOP If unsure, say N. +config GPIO_IXP4XX + bool "Intel IXP4xx GPIO" + depends on ARCH_IXP4XX || COMPILE_TEST + select GPIO_GENERIC + select IRQ_DOMAIN + select IRQ_DOMAIN_HIERARCHY + help + Say yes here to support the GPIO functionality of a number of Intel + IXP4xx series of chips. + + If unsure, say N. + config GPIO_LOONGSON bool "Loongson-2/3 GPIO support" depends on CPU_LOONGSON2 || CPU_LOONGSON3drivers/gpio/Makefile +1
-0@@ -60,6 +60,7 @@ obj-$(CONFIG_GPIO_HLWD) += gpio-hlwd.o obj-$(CONFIG_HTC_EGPIO) += gpio-htc-egpio.o obj-$(CONFIG_GPIO_ICH) += gpio-ich.o obj-$(CONFIG_GPIO_IOP) += gpio-iop.o +obj-$(CONFIG_GPIO_IXP4XX) += gpio-ixp4xx.o obj-$(CONFIG_GPIO_IT87) += gpio-it87.o obj-$(CONFIG_GPIO_JANZ_TTL) += gpio-janz-ttl.o obj-$(CONFIG_GPIO_KEMPLD) += gpio-kempld.odrivers/gpio/gpio-ixp4xx.c new file +0
-0
drivers/gpio/gpio-ixp4xx.c line 8
Quoted 8 lines
drivers/gpio/gpio-ixp4xx.c new file +8
-0@@ -0,0 +1,443 @@ +// SPDX-License-Identifier: GPL-2.0 +/* +* IXP4 GPIO driver +* Copyright (C) 2019 Linus Walleij <[email protected]> +* +* based on previous work and know-how from: +* Deepak Saxena <[email protected]> +*/
Just a nit, but I'd add a newline between the includes and the header.
Also: C++ style comment for the header.
drivers/gpio/gpio-ixp4xx.c line 17
Quoted 9 lines
drivers/gpio/gpio-ixp4xx.c new file +9
-0+#include <linux/gpio/driver.h> +#include <linux/io.h> +#include <linux/irq.h> +#include <linux/irqdomain.h> +#include <linux/irqchip.h> +#include <linux/platform_device.h> +#include <linux/bitops.h> +/* Include that go away with DT transition */ +#include <linux/irqchip/irq-ixp4xx.h>
I think a newline between linux/ and asm/ includes is a good rule.
drivers/gpio/gpio-ixp4xx.c line 28
Quoted 11 lines
drivers/gpio/gpio-ixp4xx.c new file +11
-0+#include <asm/mach-types.h> + +#define IXP4XX_GPIO_GPOUTR 0x00 +#define IXP4XX_GPIO_GPOER 0x04 +#define IXP4XX_GPIO_GPINR 0x08 +#define IXP4XX_GPIO_GPISR 0x0C +#define IXP4XX_GPIO_GPIT1R 0x10 +#define IXP4XX_GPIO_GPIT2R 0x14 +#define IXP4XX_GPIO_GPCLKR 0x18 +#define IXP4XX_GPIO_GPDBSELR 0x1C +
Since these are registers offsets - maybe the prefix could be IXP4XX_GPIO_REG_* or IXP4XX_GPIO_OFF_*? I think it's more readable.
drivers/gpio/gpio-ixp4xx.c line 40
Quoted 12 lines
drivers/gpio/gpio-ixp4xx.c new file +12
-0+/* +* The hardware uses 3 bits to indicate interrupt "style". +* we clear and set these three bits accordingly. The lower 24 +* bits in two registers (GPIT1R and GPIT2R) are used to set up +* the style for 8 lines each for a total of 16 GPIO lines. +*/ +#define IXP4XX_GPIO_STYLE_ACTIVE_HIGH 0x0 +#define IXP4XX_GPIO_STYLE_ACTIVE_LOW 0x1 +#define IXP4XX_GPIO_STYLE_RISING_EDGE 0x2 +#define IXP4XX_GPIO_STYLE_FALLING_EDGE 0x3 +#define IXP4XX_GPIO_STYLE_TRANSITIONAL 0x4 +#define IXP4XX_GPIO_STYLE_MASK 0x7
I'd use GENMASK(2, 0) here.
Quoted 65 lines
drivers/gpio/gpio-ixp4xx.c new file +65
-0+#define IXP4XX_GPIO_STYLE_SIZE 3 + +/** +* struct ixp4xx_gpio - IXP4 GPIO state container +* @dev: containing device for this instance +* @fwnode: the fwnode for this GPIO chip +* @gc: gpiochip for this instance +* @domain: irqdomain for this chip instance +* @base: remapped I/O-memory base +* @irq_edge: Each bit represents an IRQ: 1: edge-triggered, +* 0: level triggered +*/ +struct ixp4xx_gpio { +struct device *dev; +struct fwnode_handle *fwnode; +struct gpio_chip gc; +struct irq_domain *domain; +void __iomem *base; +unsigned long long irq_edge; +}; + +/** +* struct ixp4xx_gpio_map - IXP4 GPIO to parent IRQ map +* @gpio_offset: offset of the IXP4 GPIO line +* @parent_hwirq: hwirq on the parent IRQ controller +*/ +struct ixp4xx_gpio_map { +int gpio_offset; +int parent_hwirq; +}; + +/* GPIO lines 0..12 have corresponding IRQs, GPIOs 13..15 have no IRQs */ +const struct ixp4xx_gpio_map ixp4xx_gpiomap[] = { + { .gpio_offset =0 , .parent_hwirq =6 }, + { .gpio_offset =1 , .parent_hwirq =7 }, + { .gpio_offset =2 , .parent_hwirq =19 }, + { .gpio_offset =3 , .parent_hwirq =20 }, + { .gpio_offset =4 , .parent_hwirq =21 }, + { .gpio_offset =5 , .parent_hwirq =22 }, + { .gpio_offset =6 , .parent_hwirq =23 }, + { .gpio_offset =7 , .parent_hwirq =24 }, + { .gpio_offset =8 , .parent_hwirq =25 }, + { .gpio_offset =9 , .parent_hwirq =26 }, + { .gpio_offset =10 , .parent_hwirq =27 }, + { .gpio_offset =11 , .parent_hwirq =28 }, + { .gpio_offset =12 , .parent_hwirq =29 }, +}; + +static void ixp4xx_gpio_irq_ack (struct irq_data *d) +{ +struct ixp4xx_gpio *g =irq_data_get_irq_chip_data (d); + +__raw_writel (BIT (d->hwirq), g->base +IXP4XX_GPIO_GPISR ); +} + +static void ixp4xx_gpio_irq_unmask (struct irq_data *d) +{ +struct ixp4xx_gpio *g =irq_data_get_irq_chip_data (d); + +/* ACK when unmasking if not edge-triggered */ +if (!(g->irq_edge &BIT (d->hwirq))) +ixp4xx_gpio_irq_ack (d); + +irq_chip_unmask_parent (d); +}
drivers/gpio/gpio-ixp4xx.c line 115
Quoted 10 lines
drivers/gpio/gpio-ixp4xx.c new file +10
-0+ +static int ixp4xx_gpio_irq_set_type (struct irq_data *d,unsigned int type) +{ +struct ixp4xx_gpio *g =irq_data_get_irq_chip_data (d); +int line = d->hwirq; +u32 int_style; +unsigned long flags; +u32 int_reg; +u32 val; +
I'm personally a fan of putting variables of the same type in the same line and arranging them in reverse-christmas tree order, but feel free to ignore it.
Quoted 35 lines
drivers/gpio/gpio-ixp4xx.c new file +35
-0+switch (type) { +case IRQ_TYPE_EDGE_BOTH : +irq_set_handler_locked (d, handle_edge_irq); + int_style =IXP4XX_GPIO_STYLE_TRANSITIONAL ; + g->irq_edge |=BIT (d->hwirq); +break ; +case IRQ_TYPE_EDGE_RISING : +irq_set_handler_locked (d, handle_edge_irq); + int_style =IXP4XX_GPIO_STYLE_RISING_EDGE ; + g->irq_edge |=BIT (d->hwirq); +break ; +case IRQ_TYPE_EDGE_FALLING : +irq_set_handler_locked (d, handle_edge_irq); + int_style =IXP4XX_GPIO_STYLE_FALLING_EDGE ; + g->irq_edge |=BIT (d->hwirq); +break ; +case IRQ_TYPE_LEVEL_HIGH : +irq_set_handler_locked (d, handle_level_irq); + int_style =IXP4XX_GPIO_STYLE_ACTIVE_HIGH ; + g->irq_edge &= ~BIT (d->hwirq); +break ; +case IRQ_TYPE_LEVEL_LOW : +irq_set_handler_locked (d, handle_level_irq); + int_style =IXP4XX_GPIO_STYLE_ACTIVE_LOW ; + g->irq_edge &= ~BIT (d->hwirq); +break ; +default : +return -EINVAL ; + } + +if (line >=8 ) { +/* pins 8-15 */ + line -=8 ; + int_reg =IXP4XX_GPIO_GPIT2R ; + }else {
drivers/gpio/gpio-ixp4xx.c line 160
Quoted 10 lines
drivers/gpio/gpio-ixp4xx.c new file +10
-0+/* pins 0-7 */ + int_reg =IXP4XX_GPIO_GPIT1R ; + } + +spin_lock_irqsave (&g->gc.bgpio_lock, flags); + +/* Clear the style for the appropriate pin */ + val =__raw_readl (g->base + int_reg); + val &= ~(IXP4XX_GPIO_STYLE_MASK << (line *IXP4XX_GPIO_STYLE_SIZE )); +__raw_writel (val, g->base + int_reg);
I know you're not using regmap, because this driver's based on gpio-mmio, but I'm wondering if you could maybe wrap those three operations in a helper wrapper e.g. ixp4xx_update_reg() or something to make it easier to read. Same below.
Quoted 16 lines
drivers/gpio/gpio-ixp4xx.c new file +16
-0+ +__raw_writel (BIT (line), g->base +IXP4XX_GPIO_GPISR ); + +/* Set the new style */ + val =__raw_readl (g->base + int_reg); + val |= (int_style << (line *IXP4XX_GPIO_STYLE_SIZE )); +__raw_writel (val, g->base + int_reg); + +/* Force-configure this line as an input */ + val =__raw_readl (g->base +IXP4XX_GPIO_GPOER ); + val |=BIT (d->hwirq); +__raw_writel (val, g->base +IXP4XX_GPIO_GPOER ); + +spin_unlock_irqrestore (&g->gc.bgpio_lock, flags); + +/* This parent only accept level high (asserted) */
drivers/gpio/gpio-ixp4xx.c line 186
Quoted 10 lines
drivers/gpio/gpio-ixp4xx.c new file +10
-0+return irq_chip_set_type_parent (d,IRQ_TYPE_LEVEL_HIGH ); +} + +static struct irq_chip ixp4xx_gpio_irqchip = { + .name ="IXP4GPIO" , + .irq_ack = ixp4xx_gpio_irq_ack, + .irq_mask = irq_chip_mask_parent, + .irq_unmask = ixp4xx_gpio_irq_unmask, + .irq_set_type = ixp4xx_gpio_irq_set_type, +};
I assume this device cannot have multiple instances, so it's safe to have a static irqchip?
Quoted 4 lines
drivers/gpio/gpio-ixp4xx.c new file +4
-0+ +static int ixp4xx_gpio_to_irq (struct gpio_chip *gc,unsigned int offset) +{ +struct ixp4xx_gpio *g =gpiochip_get_data (gc);
drivers/gpio/gpio-ixp4xx.c line 200
Quoted 10 lines
drivers/gpio/gpio-ixp4xx.c new file +10
-0+struct irq_fwspec fwspec; + + fwspec.fwnode = g->fwnode; + fwspec.param_count =2 ; + fwspec.param[0 ] = offset; + fwspec.param[1 ] =IRQ_TYPE_NONE ; + +return irq_create_fwspec_mapping (&fwspec); +} +
This is were I start to struggle. I'm still not very well versed in irq domain hierarchies yet. You already explain the concept in the commit message, but it would be great if you could add a comment describing the technical details of implementation here and in other related callbacks. The whole fwspec thingy is not very obvious and it would serve as an example for the future.
drivers/gpio/gpio-ixp4xx.c line 212
Quoted 12 lines
drivers/gpio/gpio-ixp4xx.c new file +12
-0+static int ixp4xx_gpio_irq_domain_translate (struct irq_domain *domain, +struct irq_fwspec *fwspec, +unsigned long *hwirq, +unsigned int *type) +{ + +/* We support standard DT translation */ +if (is_of_node (fwspec->fwnode) && fwspec->param_count ==2 ) { + *hwirq = fwspec->param[0 ]; + *type = fwspec->param[1 ]; +return 0 ; + }
This logic is a bit non-intuitive - maybe you could first check for error conditions and then do any processing?
Quoted 214 lines
drivers/gpio/gpio-ixp4xx.c new file +214
-0+ +/* This goes away when we transition to DT */ +if (is_fwnode_irqchip (fwspec->fwnode)) { +if (fwspec->param_count !=2 ) +return -EINVAL ; + *hwirq = fwspec->param[0 ]; + *type = fwspec->param[1 ]; +WARN_ON (*type ==IRQ_TYPE_NONE ); +return 0 ; + } +return -EINVAL ; +} + +static int ixp4xx_gpio_irq_domain_alloc (struct irq_domain *d, +unsigned int irq,unsigned int nr_irqs, +void *data) +{ +struct ixp4xx_gpio *g = d->host_data; +irq_hw_number_t hwirq; +unsigned int type =IRQ_TYPE_NONE ; +struct irq_fwspec *fwspec = data; +int ret; +int i; + + ret =ixp4xx_gpio_irq_domain_translate (d, fwspec, &hwirq, &type); +if (ret) +return ret; + +dev_dbg (g->dev,"allocate IRQ %d..%d, hwirq %lu..%lu\n" , + irq, irq + nr_irqs -1 , + hwirq, hwirq + nr_irqs -1 ); + +for (i =0 ; i < nr_irqs; i++) { +struct irq_fwspec parent_fwspec; +const struct ixp4xx_gpio_map *map; +int j; + +/* Not all lines support IRQs */ +for (j =0 ; j <ARRAY_SIZE (ixp4xx_gpiomap); j++) { + map = &ixp4xx_gpiomap[j]; +if (map->gpio_offset == hwirq) +break ; + } +if (j ==ARRAY_SIZE (ixp4xx_gpiomap)) { +dev_err (g->dev,"can't look up hwirq %lu\n" , hwirq); +return -EINVAL ; + } +dev_dbg (g->dev,"found parent hwirq %u\n" , map->parent_hwirq); + +/* +* We set handle_bad_irq because the .set_type() should +* always be invoked and set the right type of handler. +*/ +irq_domain_set_info (d, + irq + i, + hwirq + i, + &ixp4xx_gpio_irqchip, + g, + handle_bad_irq, +NULL ,NULL ); +irq_set_probe (irq + i); + +/* +* Create a IRQ fwspec to send up to the parent irqdomain: +* specify the hwirq we address on the parent and tie it +* all together up the chain. +*/ + parent_fwspec.fwnode = d->parent->fwnode; + parent_fwspec.param_count =2 ; + parent_fwspec.param[0 ] = map->parent_hwirq; +/* This parent only handles asserted level IRQs */ + parent_fwspec.param[1 ] =IRQ_TYPE_LEVEL_HIGH ; +dev_dbg (g->dev,"alloc_irqs_parent for %d parent hwirq %d\n" , + irq + i, map->parent_hwirq); + ret =irq_domain_alloc_irqs_parent (d, irq + i,1 , + &parent_fwspec); +if (ret) +dev_err (g->dev, +"failed to allocate parent hwirq %d for hwirq %lu\n" , + map->parent_hwirq, hwirq); + } + +return 0 ; +} + +static const struct irq_domain_ops ixp4xx_gpio_irqdomain_ops = { + .translate = ixp4xx_gpio_irq_domain_translate, + .alloc = ixp4xx_gpio_irq_domain_alloc, + .free = irq_domain_free_irqs_common, +}; + +static int ixp4xx_gpio_probe (struct platform_device *pdev) +{ +unsigned long flags; +struct device *dev = &pdev->dev; +struct irq_domain *parent; +struct resource *res; +struct ixp4xx_gpio *g; +int ret; +int i; + + g =devm_kzalloc (dev,sizeof (*g),GFP_KERNEL ); +if (!g) +return -ENOMEM ; + g->dev = dev; + + res =platform_get_resource (pdev,IORESOURCE_MEM ,0 ); + g->base =devm_ioremap_resource (dev, res); +if (IS_ERR (g->base)) { +dev_err (dev,"ioremap error\n" ); +return PTR_ERR (g->base); + } + +/* +* Make sure GPIO 14 and 15 are NOT used as clocks but GPIO on +* specific machines. +*/ +if (machine_is_dsmg600 () ||machine_is_nas100d ()) +__raw_writel (0x0 , g->base +IXP4XX_GPIO_GPCLKR ); + +/* +* This is a very special big-endian ARM issue: when the IXP4xx is +* run in big endian mode, all registers in the machine are switched +* around to the CPU-native endianness. As you see mostly in the +* driver we use __raw_readl()/__raw_writel() to access the registers +* in the appropriate order. With the GPIO library we need to specify +* byte order explicitly, so this flag needs to be set when compiling +* for big endian. +*/ +#if defined(CONFIG_CPU_BIG_ENDIAN ) + flags =BGPIOF_BIG_ENDIAN_BYTE_ORDER ; +#else + flags =0 ; +#endif + +/* Populate and register gpio chip */ + ret =bgpio_init (&g->gc, dev,4 , + g->base +IXP4XX_GPIO_GPINR , + g->base +IXP4XX_GPIO_GPOUTR , +NULL , +NULL , + g->base +IXP4XX_GPIO_GPOER , + flags); +if (ret) { +dev_err (dev,"unable to init generic GPIO\n" ); +return ret; + } + g->gc.to_irq = ixp4xx_gpio_to_irq; + g->gc.ngpio =16 ; + g->gc.label ="IXP4XX_GPIO_CHIP" ; +/* +* TODO: when we have migrated to device tree and all GPIOs +* are fetched using phandles, set this to -1 to get rid of +* the fixed gpiochip base. +*/ + g->gc.base =0 ; + g->gc.parent = &pdev->dev; + g->gc.owner =THIS_MODULE ; + + ret =devm_gpiochip_add_data (dev, &g->gc, g); +if (ret) { +dev_err (dev,"failed to add SoC gpiochip\n" ); +return ret; + } + +/* +* When we convert to device tree we will simply look up the +* parent irqdomain using irq_find_host(parent) as parent comes +* from IRQCHIP_DECLARE(), then use of_node_to_fwnode() to get +* the fwnode. For now we need this boardfile style code. +*/ + parent =ixp4xx_get_irq_domain (); + g->fwnode =irq_domain_alloc_fwnode (g->base); +if (!g->fwnode) { +dev_err (dev,"no domain base\n" ); +return -ENODEV ; + } + g->domain =irq_domain_create_hierarchy (parent, +IRQ_DOMAIN_FLAG_HIERARCHY , +ARRAY_SIZE (ixp4xx_gpiomap), + g->fwnode, + &ixp4xx_gpio_irqdomain_ops, + g); +if (!g->domain) { +irq_domain_free_fwnode (g->fwnode); +dev_err (dev,"no hierarchical irq domain\n" ); +return ret; + } + +/* +* After adding OF support, this is no longer needed: irqs +* will be allocated for the respective fwnodes. +*/ +for (i =0 ; i <ARRAY_SIZE (ixp4xx_gpiomap); i++) { +const struct ixp4xx_gpio_map *map = &ixp4xx_gpiomap[i]; +struct irq_fwspec fwspec; + + fwspec.fwnode = g->fwnode; +/* This is the hwirq for the GPIO line side of things */ + fwspec.param[0 ] = map->gpio_offset; + fwspec.param[1 ] =IRQ_TYPE_EDGE_RISING ; + fwspec.param_count =2 ; + ret =__irq_domain_alloc_irqs (g->domain, +-1 ,/* just pick something */ +1 , +NUMA_NO_NODE , + &fwspec, + false, +NULL ); +if (ret <0 ) { +irq_domain_free_fwnode (g->fwnode); +dev_err (dev, +"can not allocate irq for GPIO line %d parent hwirq %d in hierarchy domain: %d\n" , + map->gpio_offset, map->parent_hwirq, ret);
drivers/gpio/gpio-ixp4xx.c line 436
Quoted 10 lines
drivers/gpio/gpio-ixp4xx.c new file +10
-0+return ret; + } + } + +platform_set_drvdata (pdev, g); +dev_info (dev,"IXP4 GPIO @%p registered\n" , g->base); + +return 0 ; +} +
Don't you need to dispose of the domain in the remove callback? They don't seem to have devm_ variants yet.
Quoted 10 lines
drivers/gpio/gpio-ixp4xx.c new file +7
-1+static struct platform_driver ixp4xx_gpio_driver = { + .driver = { + .name ="ixp4xx-gpio" , + }, + .probe = ixp4xx_gpio_probe, +}; +builtin_platform_driver (ixp4xx_gpio_driver); --2.20.1
Best regards,
Bartosz Golaszewski
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Re: [PATCH 05/17 v1] gpio: ixp4xx: Add driver for the IXP4xx GPIO
Hi Bartosz,
thanks for the review!
Quoted 1 line · Bartosz Golaszewski
niedz., 3 lut 2019 o 22:42 Linus Walleij <[email protected]> napisał(a):
(...)
Quoted 2 lines
Just a nit, but I'd add a newline between the includes and the header.
Also: C++ style comment for the header.
OK
Quoted 3 lines
Quoted 1 line
+#include <
linux/irqchip/irq-ixp4xx.h>I think a newline between linux/ and asm/ includes is a good rule.
OK
Quoted 11 lines
drivers/gpio/gpio-ixp4xx.c line 27
Quoted 8 lines
drivers/gpio/gpio-ixp4xx.c new file +8
-0+#define IXP4XX_GPIO_GPOUTR 0x00 +#define IXP4XX_GPIO_GPOER 0x04 +#define IXP4XX_GPIO_GPINR 0x08 +#define IXP4XX_GPIO_GPISR 0x0C +#define IXP4XX_GPIO_GPIT1R 0x10 +#define IXP4XX_GPIO_GPIT2R 0x14 +#define IXP4XX_GPIO_GPCLKR 0x18 +#define IXP4XX_GPIO_GPDBSELR 0x1CSince these are registers offsets - maybe the prefix could be IXP4XX_GPIO_REG_* or IXP4XX_GPIO_OFF_*? I think it's more readable.
OK I renamed them IXP4XX_REG_GPOUT etc.
Quoted 3 lines
Quoted 1 line
+#define
IXP4XX_GPIO_STYLE_MASK0x7I'd use
GENMASK(2, 0)here.
OK
Quoted 9 lines
drivers/gpio/gpio-ixp4xx.c line 160
Quoted 4 lines
drivers/gpio/gpio-ixp4xx.c new file +4
-0+/* Clear the style for the appropriate pin */ + val =__raw_readl (g->base + int_reg); + val &= ~(IXP4XX_GPIO_STYLE_MASK << (line *IXP4XX_GPIO_STYLE_SIZE )); +__raw_writel (val, g->base + int_reg);I know you're not using regmap, because this driver's based on gpio-mmio, but I'm wondering if you could maybe wrap those three operations in a helper wrapper e.g.
ixp4xx_update_reg()or something to make it easier to read. Same below.
I'm uncertain about that, I feel that kind of stuff creates extra runpaths that make the code hard to read, the compiler will of course inline it, but I like the read-modify-write explicit instead of wrapped in a function.
Quoted 10 lines
drivers/gpio/gpio-ixp4xx.c line 186
Quoted 7 lines
drivers/gpio/gpio-ixp4xx.c new file +7
-0+static struct irq_chip ixp4xx_gpio_irqchip = { + .name ="IXP4GPIO" , + .irq_ack = ixp4xx_gpio_irq_ack, + .irq_mask = irq_chip_mask_parent, + .irq_unmask = ixp4xx_gpio_irq_unmask, + .irq_set_type = ixp4xx_gpio_irq_set_type, +};I assume this device cannot have multiple instances, so it's safe to have a static irqchip?
Yes there can be only one.
Quoted 12 lines
Quoted 12 lines
drivers/gpio/gpio-ixp4xx.c new file +12
-0+static int ixp4xx_gpio_to_irq (struct gpio_chip *gc,unsigned int offset) +{ +struct ixp4xx_gpio *g =gpiochip_get_data (gc); +struct irq_fwspec fwspec; + + fwspec.fwnode = g->fwnode; + fwspec.param_count =2 ; + fwspec.param[0 ] = offset; + fwspec.param[1 ] =IRQ_TYPE_NONE ; + +return irq_create_fwspec_mapping (&fwspec); +}
Quoted 8 lines
Quoted 1 line
+
This is were I start to struggle. I'm still not very well versed in irq domain hierarchies yet. You already explain the concept in the commit message, but it would be great if you could add a comment describing the technical details of implementation here and in other related callbacks. The whole fwspec thingy is not very obvious and it would serve as an example for the future.
I wrote a paragraph of explanations but I realized that I was just writing documentation that should rather be in irqdomain. My plan is to update the GPIO driver documentation with a thorough description of hierarchical irqs instead.
Quoted 7 lines
Quoted 7 lines
drivers/gpio/gpio-ixp4xx.c new file +7
-0+static int ixp4xx_gpio_irq_domain_translate (struct irq_domain *domain, +struct irq_fwspec *fwspec, +unsigned long *hwirq, +unsigned int *type) +{ + +/* We support standard DT translation */
Quoted 8 lines
drivers/gpio/gpio-ixp4xx.c line 212
Quoted 5 lines
drivers/gpio/gpio-ixp4xx.c new file +5
-0+if (is_of_node (fwspec->fwnode) && fwspec->param_count ==2 ) { + *hwirq = fwspec->param[0 ]; + *type = fwspec->param[1 ]; +return 0 ; + }This logic is a bit non-intuitive - maybe you could first check for error conditions and then do any processing?
Brian has created a generic twocell translation helper in irqchip for this, so I will refactor on top of that at some point and this complexity goes away.
Quoted 2 lines
Don't you need to dispose of the domain in the remove callback? They don't seem to have
devm_variants yet.
This is a bool Kconfig symbol so the driver is compiled into the kernel. Once probed, the irqchip/domain never goes away. If I try to remove it it would just take down the whole system with it, so even if I would implement it it would make no sense. There is something of a "hardness" in how tight an irqdomain/chip is coupled to a system, and on this system it is (currently) used for a lot of static board files and it just can't go away. (The opposite being e.g. a USB expander gpiochip which should me a module and can come and go as it please.)
We could reconsider once all is moved over to device tree and more dynamic though.
Yours,
Linus Walleij
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
PATCH 6/17 ARM: ixp4xx: Switch to use new IRQ+GPIO drivers
In reply to Linus WalleijThis deletes the old irq+gpiochip combo from the IXP4xx machine and switches it over to use the new drivers merged in respective subsystem.
---
IRQ+GPIO folks: here you see how I activate those new drivers. Intended to be merged through ARM SoC.
--- arch/arm/Kconfig | 3 +- arch/arm/mach-ixp4xx/common.c | 318 ++---------------- arch/arm/mach-ixp4xx/dsmg600-setup.c | 3 - .../mach-ixp4xx/include/mach/ixp4xx-regs.h | 89 ----- arch/arm/mach-ixp4xx/nas100d-setup.c | 3 - 5 files changed, 24 insertions(+), 392 deletions(-)
arch/arm/Kconfig +2 -1
@@ -432,10 +432,11 @@ config ARCH_IXP4XX select DMABOUNCE if PCI select GENERIC_CLOCKEVENTS select GENERIC_IRQ_MULTI_HANDLER + select GPIO_IXP4XX select GPIOLIB select HAVE_PCI + select IXP4XX_IRQ select NEED_MACH_IO_H - select SPARSE_IRQ select USB_EHCI_BIG_ENDIAN_DESC select USB_EHCI_BIG_ENDIAN_MMIO help
arch/arm/mach-ixp4xx/common.c +22 -296
374 lines not on this page · raw message
arch/arm/mach-ixp4xx/dsmg600-setup.c +0 -3
@@ -270,9 +270,6 @@ static void __init dsmg600_init(void) {ixp4xx_sys_init (); -/* Make sure that GPIO14 and GPIO15 are not used as clocks */ - *IXP4XX_GPIO_GPCLKR =0 ; - dsmg600_flash_resource.start =IXP4XX_EXP_BUS_BASE (0 ); dsmg600_flash_resource.end =IXP4XX_EXP_BUS_BASE (0 ) + ixp4xx_exp_bus_size -1 ;
arch/arm/mach-ixp4xx/include/mach/ixp4xx-regs.h +0 -89
95 lines not on this page · raw message
arch/arm/mach-ixp4xx/nas100d-setup.c +0 -3
@@ -281,9 +281,6 @@ static void __init nas100d_init(void)ixp4xx_sys_init (); -/* gpio 14 and 15 are _not_ clocks */ - *IXP4XX_GPIO_GPCLKR =0 ; - nas100d_flash_resource.start =IXP4XX_EXP_BUS_BASE (0 ); nas100d_flash_resource.end =IXP4XX_EXP_BUS_BASE (0 ) + ixp4xx_exp_bus_size -1 ;
Signature · 7 lines
2.20.1 _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
PATCH 7/17 clocksource/drivers/ixp4xx: Add driver
In reply to Linus WalleijThis adds a new slightly rewritten timer driver for the Intel IXP4xx clocksource, clockevent and delay timer.
---
Clocksource/timer maintainers: I am requesting an ACK for this once you're happy with the driver, as I intend to merge all of this IXP4xx rework through ARM SoC.
--- MAINTAINERS | 2 + drivers/clocksource/Kconfig | 7 + drivers/clocksource/Makefile | 1 + drivers/clocksource/timer-ixp4xx.c | 249 +++++++++++++++++++++ include/linux/platform_data/timer-ixp4xx.h | 11 + 5 files changed, 270 insertions(+) create mode 100644 drivers/clocksource/timer-ixp4xx.c create mode 100644 include/linux/platform_data/timer-ixp4xx.h
MAINTAINERS +2 -0
@@ -1651,9 +1651,11 @@ M: Krzysztof Halasa <[email protected]> L: [email protected] (moderated for non-subscribers) S: Maintained F: arch/arm/mach-ixp4xx/ +F: drivers/clocksource/timer-ixp4xx.c F: drivers/gpio/gpio-ixp4xx.c F: drivers/irqchip/irq-ixp4xx.c F: include/linux/irqchip/irq-ixp4xx.h +F: include/linux/platform_data/timer-ixp4xx.h ARM/INTEL RESEARCH IMOTE/STARGATE 2 MACHINE SUPPORT M: Jonathan Cameron <[email protected]>
drivers/clocksource/Kconfig +7 -0
@@ -69,6 +69,13 @@ config FTTMR010_TIMER Enables support for the Faraday Technology timer block FTTMR010. +config IXP4XX_TIMER + bool "Intel XScale IXP4xx timer driver" if COMPILE_TEST + depends on HAS_IOMEM + select CLKSRC_MMIO + help + Enables support for the Intel XScale IXP4xx SoC timer. + config ROCKCHIP_TIMER bool "Rockchip timer driver" if COMPILE_TEST depends on ARM || ARM64
drivers/clocksource/Makefile +1 -0
@@ -20,6 +20,7 @@ obj-$(CONFIG_OMAP_DM_TIMER) += timer-ti-dm.o obj-$(CONFIG_DW_APB_TIMER) += dw_apb_timer.o obj-$(CONFIG_DW_APB_TIMER_OF) += dw_apb_timer_of.o obj-$(CONFIG_FTTMR010_TIMER) += timer-fttmr010.o +obj-$(CONFIG_IXP4XX_TIMER) += timer-ixp4xx.o obj-$(CONFIG_ROCKCHIP_TIMER) += timer-rockchip.o obj-$(CONFIG_CLKSRC_NOMADIK_MTU) += nomadik-mtu.o obj-$(CONFIG_CLKSRC_DBX500_PRCMU) += clksrc-dbx500-prcmu.o
drivers/clocksource/timer-ixp4xx.c new file +249 -0
249 lines not on this page · raw message
include/linux/platform_data/timer-ixp4xx.h new file +11 -0
@@ -0,0 +1,11 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef __TIMER_IXP4XX_H +#define __TIMER_IXP4XX_H + +#include <linux/ioport.h> + +void __init ixp4xx_timer_setup (resource_size_t timerbase, +int timer_irq, +unsigned int timer_freq); + +#endif
Signature · 7 lines
2.20.1 _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
PATCH 8/17 ARM: ixp4xx: Switch to use new timer driver
In reply to Linus WalleijThis augments the IXP4xx to select and use the new timer driver in drivers/clocksource and removes the old code in the machine.
---
Clocksource/timer maintainers: here you see how I activate this new driver. Intended to be merged through ARM SoC.
--- arch/arm/Kconfig | 2 +- arch/arm/mach-ixp4xx/common.c | 153 +--------------------------------- 2 files changed, 5 insertions(+), 150 deletions(-)
arch/arm/Kconfig +1 -1
@@ -427,7 +427,6 @@ config ARCH_IXP4XX depends on MMU select ARCH_HAS_DMA_SET_COHERENT_MASK select ARCH_SUPPORTS_BIG_ENDIAN - select CLKSRC_MMIO select CPU_XSCALE select DMABOUNCE if PCI select GENERIC_CLOCKEVENTS
@@ -436,6 +435,7 @@ config ARCH_IXP4XX select GPIOLIB select HAVE_PCI select IXP4XX_IRQ + select IXP4XX_TIMER select NEED_MACH_IO_H select USB_EHCI_BIG_ENDIAN_DESC select USB_EHCI_BIG_ENDIAN_MMIO
arch/arm/mach-ixp4xx/common.c +4 -149
187 lines not on this page · raw message
Signature · 7 lines
2.20.1 _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
PATCH 9/17 irqchip: ixp4xx: Add DT bindings
In reply to Linus WalleijThis adds device tree bindings for the IXP4xx interrupt controller. It's a standard 2-cell controller.
---
irqchip maintainers: I am requesting an ACK for this once you're happy with the bindings, as I intend to merge all of this IXP4xx rework through ARM SoC.
--- .../intel,ixp4xx-interrupt.txt | 33 +++++++++++++++++++ MAINTAINERS | 1 + 2 files changed, 34 insertions(+) create mode 100644 Documentation/devicetree/bindings/interrupt-controller/intel,ixp4xx-interrupt.txt
Documentation/devicetree/bindings/interrupt-controller/intel,ixp4xx-interrupt.txt new file +33 -0
@@ -0,0 +1,33 @@ +* Intel IXP4xx XScale Networking Processors Interrupt Controller + +This interrupt controller is found in the Intel IXP4xx processors. +Some processors have 32 interrupts, some have up to 64 interrupts. +The exact number of interrupts is determined from the compatible +string. + +The distinct IXP4xx families with different interrupt controller +variations are IXP42x, IXP43x, IXP45x and IXP46x. Those four +families were the only ones to reach the developer and consumer +market. + +Required properties: +- compatible: must be one of + "intel,ixp42x-interrupt" + "intel,ixp43x-interrupt" + "intel,ixp45x-interrupt" + "intel,ixp46x-interrupt" +- reg: The register bank for the interrupt controller. +- interrupt-controller: Identifies the node as an interrupt controller +- #interrupt-cells: The number of cells to define the interrupts. + Must be <2>. The bindings follows the standard binding for controllers + with two cells specified in + interrupt-controller/interrupts.txt + +Example: + +intcon: interrupt-controller@c8003000 { + compatible = "intel,ixp43x-interrupt"; + reg = <0xc8003000 0x100>; + interrupt-controller; + #interrupt-cells = <2>; +};
MAINTAINERS +1 -0
@@ -1650,6 +1650,7 @@ M: Imre Kaloz <[email protected]> M: Krzysztof Halasa <[email protected]> L: [email protected] (moderated for non-subscribers) S: Maintained +F: Documentation/devicetree/bindings/interrupt-controller/intel,ixp4xx-interrupt.txt F: arch/arm/mach-ixp4xx/ F: drivers/clocksource/timer-ixp4xx.c F: drivers/gpio/gpio-ixp4xx.c
Signature · 1 line
2.20.1
Re: [PATCH 09/17 v1] irqchip: ixp4xx: Add DT bindings
Quoted 3 lines · Linus Walleij
This adds device tree bindings for the IXP4xx interrupt controller. It's a standard 2-cell controller.
Not required, but writing as a schema would be great. Looks like it would be straight forward.
Quoted 29 lines
Cc Marc Zyngier <[email protected]>Cc Jason Cooper <[email protected]>Cc Thomas Gleixner <[email protected]>Signed-off-by Linus Walleij <[email protected]>---
irqchip maintainers: I am requesting an ACK for this once you're happy with the bindings, as I intend to merge all of this IXP4xx rework through ARM SoC.--- .../intel,ixp4xx-interrupt.txt | 33 +++++++++++++++++++ MAINTAINERS | 1 + 2 files changed, 34 insertions(+) create mode 100644 Documentation/devicetree/bindings/interrupt-controller/intel,ixp4xx-interrupt.txtDocumentation/devicetree/bindings/interrupt-controller/intel,ixp4xx-interrupt.txt new file +8
-0@@ -0,0 +1,33 @@ +* Intel IXP4xx XScale Networking Processors Interrupt Controller + +This interrupt controller is found in the Intel IXP4xx processors. +Some processors have 32 interrupts, some have up to 64 interrupts. +The exact number of interrupts is determined from the compatible +string. + +The distinct IXP4xx families with different interrupt controller
Documentation/devicetree/bindings/interrupt-controller/intel,ixp4xx-interrupt.txt line 18
Quoted 10 lines
Documentation/devicetree/bindings/interrupt-controller/intel,ixp4xx-interrupt.txt new file +10
-0+variations are IXP42x, IXP43x, IXP45x and IXP46x. Those four +families were the only ones to reach the developer and consumer +market. + +Required properties: +- compatible: must be one of + "intel,ixp42x-interrupt" + "intel,ixp43x-interrupt" + "intel,ixp45x-interrupt" + "intel,ixp46x-interrupt"
While we normally don't allow wildcards, I'm guessing this is all so old^W mature that it will be fine.
PATCH 10/17 irqchip: ixp4xx: Add OF initialization support
In reply to Linus WalleijThis adds support for probing and settin up the IXP4xx irqchip from device tree.
---
irqchip maintainers: I am requesting an ACK for this once you're happy with the driver, as I intend to merge all of this IXP4xx rework through ARM SoC.
--- drivers/irqchip/irq-ixp4xx.c | 45 ++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+)
drivers/irqchip/irq-ixp4xx.c +45 -0
@@ -15,6 +15,9 @@#include <linux/irqchip.h> #include <linux/irqchip/irq-ixp4xx.h> #include <linux/irqdomain.h> +#include <linux/of.h> +#include <linux/of_address.h> +#include <linux/of_irq.h> #include <linux/platform_device.h> #include <linux/cpu.h>
@@ -358,3 +361,45 @@ void __init ixp4xx_irq_init(resource_size_t irqbase, } }EXPORT_SYMBOL_GPL (ixp4xx_irq_init); + +#ifdef CONFIG_OF +int __init ixp4xx_of_init_irq (struct device_node *np, +struct device_node *parent) +{ +struct ixp4xx_irq *ixi = &ixirq; +void __iomem *base; +struct fwnode_handle *fwnode; +bool is_356; +int ret; + + base =of_iomap (np,0 ); +if (!base) { +pr_crit ("IXP4XX: could not ioremap interrupt controller\n" ); +return -ENODEV ; + } + fwnode =of_node_to_fwnode (np); +if (!fwnode) { +pr_crit ("IXP4XX: no domain handle\n" ); +return -ENODEV ; + } + +/* These chip variants have 64 interrupts */ + is_356 =of_device_is_compatible (np,"intel,ixp43x-interrupt" ) || +of_device_is_compatible (np,"intel,ixp45x-interrupt" ) || +of_device_is_compatible (np,"intel,ixp46x-interrupt" ); + + ret =ixp4xx_irq_setup (ixi, base, fwnode, is_356); +if (ret) +pr_crit ("IXP4XX: failed to set up irqchip\n" ); + +return ret; +} +IRQCHIP_DECLARE (ixp42x,"intel,ixp42x-interrupt" , + ixp4xx_of_init_irq); +IRQCHIP_DECLARE (ixp43x,"intel,ixp43x-interrupt" , + ixp4xx_of_init_irq); +IRQCHIP_DECLARE (ixp45x,"intel,ixp45x-interrupt" , + ixp4xx_of_init_irq); +IRQCHIP_DECLARE (ixp46x,"intel,ixp46x-interrupt" , + ixp4xx_of_init_irq); +#endif
Signature · 7 lines
2.20.1 _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
PATCH 11/17 clocksource/drivers/ixp4xx: Add DT bindings
In reply to Linus WalleijThis adds device tree bindings for the Intel IXP4xx timers.
---
Clocksource/timer maintainers: I am requesting an ACK for this once you're happy with the bindings, as I intend to merge all of this IXP4xx rework through ARM SoC.
--- .../bindings/timer/intel,ixp4xx-timer.txt | 18 ++++++++++++++++++ MAINTAINERS | 1 + 2 files changed, 19 insertions(+) create mode 100644 Documentation/devicetree/bindings/timer/intel,ixp4xx-timer.txt
Documentation/devicetree/bindings/timer/intel,ixp4xx-timer.txt new file +18 -0
@@ -0,0 +1,18 @@ +Intel IXP4xx XScale Networking Processors Timers + +This timer is found in the Intel IXP4xx processors. + +Required properties: + +- compatible : Must be + "intel,ixp4xx-timer" +- reg : Should contain registers location and length +- interrupts : Should contain the two timer interrupts + +Example: + +timer@c8005000 { + compatible = "intel,ixp4xx-timer"; + reg = <0xc8005000 0x100>; + interrupts = <5 IRQ_TYPE_LEVEL_HIGH>; +};
MAINTAINERS +1 -0
@@ -1651,6 +1651,7 @@ M: Krzysztof Halasa <[email protected]> L: [email protected] (moderated for non-subscribers) S: Maintained F: Documentation/devicetree/bindings/interrupt-controller/intel,ixp4xx-interrupt.txt +F: Documentation/devicetree/bindings/timer/intel,ixp4xx-timer.txt F: arch/arm/mach-ixp4xx/ F: drivers/clocksource/timer-ixp4xx.c F: drivers/gpio/gpio-ixp4xx.c
Signature · 1 line
2.20.1
Re: [PATCH 11/17 v1] clocksource/drivers/ixp4xx: Add DT bindings
Quoted 12 lines · Linus Walleij
This adds device tree bindings for the Intel IXP4xx timers.
Cc Daniel Lezcano <[email protected]>Cc Thomas Gleixner <[email protected]>Signed-off-by Linus Walleij <[email protected]>---
Clocksource/timer maintainers: I am requesting an ACK for this once you're happy with the bindings, as I intend to merge all of this IXP4xx rework through ARM SoC.
Quoted 5 lines
--- .../bindings/timer/intel,ixp4xx-timer.txt | 18 ++++++++++++++++++ MAINTAINERS | 1 + 2 files changed, 19 insertions(+) create mode 100644 Documentation/devicetree/bindings/timer/intel,ixp4xx-timer.txt
Same wish and comments here...
Daniel Lezcano
Acked-byRe: [PATCH 11/17 v1] clocksource/drivers/ixp4xx: Add DT bindings
Quoted 19 lines · Rob Herring
Quoted 12 lines · Linus Walleij
This adds device tree bindings for the Intel IXP4xx timers.
Cc Daniel Lezcano <[email protected]>Cc Thomas Gleixner <[email protected]>Signed-off-by Linus Walleij <[email protected]>---
Clocksource/timer maintainers: I am requesting an ACK for this once you're happy with the bindings, as I intend to merge all of this IXP4xx rework through ARM SoC.Quoted 5 lines
--- .../bindings/timer/intel,ixp4xx-timer.txt | 18 ++++++++++++++++++ MAINTAINERS | 1 + 2 files changed, 19 insertions(+) create mode 100644 Documentation/devicetree/bindings/timer/intel,ixp4xx-timer.txt
Quoted 3 lines
Same wish and comments here...
Reviewed-by Rob Herring <[email protected]>
Thanks,
Signature · 11 lines
<http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs Follow Linaro: <http://www.facebook.com/pages/Linaro> Facebook | <http://twitter.com/#!/linaroorg> Twitter | <http://www.linaro.org/linaro-blog/> Blog _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
PATCH 12/17 clocksource/drivers/ixp4xx: Add OF initialization support
In reply to Linus WalleijThis adds support for setting up the IXP4xx timer driver from device tree.
---
Clocksource/timer maintainers: I am requesting an ACK for this once you're happy with the driver, as I intend to merge all of this IXP4xx rework through ARM SoC.
--- drivers/clocksource/timer-ixp4xx.c | 35 ++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+)
drivers/clocksource/timer-ixp4xx.c +35 -0
@@ -16,6 +16,8 @@#include <linux/slab.h> #include <linux/bitops.h> #include <linux/delay.h> +#include <linux/of_address.h> +#include <linux/of_irq.h> /* Goes away with OF conversion */ #include <linux/platform_data/timer-ixp4xx.h>
@@ -247,3 +249,36 @@ void __init ixp4xx_timer_setup(resource_size_t timerbase,ixp4xx_timer_register (base, timer_irq, timer_freq); }EXPORT_SYMBOL_GPL (ixp4xx_timer_setup); + +#ifdef CONFIG_OF +static __init int ixp4xx_of_timer_init (struct device_node *np) +{ +void __iomem *base; +int irq; +int ret; + + base =of_iomap (np,0 ); +if (!base) { +pr_crit ("IXP4xx: can't remap timer\n" ); +return -ENODEV ; + } + + irq =irq_of_parse_and_map (np,0 ); +if (irq <=0 ) { +pr_err ("Can't parse IRQ\n" ); + ret = -EINVAL ; + goto out_unmap; + } + +/* TODO: get some fixed clocks into the device tree */ + ret =ixp4xx_timer_register (base, irq,66666000 ); +if (ret) + goto out_unmap; +return 0 ; + +out_unmap: +iounmap (base); +return ret; +} +TIMER_OF_DECLARE (ixp4xx,"intel,ixp4xx-timer" , ixp4xx_of_timer_init); +#endif
Signature · 7 lines
2.20.1 _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Re: [PATCH 12/17 v1] clocksource/drivers/ixp4xx: Add OF initialization support
Quoted 10 lines · Linus Walleij
This adds support for setting up the IXP4xx timer driver from device tree.
Cc Daniel Lezcano <[email protected]>Cc Thomas Gleixner <[email protected]>Signed-off-by Linus Walleij <[email protected]>---
Clocksource/timer maintainers: I am requesting an ACK for this once you're happy with the driver, as I intend to merge all of this IXP4xx rework through ARM SoC.
Quoted 55 lines
--- drivers/clocksource/timer-ixp4xx.c | 35 ++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+)drivers/clocksource/timer-ixp4xx.c +35
-0@@ -16,6 +16,8 @@#include <linux/slab.h> #include <linux/bitops.h> #include <linux/delay.h> +#include <linux/of_address.h> +#include <linux/of_irq.h> /* Goes away with OF conversion */ #include <linux/platform_data/timer-ixp4xx.h> @@ -247,3 +249,36 @@ void __init ixp4xx_timer_setup(resource_size_t timerbase,ixp4xx_timer_register (base, timer_irq, timer_freq); }EXPORT_SYMBOL_GPL (ixp4xx_timer_setup); + +#ifdef CONFIG_OF +static __init int ixp4xx_of_timer_init (struct device_node *np) +{ +void __iomem *base; +int irq; +int ret; + + base =of_iomap (np,0 ); +if (!base) { +pr_crit ("IXP4xx: can't remap timer\n" ); +return -ENODEV ; + } + + irq =irq_of_parse_and_map (np,0 ); +if (irq <=0 ) { +pr_err ("Can't parse IRQ\n" ); + ret = -EINVAL ; + goto out_unmap; + } + +/* TODO: get some fixed clocks into the device tree */ + ret =ixp4xx_timer_register (base, irq,66666000 ); +if (ret) + goto out_unmap; +return 0 ; + +out_unmap: +iounmap (base); +return ret; +} +TIMER_OF_DECLARE (ixp4xx,"intel,ixp4xx-timer" , ixp4xx_of_timer_init); +#endif
Signature · 11 lines
<http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs Follow Linaro: <http://www.facebook.com/pages/Linaro> Facebook | <http://twitter.com/#!/linaroorg> Twitter | <http://www.linaro.org/linaro-blog/> Blog _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
PATCH 13/17 gpio: ixp4xx: Add DT bindings
In reply to Linus WalleijThis adds DT bindings for the IXP4xx GPIO controller.
---
Bartosz: looking for your ACK on this, it'd be good if the other GPIO maintainer is aligned with my ideas here. I intend to merge this through the ARM SoC tree.
--- .../bindings/gpio/intel,ixp4xx-gpio.txt | 38 +++++++++++++++++++ MAINTAINERS | 1 + 2 files changed, 39 insertions(+) create mode 100644 Documentation/devicetree/bindings/gpio/intel,ixp4xx-gpio.txt
Documentation/devicetree/bindings/gpio/intel,ixp4xx-gpio.txt new file +38 -0
@@ -0,0 +1,38 @@ +Intel IXP4xx XScale Networking Processors GPIO + +This GPIO controller is found in the Intel IXP4xx processors. +It supports 16 GPIO lines. + +The interrupt portions of the GPIO controller is hierarchical: +the synchronous edge detector is part of the GPIO block, but the +actual enabling/disabling of the interrupt line is done in the +main IXP4xx interrupt controller which has a 1:1 mapping for +the first 12 GPIO lines to 12 system interrupts. + +The remaining 4 GPIO lines can not be used for receiving +interrupts. + +The interrupt parent of this GPIO controller must be the +IXP4xx interrupt controller. + +Required properties: + +- compatible : Should be + "intel,ixp4xx-gpio" +- reg : Should contain registers location and length +- gpio-controller : marks this as a GPIO controller +- #gpio-cells : Should be 2, see gpio/gpio.txt +- interrupt-controller : marks this as an interrupt controller +- #interrupt-cells : a standard two-cell interrupt, see + interrupt-controller/interrupts.txt + +Example: + +gpio0: gpio@c8004000 { + compatible = "intel,ixp4xx-gpio"; + reg = <0xc8004000 0x1000>; + gpio-controller; + #gpio-cells = <2>; + interrupt-controller; + #interrupt-cells = <2>; +};
MAINTAINERS +1 -0
@@ -1650,6 +1650,7 @@ M: Imre Kaloz <[email protected]> M: Krzysztof Halasa <[email protected]> L: [email protected] (moderated for non-subscribers) S: Maintained +F: Documentation/devicetree/bindings/gpio/intel,ixp4xx-gpio.txt F: Documentation/devicetree/bindings/interrupt-controller/intel,ixp4xx-interrupt.txt F: Documentation/devicetree/bindings/timer/intel,ixp4xx-timer.txt F: arch/arm/mach-ixp4xx/
Signature · 1 line
2.20.1
Re: [PATCH 13/17 v1] gpio: ixp4xx: Add DT bindings
niedz., 3 lut 2019 o 22:42 Linus Walleij <[email protected]> napisał(a):
Quoted 73 lines
This adds DT bindings for the IXP4xx GPIO controller.
Cc Bartosz Golaszewski <[email protected]>Signed-off-by Linus Walleij <[email protected]>---
Bartosz: looking for your ACK on this, it'd be good if the other GPIO maintainer is aligned with my ideas here. I intend to merge this through the ARM SoC tree.--- .../bindings/gpio/intel,ixp4xx-gpio.txt | 38 +++++++++++++++++++ MAINTAINERS | 1 + 2 files changed, 39 insertions(+) create mode 100644 Documentation/devicetree/bindings/gpio/intel,ixp4xx-gpio.txtDocumentation/devicetree/bindings/gpio/intel,ixp4xx-gpio.txt new file +38
-0@@ -0,0 +1,38 @@ +Intel IXP4xx XScale Networking Processors GPIO + +This GPIO controller is found in the Intel IXP4xx processors. +It supports 16 GPIO lines. + +The interrupt portions of the GPIO controller is hierarchical: +the synchronous edge detector is part of the GPIO block, but the +actual enabling/disabling of the interrupt line is done in the +main IXP4xx interrupt controller which has a 1:1 mapping for +the first 12 GPIO lines to 12 system interrupts. + +The remaining 4 GPIO lines can not be used for receiving +interrupts. + +The interrupt parent of this GPIO controller must be the +IXP4xx interrupt controller. + +Required properties: + +- compatible : Should be + "intel,ixp4xx-gpio" +- reg : Should contain registers location and length +- gpio-controller : marks this as a GPIO controller +- #gpio-cells : Should be 2, see gpio/gpio.txt +- interrupt-controller : marks this as an interrupt controller +- #interrupt-cells : a standard two-cell interrupt, see + interrupt-controller/interrupts.txt + +Example: + +gpio0: gpio@c8004000 { + compatible = "intel,ixp4xx-gpio"; + reg = <0xc8004000 0x1000>; + gpio-controller; + #gpio-cells = <2>; + interrupt-controller; + #interrupt-cells = <2>; +};MAINTAINERS +1
-1@@ -1650,6 +1650,7 @@ M: Imre Kaloz <[email protected]> M: Krzysztof Halasa <[email protected]> L: [email protected] (moderated for non-subscribers) S: Maintained +F: Documentation/devicetree/bindings/gpio/intel,ixp4xx-gpio.txt F: Documentation/devicetree/bindings/interrupt-controller/intel,ixp4xx-interrupt.txt F: Documentation/devicetree/bindings/timer/intel,ixp4xx-timer.txt F: arch/arm/mach-ixp4xx/ --
Quoted 2 lines
2.20.1
Looks good to me.
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Re: [PATCH 13/17 v1] gpio: ixp4xx: Add DT bindings
In reply to Linus WalleijQuoted 10 lines · Linus Walleij
This adds DT bindings for the IXP4xx GPIO controller.
Cc Bartosz Golaszewski <[email protected]>Signed-off-by Linus Walleij <[email protected]>---
Bartosz: looking for your ACK on this, it'd be good if the other GPIO maintainer is aligned with my ideas here. I intend to merge this through the ARM SoC tree.
Quoted 5 lines
--- .../bindings/gpio/intel,ixp4xx-gpio.txt | 38 +++++++++++++++++++ MAINTAINERS | 1 + 2 files changed, 39 insertions(+) create mode 100644 Documentation/devicetree/bindings/gpio/intel,ixp4xx-gpio.txt
PATCH 14/17 gpio: ixp4xx: Add OF probing support
In reply to Linus WalleijThis adds device tree probe and registration support for the IXP4xx GPIO driver.
---
Bartosz: looking for your ACK on this, it'd be good if the other GPIO maintainer is aligned with my ideas here. I intend to merge this through the ARM SoC tree.
--- drivers/gpio/gpio-ixp4xx.c | 84 ++++++++++++++++++++++++++------------ 1 file changed, 57 insertions(+), 27 deletions(-)
drivers/gpio/gpio-ixp4xx.c +57 -27
@@ -11,6 +11,7 @@#include <linux/irq.h> #include <linux/irqdomain.h> #include <linux/irqchip.h> +#include <linux/of_irq.h> #include <linux/platform_device.h> #include <linux/bitops.h> /* Include that go away with DT transition */
@@ -305,6 +306,7 @@ static int ixp4xx_gpio_probe(struct platform_device *pdev) {unsigned long flags;struct device *dev = &pdev->dev; +struct device_node *np = dev->of_node;struct irq_domain *parent;struct resource *res;struct ixp4xx_gpio *g;
@@ -381,11 +383,27 @@ static int ixp4xx_gpio_probe(struct platform_device *pdev)* from IRQCHIP_DECLARE(), then use of_node_to_fwnode() to get * the fwnode. For now we need this boardfile style code. */ - parent =ixp4xx_get_irq_domain (); - g->fwnode =irq_domain_alloc_fwnode (g->base); -if (!g->fwnode) { -dev_err (dev,"no domain base\n" ); -return -ENODEV ; +if (np) { +struct device_node *irq_parent; + + irq_parent =of_irq_find_parent (np); +if (!irq_parent) { +dev_err (dev,"no IRQ parent node\n" ); +return -ENODEV ; + } + parent =irq_find_host (irq_parent); +if (!parent) { +dev_err (dev,"no IRQ parent domain\n" ); +return -ENODEV ; + } + g->fwnode =of_node_to_fwnode (np); + }else { + parent =ixp4xx_get_irq_domain (); + g->fwnode =irq_domain_alloc_fwnode (g->base); +if (!g->fwnode) { +dev_err (dev,"no domain base\n" ); +return -ENODEV ; + } } g->domain = irq_domain_create_hierarchy(parent, IRQ_DOMAIN_FLAG_HIERARCHY,
@@ -403,28 +421,31 @@ static int ixp4xx_gpio_probe(struct platform_device *pdev)* After adding OF support, this is no longer needed: irqs * will be allocated for the respective fwnodes. */ -for (i =0 ; i <ARRAY_SIZE (ixp4xx_gpiomap); i++) { -const struct ixp4xx_gpio_map *map = &ixp4xx_gpiomap[i]; -struct irq_fwspec fwspec; - - fwspec.fwnode = g->fwnode; -/* This is the hwirq for the GPIO line side of things */ - fwspec.param[0 ] = map->gpio_offset; - fwspec.param[1 ] =IRQ_TYPE_EDGE_RISING ; - fwspec.param_count =2 ; - ret =__irq_domain_alloc_irqs (g->domain, --1 ,/* just pick something */ -1 , -NUMA_NO_NODE , - &fwspec, - false, -NULL ); -if (ret <0 ) { -irq_domain_free_fwnode (g->fwnode); -dev_err (dev, -"can not allocate irq for GPIO line %d parent hwirq %d in hierarchy domain: %d\n" , - map->gpio_offset, map->parent_hwirq, ret); -return ret; +if (!np) { +for (i =0 ; i <ARRAY_SIZE (ixp4xx_gpiomap); i++) { +const struct ixp4xx_gpio_map *map = &ixp4xx_gpiomap[i]; +struct irq_fwspec fwspec; + + fwspec.fwnode = g->fwnode; +/* This is the hwirq for the GPIO line side of things */ + fwspec.param[0 ] = map->gpio_offset; + fwspec.param[1 ] =IRQ_TYPE_EDGE_RISING ; + fwspec.param_count =2 ; + ret =__irq_domain_alloc_irqs (g->domain, +-1 ,/* just pick something */ +1 , +NUMA_NO_NODE , + &fwspec, + false, +NULL ); +if (ret <0 ) { +irq_domain_free_fwnode (g->fwnode); +dev_err (dev, +"can not allocate irq for GPIO line %d parent hwirq %d in hierarchy domain: %d\n" , + map->gpio_offset, map->parent_hwirq, + ret); +return ret; + } } }
@@ -434,9 +455,18 @@ static int ixp4xx_gpio_probe(struct platform_device *pdev)return 0 ; } +static const struct of_device_id ixp4xx_gpio_of_match[] = { + { + .compatible ="intel,ixp4xx-gpio" , + }, + {}, +}; + +static struct platform_driver ixp4xx_gpio_driver = { .driver = { .name ="ixp4xx-gpio" , + .of_match_table =of_match_ptr (ixp4xx_gpio_of_match), }, .probe = ixp4xx_gpio_probe, };
Signature · 7 lines
2.20.1 _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Re: [PATCH 14/17 v1] gpio: ixp4xx: Add OF probing support
niedz., 3 lut 2019 o 22:42 Linus Walleij <[email protected]> napisał(a):
Quoted 4 lines
This adds device tree probe and registration support for the IXP4xx GPIO driver.
What is the reason for not merging it with the patch adding the driver?
Quoted 31 lines
Cc Bartosz Golaszewski <[email protected]>Signed-off-by Linus Walleij <[email protected]>---
Bartosz: looking for your ACK on this, it'd be good if the other GPIO maintainer is aligned with my ideas here. I intend to merge this through the ARM SoC tree.--- drivers/gpio/gpio-ixp4xx.c | 84 ++++++++++++++++++++++++++------------ 1 file changed, 57 insertions(+), 27 deletions(-)drivers/gpio/gpio-ixp4xx.c +2
-0@@ -11,6 +11,7 @@#include <linux/irq.h> #include <linux/irqdomain.h> #include <linux/irqchip.h> +#include <linux/of_irq.h> #include <linux/platform_device.h> #include <linux/bitops.h> /* Include that go away with DT transition */ @@ -305,6 +306,7 @@ static int ixp4xx_gpio_probe(struct platform_device *pdev) {unsigned long flags;struct device *dev = &pdev->dev; +struct device_node *np = dev->of_node;struct irq_domain *parent;struct resource *res;struct ixp4xx_gpio *g;
drivers/gpio/gpio-ixp4xx.c static int ixp4xx_gpio_probe(struct platform_device *pdev) · line 385
Quoted 3 lines
drivers/gpio/gpio-ixp4xx.c +0
-0@@ -381,11 +383,27 @@ static int ixp4xx_gpio_probe(struct platform_device *pdev)* from IRQCHIP_DECLARE(), then use of_node_to_fwnode() to get * the fwnode. For now we need this boardfile style code. */
Is this comment still valid after this patch? Or is this maybe incomplete DT support (probing only)? If so it need clarifying.
Quoted 30 lines
drivers/gpio/gpio-ixp4xx.c +21
-5- parent =ixp4xx_get_irq_domain (); - g->fwnode =irq_domain_alloc_fwnode (g->base); -if (!g->fwnode) { -dev_err (dev,"no domain base\n" ); -return -ENODEV ; +if (np) { +struct device_node *irq_parent; + + irq_parent =of_irq_find_parent (np); +if (!irq_parent) { +dev_err (dev,"no IRQ parent node\n" ); +return -ENODEV ; + } + parent =irq_find_host (irq_parent); +if (!parent) { +dev_err (dev,"no IRQ parent domain\n" ); +return -ENODEV ; + } + g->fwnode =of_node_to_fwnode (np); + }else { + parent =ixp4xx_get_irq_domain (); + g->fwnode =irq_domain_alloc_fwnode (g->base); +if (!g->fwnode) { +dev_err (dev,"no domain base\n" ); +return -ENODEV ; + } } g->domain = irq_domain_create_hierarchy(parent, IRQ_DOMAIN_FLAG_HIERARCHY,
drivers/gpio/gpio-ixp4xx.c static int ixp4xx_gpio_probe(struct platform_device *pdev) · line 423
Quoted 3 lines
drivers/gpio/gpio-ixp4xx.c +0
-0@@ -403,28 +421,31 @@ static int ixp4xx_gpio_probe(struct platform_device *pdev)* After adding OF support, this is no longer needed: irqs * will be allocated for the respective fwnodes. */
Same with the comment here.
Quoted 70 lines
drivers/gpio/gpio-ixp4xx.c +34
-23-for (i =0 ; i <ARRAY_SIZE (ixp4xx_gpiomap); i++) { -const struct ixp4xx_gpio_map *map = &ixp4xx_gpiomap[i]; -struct irq_fwspec fwspec; - - fwspec.fwnode = g->fwnode; -/* This is the hwirq for the GPIO line side of things */ - fwspec.param[0 ] = map->gpio_offset; - fwspec.param[1 ] =IRQ_TYPE_EDGE_RISING ; - fwspec.param_count =2 ; - ret =__irq_domain_alloc_irqs (g->domain, --1 ,/* just pick something */ -1 , -NUMA_NO_NODE , - &fwspec, - false, -NULL ); -if (ret <0 ) { -irq_domain_free_fwnode (g->fwnode); -dev_err (dev, -"can not allocate irq for GPIO line %d parent hwirq %d in hierarchy domain: %d\n" , - map->gpio_offset, map->parent_hwirq, ret); -return ret; +if (!np) { +for (i =0 ; i <ARRAY_SIZE (ixp4xx_gpiomap); i++) { +const struct ixp4xx_gpio_map *map = &ixp4xx_gpiomap[i]; +struct irq_fwspec fwspec; + + fwspec.fwnode = g->fwnode; +/* This is the hwirq for the GPIO line side of things */ + fwspec.param[0 ] = map->gpio_offset; + fwspec.param[1 ] =IRQ_TYPE_EDGE_RISING ; + fwspec.param_count =2 ; + ret =__irq_domain_alloc_irqs (g->domain, +-1 ,/* just pick something */ +1 , +NUMA_NO_NODE , + &fwspec, + false, +NULL ); +if (ret <0 ) { +irq_domain_free_fwnode (g->fwnode); +dev_err (dev, +"can not allocate irq for GPIO line %d parent hwirq %d in hierarchy domain: %d\n" , + map->gpio_offset, map->parent_hwirq, + ret); +return ret; + } } }@@ -434,9 +455,18 @@ static int ixp4xx_gpio_probe(struct platform_device *pdev)return 0 ; } +static const struct of_device_id ixp4xx_gpio_of_match[] = { + { + .compatible ="intel,ixp4xx-gpio" , + }, + {}, +}; + +static struct platform_driver ixp4xx_gpio_driver = { .driver = { .name ="ixp4xx-gpio" , + .of_match_table =of_match_ptr (ixp4xx_gpio_of_match), }, .probe = ixp4xx_gpio_probe, }; --
Quoted 2 lines
2.20.1
Bart
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Re: [PATCH 14/17 v1] gpio: ixp4xx: Add OF probing support
Quoted 6 lines · Bartosz Golaszewski
niedz., 3 lut 2019 o 22:42 Linus Walleij <[email protected]> napisał(a):
Quoted 3 lines
This adds device tree probe and registration support for the IXP4xx GPIO driver.
What is the reason for not merging it with the patch adding the driver?
Since I am not adding a new never before used gpio driver but refactoring an existing system, I need to take one technical step at the time for bisectability and readability.
If I was adding a driver for a totally new system indeed it would be in the same patch.
Quoted 7 lines
drivers/gpio/gpio-ixp4xx.c static int ixp4xx_gpio_probe(struct platform_device *pdev) · line 385
Quoted 4 lines
drivers/gpio/gpio-ixp4xx.c +0
-0@@ -381,11 +383,27 @@ static int ixp4xx_gpio_probe(struct platform_device *pdev)* from IRQCHIP_DECLARE(), then use of_node_to_fwnode() to get * the fwnode. For now we need this boardfile style code. */ Is this comment still valid after this patch? Or is this maybe incomplete DT support (probing only)? If so it need clarifying.
We are supporting board files and device tree in parallel during a transition period, the driver handled both static and dynamic assignment (hence the complexity). This is the typical mess with converting old systems in to new ones, a few kernels down the road when all boardfiles are converted to device trees the complexity can be removed.
But it should not say "after adding OF support" but rather "when we are using OF exclusively".
Yours,
Linus Walleij
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
PATCH 15/17 ARM: ixp4xx: Add DT bindings
In reply to Linus WalleijThis adds initial device tree bindings for the IXP4xx machines. This time I tried something wild and crazy and try to make proper JSON-style YAML bindings for the top level.
---
I have no clear idea on how to auto-test this schema for validity, since it is a bit of a new thing I hope to figure it out as we go.
--- .../devicetree/bindings/arm/intel-ixp4xx.yaml | 22 +++++++++++++++++++ MAINTAINERS | 1 + 2 files changed, 23 insertions(+) create mode 100644 Documentation/devicetree/bindings/arm/intel-ixp4xx.yaml
Documentation/devicetree/bindings/arm/intel-ixp4xx.yaml new file +22 -0
@@ -0,0 +1,22 @@ +# SPDX-License-Identifier: GPL-2.0 +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/arm/intel-ixp4xx.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Intel IXP4xx Device Tree Bindings + +maintainers: + - Linus Walleij <[email protected]> + +properties: + compatible: + oneOf: + - items: + - enum: + - linksys,nslu2 + - const: intel,ixp42x + - items: + - enum: + - gateworks,gw2358-4 + - const: intel,ixp43x
MAINTAINERS +1 -0
@@ -1650,6 +1650,7 @@ M: Imre Kaloz <[email protected]> M: Krzysztof Halasa <[email protected]> L: [email protected] (moderated for non-subscribers) S: Maintained +F: Documentation/devicetree/bindings/arm/intel-ixp4xx.yaml F: Documentation/devicetree/bindings/gpio/intel,ixp4xx-gpio.txt F: Documentation/devicetree/bindings/interrupt-controller/intel,ixp4xx-interrupt.txt F: Documentation/devicetree/bindings/timer/intel,ixp4xx-timer.txt
Signature · 1 line
2.20.1
Re: [PATCH 15/17 v1] ARM: ixp4xx: Add DT bindings
Quoted 11 lines · Linus Walleij
This adds initial device tree bindings for the IXP4xx machines. This time I tried something wild and crazy and try to make proper JSON-style YAML bindings for the top level.
Signed-off-by Linus Walleij <[email protected]>---
I have no clear idea on how to auto-test this schema for validity, since it is a bit of a new thing I hope to figure it out as we go.
Is Documentation/devicetree/writing-schema.md missing something on how to?
The DT patchwork instance will have test results too, but in this case it couldn't apply the patch since MAINTAINERS has a dependency...
Quoted 5 lines
--- .../devicetree/bindings/arm/intel-ixp4xx.yaml | 22 +++++++++++++++++++ MAINTAINERS | 1 + 2 files changed, 23 insertions(+) create mode 100644 Documentation/devicetree/bindings/arm/intel-ixp4xx.yaml
In any case, the manual checker thinks this looks fine.
Re: [PATCH 15/17 v1] ARM: ixp4xx: Add DT bindings
Quoted 6 lines · Rob Herring
Quoted 5 lines · Linus Walleij
This adds initial device tree bindings for the IXP4xx machines. This time I tried something wild and crazy and try to make proper JSON-style YAML bindings for the top level.
Quoted 8 lines
Quoted 6 lines
Signed-off-by Linus Walleij <[email protected]>---
I have no clear idea on how to auto-test this schema for validity, since it is a bit of a new thing I hope to figure it out as we go.Is
Documentation/devicetree/writing-schema.mdmissing something on how to?
Yay! Now I finally got around to testing this, and it really works smooth!
I already had it help me find issues with my device trees and all. This is really paying off from day one, a bit of threshold but it delivers.
Yours,
Linus Walleij
PATCH 16/17 ARM: ixp4xx: Add device tree boot support
In reply to Linus WalleijThis adds a minimal support for booting IXP4xx systems from device tree.
We have to add hacks to the QMGR, NPE and notably also ethernet and watchdog drivers so that they don't crash the platform: these drivers are unconditionally starting to grab regions of statically remapped IO space with no concern of the device model or other platforms.
We will go in and properly fix these drivers as we go along but for now this hack gets us to a place where we can start working on proper device tree support for these platforms.
--- arch/arm/mach-ixp4xx/Kconfig | 14 +++++++ arch/arm/mach-ixp4xx/Makefile | 3 ++ arch/arm/mach-ixp4xx/ixp4xx-of.c | 49 ++++++++++++++++++++++++ arch/arm/mach-ixp4xx/ixp4xx_npe.c | 5 +++ arch/arm/mach-ixp4xx/ixp4xx_qmgr.c | 5 +++ drivers/net/ethernet/xscale/ixp4xx_eth.c | 10 +++++ drivers/watchdog/ixp4xx_wdt.c | 9 +++++ 7 files changed, 95 insertions(+) create mode 100644 arch/arm/mach-ixp4xx/ixp4xx-of.c
arch/arm/mach-ixp4xx/Kconfig +14 -0
@@ -4,6 +4,20 @@ menu "Intel IXP4xx Implementation Options" comment "IXP4xx Platforms" +config MACH_IXP4XX_OF + bool + prompt "Devce Tree IXP4xx boards" + default y + select ARM_APPENDED_DTB # Old Redboot bootloaders deployed + select I2C + select I2C_IOP3XX + select PCI + select SERIAL_OF_PLATFORM + select TIMER_OF + select USE_OF + help + Say 'Y' here to support Device Tree-based IXP4xx platforms. + config MACH_NSLU2 bool prompt "Linksys NSLU2"
arch/arm/mach-ixp4xx/Makefile +3 -0
@@ -6,6 +6,9 @@ obj-pci-y := obj-pci-n := +# Device tree platform +obj-pci-$(CONFIG_MACH_IXP4XX_OF) += ixp4xx-of.o + obj-pci-$(CONFIG_ARCH_IXDP4XX) += ixdp425-pci.o obj-pci-$(CONFIG_MACH_AVILA) += avila-pci.o obj-pci-$(CONFIG_MACH_IXDPG425) += ixdpg425-pci.o
arch/arm/mach-ixp4xx/ixp4xx-of.c new file +49 -0
49 lines not on this page · raw message
arch/arm/mach-ixp4xx/ixp4xx_npe.c +5 -0
@@ -20,6 +20,7 @@#include <linux/io.h> #include <linux/kernel.h> #include <linux/module.h> +#include <linux/of.h> #include <mach/npe.h> #define DEBUG_MSG 0
@@ -688,6 +689,10 @@ static int __init npe_init_module(void)int i, found =0 ; +/* This driver does not work with device tree */ +if (of_have_populated_dt ()) +return -ENODEV ; +for (i =0 ; i <NPE_COUNT ; i++) {struct npe *npe = &npe_tab[i]; if (!(ixp4xx_read_feature_bits() &
arch/arm/mach-ixp4xx/ixp4xx_qmgr.c +5 -0
@@ -12,6 +12,7 @@#include <linux/interrupt.h> #include <linux/kernel.h> #include <linux/module.h> +#include <linux/of.h> #include <mach/qmgr.h> #include "irqs.h"
@@ -289,6 +290,10 @@ static int qmgr_init(void)int i, err;irq_handler_t handler1, handler2; +/* This driver does not work with device tree */ +if (of_have_populated_dt ()) +return -ENODEV ; + mem_res =request_mem_region (IXP4XX_QMGR_BASE_PHYS ,IXP4XX_QMGR_REGION_SIZE ,"IXP4xx Queue Manager" );
drivers/net/ethernet/xscale/ixp4xx_eth.c +10 -0
@@ -31,6 +31,7 @@#include <linux/io.h> #include <linux/kernel.h> #include <linux/net_tstamp.h> +#include <linux/of.h> #include <linux/phy.h> #include <linux/platform_device.h> #include <linux/ptp_classify.h>
@@ -1497,6 +1498,15 @@ static struct platform_driver ixp4xx_eth_driver = {static int __init eth_init_module (void ) {int err; + +/* +* FIXME: we bail out on device tree boot but this really needs +* to be fixed in a nicer way: this registers the MDIO bus before +* even matching the driver infrastructure, we should only probe +* detected hardware. +*/ +if (of_have_populated_dt ()) +return -ENODEV ;if ((err =ixp4xx_mdio_register ()))return err;return platform_driver_register (&ixp4xx_eth_driver);
drivers/watchdog/ixp4xx_wdt.c +9 -0
@@ -21,6 +21,7 @@#include <linux/kernel.h> #include <linux/fs.h> #include <linux/miscdevice.h> +#include <linux/of.h> #include <linux/watchdog.h> #include <linux/init.h> #include <linux/bitops.h>
@@ -176,6 +177,14 @@ static int __init ixp4xx_wdt_init(void) {int ret; +/* +* FIXME: we bail out on device tree boot but this really needs +* to be fixed in a nicer way: this registers the MDIO bus before +* even matching the driver infrastructure, we should only probe +* detected hardware. +*/ +if (of_have_populated_dt ()) +return -ENODEV ;if (!(read_cpuid_id () &0xf ) && !cpu_is_ixp46x ()) {pr_err ("Rev. A0 IXP42x CPU detected - watchdog disabled\n" );
Signature · 7 lines
2.20.1 _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
PATCH 17/17 RFC: ARM: dts: Add some initial IXP4xx device trees
In reply to Linus WalleijThis adds a device tree for the IXP4xx-based Linksys NSLU2 and Gateworks GW2358-4 which is one platform in the Gateworks Cambria family.
These will be the first IXP4xx device tree platforms.
---
Since several of the DT bindings in these trees are not yet reviewed or merged upstream, this patch is RFC only, presented to make the review of the rest of the series readable.
--- arch/arm/boot/dts/Makefile | 3 + .../boot/dts/intel-ixp42x-linksys-nslu2.dts | 111 ++++++++++++++++++ arch/arm/boot/dts/intel-ixp42x.dtsi | 25 ++++ .../dts/intel-ixp43x-gateworks-gw2358-4.dts | 96 +++++++++++++++ arch/arm/boot/dts/intel-ixp43x.dtsi | 15 +++ arch/arm/boot/dts/intel-ixp45x-ixp46x.dtsi | 34 ++++++ arch/arm/boot/dts/intel-ixp4xx.dtsi | 58 +++++++++ 7 files changed, 342 insertions(+) create mode 100644 arch/arm/boot/dts/intel-ixp42x-linksys-nslu2.dts create mode 100644 arch/arm/boot/dts/intel-ixp42x.dtsi create mode 100644 arch/arm/boot/dts/intel-ixp43x-gateworks-gw2358-4.dts create mode 100644 arch/arm/boot/dts/intel-ixp43x.dtsi create mode 100644 arch/arm/boot/dts/intel-ixp45x-ixp46x.dtsi create mode 100644 arch/arm/boot/dts/intel-ixp4xx.dtsi
arch/arm/boot/dts/Makefile +3 -0
@@ -227,6 +227,9 @@ dtb-$(CONFIG_ARCH_HIX5HD2) += \ dtb-$(CONFIG_ARCH_INTEGRATOR) += \ integratorap.dtb \ integratorcp.dtb +dtb-$(CONFIG_ARCH_IXP4XX) += \ + intel-ixp42x-linksys-nslu2.dtb \ + intel-ixp43x-gateworks-gw2358-4.dtb dtb-$(CONFIG_ARCH_KEYSTONE) += \ keystone-k2hk-evm.dtb \ keystone-k2l-evm.dtb \
arch/arm/boot/dts/intel-ixp42x-linksys-nslu2.dts new file +111 -0
111 lines not on this page · raw message
arch/arm/boot/dts/intel-ixp42x.dtsi new file +25 -0
@@ -0,0 +1,25 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Device Tree file for Intel XScale Network Processors + * in the IXP 42x series. This series has 32 interrupts. + */ +#include "intel-ixp4xx.dtsi" + +/ { + soc { + interrupt-controller@c8003000 { + compatible = "intel,ixp42x-interrupt"; + }; + + /* + * This is the USB Device Mode (UDC) controller, which is used + * to present the IXP4xx as a device on a USB bus. + */ + usb@c800b000 { + compatible = "intel,ixp4xx-udc"; + reg = <0xc800b000 0x1000>; + interrupts = <12 IRQ_TYPE_LEVEL_HIGH>; + status = "disabled"; + }; + }; +};
arch/arm/boot/dts/intel-ixp43x-gateworks-gw2358-4.dts new file +96 -0
96 lines not on this page · raw message
arch/arm/boot/dts/intel-ixp43x.dtsi new file +15 -0
@@ -0,0 +1,15 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Device Tree file for Intel XScale Network Processors + * in the IXP 43x series. This series has 64 interrupts and adds a few more + * peripherals over the 42x series. + */ +#include "intel-ixp4xx.dtsi" + +/ { + soc { + interrupt-controller@c8003000 { + compatible = "intel,ixp43x-interrupt"; + }; + }; +};
arch/arm/boot/dts/intel-ixp45x-ixp46x.dtsi new file +34 -0
@@ -0,0 +1,34 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Device Tree file for Intel XScale Network Processors + * in the IXP45x and IXP46x series. This series has 64 interrupts and adds a + * few more peripherals over the 42x and 43x series so this extends the + * basic IXP4xx DTSI. + */ +#include "intel-ixp4xx.dtsi" + +/ { + soc { + interrupt-controller@c8003000 { + compatible = "intel,ixp43x-interrupt"; + }; + + /* + * This is the USB Device Mode (UDC) controller, which is used + * to present the IXP4xx as a device on a USB bus. + */ + usb@c800b000 { + compatible = "intel,ixp4xx-udc"; + reg = <0xc800b000 0x1000>; + interrupts = <12 IRQ_TYPE_LEVEL_HIGH>; + status = "disabled"; + }; + + i2c@c8011000 { + compatible = "intel,ixp4xx-i2c"; + reg = <0xc8011000 0x18>; + interrupts = <33 IRQ_TYPE_LEVEL_HIGH>; + status = "disabled"; + }; + }; +};
arch/arm/boot/dts/intel-ixp4xx.dtsi new file +58 -0
58 lines not on this page · raw message
Signature · 7 lines
2.20.1 _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel