MIPS: Octeon: Use Device Tree.
Subsystems (7)
v6 cover MIPS: Octeon: Use Device Tree.
From: David Daney <[email protected]>
This code has now had extensive testing, it is running on more than 10 different boards and SOC combinations.
The patches in this set are all in the arch/mips tree and should probably be merged by Ralf.
They do depend on this libfdt patch:
http://marc.info/?l=linux-kernel&m=133054335203615
New in v6:
o Device Tree bindings updated based on feedback and more actual use.
o Use of irq_domain support added to recent kernels.
New in v5:
o New irq triggering mode constants.
o Boot protocol to pass flattened device tree from bootloader. This protocol may change based on attempts to arrive at a common protocol for all MIPS boards.
New in v4:
o Cleanup and error checking suggested by Sergei Shtylyov.
o Use device tree passed by bootloader if present.
New in v3:
o More updates to device tree bindings, and perhaps more importantly descriptions/definitions of the bindings
o Cleanup and style improvements as suggested by Grant Likley.
o Omitted all the driver changes, as they are unchanged from the last set, and at this stage the patches are just an RFC.
New in v2:
o Changed many device tree bindings. They should be closer to the standard naming scheme now.
o Editing of the template device tree is done in the flattened form using libfdt.
o Standard platform driver functions used in preference to the of_platform variety.
v1:
Background: The Octeon family of SOCs has a variety of on-chip controllers for Ethernet, MDIO, I2C, and several other I/O devices. These chips are used on boards with a great variety of different configurations. To date, the configuration and bus topology information has been hard coded in the drivers and support code.
To facilitate supporting new chips and boards, we are using the Device Tree to encode the configuration information. The migration from the legacy approach to the device tree is as follows:
o A device tree template is statically linked into the kernel image. Based on SOC type and board type, legacy configuration probing code is used to prune and patch the device tree template.
o New SOCs and boards will directly use a device tree passed by the bootloader.
David Daney (5):
MIPS: Octeon: Add device tree source files.
MIPS: Don't define early_init_devtree() and device_tree_init() in
prom.c for CPU_CAVIUM_OCTEON
MIPS: Octeon: Add irq handlers for GPIO interrupts.
MIPS: Octeon: Setup irq_domains for interrupts.
MIPS: Octeon: Initialize and fixup device tree.
.../bindings/ata/cavium-compact-flash.txt | 30 + .../bindings/gpio/cavium-octeon-gpio.txt | 48 ++ .../devicetree/bindings/i2c/cavium-i2c.txt | 34 ++ .../devicetree/bindings/mips/cavium/bootbus.txt | 126 ++++ .../devicetree/bindings/mips/cavium/ciu.txt | 26 + .../devicetree/bindings/mips/cavium/ciu2.txt | 27 + .../devicetree/bindings/mips/cavium/dma-engine.txt | 21 + .../devicetree/bindings/mips/cavium/uctl.txt | 47 ++ .../devicetree/bindings/net/cavium-mdio.txt | 27 + .../devicetree/bindings/net/cavium-mix.txt | 40 ++ .../devicetree/bindings/net/cavium-pip.txt | 98 +++ .../devicetree/bindings/serial/cavium-uart.txt | 19 + arch/mips/Kconfig | 3 + arch/mips/cavium-octeon/.gitignore | 2 + arch/mips/cavium-octeon/Makefile | 16 + arch/mips/cavium-octeon/octeon-irq.c | 395 +++++++++++-- arch/mips/cavium-octeon/octeon-platform.c | 523 ++++++++++++++++- arch/mips/cavium-octeon/octeon_3xxx.dts | 571 ++++++++++++++++++ arch/mips/cavium-octeon/octeon_68xx.dts | 625 ++++++++++++++++++++ arch/mips/cavium-octeon/setup.c | 45 ++ arch/mips/kernel/prom.c | 2 + 21 files changed, 2661 insertions(+), 64 deletions(-) create mode 100644 Documentation/devicetree/bindings/ata/cavium-compact-flash.txt create mode 100644 Documentation/devicetree/bindings/gpio/cavium-octeon-gpio.txt create mode 100644 Documentation/devicetree/bindings/i2c/cavium-i2c.txt create mode 100644 Documentation/devicetree/bindings/mips/cavium/bootbus.txt create mode 100644 Documentation/devicetree/bindings/mips/cavium/ciu.txt create mode 100644 Documentation/devicetree/bindings/mips/cavium/ciu2.txt create mode 100644 Documentation/devicetree/bindings/mips/cavium/dma-engine.txt create mode 100644 Documentation/devicetree/bindings/mips/cavium/uctl.txt create mode 100644 Documentation/devicetree/bindings/net/cavium-mdio.txt create mode 100644 Documentation/devicetree/bindings/net/cavium-mix.txt create mode 100644 Documentation/devicetree/bindings/net/cavium-pip.txt create mode 100644 Documentation/devicetree/bindings/serial/cavium-uart.txt create mode 100644 arch/mips/cavium-octeon/.gitignore create mode 100644 arch/mips/cavium-octeon/octeon_3xxx.dts create mode 100644 arch/mips/cavium-octeon/octeon_68xx.dts
Signature · 1 line
1.7.2.3
PATCH v6 1/5 MIPS: Octeon: Add device tree source files.
From: David Daney <[email protected]>
The two device tree files octeon_3xxx.dts and octeon_68xx.dts are trimmed by code in a subsequent patch to reflect the hardware actually present on the board. To this end several properties that are not part of the declared bindings are added to aid in trimming off unwanted nodes. Since the device tree and the code that trims it are bound into the kernel binary, these 'marker' properties never escape into the wild, and are purely an implementation detail of the kernel early boot process. This is done for backwards compatibility with existing boards (identified by a board type enumeration value by their bootloaders). New boards will always pass a device tree from the bootloader, the built-in trees are ignored in this case.
--- .../bindings/ata/cavium-compact-flash.txt | 30 + .../bindings/gpio/cavium-octeon-gpio.txt | 48 ++ .../devicetree/bindings/i2c/cavium-i2c.txt | 34 ++ .../devicetree/bindings/mips/cavium/bootbus.txt | 126 ++++ .../devicetree/bindings/mips/cavium/ciu.txt | 26 + .../devicetree/bindings/mips/cavium/ciu2.txt | 27 + .../devicetree/bindings/mips/cavium/dma-engine.txt | 21 + .../devicetree/bindings/mips/cavium/uctl.txt | 47 ++ .../devicetree/bindings/net/cavium-mdio.txt | 27 + .../devicetree/bindings/net/cavium-mix.txt | 40 ++ .../devicetree/bindings/net/cavium-pip.txt | 98 +++ .../devicetree/bindings/serial/cavium-uart.txt | 19 + arch/mips/cavium-octeon/.gitignore | 2 + arch/mips/cavium-octeon/Makefile | 13 + arch/mips/cavium-octeon/octeon_3xxx.dts | 571 ++++++++++++++++++ arch/mips/cavium-octeon/octeon_68xx.dts | 625 ++++++++++++++++++++ 16 files changed, 1754 insertions(+), 0 deletions(-) create mode 100644 Documentation/devicetree/bindings/ata/cavium-compact-flash.txt create mode 100644 Documentation/devicetree/bindings/gpio/cavium-octeon-gpio.txt create mode 100644 Documentation/devicetree/bindings/i2c/cavium-i2c.txt create mode 100644 Documentation/devicetree/bindings/mips/cavium/bootbus.txt create mode 100644 Documentation/devicetree/bindings/mips/cavium/ciu.txt create mode 100644 Documentation/devicetree/bindings/mips/cavium/ciu2.txt create mode 100644 Documentation/devicetree/bindings/mips/cavium/dma-engine.txt create mode 100644 Documentation/devicetree/bindings/mips/cavium/uctl.txt create mode 100644 Documentation/devicetree/bindings/net/cavium-mdio.txt create mode 100644 Documentation/devicetree/bindings/net/cavium-mix.txt create mode 100644 Documentation/devicetree/bindings/net/cavium-pip.txt create mode 100644 Documentation/devicetree/bindings/serial/cavium-uart.txt create mode 100644 arch/mips/cavium-octeon/.gitignore create mode 100644 arch/mips/cavium-octeon/octeon_3xxx.dts create mode 100644 arch/mips/cavium-octeon/octeon_68xx.dts
Documentation/devicetree/bindings/ata/cavium-compact-flash.txt new file +30 -0
@@ -0,0 +1,30 @@ +* Compact Flash + +The Cavium Compact Flash device is connected to the Octeon Boot Bus, +and is thus a child of the Boot Bus device. It can read and write +industry standard compact flash devices. + +Properties: +- compatible: "cavium,ebt3000-compact-flash"; + + Compatibility with many Cavium evaluation boards. + +- reg: The base address of the the CF chip select banks. Depending on + the device configuration, there may be one or two banks. + +- cavium,bus-width: The width of the connection to the CF devices. Valid + values are 8 and 16. + +- cavium,true-ide: Optional, if present the CF connection is in True IDE mode. + +- cavium,dma-engine-handle: Optional, a phandle for the DMA Engine connected + to this device. + +Example: + compact-flash@5,0 { + compatible = "cavium,ebt3000-compact-flash"; + reg = <5 0 0x10000>, <6 0 0x10000>; + cavium,bus-width = <16>; + cavium,true-ide; + cavium,dma-engine-handle = <&dma0>; + };
Documentation/devicetree/bindings/gpio/cavium-octeon-gpio.txt new file +48 -0
48 lines not on this page · raw message
Documentation/devicetree/bindings/i2c/cavium-i2c.txt new file +34 -0
@@ -0,0 +1,34 @@ +* Two Wire Serial Interface (TWSI) / I2C + +- compatible: "cavium,octeon-3860-twsi" + + Compatibility with all cn3XXX, cn5XXX and cn6XXX SOCs. + +- reg: The base address of the TWSI/I2C bus controller register bank. + +- #address-cells: Must be <1>. + +- #size-cells: Must be <0>. I2C addresses have no size component. + +- interrupts: A single interrupt specifier. + +- clock-frequency: The I2C bus clock rate in Hz. + +Example: + twsi0: i2c@1180000001000 { + #address-cells = <1>; + #size-cells = <0>; + compatible = "cavium,octeon-3860-twsi"; + reg = <0x11800 0x00001000 0x0 0x200>; + interrupts = <0 45>; + clock-frequency = <100000>; + + rtc@68 { + compatible = "dallas,ds1337"; + reg = <0x68>; + }; + tmp@4c { + compatible = "ti,tmp421"; + reg = <0x4c>; + }; + };
Documentation/devicetree/bindings/mips/cavium/bootbus.txt new file +126 -0
126 lines not on this page · raw message
Documentation/devicetree/bindings/mips/cavium/ciu.txt new file +26 -0
@@ -0,0 +1,26 @@ +* Central Interrupt Unit + +Properties: +- compatible: "cavium,octeon-3860-ciu" + + Compatibility with all cn3XXX, cn5XXX and cn63XX SOCs. + +- interrupt-controller: This is an interrupt controller. + +- reg: The base address of the CIU's register bank. + +- #interrupt-cells: Must be <2>. The first cell is the bank within + the CIU and may have a value of 0 or 1. The second cell is the bit + within the bank and may have a value between 0 and 63. + +Example: + interrupt-controller@1070000000000 { + compatible = "cavium,octeon-3860-ciu"; + interrupt-controller; + /* Interrupts are specified by two parts: + * 1) Controller register (0 or 1) + * 2) Bit within the register (0..63) + */ + #interrupt-cells = <2>; + reg = <0x10700 0x00000000 0x0 0x7000>; + };
Documentation/devicetree/bindings/mips/cavium/ciu2.txt new file +27 -0
@@ -0,0 +1,27 @@ +* Central Interrupt Unit + +Properties: +- compatible: "cavium,octeon-6880-ciu2" + + Compatibility with 68XX SOCs. + +- interrupt-controller: This is an interrupt controller. + +- reg: The base address of the CIU's register bank. + +- #interrupt-cells: Must be <2>. The first cell is the bank within + the CIU and may have a value between 0 and 63. The second cell is + the bit within the bank and may also have a value between 0 and 63. + +Example: + interrupt-controller@1070100000000 { + compatible = "cavium,octeon-6880-ciu2"; + interrupt-controller; + /* Interrupts are specified by two parts: + * 1) Controller register (0..63) + * 2) Bit within the register (0..63) + */ + #address-cells = <0>; + #interrupt-cells = <2>; + reg = <0x10701 0x00000000 0x0 0x4000000>; + };
Documentation/devicetree/bindings/mips/cavium/dma-engine.txt new file +21 -0
@@ -0,0 +1,21 @@ +* DMA Engine. + +The Octeon DMA Engine transfers between the Boot Bus and main memory. +The DMA Engine will be refered to by phandle by any device that is +connected to it. + +Properties: +- compatible: "cavium,octeon-5750-bootbus-dma" + + Compatibility with all cn52XX, cn56XX and cn6XXX SOCs. + +- reg: The base address of the DMA Engine's register bank. + +- interrupts: A single interrupt specifier. + +Example: + dma0: dma-engine@1180000000100 { + compatible = "cavium,octeon-5750-bootbus-dma"; + reg = <0x11800 0x00000100 0x0 0x8>; + interrupts = <0 63>; + };
Documentation/devicetree/bindings/mips/cavium/uctl.txt new file +47 -0
47 lines not on this page · raw message
Documentation/devicetree/bindings/net/cavium-mdio.txt new file +27 -0
@@ -0,0 +1,27 @@ +* System Management Interface (SMI) / MDIO + +Properties: +- compatible: "cavium,octeon-3860-mdio" + + Compatibility with all cn3XXX, cn5XXX and cn6XXX SOCs. + +- reg: The base address of the MDIO bus controller register bank. + +- #address-cells: Must be <1>. + +- #size-cells: Must be <0>. MDIO addresses have no size component. + +Typically an MDIO bus might have several children. + +Example: + mdio@1180000001800 { + compatible = "cavium,octeon-3860-mdio"; + #address-cells = <1>; + #size-cells = <0>; + reg = <0x11800 0x00001800 0x0 0x40>; + + ethernet-phy@0 { + ... + reg = <0>; + }; + };
Documentation/devicetree/bindings/net/cavium-mix.txt new file +40 -0
@@ -0,0 +1,40 @@ +* MIX Ethernet controller. + +Properties: +- compatible: "cavium,octeon-5750-mix" + + Compatibility with all cn5XXX and cn6XXX SOCs populated with MIX + devices. + +- reg: The base addresses of four separate register banks. The first + bank contains the MIX registers. The second bank the corresponding + AGL registers. The third bank are the AGL registers shared by all + MIX devices present. The fourth bank is the AGL_PRT_CTL shared by + all MIX devices present. + +- cell-index: A single cell specifying which portion of the shared + register banks corresponds to this MIX device. + +- interrupts: Two interrupt specifiers. The first is the MIX + interrupt routing and the second the routing for the AGL interrupts. + +- mac-address: Optional, the MAC address to assign to the device. + +- local-mac-address: Optional, the MAC address to assign to the device + if mac-address is not specified. + +- phy-handle: Optional, a phandle for the PHY device connected to this device. + +Example: + ethernet@1070000100800 { + compatible = "cavium,octeon-5750-mix"; + reg = <0x10700 0x00100800 0x0 0x100>, /* MIX */ + <0x11800 0xE0000800 0x0 0x300>, /* AGL */ + <0x11800 0xE0000400 0x0 0x400>, /* AGL_SHARED */ + <0x11800 0xE0002008 0x0 0x8>; /* AGL_PRT_CTL */ + cell-index = <1>; + interrupts = <1 18>, < 1 46>; + local-mac-address = [ 00 0f b7 10 63 54 ]; + phy-handle = <&phy1>; + }; +
Documentation/devicetree/bindings/net/cavium-pip.txt new file +98 -0
98 lines not on this page · raw message
Documentation/devicetree/bindings/serial/cavium-uart.txt new file +19 -0
@@ -0,0 +1,19 @@ +* Universal Asynchronous Receiver/Transmitter (UART) + +- compatible: "cavium,octeon-3860-uart" + + Compatibility with all cn3XXX, cn5XXX and cn6XXX SOCs. + +- reg: The base address of the UART register bank. + +- interrupts: A single interrupt specifier. + +- current-speed: Optional, the current bit rate in bits per second. + +Example: + uart1: serial@1180000000c00 { + compatible = "cavium,octeon-3860-uart","ns16550"; + reg = <0x11800 0x00000c00 0x0 0x400>; + current-speed = <115200>; + interrupts = <0 35>; + };
arch/mips/cavium-octeon/.gitignore new file +2 -0
@@ -0,0 +1,2 @@ +*.dtb.S +*.dtb
arch/mips/cavium-octeon/Makefile +13 -0
@@ -15,3 +15,16 @@ obj-y += octeon-memcpy.o obj-y += executive/ obj-$(CONFIG_SMP) += smp.o + +DTS_FILES = octeon_3xxx.dts octeon_68xx.dts +DTB_FILES = $(patsubst %.dts, %.dtb, $(DTS_FILES)) + +obj-y += $(patsubst %.dts, %.dtb.o, $(DTS_FILES)) + +$(obj)/%.dtb: $(src)/%.dts FORCE + $(call if_changed_dep,dtc) + +# Let's keep the .dtb files around in case we want to look at them. +.SECONDARY: $(addprefix $(obj)/, $(DTB_FILES)) + +clean-files += $(DTB_FILES) $(patsubst %.dtb, %.dtb.S, $(DTB_FILES))
arch/mips/cavium-octeon/octeon_3xxx.dts new file +571 -0
571 lines not on this page · raw message
arch/mips/cavium-octeon/octeon_68xx.dts new file +625 -0
625 lines not on this page · raw message
Signature · 1 line
1.7.2.3
PATCH v6 2/5 MIPS: Don't define early_init_devtree() and device_tree_init() in prom.c for CPU_CAVIUM_OCTEON
In reply to David DaneyFrom: David Daney <david.daney-YGCgFSpz5w/[email protected]>
This code is not common enough to be in a shared file, so OCTEON defines it's own versions.
When the last of this target specific code is moved out, we can remove all of this.
--- arch/mips/kernel/prom.c | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-)
arch/mips/kernel/prom.c +2 -0
@@ -60,6 +60,7 @@ void __init early_init_dt_setup_initrd_arch(unsigned long start, }#endif +#ifndef CONFIG_CPU_CAVIUM_OCTEON void __init early_init_devtree (void *params) {/* Setup flat device-tree pointer */
@@ -95,3 +96,4 @@ void __init device_tree_init(void)/* free the space reserved for the dt blob */ free_mem_mach(base, size); } +#endif /* !CONFIG_CPU_CAVIUM_OCTEON */
Signature · 1 line
1.7.2.3
PATCH v6 3/5 MIPS: Octeon: Add irq handlers for GPIO interrupts.
In reply to David DaneyFrom: David Daney <[email protected]>
This is needed for follow-on on patches for Octeon to use the Device Tree to configure GPIO interrupts.
--- arch/mips/cavium-octeon/octeon-irq.c | 96 +++++++++++++++++++++++++++++++++- 1 files changed, 95 insertions(+), 1 deletions(-)
arch/mips/cavium-octeon/octeon-irq.c +95 -1
@@ -505,6 +505,72 @@ static void octeon_irq_ciu_enable_all_v2(struct irq_data *data) } } +static void octeon_irq_gpio_setup (struct irq_data *data) +{ +union cvmx_gpio_bit_cfgx cfg; +int bit = data->irq -OCTEON_IRQ_GPIO0 ; +u32 t =irqd_get_trigger_type (data); + + cfg.u64 =0 ; + cfg.s.int_en =1 ; + cfg.s.int_type = (t & (IRQ_TYPE_EDGE_RISING |IRQ_TYPE_EDGE_FALLING )) !=0 ; + cfg.s.rx_xor = (t & (IRQ_TYPE_LEVEL_LOW |IRQ_TYPE_EDGE_FALLING )) !=0 ; + +/* 1 uS glitch filter*/ + cfg.s.fil_cnt =7 ; + cfg.s.fil_sel =3 ; + +cvmx_write_csr (CVMX_GPIO_BIT_CFGX (bit), cfg.u64); +} + +static void octeon_irq_ciu_enable_gpio_v2 (struct irq_data *data) +{ +octeon_irq_gpio_setup (data); +octeon_irq_ciu_enable_v2 (data); +} + +static void octeon_irq_ciu_enable_gpio (struct irq_data *data) +{ +octeon_irq_gpio_setup (data); +octeon_irq_ciu_enable (data); +} + +static int octeon_irq_ciu_gpio_set_type (struct irq_data *data,unsigned int t) +{ +u32 current_type =irqd_get_trigger_type (data); + +/* If the type has been set, don't change it */ +if (current_type && current_type != t) +return -EINVAL ; + +irqd_set_trigger_type (data, t); +return IRQ_SET_MASK_OK ; +} + +static void octeon_irq_ciu_disable_gpio_v2 (struct irq_data *data) +{ +int bit = data->irq -OCTEON_IRQ_GPIO0 ; +cvmx_write_csr (CVMX_GPIO_BIT_CFGX (bit),0 ); + +octeon_irq_ciu_disable_all_v2 (data); +} + +static void octeon_irq_ciu_disable_gpio (struct irq_data *data) +{ +int bit = data->irq -OCTEON_IRQ_GPIO0 ; +cvmx_write_csr (CVMX_GPIO_BIT_CFGX (bit),0 ); + +octeon_irq_ciu_disable_all (data); +} + +static void octeon_irq_ciu_gpio_ack (struct irq_data *data) +{ +int bit = data->irq -OCTEON_IRQ_GPIO0 ; +u64 mask =1ull << bit; + +cvmx_write_csr (CVMX_GPIO_INT_CLR , mask); +} +#ifdef CONFIG_SMP static void octeon_irq_cpu_offline_ciu (struct irq_data *data)
@@ -717,6 +783,31 @@ static struct irq_chip octeon_irq_chip_ciu_mbox = { .flags = IRQCHIP_ONOFFLINE_ENABLED, }; +static struct irq_chip octeon_irq_chip_ciu_gpio_v2 = { + .name ="CIU-GPIO" , + .irq_enable = octeon_irq_ciu_enable_gpio_v2, + .irq_disable = octeon_irq_ciu_disable_gpio_v2, + .irq_ack = octeon_irq_ciu_gpio_ack, + .irq_mask = octeon_irq_ciu_disable_local_v2, + .irq_unmask = octeon_irq_ciu_enable_v2, + .irq_set_type = octeon_irq_ciu_gpio_set_type, +#ifdef CONFIG_SMP + .irq_set_affinity = octeon_irq_ciu_set_affinity_v2, +#endif +}; + +static struct irq_chip octeon_irq_chip_ciu_gpio = { + .name ="CIU-GPIO" , + .irq_enable = octeon_irq_ciu_enable_gpio, + .irq_disable = octeon_irq_ciu_disable_gpio, + .irq_mask = octeon_irq_dummy_mask, + .irq_ack = octeon_irq_ciu_gpio_ack, + .irq_set_type = octeon_irq_ciu_gpio_set_type, +#ifdef CONFIG_SMP + .irq_set_affinity = octeon_irq_ciu_set_affinity, +#endif +}; +/* * Watchdog interrupts are special. They are associated with a single * core, so we hardwire the affinity to that core.
@@ -890,6 +981,7 @@ static void __init octeon_irq_init_ciu(void)struct irq_chip *chip_edge;struct irq_chip *chip_mbox;struct irq_chip *chip_wd; +struct irq_chip *chip_gpio;octeon_irq_init_ciu_percpu (); octeon_irq_setup_secondary = octeon_irq_setup_secondary_ciu;
@@ -904,6 +996,7 @@ static void __init octeon_irq_init_ciu(void) chip_edge = &octeon_irq_chip_ciu_edge_v2; chip_mbox = &octeon_irq_chip_ciu_mbox_v2; chip_wd = &octeon_irq_chip_ciu_wd_v2; + chip_gpio = &octeon_irq_chip_ciu_gpio_v2; }else { octeon_irq_ip2 = octeon_irq_ip2_v1; octeon_irq_ip3 = octeon_irq_ip3_v1;
@@ -911,6 +1004,7 @@ static void __init octeon_irq_init_ciu(void) chip_edge = &octeon_irq_chip_ciu_edge; chip_mbox = &octeon_irq_chip_ciu_mbox; chip_wd = &octeon_irq_chip_ciu_wd; + chip_gpio = &octeon_irq_chip_ciu_gpio; } octeon_irq_ip4 = octeon_irq_ip4_mask;
@@ -921,7 +1015,7 @@ static void __init octeon_irq_init_ciu(void)for (i =0 ; i <16 ; i++)octeon_irq_set_ciu_mapping (i +OCTEON_IRQ_WORKQ0 ,0 , i +0 , chip, handle_level_irq);for (i =0 ; i <16 ; i++) -octeon_irq_set_ciu_mapping (i +OCTEON_IRQ_GPIO0 ,0 , i +16 , chip, handle_level_irq); +octeon_irq_set_ciu_mapping (i +OCTEON_IRQ_GPIO0 ,0 , i +16 , chip_gpio, handle_level_irq);octeon_irq_set_ciu_mapping (OCTEON_IRQ_MBOX0 ,0 ,32 , chip_mbox, handle_percpu_irq);octeon_irq_set_ciu_mapping (OCTEON_IRQ_MBOX1 ,0 ,33 , chip_mbox, handle_percpu_irq);
Signature · 1 line
1.7.2.3
PATCH v6 4/5 MIPS: Octeon: Setup irq_domains for interrupts.
In reply to David DaneyFrom: David Daney <[email protected]>
Select IRQ_DOMAIN so the core irq_domain code and supply irq_create_of_mapping().
--- arch/mips/Kconfig | 1 + arch/mips/cavium-octeon/octeon-irq.c | 301 +++++++++++++++++++++++++++------- 2 files changed, 239 insertions(+), 63 deletions(-)
arch/mips/Kconfig +1 -0
@@ -1432,6 +1432,7 @@ config CPU_CAVIUM_OCTEON select WEAK_ORDERING select CPU_SUPPORTS_HIGHMEM select CPU_SUPPORTS_HUGEPAGES + select IRQ_DOMAIN help The Cavium Octeon processor is a highly integrated chip containing many ethernet hardware widgets for networking tasks. The processor
arch/mips/cavium-octeon/octeon-irq.c +238 -63
367 lines not on this page · raw message
Signature · 1 line
1.7.2.3
Re: [PATCH v6 4/5] MIPS: Octeon: Setup irq_domains for interrupts.
David,
Quoted 16 lines · David Daney
From: David Daney <[email protected]>
Select
IRQ_DOMAINso the coreirq_domaincode and supplyirq_create_of_mapping().Signed-off-by David Daney <[email protected]>--- arch/mips/Kconfig | 1 + arch/mips/cavium-octeon/octeon-irq.c | 301 +++++++++++++++++++++++++++------- 2 files changed, 239 insertions(+), 63 deletions(-)arch/mips/Kconfig +0
-0
arch/mips/Kconfig config CPU_CAVIUM_OCTEON · line 1435
Quoted 4 lines
arch/mips/Kconfig +1
-0@@ -1432,6 +1432,7 @@ config CPU_CAVIUM_OCTEON select WEAK_ORDERING select CPU_SUPPORTS_HIGHMEM select CPU_SUPPORTS_HUGEPAGES + select IRQ_DOMAIN
IIRC, Grant has a patch cued up that enables IRQ_DOMAIN for all of MIPS.
Quoted 42 lines
arch/mips/Kconfig +0
-0help The Cavium Octeon processor is a highly integrated chip containing many ethernet hardware widgets for networking tasks. The processorarch/mips/cavium-octeon/octeon-irq.c +8
-3@@ -3,14 +3,16 @@* License. See the file "COPYING" in the main directory of this archive * for more details. * -* Copyright (C) 2004-2008, 2009, 2010, 2011 Cavium Networks +* Copyright (C) 2004-2008, 2009, 2010, 2011, 2012 Cavium Networks */.#include <linux/interrupt.h> +#include <linux/irqdomain.h> #include <linux/bitops.h> #include <linux/percpu.h> #include <linux/irq.h> #include <linux/smp.h> +#include <linux/of.h> #include <asm/octeon/octeon.h> @@ -42,20 +44,27 @@ struct octeon_core_chip_data {static struct octeon_core_chip_data octeon_irq_core_chip_data[MIPS_CORE_IRQ_LINES ]; -static void __init octeon_irq_set_ciu_mapping (int irq,int line,int bit, +static void __init octeon_irq_set_ciu_mapping (unsigned int irq, +unsigned int line, +unsigned int bit, +struct irq_domain *domain,struct irq_chip *chip,irq_flow_handler_t handler) { +struct irq_data *irqd;union octeon_ciu_chip_data cd;irq_set_chip_and_handler (irq, chip, handler); -
arch/mips/cavium-octeon/octeon-irq.c struct octeon_core_chip_data { · line 67
Quoted 10 lines
arch/mips/cavium-octeon/octeon-irq.c +4
-0cd.l =0 ; cd.s.line = line; cd.s.bit = bit;irq_set_chip_data (irq, cd.p); octeon_irq_ciu_to_irq[line][bit] = irq; + + irqd =irq_get_irq_data (irq); + irqd->hwirq = line <<6 | bit; + irqd->domain = domain;
I think the domain code will set these.
Quoted 123 lines
arch/mips/cavium-octeon/octeon-irq.c +105
-0}static int octeon_coreid_for_cpu (int cpu)@@ -855,6 +864,107 @@ static struct irq_chip octeon_irq_chip_ciu_wd = { .irq_mask = octeon_irq_dummy_mask, }; +static int octeon_irq_gpio_xlat (struct irq_domain *d, +struct device_node *node, +const u32 *intspec, +unsigned int intsize, +unsigned long *out_hwirq, +unsigned int *out_type) +{ +unsigned int irq; +unsigned int type; +unsigned int ciu =0 , bit =0 ; +unsigned int pin; +unsigned int trigger; +bool set_edge_handler = false; + +if (d->of_node != node) +return -EINVAL ; + +if (intsize <2 ) +return -EINVAL ; + + pin = intspec[0 ]; +if (pin >=16 ) +return -EINVAL ; + + trigger = intspec[1 ]; + +switch (trigger) { +case 1 : + type =IRQ_TYPE_EDGE_RISING ; + set_edge_handler = true; +break ; +case 2 : + type =IRQ_TYPE_EDGE_FALLING ; + set_edge_handler = true; +break ; +case 4 : + type =IRQ_TYPE_LEVEL_HIGH ; +break ; +case 8 : + type =IRQ_TYPE_LEVEL_LOW ; +break ; +default : +pr_err ("Error: (%s) Invalid irq trigger specification: %x\n" , + node->name, + trigger); + type =IRQ_TYPE_LEVEL_LOW ; +break ; + } + *out_type = type; + *out_hwirq = ((unsigned long )d->host_data) + pin; + + ciu = *out_hwirq >>6 ; + bit = *out_hwirq &0x3f ; + + irq = octeon_irq_ciu_to_irq[ciu][bit]; + +if (set_edge_handler) +__irq_set_handler (irq, handle_edge_irq,0 ,NULL ); + +return 0 ; +} + +static int octeon_irq_ciu_xlat (struct irq_domain *d, +struct device_node *node, +const u32 *intspec, +unsigned int intsize, +unsigned long *out_hwirq, +unsigned int *out_type) +{ +unsigned int ciu, bit; + + ciu = intspec[0 ]; + bit = intspec[1 ]; + +if (ciu >1 || bit >63 ) +return -EINVAL ; + +if (octeon_irq_ciu_to_irq[ciu][bit] ==0 ) +return -EINVAL ; + + *out_hwirq = (ciu <<6 ) | bit; + *out_type =0 ; + +return 0 ; +} +static int octeon_irq_dummy_map (struct irq_domain *d, +unsigned int virq,irq_hw_number_t hw) +{ +return 0 ; +} + +static struct irq_domain_ops octeon_irq_domain_ciu_ops = { + .map = octeon_irq_dummy_map, + .xlate = octeon_irq_ciu_xlat, +}; + +static struct irq_domain_ops octeon_irq_domain_gpio_ops = { + .map = octeon_irq_dummy_map, + .xlate = octeon_irq_gpio_xlat, +}; +static void octeon_irq_ip2_v1 (void ) {const unsigned long core_id =cvmx_get_core_num ();@@ -982,6 +1092,10 @@ static void __init octeon_irq_init_ciu(void)struct irq_chip *chip_mbox;struct irq_chip *chip_wd;struct irq_chip *chip_gpio; +struct device_node *gpio_node; +struct device_node *ciu_node; +struct irq_domain *gpio_domain; +struct irq_domain *ciu_domain;octeon_irq_init_ciu_percpu (); octeon_irq_setup_secondary = octeon_irq_setup_secondary_ciu;
arch/mips/cavium-octeon/octeon-irq.c static void __init octeon_irq_init_ciu(void) · line 1131
Quoted 7 lines
arch/mips/cavium-octeon/octeon-irq.c +4
-0@@ -1011,83 +1125,144 @@ static void __init octeon_irq_init_ciu(void)/* Mips internal */ octeon_irq_init_core (); + gpio_node =of_find_compatible_node (NULL ,NULL ,"cavium,octeon-3860-gpio" ); + ciu_node =of_find_compatible_node (NULL ,NULL ,"cavium,octeon-3860-ciu" ); +/* gpio domain host_data is the base hwirq number. */ + gpio_domain =irq_domain_add_linear (gpio_node,16 , &octeon_irq_domain_gpio_ops, (void *)16 );
It would be better to define a struct here rather than casting a data value to a ptr.
Quoted 185 lines
arch/mips/cavium-octeon/octeon-irq.c +108
-60+ ciu_domain =irq_domain_add_tree (ciu_node, &octeon_irq_domain_ciu_ops,NULL ); +/* CIU_0 */ for (i =0 ; i <16 ; i++) -octeon_irq_set_ciu_mapping (i +OCTEON_IRQ_WORKQ0 ,0 , i +0 , chip, handle_level_irq); +octeon_irq_set_ciu_mapping (i +OCTEON_IRQ_WORKQ0 ,0 , i +0 , + ciu_domain, chip, handle_level_irq); +for (i =0 ; i <16 ; i++) -octeon_irq_set_ciu_mapping (i +OCTEON_IRQ_GPIO0 ,0 , i +16 , chip_gpio, handle_level_irq); +octeon_irq_set_ciu_mapping (i +OCTEON_IRQ_GPIO0 ,0 , i +16 , + gpio_domain, chip_gpio, handle_level_irq); -octeon_irq_set_ciu_mapping (OCTEON_IRQ_MBOX0 ,0 ,32 , chip_mbox, handle_percpu_irq); -octeon_irq_set_ciu_mapping (OCTEON_IRQ_MBOX1 ,0 ,33 , chip_mbox, handle_percpu_irq); +octeon_irq_set_ciu_mapping (OCTEON_IRQ_MBOX0 ,0 ,32 , + ciu_domain, chip_mbox, handle_percpu_irq); +octeon_irq_set_ciu_mapping (OCTEON_IRQ_MBOX1 ,0 ,33 , + ciu_domain, chip_mbox, handle_percpu_irq); -octeon_irq_set_ciu_mapping (OCTEON_IRQ_UART0 ,0 ,34 , chip, handle_level_irq); -octeon_irq_set_ciu_mapping (OCTEON_IRQ_UART1 ,0 ,35 , chip, handle_level_irq); +octeon_irq_set_ciu_mapping (OCTEON_IRQ_UART0 ,0 ,34 , + ciu_domain, chip, handle_level_irq); +octeon_irq_set_ciu_mapping (OCTEON_IRQ_UART1 ,0 ,35 , + ciu_domain, chip, handle_level_irq);for (i =0 ; i <4 ; i++) -octeon_irq_set_ciu_mapping (i +OCTEON_IRQ_PCI_INT0 ,0 , i +36 , chip, handle_level_irq); +octeon_irq_set_ciu_mapping (i +OCTEON_IRQ_PCI_INT0 ,0 , i +36 , + ciu_domain, chip, handle_level_irq);for (i =0 ; i <4 ; i++) -octeon_irq_set_ciu_mapping (i +OCTEON_IRQ_PCI_MSI0 ,0 , i +40 , chip, handle_level_irq); +octeon_irq_set_ciu_mapping (i +OCTEON_IRQ_PCI_MSI0 ,0 , i +40 , + ciu_domain, chip, handle_level_irq); -octeon_irq_set_ciu_mapping (OCTEON_IRQ_TWSI ,0 ,45 , chip, handle_level_irq); -octeon_irq_set_ciu_mapping (OCTEON_IRQ_RML ,0 ,46 , chip, handle_level_irq); -octeon_irq_set_ciu_mapping (OCTEON_IRQ_TRACE0 ,0 ,47 , chip, handle_level_irq); +octeon_irq_set_ciu_mapping (OCTEON_IRQ_TWSI ,0 ,45 , + ciu_domain, chip, handle_level_irq); +octeon_irq_set_ciu_mapping (OCTEON_IRQ_RML ,0 ,46 , + ciu_domain, chip, handle_level_irq); +octeon_irq_set_ciu_mapping (OCTEON_IRQ_TRACE0 ,0 ,47 , + ciu_domain, chip, handle_level_irq);for (i =0 ; i <2 ; i++) -octeon_irq_set_ciu_mapping (i +OCTEON_IRQ_GMX_DRP0 ,0 , i +48 , chip_edge, handle_edge_irq); +octeon_irq_set_ciu_mapping (i +OCTEON_IRQ_GMX_DRP0 ,0 , i +48 , + ciu_domain, chip_edge, handle_edge_irq); -octeon_irq_set_ciu_mapping (OCTEON_IRQ_IPD_DRP ,0 ,50 , chip_edge, handle_edge_irq); -octeon_irq_set_ciu_mapping (OCTEON_IRQ_KEY_ZERO ,0 ,51 , chip_edge, handle_edge_irq); +octeon_irq_set_ciu_mapping (OCTEON_IRQ_IPD_DRP ,0 ,50 , + ciu_domain, chip_edge, handle_edge_irq); +octeon_irq_set_ciu_mapping (OCTEON_IRQ_KEY_ZERO ,0 ,51 , + ciu_domain, chip_edge, handle_edge_irq);for (i =0 ; i <4 ; i++) -octeon_irq_set_ciu_mapping (i +OCTEON_IRQ_TIMER0 ,0 , i +52 , chip_edge, handle_edge_irq); - -octeon_irq_set_ciu_mapping (OCTEON_IRQ_USB0 ,0 ,56 , chip, handle_level_irq); -octeon_irq_set_ciu_mapping (OCTEON_IRQ_PCM ,0 ,57 , chip, handle_level_irq); -octeon_irq_set_ciu_mapping (OCTEON_IRQ_MPI ,0 ,58 , chip, handle_level_irq); -octeon_irq_set_ciu_mapping (OCTEON_IRQ_TWSI2 ,0 ,59 , chip, handle_level_irq); -octeon_irq_set_ciu_mapping (OCTEON_IRQ_POWIQ ,0 ,60 , chip, handle_level_irq); -octeon_irq_set_ciu_mapping (OCTEON_IRQ_IPDPPTHR ,0 ,61 , chip, handle_level_irq); -octeon_irq_set_ciu_mapping (OCTEON_IRQ_MII0 ,0 ,62 , chip, handle_level_irq); -octeon_irq_set_ciu_mapping (OCTEON_IRQ_BOOTDMA ,0 ,63 , chip, handle_level_irq); +octeon_irq_set_ciu_mapping (i +OCTEON_IRQ_TIMER0 ,0 , i +52 , + ciu_domain, chip_edge, handle_edge_irq); + +octeon_irq_set_ciu_mapping (OCTEON_IRQ_USB0 ,0 ,56 , + ciu_domain, chip, handle_level_irq); +octeon_irq_set_ciu_mapping (OCTEON_IRQ_PCM ,0 ,57 , + ciu_domain, chip, handle_level_irq); +octeon_irq_set_ciu_mapping (OCTEON_IRQ_MPI ,0 ,58 , + ciu_domain, chip, handle_level_irq); +octeon_irq_set_ciu_mapping (OCTEON_IRQ_TWSI2 ,0 ,59 , + ciu_domain, chip, handle_level_irq); +octeon_irq_set_ciu_mapping (OCTEON_IRQ_POWIQ ,0 ,60 , + ciu_domain, chip, handle_level_irq); +octeon_irq_set_ciu_mapping (OCTEON_IRQ_IPDPPTHR ,0 ,61 , + ciu_domain, chip, handle_level_irq); +octeon_irq_set_ciu_mapping (OCTEON_IRQ_MII0 ,0 ,62 , + ciu_domain, chip, handle_level_irq); +octeon_irq_set_ciu_mapping (OCTEON_IRQ_BOOTDMA ,0 ,63 , + ciu_domain, chip, handle_level_irq);/* CIU_1 */ for (i =0 ; i <16 ; i++) -octeon_irq_set_ciu_mapping (i +OCTEON_IRQ_WDOG0 ,1 , i +0 , chip_wd, handle_level_irq); - -octeon_irq_set_ciu_mapping (OCTEON_IRQ_UART2 ,1 ,16 , chip, handle_level_irq); -octeon_irq_set_ciu_mapping (OCTEON_IRQ_USB1 ,1 ,17 , chip, handle_level_irq); -octeon_irq_set_ciu_mapping (OCTEON_IRQ_MII1 ,1 ,18 , chip, handle_level_irq); -octeon_irq_set_ciu_mapping (OCTEON_IRQ_NAND ,1 ,19 , chip, handle_level_irq); -octeon_irq_set_ciu_mapping (OCTEON_IRQ_MIO ,1 ,20 , chip, handle_level_irq); -octeon_irq_set_ciu_mapping (OCTEON_IRQ_IOB ,1 ,21 , chip, handle_level_irq); -octeon_irq_set_ciu_mapping (OCTEON_IRQ_FPA ,1 ,22 , chip, handle_level_irq); -octeon_irq_set_ciu_mapping (OCTEON_IRQ_POW ,1 ,23 , chip, handle_level_irq); -octeon_irq_set_ciu_mapping (OCTEON_IRQ_L2C ,1 ,24 , chip, handle_level_irq); -octeon_irq_set_ciu_mapping (OCTEON_IRQ_IPD ,1 ,25 , chip, handle_level_irq); -octeon_irq_set_ciu_mapping (OCTEON_IRQ_PIP ,1 ,26 , chip, handle_level_irq); -octeon_irq_set_ciu_mapping (OCTEON_IRQ_PKO ,1 ,27 , chip, handle_level_irq); -octeon_irq_set_ciu_mapping (OCTEON_IRQ_ZIP ,1 ,28 , chip, handle_level_irq); -octeon_irq_set_ciu_mapping (OCTEON_IRQ_TIM ,1 ,29 , chip, handle_level_irq); -octeon_irq_set_ciu_mapping (OCTEON_IRQ_RAD ,1 ,30 , chip, handle_level_irq); -octeon_irq_set_ciu_mapping (OCTEON_IRQ_KEY ,1 ,31 , chip, handle_level_irq); -octeon_irq_set_ciu_mapping (OCTEON_IRQ_DFA ,1 ,32 , chip, handle_level_irq); -octeon_irq_set_ciu_mapping (OCTEON_IRQ_USBCTL ,1 ,33 , chip, handle_level_irq); -octeon_irq_set_ciu_mapping (OCTEON_IRQ_SLI ,1 ,34 , chip, handle_level_irq); -octeon_irq_set_ciu_mapping (OCTEON_IRQ_DPI ,1 ,35 , chip, handle_level_irq); - -octeon_irq_set_ciu_mapping (OCTEON_IRQ_AGX0 ,1 ,36 , chip, handle_level_irq); - -octeon_irq_set_ciu_mapping (OCTEON_IRQ_AGL ,1 ,46 , chip, handle_level_irq); - -octeon_irq_set_ciu_mapping (OCTEON_IRQ_PTP ,1 ,47 , chip_edge, handle_edge_irq); - -octeon_irq_set_ciu_mapping (OCTEON_IRQ_PEM0 ,1 ,48 , chip, handle_level_irq); -octeon_irq_set_ciu_mapping (OCTEON_IRQ_PEM1 ,1 ,49 , chip, handle_level_irq); -octeon_irq_set_ciu_mapping (OCTEON_IRQ_SRIO0 ,1 ,50 , chip, handle_level_irq); -octeon_irq_set_ciu_mapping (OCTEON_IRQ_SRIO1 ,1 ,51 , chip, handle_level_irq); -octeon_irq_set_ciu_mapping (OCTEON_IRQ_LMC0 ,1 ,52 , chip, handle_level_irq); -octeon_irq_set_ciu_mapping (OCTEON_IRQ_DFM ,1 ,56 , chip, handle_level_irq); -octeon_irq_set_ciu_mapping (OCTEON_IRQ_RST ,1 ,63 , chip, handle_level_irq); +octeon_irq_set_ciu_mapping (i +OCTEON_IRQ_WDOG0 ,1 , i +0 , + ciu_domain, chip_wd, handle_level_irq); + +octeon_irq_set_ciu_mapping (OCTEON_IRQ_UART2 ,1 ,16 , + ciu_domain, chip, handle_level_irq); +octeon_irq_set_ciu_mapping (OCTEON_IRQ_USB1 ,1 ,17 , + ciu_domain, chip, handle_level_irq); +octeon_irq_set_ciu_mapping (OCTEON_IRQ_MII1 ,1 ,18 , + ciu_domain, chip, handle_level_irq); +octeon_irq_set_ciu_mapping (OCTEON_IRQ_NAND ,1 ,19 , + ciu_domain, chip, handle_level_irq); +octeon_irq_set_ciu_mapping (OCTEON_IRQ_MIO ,1 ,20 , + ciu_domain, chip, handle_level_irq); +octeon_irq_set_ciu_mapping (OCTEON_IRQ_IOB ,1 ,21 , + ciu_domain, chip, handle_level_irq); +octeon_irq_set_ciu_mapping (OCTEON_IRQ_FPA ,1 ,22 , + ciu_domain, chip, handle_level_irq); +octeon_irq_set_ciu_mapping (OCTEON_IRQ_POW ,1 ,23 , + ciu_domain, chip, handle_level_irq); +octeon_irq_set_ciu_mapping (OCTEON_IRQ_L2C ,1 ,24 , + ciu_domain, chip, handle_level_irq); +octeon_irq_set_ciu_mapping (OCTEON_IRQ_IPD ,1 ,25 , + ciu_domain, chip, handle_level_irq); +octeon_irq_set_ciu_mapping (OCTEON_IRQ_PIP ,1 ,26 , + ciu_domain, chip, handle_level_irq); +octeon_irq_set_ciu_mapping (OCTEON_IRQ_PKO ,1 ,27 , + ciu_domain, chip, handle_level_irq); +octeon_irq_set_ciu_mapping (OCTEON_IRQ_ZIP ,1 ,28 , + ciu_domain, chip, handle_level_irq); +octeon_irq_set_ciu_mapping (OCTEON_IRQ_TIM ,1 ,29 , + ciu_domain, chip, handle_level_irq); +octeon_irq_set_ciu_mapping (OCTEON_IRQ_RAD ,1 ,30 , + ciu_domain, chip, handle_level_irq); +octeon_irq_set_ciu_mapping (OCTEON_IRQ_KEY ,1 ,31 , + ciu_domain, chip, handle_level_irq); +octeon_irq_set_ciu_mapping (OCTEON_IRQ_DFA ,1 ,32 , + ciu_domain, chip, handle_level_irq); +octeon_irq_set_ciu_mapping (OCTEON_IRQ_USBCTL ,1 ,33 , + ciu_domain, chip, handle_level_irq); +octeon_irq_set_ciu_mapping (OCTEON_IRQ_SLI ,1 ,34 , + ciu_domain, chip, handle_level_irq); +octeon_irq_set_ciu_mapping (OCTEON_IRQ_DPI ,1 ,35 , + ciu_domain, chip, handle_level_irq); + +octeon_irq_set_ciu_mapping (OCTEON_IRQ_AGX0 ,1 ,36 , + ciu_domain, chip, handle_level_irq); + +octeon_irq_set_ciu_mapping (OCTEON_IRQ_AGL ,1 ,46 , + ciu_domain, chip, handle_level_irq); + +octeon_irq_set_ciu_mapping (OCTEON_IRQ_PTP ,1 ,47 , + ciu_domain, chip_edge, handle_edge_irq); + +octeon_irq_set_ciu_mapping (OCTEON_IRQ_PEM0 ,1 ,48 , + ciu_domain, chip, handle_level_irq); +octeon_irq_set_ciu_mapping (OCTEON_IRQ_PEM1 ,1 ,49 , + ciu_domain, chip, handle_level_irq); + octeon_irq_set_ciu_mapping(OCTEON_IRQ_SRIO0, 1, 50,
arch/mips/cavium-octeon/octeon-irq.c static void __init octeon_irq_init_ciu(void) · line 1266
Quoted 10 lines
arch/mips/cavium-octeon/octeon-irq.c +9
-0+ ciu_domain, chip, handle_level_irq); +octeon_irq_set_ciu_mapping (OCTEON_IRQ_SRIO1 ,1 ,51 , + ciu_domain, chip, handle_level_irq); +octeon_irq_set_ciu_mapping (OCTEON_IRQ_LMC0 ,1 ,52 , + ciu_domain, chip, handle_level_irq); +octeon_irq_set_ciu_mapping (OCTEON_IRQ_DFM ,1 ,56 , + ciu_domain, chip, handle_level_irq); +octeon_irq_set_ciu_mapping (OCTEON_IRQ_RST ,1 ,63 , + ciu_domain, chip, handle_level_irq);
Can all these calls be moved into the .map function somehow?
edge vs. level should be driven by dts.
Rob
Quoted 2 lines
arch/mips/cavium-octeon/octeon-irq.c +0
-0/* Enable the CIU lines */ set_c0_status (STATUSF_IP3 |STATUSF_IP2 );
Re: [PATCH v6 4/5] MIPS: Octeon: Setup irq_domains for interrupts.
On 03/02/2012 06:22 AM, Rob Herring wrote:
[...]
Quoted 12 lines
arch/mips/Kconfig config CPU_CAVIUM_OCTEON · line 1435
Quoted 9 lines
arch/mips/Kconfig +1
-0@@ -1432,6 +1432,7 @@ config CPU_CAVIUM_OCTEON select WEAK_ORDERING select CPU_SUPPORTS_HIGHMEM select CPU_SUPPORTS_HUGEPAGES + select IRQ_DOMAINIIRC, Grant has a patch cued up that enables
IRQ_DOMAINfor all of MIPS.
Indeed, I now see it in linux-next. I will remove this one.
Quoted 7 lines
Quoted 7 lines
arch/mips/Kconfig +0
-0help The Cavium Octeon processor is a highly integrated chip containing many ethernet hardware widgets for networking tasks. The processorarch/mips/cavium-octeon/octeon-irq.c +0
-0
[...]
Quoted 16 lines
Quoted 16 lines
arch/mips/cavium-octeon/octeon-irq.c +5
-1+static void __init octeon_irq_set_ciu_mapping (unsigned int irq, +unsigned int line, +unsigned int bit, +struct irq_domain *domain,struct irq_chip *chip,irq_flow_handler_t handler) { +struct irq_data *irqd;union octeon_ciu_chip_data cd;irq_set_chip_and_handler (irq, chip, handler); - cd.l =0 ; cd.s.line = line; cd.s.bit = bit;
Quoted 8 lines
arch/mips/cavium-octeon/octeon-irq.c struct octeon_core_chip_data { · line 67
Quoted 6 lines
irq_set_chip_data(irq, cd.p); octeon_irq_ciu_to_irq[line][bit] = irq;arch/mips/cavium-octeon/octeon-irq.c +4
-0+ + irqd =irq_get_irq_data (irq); + irqd->hwirq = line<<6 | bit; + irqd->domain = domain;I think the domain code will set these.
It is my understanding that the domain code only does this for:
o irq_domain_add_legacy()
o irq_create_direct_mapping()
o irq_create_mapping()
We use none of those. So I do it here.
If there is a better way, I am open to suggestions.
[...]
Quoted 15 lines
Quoted 15 lines
arch/mips/cavium-octeon/octeon-irq.c +4
-0@@ -982,6 +1092,10 @@ static void __init octeon_irq_init_ciu(void)struct irq_chip *chip_mbox;struct irq_chip *chip_wd;struct irq_chip *chip_gpio; +struct device_node *gpio_node; +struct device_node *ciu_node; +struct irq_domain *gpio_domain; +struct irq_domain *ciu_domain;octeon_irq_init_ciu_percpu (); octeon_irq_setup_secondary = octeon_irq_setup_secondary_ciu;@@ -1011,83 +1125,144 @@ static void __init octeon_irq_init_ciu(void)/* Mips internal */ octeon_irq_init_core ();
Quoted 7 lines
arch/mips/cavium-octeon/octeon-irq.c static void __init octeon_irq_init_ciu(void)
Quoted 4 lines
arch/mips/cavium-octeon/octeon-irq.c +4
-0+ gpio_node =of_find_compatible_node (NULL ,NULL ,"cavium,octeon-3860-gpio" ); + ciu_node =of_find_compatible_node (NULL ,NULL ,"cavium,octeon-3860-ciu" ); +/* gpio domain host_data is the base hwirq number. */ + gpio_domain =irq_domain_add_linear (gpio_node,16 ,&octeon_irq_domain_gpio_ops, (void *)16 );It would be better to define a struct here rather than casting a data value to a ptr.
You mean allocate storage for the data somewhere and then pass a pointer to it?
If so, I could, but it would just be adding code and data size just to satisfy some coding style thing...
Or do you want a union of the pointer and my int? That would use the same amount of storage, but add more source code to gain what?
[...]
Quoted 9 lines
Quoted 9 lines
arch/mips/cavium-octeon/octeon-irq.c +9
-0+octeon_irq_set_ciu_mapping (OCTEON_IRQ_PEM0 ,1 ,48 , + ciu_domain, chip, handle_level_irq); +octeon_irq_set_ciu_mapping (OCTEON_IRQ_PEM1 ,1 ,49 , + ciu_domain, chip, handle_level_irq); +octeon_irq_set_ciu_mapping (OCTEON_IRQ_SRIO0 ,1 ,50 , + ciu_domain, chip, handle_level_irq); +octeon_irq_set_ciu_mapping (OCTEON_IRQ_SRIO1 ,1 ,51 , + ciu_domain, chip, handle_level_irq); + octeon_irq_set_ciu_mapping(OCTEON_IRQ_LMC0, 1, 52,
Quoted 9 lines
arch/mips/cavium-octeon/octeon-irq.c static void __init octeon_irq_init_ciu(void) · line 1266
Quoted 6 lines
arch/mips/cavium-octeon/octeon-irq.c +5
-0+ ciu_domain, chip, handle_level_irq); +octeon_irq_set_ciu_mapping (OCTEON_IRQ_DFM ,1 ,56 , + ciu_domain, chip, handle_level_irq); +octeon_irq_set_ciu_mapping (OCTEON_IRQ_RST ,1 ,63 , + ciu_domain, chip, handle_level_irq);Can all these calls be moved into the .map function somehow?
No, the non-OF code using the OCTEON_IRQ_* symbols doesn't use irq_domain, so the .map function would never be used.
Quoted 2 lines
edge vs. level should be driven by dts.
We may have to disagree on this point. Because:
1) edge vs. level can be accurately probed, as we do here.
2) The dts doesnt contain the information.
David Daney
Re: [PATCH v6 4/5] MIPS: Octeon: Setup irq_domains for interrupts.
Quoted 54 lines · David Daney
On 03/02/2012 06:22 AM, Rob Herring wrote:
[...]Quoted 12 lines
arch/mips/Kconfig config CPU_CAVIUM_OCTEON · line 1435
Quoted 9 lines
arch/mips/Kconfig +1
-0@@ -1432,6 +1432,7 @@ config CPU_CAVIUM_OCTEON select WEAK_ORDERING select CPU_SUPPORTS_HIGHMEM select CPU_SUPPORTS_HUGEPAGES + select IRQ_DOMAINIIRC, Grant has a patch cued up that enables
IRQ_DOMAINfor all of MIPS.Indeed, I now see it in linux-next. I will remove this one.
Quoted 7 lines
Quoted 7 lines
arch/mips/Kconfig +0
-0help The Cavium Octeon processor is a highly integrated chip containing many ethernet hardware widgets for networking tasks. The processorarch/mips/cavium-octeon/octeon-irq.c +0
-0[...]
Quoted 16 lines
Quoted 16 lines
arch/mips/cavium-octeon/octeon-irq.c +5
-1+static void __init octeon_irq_set_ciu_mapping (unsigned int irq, +unsigned int line, +unsigned int bit, +struct irq_domain *domain,struct irq_chip *chip,irq_flow_handler_t handler) { +struct irq_data *irqd;union octeon_ciu_chip_data cd;irq_set_chip_and_handler (irq, chip, handler); - cd.l =0 ; cd.s.line = line; cd.s.bit = bit;Quoted 8 lines
arch/mips/cavium-octeon/octeon-irq.c struct octeon_core_chip_data { · line 67
Quoted 6 lines
irq_set_chip_data(irq, cd.p); octeon_irq_ciu_to_irq[line][bit] = irq;arch/mips/cavium-octeon/octeon-irq.c +4
-0+ + irqd =irq_get_irq_data (irq); + irqd->hwirq = line<<6 | bit; + irqd->domain = domain;I think the domain code will set these.
It is my understanding that the domain code only does this for:
o
irq_domain_add_legacy()
Quoted 7 lines
o
irq_create_direct_mapping()o
irq_create_mapping()We use none of those. So I do it here.
If there is a better way, I am open to suggestions.
irq_create_mapping is called by irq_create_of_mapping() which is in turn called by irq_of_parse_and-map(). irq_domain always manages the hwirq and domain values. Driver code cannot manipulate them manually.
g.
Re: [PATCH v6 4/5] MIPS: Octeon: Setup irq_domains for interrupts.
Quoted 59 lines · Grant Likely
Quoted 58 lines · David Daney
On 03/02/2012 06:22 AM, Rob Herring wrote:
[...]Quoted 12 lines
arch/mips/Kconfig config CPU_CAVIUM_OCTEON · line 1435
Quoted 9 lines
arch/mips/Kconfig +1
-0@@ -1432,6 +1432,7 @@ config CPU_CAVIUM_OCTEON select WEAK_ORDERING select CPU_SUPPORTS_HIGHMEM select CPU_SUPPORTS_HUGEPAGES + select IRQ_DOMAINIIRC, Grant has a patch cued up that enables
IRQ_DOMAINfor all of MIPS.Indeed, I now see it in linux-next. I will remove this one.
Quoted 7 lines
Quoted 7 lines
arch/mips/Kconfig +0
-0help The Cavium Octeon processor is a highly integrated chip containing many ethernet hardware widgets for networking tasks. The processorarch/mips/cavium-octeon/octeon-irq.c +0
-0[...]
Quoted 16 lines
Quoted 16 lines
arch/mips/cavium-octeon/octeon-irq.c +5
-1+static void __init octeon_irq_set_ciu_mapping (unsigned int irq, +unsigned int line, +unsigned int bit, +struct irq_domain *domain,struct irq_chip *chip,irq_flow_handler_t handler) { +struct irq_data *irqd;union octeon_ciu_chip_data cd;irq_set_chip_and_handler (irq, chip, handler); - cd.l =0 ; cd.s.line = line; cd.s.bit = bit;Quoted 8 lines
arch/mips/cavium-octeon/octeon-irq.c struct octeon_core_chip_data { · line 67
Quoted 6 lines
irq_set_chip_data(irq, cd.p); octeon_irq_ciu_to_irq[line][bit] = irq;arch/mips/cavium-octeon/octeon-irq.c +4
-0+ + irqd =irq_get_irq_data (irq); + irqd->hwirq = line<<6 | bit; + irqd->domain = domain;I think the domain code will set these.
It is my understanding that the domain code only does this for:
o
irq_domain_add_legacy()o
irq_create_direct_mapping()o
irq_create_mapping()
Quoted 9 lines
Quoted 3 lines
We use none of those. So I do it here.
If there is a better way, I am open to suggestions.
irq_create_mappingis called byirq_create_of_mapping()which is in turn called by irq_of_parse_and-map().irq_domainalways manages the hwirq and domain values. Driver code cannot manipulate them manually.
I really must be missing something.
Given:
1) I must have a mapping between hwirq and irq that I control so that non-OF code using the OCTEON_IRQ_* constants continues to work.
2) irq_create_mapping() will allocate a random irq value if none is already assigned to the hwirq.
Therefore: To avoid having random irq values assigned, I must manually assign them.
David Daney
Re: [PATCH v6 4/5] MIPS: Octeon: Setup irq_domains for interrupts.
Quoted 75 lines · David Daney
Quoted 64 lines · Grant Likely
Quoted 62 lines · David Daney
On 03/02/2012 06:22 AM, Rob Herring wrote:
[...]Quoted 4 lines
Quoted 4 lines
arch/mips/Kconfig +0
-0Quoted 9 lines
arch/mips/Kconfig config CPU_CAVIUM_OCTEON · line 1435
Quoted 5 lines
arch/mips/Kconfig +1
-0@@ -1432,6 +1432,7 @@ config CPU_CAVIUM_OCTEON select WEAK_ORDERING select CPU_SUPPORTS_HIGHMEM select CPU_SUPPORTS_HUGEPAGES + select IRQ_DOMAINIIRC, Grant has a patch cued up that enables
IRQ_DOMAINfor all of MIPS.Indeed, I now see it in linux-next. I will remove this one.
Quoted 10 lines
Quoted 10 lines
arch/mips/Kconfig +0
-0help The Cavium Octeon processor is a highly integrated chipcontaining
many ethernet hardware widgets for networking tasks. The
processorarch/mips/cavium-octeon/octeon-irq.c +0
-0[...]
Quoted 16 lines
Quoted 16 lines
arch/mips/cavium-octeon/octeon-irq.c +5
-1+static void __init octeon_irq_set_ciu_mapping (unsigned int irq, +unsigned int line, +unsigned int bit, +struct irq_domain *domain,struct irq_chip *chip,irq_flow_handler_t handler) { +struct irq_data *irqd;union octeon_ciu_chip_data cd;irq_set_chip_and_handler (irq, chip, handler); - cd.l =0 ; cd.s.line = line; cd.s.bit = bit;Quoted 8 lines
arch/mips/cavium-octeon/octeon-irq.c struct octeon_core_chip_data { · line 67
Quoted 6 lines
irq_set_chip_data(irq, cd.p); octeon_irq_ciu_to_irq[line][bit] = irq;arch/mips/cavium-octeon/octeon-irq.c +4
-0+ + irqd =irq_get_irq_data (irq); + irqd->hwirq = line<<6 | bit; + irqd->domain = domain;I think the domain code will set these.
It is my understanding that the domain code only does this for:
o
irq_domain_add_legacy()o
irq_create_direct_mapping()o
irq_create_mapping()Quoted 9 lines
Quoted 3 lines
We use none of those. So I do it here.
If there is a better way, I am open to suggestions.
irq_create_mappingis called byirq_create_of_mapping()which is in turn called by irq_of_parse_and-map().irq_domainalways manages the hwirq and domain values. Driver code cannot manipulate them manually.
Quoted 6 lines
I really must be missing something.
Given:
1) I must have a mapping between hwirq and irq that I control so that non-OF code using the OCTEON_IRQ_* constants continues to work.
Those defines are what you need to work to get rid of.
Quoted 6 lines
2)
irq_create_mapping()will allocate a random irq value if none is already assigned to the hwirq.Therefore: To avoid having random irq values assigned, I must manually assign them.
So you should be using legacy domain if you need to maintain fixed hwirq to linux irq numbers. "linear" is a bit confusing as it doesn't mean linear 1:1 irq number assignment, but linear search.
Ultimately, for DT boot you should use of_irq_init to scan the dts, and then create a linear domain for each interrupt controller node. You may need to decide on linear vs. legacy at runtime based on having a DT node pointer or not.
Rob
Re: [PATCH v6 4/5] MIPS: Octeon: Setup irq_domains for interrupts.
Quoted 41 lines · Rob Herring
Quoted 40 lines · David Daney
Quoted 39 lines · Grant Likely
arch/mips/cavium-octeon/octeon-irq.c +9
-1+static void __init octeon_irq_set_ciu_mapping (unsigned int irq, +unsigned int line, +unsigned int bit, +struct irq_domain *domain,struct irq_chip *chip,irq_flow_handler_t handler) { +struct irq_data *irqd;union octeon_ciu_chip_data cd;irq_set_chip_and_handler (irq, chip, handler); - cd.l =0 ; cd.s.line = line; cd.s.bit = bit;irq_set_chip_data (irq, cd.p); octeon_irq_ciu_to_irq[line][bit] = irq; + + irqd =irq_get_irq_data (irq); + irqd->hwirq = line<<6 | bit; + irqd->domain = domain;Quoted 5 lines
Quoted 1 line
I think the domain code will set these.
It is my understanding that the domain code only does this for:
o
irq_domain_add_legacy()Quoted 7 lines
o
irq_create_direct_mapping()o
irq_create_mapping()We use none of those. So I do it here.
If there is a better way, I am open to suggestions.
irq_create_mappingis called byirq_create_of_mapping()which is in turn called by irq_of_parse_and-map().irq_domainalways manages the hwirq and domain values. Driver code cannot manipulate them manually.
Quoted 7 lines
Quoted 6 lines
I really must be missing something.
Given:
1) I must have a mapping between hwirq and irq that I control so that non-OF code using the OCTEON_IRQ_* constants continues to work.
Those defines are what you need to work to get rid of.
We are not starting from a blank slate here. There is a lot of in-tree code using these symbols. We cannot make them disappear with wishful thinking.
The first step is a switch to irq_domains using the existing mappings.
After we do that, I have patches to transition some drivers to use the OF mapping via irq_domains. After those are merged, we can work toward getting rid of OCTEON_IRQ_*. But I think it must be the last step in the process, not the first.
Quoted 10 lines
Quoted 7 lines
2)
irq_create_mapping()will allocate a random irq value if none is already assigned to the hwirq.Therefore: To avoid having random irq values assigned, I must manually assign them.
So you should be using legacy domain if you need to maintain fixed hwirq to linux irq numbers. "linear" is a bit confusing as it doesn't mean linear 1:1 irq number assignment, but linear search.
My reading of Grant's code in linux-next directly contradicts this statement. There is no code in irqdomain.c, that I can see, that allows me to have an arbitrary mapping of irq <--> hwirq values.
Quoted 5 lines
Ultimately, for DT boot you should use
of_irq_initto scan the dts, and then create a linear domain for each interrupt controller node. You may need to decide on linear vs. legacy at runtime based on having a DT node pointer or not.
Perhaps, but we need to take the first step before gradually arriving at some Ultimate Solution.
We will also need to handle irq controllers with 2^20 sparsely populated hwirq values, so linear domains will probably be out of the question there.
David Daney
Re: [PATCH v6 4/5] MIPS: Octeon: Setup irq_domains for interrupts.
Quoted 67 lines · David Daney
Quoted 41 lines · Rob Herring
Quoted 40 lines · David Daney
Quoted 39 lines · Grant Likely
(quoted diff) +9
-1+static void __init octeon_irq_set_ciu_mapping(unsigned int irq, + unsigned int line, + unsigned int bit, + struct irq_domain *domain, struct irq_chip *chip, irq_flow_handler_t handler) { + struct irq_data *irqd; union octeon_ciu_chip_data cd; irq_set_chip_and_handler(irq, chip, handler); - cd.l = 0; cd.s.line = line; cd.s.bit = bit; irq_set_chip_data(irq, cd.p); octeon_irq_ciu_to_irq[line][bit] = irq; + + irqd = irq_get_irq_data(irq); + irqd->hwirq = line<< 6 | bit; + irqd->domain = domain;Quoted 5 lines
Quoted 1 line
I think the domain code will set these.
It is my understanding that the domain code only does this for:
o
irq_domain_add_legacy()Quoted 7 lines
o
irq_create_direct_mapping()o
irq_create_mapping()We use none of those. So I do it here.
If there is a better way, I am open to suggestions.
irq_create_mappingis called byirq_create_of_mapping()which is in turn called by irq_of_parse_and-map().irq_domainalways manages the hwirq and domain values. Driver code cannot manipulate them manually.Quoted 7 lines
Quoted 6 lines
I really must be missing something.
Given:
1) I must have a mapping between hwirq and irq that I control so that non-OF code using the OCTEON_IRQ_* constants continues to work.
Those defines are what you need to work to get rid of.
We are not starting from a blank slate here. There is a lot of in-tree code using these symbols. We cannot make them disappear with wishful thinking.
The first step is a switch to
irq_domainsusing the existing mappings.After we do that, I have patches to transition some drivers to use the OF mapping via
irq_domains. After those are merged, we can work toward getting rid of OCTEON_IRQ_*. But I think it must be the last step in the process, not the first.Quoted 7 lines
Quoted 7 lines
2)
irq_create_mapping()will allocate a random irq value if none is already assigned to the hwirq.Therefore: To avoid having random irq values assigned, I must manually assign them.
Quoted 7 lines
Quoted 3 lines
So you should be using legacy domain if you need to maintain fixed hwirq to linux irq numbers. "linear" is a bit confusing as it doesn't mean linear 1:1 irq number assignment, but linear search.
My reading of Grant's code in linux-next directly contradicts this statement. There is no code in
irqdomain.c, that I can see, that allows me to have an arbitrary mapping of irq <--> hwirq values.
There are 4 kinds of mappings available; legacy, linear, radix and nomap.
Ignore nomap and radix; you don't want them.
legacy maps a contiguous range of hwirq numbers to a contiguous range of linux irq numbers. To preserve the exising #define mappings but still add DT support, this is the one that you want. The downside is that it requires all the irq_descs to be allocated ahead of time (which probably isn't a problem for you).
The linear map has a linear reverse map lookup table that allows arbitrary irq <--> hwirq mappings. This mapping is preferred, but it doesn't work if you need to preserve #defined irq mappings.
g.
Re: [PATCH v6 4/5] MIPS: Octeon: Setup irq_domains for interrupts.
Quoted 72 lines · Grant Likely
Quoted 71 lines · David Daney
Quoted 41 lines · Rob Herring
Quoted 40 lines · David Daney
Quoted 39 lines · Grant Likely
(quoted diff) +9
-1+static void __init octeon_irq_set_ciu_mapping(unsigned int irq, + unsigned int line, + unsigned int bit, + struct irq_domain *domain, struct irq_chip *chip, irq_flow_handler_t handler) { + struct irq_data *irqd; union octeon_ciu_chip_data cd; irq_set_chip_and_handler(irq, chip, handler); - cd.l = 0; cd.s.line = line; cd.s.bit = bit; irq_set_chip_data(irq, cd.p); octeon_irq_ciu_to_irq[line][bit] = irq; + + irqd = irq_get_irq_data(irq); + irqd->hwirq = line<< 6 | bit; + irqd->domain = domain;Quoted 5 lines
Quoted 1 line
I think the domain code will set these.
It is my understanding that the domain code only does this for:
o
irq_domain_add_legacy()Quoted 7 lines
o
irq_create_direct_mapping()o
irq_create_mapping()We use none of those. So I do it here.
If there is a better way, I am open to suggestions.
irq_create_mappingis called byirq_create_of_mapping()which is in turn called by irq_of_parse_and-map().irq_domainalways manages the hwirq and domain values. Driver code cannot manipulate them manually.Quoted 7 lines
Quoted 6 lines
I really must be missing something.
Given:
1) I must have a mapping between hwirq and irq that I control so that non-OF code using the OCTEON_IRQ_* constants continues to work.
Those defines are what you need to work to get rid of.
We are not starting from a blank slate here. There is a lot of in-tree code using these symbols. We cannot make them disappear with wishful thinking.
The first step is a switch to
irq_domainsusing the existing mappings.After we do that, I have patches to transition some drivers to use the OF mapping via
irq_domains. After those are merged, we can work toward getting rid of OCTEON_IRQ_*. But I think it must be the last step in the process, not the first.Quoted 10 lines
Quoted 7 lines
2)
irq_create_mapping()will allocate a random irq value if none is already assigned to the hwirq.Therefore: To avoid having random irq values assigned, I must manually assign them.
So you should be using legacy domain if you need to maintain fixed hwirq to linux irq numbers. "linear" is a bit confusing as it doesn't mean linear 1:1 irq number assignment, but linear search.
Quoted 6 lines
Quoted 3 lines
My reading of Grant's code in linux-next directly contradicts this statement. There is no code in
irqdomain.c, that I can see, that allows me to have an arbitrary mapping of irq<--> hwirq values.There are 4 kinds of mappings available; legacy, linear, radix and nomap.
Yes, I had discovered that.
Quoted 5 lines
Ignore nomap and radix; you don't want them.
legacy maps a contiguous range of hwirq numbers to a contiguous range of linux irq numbers. To preserve the exising #define mappings but still add DT support, this is the one that you want.
This is precisely the point that you and Rob seem to have missed in the last three or four back-and-forths about this.
Probably I have not explained well enough why legacy will not work.
We have three different interrupt controllers (although only one is currently in-tree). hwirq to irq mapping for them is more or less as follows:
irq hwirqCIU hwirqCIU2 hwirqCIU3
----------------------------------------------------------------------
OCTEON_IRQ_USB0 56 81 934562 OCTEON_IRQ_TWSI 45 224 100543 OCTEON_IRQ_UART0 34 228 4572
.
.
.
Now what we notice here is that there is no possible 1:1 linearly increasing mapping possible for the irq and *all* three hwirq sets. We want a single binary that contains support for all three interrupt controllers, so the OCTEON_IRQ_* values have to be the same for all three interrupt controllers. Because of this, legacy mapping is *impossible*.
Since the possible ranges of the hwirq values is very large and quite sparse, probably the radix mapping will be required.
Also to support non-OF drivers and architecture specific code for the near future, I really think the existing IRQ values *must* be preserved.
Therefore, as I said above, we need a way for my SOC/board code to specify the mapping.
Perhaps we need to add an optional function to struct irq_domain_ops that would allow the default mapping to be overridden on a per irq_domain basis.
Otherwise, I think I will have to keep poking into the internal irq_domain data structures to get the mappings I want.
What do you think?
David Daney
Re: [PATCH v6 4/5] MIPS: Octeon: Setup irq_domains for interrupts.
Quoted 91 lines · David Daney
Quoted 74 lines · Grant Likely
Quoted 72 lines · David Daney
Quoted 41 lines · Rob Herring
Quoted 40 lines · David Daney
Quoted 39 lines · Grant Likely
(quoted diff) +9
-1+static void __init octeon_irq_set_ciu_mapping(unsigned int irq, + unsigned int line, + unsigned int bit, + struct irq_domain *domain, struct irq_chip *chip, irq_flow_handler_t handler) { + struct irq_data *irqd; union octeon_ciu_chip_data cd; irq_set_chip_and_handler(irq, chip, handler); - cd.l = 0; cd.s.line = line; cd.s.bit = bit; irq_set_chip_data(irq, cd.p); octeon_irq_ciu_to_irq[line][bit] = irq; + + irqd = irq_get_irq_data(irq); + irqd->hwirq = line<< 6 | bit; + irqd->domain = domain;Quoted 5 lines
Quoted 1 line
I think the domain code will set these.
It is my understanding that the domain code only does this for:
o
irq_domain_add_legacy()Quoted 7 lines
o
irq_create_direct_mapping()o
irq_create_mapping()We use none of those. So I do it here.
If there is a better way, I am open to suggestions.
irq_create_mappingis called byirq_create_of_mapping()which is in turn called by irq_of_parse_and-map().irq_domainalways manages the hwirq and domain values. Driver code cannot manipulate them manually.Quoted 7 lines
Quoted 6 lines
I really must be missing something.
Given:
1) I must have a mapping between hwirq and irq that I control so that non-OF code using the OCTEON_IRQ_* constants continues to work.
Those defines are what you need to work to get rid of.
We are not starting from a blank slate here. There is a lot of in-tree code using these symbols. We cannot make them disappear with wishful thinking.
The first step is a switch to
irq_domainsusing the existing mappings.After we do that, I have patches to transition some drivers to use the OF mapping via
irq_domains. After those are merged, we can work toward getting rid of OCTEON_IRQ_*. But I think it must be the last step in the process, not the first.Quoted 11 lines
Quoted 7 lines
2)
irq_create_mapping()will allocate a random irq value if none is already assigned to the hwirq.Therefore: To avoid having random irq values assigned, I must manually assign them.
So you should be using legacy domain if you need to maintain fixed hwirq
to linux irq numbers. "linear" is a bit confusing as it doesn't mean linear 1:1 irq number assignment, but linear search.Quoted 6 lines
Quoted 3 lines
My reading of Grant's code in linux-next directly contradicts this statement. There is no code in
irqdomain.c, that I can see, that allows me to have an arbitrary mapping of irq<--> hwirq values.There are 4 kinds of mappings available; legacy, linear, radix and nomap.
Yes, I had discovered that.
Quoted 6 lines
Ignore nomap and radix; you don't want them.
legacy maps a contiguous range of hwirq numbers to a contiguous range of linux irq numbers. To preserve the exising #define mappings but still add
DT support, this is the one that you want.
Quoted 8 lines
This is precisely the point that you and Rob seem to have missed in the last three or four back-and-forths about this.
Probably I have not explained well enough why legacy will not work.
We have three different interrupt controllers (although only one is currently in-tree). hwirq to irq mapping for them is more or less as follows:
I'll just repeat what others have said: if it's not upstream it doesn't exist.
We have no knowledge about out of tree h/w to understand what you need
Quoted 8 lines
irq hwirqCIU hwirqCIU2 hwirqCIU3
----------------------------------------------------------------------OCTEON_IRQ_USB0 56 81 934562 OCTEON_IRQ_TWSI 45 224 100543 OCTEON_IRQ_UART0 34 228 4572.
.
.
How many actual hwirqs in each case and what is the range?
So for CIU3, it seems you would need to use a radix tree. CIU2 is probably borderline depending on what is the max number. But because you don't yet have code in tree for either yet, you can use a linear domain for now. It shouldn't be hard to switch from linear to radix later.
Quoted 6 lines
Now what we notice here is that there is no possible 1:1 linearly increasing mapping possible for the irq and *all* three hwirq sets. We want a single binary that contains support for all three interrupt controllers, so the OCTEON_IRQ_* values have to be the same for all three interrupt controllers. Because of this, legacy mapping is *impossible*.
OCTEON_IRQ_* values need to go. You may not have to do that now, but certainly before doing support for CIU2 and CIU3 you do. Those platforms should be DT only.
Quoted 4 lines
Since the possible ranges of the hwirq values is very large and quite sparse, probably the radix mapping will be required.
Yes. You're not the only one with this issue.
Quoted 3 lines
Also to support non-OF drivers and architecture specific code for the near future, I really think the existing IRQ values *must* be preserved.
For a legacy boot yes. But when you boot with DT, you should not need them. This is certainly possible as several ARM platforms do this. You need to start with minimal set of drivers enabled for DT and add them back in 1 by 1.
Rob
Quoted 13 lines
Therefore, as I said above, we need a way for my SOC/board code to specify the mapping.
Perhaps we need to add an optional function to struct
irq_domain_opsthat would allow the default mapping to be overridden on a perirq_domainbasis.Otherwise, I think I will have to keep poking into the internal
irq_domaindata structures to get the mappings I want.What do you think?
David Daney
Re: [PATCH v6 4/5] MIPS: Octeon: Setup irq_domains for interrupts.
Quoted 1 line · Rob Herring
On 03/09/2012 12:45 PM, David Daney wrote:
[...]
Quoted 44 lines
Quoted 6 lines
Probably I have not explained well enough why legacy will not work.
We have three different interrupt controllers (although only one is currently in-tree). hwirq to irq mapping for them is more or less as follows:
I'll just repeat what others have said: if it's not upstream it doesn't exist.
We have no knowledge about out of tree h/w to understand what you need
Quoted 8 lines
irq hwirqCIU hwirqCIU2 hwirqCIU3
----------------------------------------------------------------------OCTEON_IRQ_USB0 56 81 934562 OCTEON_IRQ_TWSI 45 224 100543 OCTEON_IRQ_UART0 34 228 4572.
.
.How many actual hwirqs in each case and what is the range?
So for CIU3, it seems you would need to use a radix tree. CIU2 is probably borderline depending on what is the max number. But because you don't yet have code in tree for either yet, you can use a linear domain for now. It shouldn't be hard to switch from linear to radix later.
Quoted 6 lines
Now what we notice here is that there is no possible 1:1 linearly increasing mapping possible for the irq and *all* three hwirq sets. We want a single binary that contains support for all three interrupt controllers, so the OCTEON_IRQ_* values have to be the same for all three interrupt controllers. Because of this, legacy mapping is *impossible*.
OCTEON_IRQ_* values need to go. You may not have to do that now, but certainly before doing support for CIU2 and CIU3 you do. Those platforms should be DT only.
Quoted 4 lines
Since the possible ranges of the hwirq values is very large and quite sparse, probably the radix mapping will be required.
Quoted 8 lines
Yes. You're not the only one with this issue.
Quoted 3 lines
Also to support non-OF drivers and architecture specific code for the near future, I really think the existing IRQ values *must* be preserved.
For a legacy boot yes. But when you boot with DT, you should not need them.
It is not a matter of how the system is booted, rather what all the drivers are expecting...
Quoted 4 lines
This is certainly possible as several ARM platforms do this. You need to start with minimal set of drivers enabled for DT and add them back in 1 by 1.
What I don't understand about this is what happens during the transition?
What if a shared interrupt were referred from one non-OF driver by its symbolic OCTEON_IRQ_? value, and from a second driver by its hwirq value extracted from the DT? In that case you would be referring to the same interrupt line by two different irq values, clearly that should be prevented.
At a minimum, the change made for each converted driver would have to include: removing the OCTEON_IRQ_? values, Maintain a list of hwirqs that are outside of the domain and report this by the.map() function, and then update this list.
David Daney
Quoted 17 lines
Rob
Quoted 13 lines
Therefore, as I said above, we need a way for my SOC/board code to specify the mapping.
Perhaps we need to add an optional function to struct
irq_domain_opsthat would allow the default mapping to be overridden on a perirq_domainbasis.Otherwise, I think I will have to keep poking into the internal
irq_domaindata structures to get the mappings I want.What do you think?
David Daney
Re: [PATCH v6 4/5] MIPS: Octeon: Setup irq_domains for interrupts.
Quoted 72 lines · David Daney
Quoted 1 line · Rob Herring
On 03/09/2012 12:45 PM, David Daney wrote:
[...]
Quoted 44 lines
Quoted 6 lines
Probably I have not explained well enough why legacy will not work.
We have three different interrupt controllers (although only one is currently in-tree). hwirq to irq mapping for them is more or less as follows:
I'll just repeat what others have said: if it's not upstream it doesn't exist.
We have no knowledge about out of tree h/w to understand what you need
Quoted 8 lines
irq hwirqCIU hwirqCIU2 hwirqCIU3
----------------------------------------------------------------------OCTEON_IRQ_USB0 56 81 934562 OCTEON_IRQ_TWSI 45 224 100543 OCTEON_IRQ_UART0 34 228 4572.
.
.How many actual hwirqs in each case and what is the range?
So for CIU3, it seems you would need to use a radix tree. CIU2 is probably borderline depending on what is the max number. But because you don't yet have code in tree for either yet, you can use a linear domain for now. It shouldn't be hard to switch from linear to radix later.
Quoted 6 lines
Now what we notice here is that there is no possible 1:1 linearly increasing mapping possible for the irq and *all* three hwirq sets. We want a single binary that contains support for all three interrupt controllers, so the OCTEON_IRQ_* values have to be the same for all three interrupt controllers. Because of this, legacy mapping is *impossible*.
OCTEON_IRQ_* values need to go. You may not have to do that now, but certainly before doing support for CIU2 and CIU3 you do. Those platforms should be DT only.
Quoted 4 lines
Since the possible ranges of the hwirq values is very large and quite sparse, probably the radix mapping will be required.
Quoted 8 lines
Yes. You're not the only one with this issue.
Quoted 3 lines
Also to support non-OF drivers and architecture specific code for the near future, I really think the existing IRQ values *must* be preserved.
For a legacy boot yes. But when you boot with DT, you should not need them.
It is not a matter of how the system is booted, rather what all the drivers are expecting...
Quoted 4 lines
This is certainly possible as several ARM platforms do this. You need to start with minimal set of drivers enabled for DT and add them back in 1 by 1.
What I don't understand about this is what happens during the transition?
What if a shared interrupt were referred from one non-OF driver by its symbolic
OCTEON_IRQ_? value, and from a second driver by its hwirq value extracted from the DT? In that case you would be referring to the same interrupt line by two different irq values, clearly that should be prevented.
Quoted 4 lines
At a minimum, the change made for each converted driver would have to
include: removing theOCTEON_IRQ_? values, Maintain a list of hwirqs that are outside of the domain and report this bythe.map()function, and then update this list.
Drivers should only deal with Linux irq numbers and should only get them as a resource passed into the driver probe. This is true with or without DT. I only see 2 drivers directly using OCTEON_IRQ defines: ethernet and watchdog. Fix them. The serial setup code needs to use resources as well. The other place you will see irq defines is platform device declarations (i2c is an example in your case). For DT boot, you would not register the static devices and the devices should be created dynamically.
Rob
Re: [PATCH v6 4/5] MIPS: Octeon: Setup irq_domains for interrupts.
In reply to David DaneyQuoted 57 lines · David Daney
On 03/02/2012 06:22 AM, Rob Herring wrote:
[...]Quoted 12 lines
arch/mips/Kconfig config CPU_CAVIUM_OCTEON · line 1435
Quoted 9 lines
arch/mips/Kconfig +1
-0@@ -1432,6 +1432,7 @@ config CPU_CAVIUM_OCTEON select WEAK_ORDERING select CPU_SUPPORTS_HIGHMEM select CPU_SUPPORTS_HUGEPAGES + select IRQ_DOMAINIIRC, Grant has a patch cued up that enables
IRQ_DOMAINfor all of MIPS.Indeed, I now see it in linux-next. I will remove this one.
Quoted 10 lines
Quoted 10 lines
arch/mips/Kconfig +0
-0help The Cavium Octeon processor is a highly integrated chipcontaining
many ethernet hardware widgets for networking tasks. The
processorarch/mips/cavium-octeon/octeon-irq.c +0
-0[...]
Quoted 16 lines
Quoted 16 lines
arch/mips/cavium-octeon/octeon-irq.c +5
-1+static void __init octeon_irq_set_ciu_mapping (unsigned int irq, +unsigned int line, +unsigned int bit, +struct irq_domain *domain,struct irq_chip *chip,irq_flow_handler_t handler) { +struct irq_data *irqd;union octeon_ciu_chip_data cd;irq_set_chip_and_handler (irq, chip, handler); - cd.l =0 ; cd.s.line = line; cd.s.bit = bit;Quoted 8 lines
arch/mips/cavium-octeon/octeon-irq.c struct octeon_core_chip_data { · line 67
Quoted 6 lines
irq_set_chip_data(irq, cd.p); octeon_irq_ciu_to_irq[line][bit] = irq;arch/mips/cavium-octeon/octeon-irq.c +4
-0+ + irqd =irq_get_irq_data (irq); + irqd->hwirq = line<<6 | bit; + irqd->domain = domain;I think the domain code will set these.
It is my understanding that the domain code only does this for:
o
irq_domain_add_legacy()
Quoted 7 lines
o
irq_create_direct_mapping()o
irq_create_mapping()We use none of those. So I do it here.
If there is a better way, I am open to suggestions.
How do you convert local h/w irq controller numbers in the dts to linux irq #'s?
Quoted 28 lines
[...]
Quoted 15 lines
Quoted 15 lines
arch/mips/cavium-octeon/octeon-irq.c +4
-0@@ -982,6 +1092,10 @@ static void __init octeon_irq_init_ciu(void)struct irq_chip *chip_mbox;struct irq_chip *chip_wd;struct irq_chip *chip_gpio; +struct device_node *gpio_node; +struct device_node *ciu_node; +struct irq_domain *gpio_domain; +struct irq_domain *ciu_domain;octeon_irq_init_ciu_percpu (); octeon_irq_setup_secondary = octeon_irq_setup_secondary_ciu;@@ -1011,83 +1125,144 @@ static void __init octeon_irq_init_ciu(void)/* Mips internal */ octeon_irq_init_core ();Quoted 10 lines
arch/mips/cavium-octeon/octeon-irq.c static void __init octeon_irq_init_ciu(void) · line 1134
Quoted 7 lines
arch/mips/cavium-octeon/octeon-irq.c +4
-0+ gpio_node =of_find_compatible_node (NULL ,NULL ,"cavium,octeon-3860-gpio" ); + ciu_node =of_find_compatible_node (NULL ,NULL ,"cavium,octeon-3860-ciu" ); +/* gpio domain host_data is the base hwirq number. */ + gpio_domain =irq_domain_add_linear (gpio_node,16 ,&octeon_irq_domain_gpio_ops, (void *)16 );It would be better to define a struct here rather than casting a data value to a ptr.
Quoted 8 lines
You mean allocate storage for the data somewhere and then pass a pointer to it?
If so, I could, but it would just be adding code and data size just to satisfy some coding style thing...
Or do you want a union of the pointer and my int? That would use the same amount of storage, but add more source code to gain what?
The former. It's better style, less error prone and easily expanded if more data is needed in the future.
Quoted 18 lines
[...]
Quoted 16 lines
Quoted 15 lines
arch/mips/cavium-octeon/octeon-irq.c +14
-0+octeon_irq_set_ciu_mapping (OCTEON_IRQ_PEM0 ,1 ,48 , + ciu_domain, chip, handle_level_irq); +octeon_irq_set_ciu_mapping (OCTEON_IRQ_PEM1 ,1 ,49 , + ciu_domain, chip, handle_level_irq); +octeon_irq_set_ciu_mapping (OCTEON_IRQ_SRIO0 ,1 ,50 , + ciu_domain, chip, handle_level_irq); +octeon_irq_set_ciu_mapping (OCTEON_IRQ_SRIO1 ,1 ,51 , + ciu_domain, chip, handle_level_irq); +octeon_irq_set_ciu_mapping (OCTEON_IRQ_LMC0 ,1 ,52 , + ciu_domain, chip, handle_level_irq); +octeon_irq_set_ciu_mapping (OCTEON_IRQ_DFM ,1 ,56 , + ciu_domain, chip, handle_level_irq); +octeon_irq_set_ciu_mapping (OCTEON_IRQ_RST ,1 ,63 , + ciu_domain, chip, handle_level_irq);
Quoted 6 lines
Quoted 2 lines
Can all these calls be moved into the .map function somehow?
No, the non-OF code using the OCTEON_IRQ_* symbols doesn't use
irq_domain, so the .map function would never be used.
.map is called for legacy domains during domain add.
Quoted 7 lines
Quoted 3 lines
edge vs. level should be driven by dts.
We may have to disagree on this point. Because:
1) edge vs. level can be accurately probed, as we do here.
Looks like you are just hard coding it here. Where do you read something that tells you the interrupt is level or edge?
Rob
Quoted 5 lines
2) The dts doesnt contain the information.
David Daney
Re: [PATCH v6 4/5] MIPS: Octeon: Setup irq_domains for interrupts.
Quoted 12 lines · Rob Herring
Quoted 11 lines · David Daney
arch/mips/cavium-octeon/octeon-irq.c +4
-0+ + irqd =irq_get_irq_data (irq); + irqd->hwirq = line<<6 | bit; + irqd->domain = domain;Quoted 1 line
I think the domain code will set these.
It is my understanding that the domain code only does this for:
o
irq_domain_add_legacy()o
irq_create_direct_mapping()
Quoted 7 lines
Quoted 5 lines
o
irq_create_mapping()We use none of those. So I do it here.
If there is a better way, I am open to suggestions.
How do you convert local h/w irq controller numbers in the dts to linux irq #'s?
With the calls to octeon_irq_set_ciu_mapping() ...
[...]
Quoted 16 lines
Quoted 15 lines
Quoted 15 lines
Quoted 15 lines
arch/mips/cavium-octeon/octeon-irq.c +14
-0+octeon_irq_set_ciu_mapping (OCTEON_IRQ_PEM0 ,1 ,48 , + ciu_domain, chip, handle_level_irq); +octeon_irq_set_ciu_mapping (OCTEON_IRQ_PEM1 ,1 ,49 , + ciu_domain, chip, handle_level_irq); +octeon_irq_set_ciu_mapping (OCTEON_IRQ_SRIO0 ,1 ,50 , + ciu_domain, chip, handle_level_irq); +octeon_irq_set_ciu_mapping (OCTEON_IRQ_SRIO1 ,1 ,51 , + ciu_domain, chip, handle_level_irq); +octeon_irq_set_ciu_mapping (OCTEON_IRQ_LMC0 ,1 ,52 , + ciu_domain, chip, handle_level_irq); +octeon_irq_set_ciu_mapping (OCTEON_IRQ_DFM ,1 ,56 , + ciu_domain, chip, handle_level_irq); +octeon_irq_set_ciu_mapping (OCTEON_IRQ_RST ,1 ,63 , + ciu_domain, chip, handle_level_irq);
Quoted 8 lines
Quoted 6 lines
Quoted 3 lines
Quoted 1 line
[...]
edge vs. level should be driven by dts.
We may have to disagree on this point. Because:
1) edge vs. level can be accurately probed, as we do here.
Looks like you are just hard coding it here. Where do you read something that tells you the interrupt is level or edge?
We probe for the type of interrupt controller by reading the SOC identifier number, although we can get the same information from the dts.
Once we know the type of interrupt controller, the level vs. edge is known a priori, and that knowlege is encoded in all these octeon_irq_set_ciu_mapping() calls.
And on top of this...
Quoted 2 lines
Quoted 2 lines
2) The dts doesn't contain the information.
So it is kind of a moot point.
It is not some sort of generic interrupt controller that can be configured in different ways, each line has certain properties endowed upon it by the chip designers, and once a line is assigned a particular configuration, it is never changed in future generations.
For external devices attached to the GPIO interrupt lines, things are different, we can only know the triggering via the dts, and lo and behold... it is there and we use it.
David Daney
Re: [PATCH v6 4/5] MIPS: Octeon: Setup irq_domains for interrupts.
In reply to David DaneyQuoted 61 lines · David Daney
From: David Daney <[email protected]>
Select
IRQ_DOMAINso the coreirq_domaincode and supplyirq_create_of_mapping().Signed-off-by David Daney <[email protected]>--- arch/mips/Kconfig | 1 + arch/mips/cavium-octeon/octeon-irq.c | 301 +++++++++++++++++++++++++++------- 2 files changed, 239 insertions(+), 63 deletions(-)arch/mips/Kconfig +1
-0@@ -1432,6 +1432,7 @@ config CPU_CAVIUM_OCTEON select WEAK_ORDERING select CPU_SUPPORTS_HIGHMEM select CPU_SUPPORTS_HUGEPAGES + select IRQ_DOMAIN help The Cavium Octeon processor is a highly integrated chip containing many ethernet hardware widgets for networking tasks. The processorarch/mips/cavium-octeon/octeon-irq.c +8
-2@@ -3,14 +3,16 @@* License. See the file "COPYING" in the main directory of this archive * for more details. * -* Copyright (C) 2004-2008, 2009, 2010, 2011 Cavium Networks +* Copyright (C) 2004-2008, 2009, 2010, 2011, 2012 Cavium Networks */ #include <linux/interrupt.h> +#include <linux/irqdomain.h> #include <linux/bitops.h> #include <linux/percpu.h> #include <linux/irq.h> #include <linux/smp.h> +#include <linux/of.h> #include <asm/octeon/octeon.h> @@ -42,20 +44,27 @@ struct octeon_core_chip_data {static struct octeon_core_chip_data octeon_irq_core_chip_data[MIPS_CORE_IRQ_LINES ]; -static void __init octeon_irq_set_ciu_mapping (int irq,int line,int bit, +static void __init octeon_irq_set_ciu_mapping (unsigned int irq, +unsigned int line, +unsigned int bit, +struct irq_domain *domain,struct irq_chip *chip,irq_flow_handler_t handler) { +struct irq_data *irqd;union octeon_ciu_chip_data cd;irq_set_chip_and_handler (irq, chip, handler);
arch/mips/cavium-octeon/octeon-irq.c struct octeon_core_chip_data { · line 66
Quoted 10 lines
arch/mips/cavium-octeon/octeon-irq.c +3
-1- cd.l =0 ; cd.s.line = line; cd.s.bit = bit;irq_set_chip_data (irq, cd.p); octeon_irq_ciu_to_irq[line][bit] = irq; + + irqd =irq_get_irq_data (irq); + irqd->hwirq = line <<6 | bit;
irqdomain sets up hwirq for you. Don't set it manually because it will mess up irqdomain mappings.
arch/mips/cavium-octeon/octeon-irq.c struct octeon_core_chip_data { · line 67
Quoted 1 line
arch/mips/cavium-octeon/octeon-irq.c +1
-0+ irqd->domain = domain;
Ditto here; irqdomain manages the domain pointer internally.
Quoted 52 lines
arch/mips/cavium-octeon/octeon-irq.c +45
-0}static int octeon_coreid_for_cpu (int cpu)@@ -855,6 +864,107 @@ static struct irq_chip octeon_irq_chip_ciu_wd = { .irq_mask = octeon_irq_dummy_mask, }; +static int octeon_irq_gpio_xlat (struct irq_domain *d, +struct device_node *node, +const u32 *intspec, +unsigned int intsize, +unsigned long *out_hwirq, +unsigned int *out_type) +{ +unsigned int irq; +unsigned int type; +unsigned int ciu =0 , bit =0 ; +unsigned int pin; +unsigned int trigger; +bool set_edge_handler = false; + +if (d->of_node != node) +return -EINVAL ; + +if (intsize <2 ) +return -EINVAL ; + + pin = intspec[0 ]; +if (pin >=16 ) +return -EINVAL ; + + trigger = intspec[1 ]; + +switch (trigger) { +case 1 : + type =IRQ_TYPE_EDGE_RISING ; + set_edge_handler = true; +break ; +case 2 : + type =IRQ_TYPE_EDGE_FALLING ; + set_edge_handler = true; +break ; +case 4 : + type =IRQ_TYPE_LEVEL_HIGH ; +break ; +case 8 : + type =IRQ_TYPE_LEVEL_LOW ; +break ; +default : +pr_err ("Error: (%s) Invalid irq trigger specification: %x\n" , + node->name, + trigger);
arch/mips/cavium-octeon/octeon-irq.c static struct irq_chip octeon_irq_chip_ciu_wd = { · line 921
Quoted 10 lines
arch/mips/cavium-octeon/octeon-irq.c +10
-0+ type =IRQ_TYPE_LEVEL_LOW ; +break ; + } + *out_type = type; + *out_hwirq = ((unsigned long )d->host_data) + pin; + + ciu = *out_hwirq >>6 ; + bit = *out_hwirq &0x3f ; + + irq = octeon_irq_ciu_to_irq[ciu][bit];
Again; this is overstepping onto irqdomain responsibility. Don't set up the irq in the xlate routine; only parse the date and if you need to store extra data like 'set_edge_handler' (using the hwirq number as the key). The irq setup must be done in the .map callback which will be passed the actual irq number to be used.
Quoted 268 lines
arch/mips/cavium-octeon/octeon-irq.c +171
-60+ +if (set_edge_handler) +__irq_set_handler (irq, handle_edge_irq,0 ,NULL ); + +return 0 ; +} + +static int octeon_irq_ciu_xlat (struct irq_domain *d, +struct device_node *node, +const u32 *intspec, +unsigned int intsize, +unsigned long *out_hwirq, +unsigned int *out_type) +{ +unsigned int ciu, bit; + + ciu = intspec[0 ]; + bit = intspec[1 ]; + +if (ciu >1 || bit >63 ) +return -EINVAL ; + +if (octeon_irq_ciu_to_irq[ciu][bit] ==0 ) +return -EINVAL ; + + *out_hwirq = (ciu <<6 ) | bit; + *out_type =0 ; + +return 0 ; +} +static int octeon_irq_dummy_map (struct irq_domain *d, +unsigned int virq,irq_hw_number_t hw) +{ +return 0 ; +} + +static struct irq_domain_ops octeon_irq_domain_ciu_ops = { + .map = octeon_irq_dummy_map, + .xlate = octeon_irq_ciu_xlat, +}; + +static struct irq_domain_ops octeon_irq_domain_gpio_ops = { + .map = octeon_irq_dummy_map, + .xlate = octeon_irq_gpio_xlat, +}; +static void octeon_irq_ip2_v1 (void ) {const unsigned long core_id =cvmx_get_core_num ();@@ -982,6 +1092,10 @@ static void __init octeon_irq_init_ciu(void)struct irq_chip *chip_mbox;struct irq_chip *chip_wd;struct irq_chip *chip_gpio; +struct device_node *gpio_node; +struct device_node *ciu_node; +struct irq_domain *gpio_domain; +struct irq_domain *ciu_domain;octeon_irq_init_ciu_percpu (); octeon_irq_setup_secondary = octeon_irq_setup_secondary_ciu;@@ -1011,83 +1125,144 @@ static void __init octeon_irq_init_ciu(void)/* Mips internal */ octeon_irq_init_core (); + gpio_node =of_find_compatible_node (NULL ,NULL ,"cavium,octeon-3860-gpio" ); + ciu_node =of_find_compatible_node (NULL ,NULL ,"cavium,octeon-3860-ciu" ); +/* gpio domain host_data is the base hwirq number. */ + gpio_domain =irq_domain_add_linear (gpio_node,16 , &octeon_irq_domain_gpio_ops, (void *)16 ); + ciu_domain =irq_domain_add_tree (ciu_node, &octeon_irq_domain_ciu_ops,NULL ); +/* CIU_0 */ for (i =0 ; i <16 ; i++) -octeon_irq_set_ciu_mapping (i +OCTEON_IRQ_WORKQ0 ,0 , i +0 , chip, handle_level_irq); +octeon_irq_set_ciu_mapping (i +OCTEON_IRQ_WORKQ0 ,0 , i +0 , + ciu_domain, chip, handle_level_irq); +for (i =0 ; i <16 ; i++) -octeon_irq_set_ciu_mapping (i +OCTEON_IRQ_GPIO0 ,0 , i +16 , chip_gpio, handle_level_irq); +octeon_irq_set_ciu_mapping (i +OCTEON_IRQ_GPIO0 ,0 , i +16 , + gpio_domain, chip_gpio, handle_level_irq); -octeon_irq_set_ciu_mapping (OCTEON_IRQ_MBOX0 ,0 ,32 , chip_mbox, handle_percpu_irq); -octeon_irq_set_ciu_mapping (OCTEON_IRQ_MBOX1 ,0 ,33 , chip_mbox, handle_percpu_irq); +octeon_irq_set_ciu_mapping (OCTEON_IRQ_MBOX0 ,0 ,32 , + ciu_domain, chip_mbox, handle_percpu_irq); +octeon_irq_set_ciu_mapping (OCTEON_IRQ_MBOX1 ,0 ,33 , + ciu_domain, chip_mbox, handle_percpu_irq); -octeon_irq_set_ciu_mapping (OCTEON_IRQ_UART0 ,0 ,34 , chip, handle_level_irq); -octeon_irq_set_ciu_mapping (OCTEON_IRQ_UART1 ,0 ,35 , chip, handle_level_irq); +octeon_irq_set_ciu_mapping (OCTEON_IRQ_UART0 ,0 ,34 , + ciu_domain, chip, handle_level_irq); +octeon_irq_set_ciu_mapping (OCTEON_IRQ_UART1 ,0 ,35 , + ciu_domain, chip, handle_level_irq);for (i =0 ; i <4 ; i++) -octeon_irq_set_ciu_mapping (i +OCTEON_IRQ_PCI_INT0 ,0 , i +36 , chip, handle_level_irq); +octeon_irq_set_ciu_mapping (i +OCTEON_IRQ_PCI_INT0 ,0 , i +36 , + ciu_domain, chip, handle_level_irq);for (i =0 ; i <4 ; i++) -octeon_irq_set_ciu_mapping (i +OCTEON_IRQ_PCI_MSI0 ,0 , i +40 , chip, handle_level_irq); +octeon_irq_set_ciu_mapping (i +OCTEON_IRQ_PCI_MSI0 ,0 , i +40 , + ciu_domain, chip, handle_level_irq); -octeon_irq_set_ciu_mapping (OCTEON_IRQ_TWSI ,0 ,45 , chip, handle_level_irq); -octeon_irq_set_ciu_mapping (OCTEON_IRQ_RML ,0 ,46 , chip, handle_level_irq); -octeon_irq_set_ciu_mapping (OCTEON_IRQ_TRACE0 ,0 ,47 , chip, handle_level_irq); +octeon_irq_set_ciu_mapping (OCTEON_IRQ_TWSI ,0 ,45 , + ciu_domain, chip, handle_level_irq); +octeon_irq_set_ciu_mapping (OCTEON_IRQ_RML ,0 ,46 , + ciu_domain, chip, handle_level_irq); +octeon_irq_set_ciu_mapping (OCTEON_IRQ_TRACE0 ,0 ,47 , + ciu_domain, chip, handle_level_irq);for (i =0 ; i <2 ; i++) -octeon_irq_set_ciu_mapping (i +OCTEON_IRQ_GMX_DRP0 ,0 , i +48 , chip_edge, handle_edge_irq); +octeon_irq_set_ciu_mapping (i +OCTEON_IRQ_GMX_DRP0 ,0 , i +48 , + ciu_domain, chip_edge, handle_edge_irq); -octeon_irq_set_ciu_mapping (OCTEON_IRQ_IPD_DRP ,0 ,50 , chip_edge, handle_edge_irq); -octeon_irq_set_ciu_mapping (OCTEON_IRQ_KEY_ZERO ,0 ,51 , chip_edge, handle_edge_irq); +octeon_irq_set_ciu_mapping (OCTEON_IRQ_IPD_DRP ,0 ,50 , + ciu_domain, chip_edge, handle_edge_irq); +octeon_irq_set_ciu_mapping (OCTEON_IRQ_KEY_ZERO ,0 ,51 , + ciu_domain, chip_edge, handle_edge_irq);for (i =0 ; i <4 ; i++) -octeon_irq_set_ciu_mapping (i +OCTEON_IRQ_TIMER0 ,0 , i +52 , chip_edge, handle_edge_irq); - -octeon_irq_set_ciu_mapping (OCTEON_IRQ_USB0 ,0 ,56 , chip, handle_level_irq); -octeon_irq_set_ciu_mapping (OCTEON_IRQ_PCM ,0 ,57 , chip, handle_level_irq); -octeon_irq_set_ciu_mapping (OCTEON_IRQ_MPI ,0 ,58 , chip, handle_level_irq); -octeon_irq_set_ciu_mapping (OCTEON_IRQ_TWSI2 ,0 ,59 , chip, handle_level_irq); -octeon_irq_set_ciu_mapping (OCTEON_IRQ_POWIQ ,0 ,60 , chip, handle_level_irq); -octeon_irq_set_ciu_mapping (OCTEON_IRQ_IPDPPTHR ,0 ,61 , chip, handle_level_irq); -octeon_irq_set_ciu_mapping (OCTEON_IRQ_MII0 ,0 ,62 , chip, handle_level_irq); -octeon_irq_set_ciu_mapping (OCTEON_IRQ_BOOTDMA ,0 ,63 , chip, handle_level_irq); +octeon_irq_set_ciu_mapping (i +OCTEON_IRQ_TIMER0 ,0 , i +52 , + ciu_domain, chip_edge, handle_edge_irq); + +octeon_irq_set_ciu_mapping (OCTEON_IRQ_USB0 ,0 ,56 , + ciu_domain, chip, handle_level_irq); +octeon_irq_set_ciu_mapping (OCTEON_IRQ_PCM ,0 ,57 , + ciu_domain, chip, handle_level_irq); +octeon_irq_set_ciu_mapping (OCTEON_IRQ_MPI ,0 ,58 , + ciu_domain, chip, handle_level_irq); +octeon_irq_set_ciu_mapping (OCTEON_IRQ_TWSI2 ,0 ,59 , + ciu_domain, chip, handle_level_irq); +octeon_irq_set_ciu_mapping (OCTEON_IRQ_POWIQ ,0 ,60 , + ciu_domain, chip, handle_level_irq); +octeon_irq_set_ciu_mapping (OCTEON_IRQ_IPDPPTHR ,0 ,61 , + ciu_domain, chip, handle_level_irq); +octeon_irq_set_ciu_mapping (OCTEON_IRQ_MII0 ,0 ,62 , + ciu_domain, chip, handle_level_irq); +octeon_irq_set_ciu_mapping (OCTEON_IRQ_BOOTDMA ,0 ,63 , + ciu_domain, chip, handle_level_irq);/* CIU_1 */ for (i =0 ; i <16 ; i++) -octeon_irq_set_ciu_mapping (i +OCTEON_IRQ_WDOG0 ,1 , i +0 , chip_wd, handle_level_irq); - -octeon_irq_set_ciu_mapping (OCTEON_IRQ_UART2 ,1 ,16 , chip, handle_level_irq); -octeon_irq_set_ciu_mapping (OCTEON_IRQ_USB1 ,1 ,17 , chip, handle_level_irq); -octeon_irq_set_ciu_mapping (OCTEON_IRQ_MII1 ,1 ,18 , chip, handle_level_irq); -octeon_irq_set_ciu_mapping (OCTEON_IRQ_NAND ,1 ,19 , chip, handle_level_irq); -octeon_irq_set_ciu_mapping (OCTEON_IRQ_MIO ,1 ,20 , chip, handle_level_irq); -octeon_irq_set_ciu_mapping (OCTEON_IRQ_IOB ,1 ,21 , chip, handle_level_irq); -octeon_irq_set_ciu_mapping (OCTEON_IRQ_FPA ,1 ,22 , chip, handle_level_irq); -octeon_irq_set_ciu_mapping (OCTEON_IRQ_POW ,1 ,23 , chip, handle_level_irq); -octeon_irq_set_ciu_mapping (OCTEON_IRQ_L2C ,1 ,24 , chip, handle_level_irq); -octeon_irq_set_ciu_mapping (OCTEON_IRQ_IPD ,1 ,25 , chip, handle_level_irq); -octeon_irq_set_ciu_mapping (OCTEON_IRQ_PIP ,1 ,26 , chip, handle_level_irq); -octeon_irq_set_ciu_mapping (OCTEON_IRQ_PKO ,1 ,27 , chip, handle_level_irq); -octeon_irq_set_ciu_mapping (OCTEON_IRQ_ZIP ,1 ,28 , chip, handle_level_irq); -octeon_irq_set_ciu_mapping (OCTEON_IRQ_TIM ,1 ,29 , chip, handle_level_irq); -octeon_irq_set_ciu_mapping (OCTEON_IRQ_RAD ,1 ,30 , chip, handle_level_irq); -octeon_irq_set_ciu_mapping (OCTEON_IRQ_KEY ,1 ,31 , chip, handle_level_irq); -octeon_irq_set_ciu_mapping (OCTEON_IRQ_DFA ,1 ,32 , chip, handle_level_irq); -octeon_irq_set_ciu_mapping (OCTEON_IRQ_USBCTL ,1 ,33 , chip, handle_level_irq); -octeon_irq_set_ciu_mapping (OCTEON_IRQ_SLI ,1 ,34 , chip, handle_level_irq); -octeon_irq_set_ciu_mapping (OCTEON_IRQ_DPI ,1 ,35 , chip, handle_level_irq); - -octeon_irq_set_ciu_mapping (OCTEON_IRQ_AGX0 ,1 ,36 , chip, handle_level_irq); - -octeon_irq_set_ciu_mapping (OCTEON_IRQ_AGL ,1 ,46 , chip, handle_level_irq); - -octeon_irq_set_ciu_mapping (OCTEON_IRQ_PTP ,1 ,47 , chip_edge, handle_edge_irq); - -octeon_irq_set_ciu_mapping (OCTEON_IRQ_PEM0 ,1 ,48 , chip, handle_level_irq); -octeon_irq_set_ciu_mapping (OCTEON_IRQ_PEM1 ,1 ,49 , chip, handle_level_irq); -octeon_irq_set_ciu_mapping (OCTEON_IRQ_SRIO0 ,1 ,50 , chip, handle_level_irq); -octeon_irq_set_ciu_mapping (OCTEON_IRQ_SRIO1 ,1 ,51 , chip, handle_level_irq); -octeon_irq_set_ciu_mapping (OCTEON_IRQ_LMC0 ,1 ,52 , chip, handle_level_irq); -octeon_irq_set_ciu_mapping (OCTEON_IRQ_DFM ,1 ,56 , chip, handle_level_irq); -octeon_irq_set_ciu_mapping (OCTEON_IRQ_RST ,1 ,63 , chip, handle_level_irq); +octeon_irq_set_ciu_mapping (i +OCTEON_IRQ_WDOG0 ,1 , i +0 , + ciu_domain, chip_wd, handle_level_irq); + +octeon_irq_set_ciu_mapping (OCTEON_IRQ_UART2 ,1 ,16 , + ciu_domain, chip, handle_level_irq); +octeon_irq_set_ciu_mapping (OCTEON_IRQ_USB1 ,1 ,17 , + ciu_domain, chip, handle_level_irq); +octeon_irq_set_ciu_mapping (OCTEON_IRQ_MII1 ,1 ,18 , + ciu_domain, chip, handle_level_irq); +octeon_irq_set_ciu_mapping (OCTEON_IRQ_NAND ,1 ,19 , + ciu_domain, chip, handle_level_irq); +octeon_irq_set_ciu_mapping (OCTEON_IRQ_MIO ,1 ,20 , + ciu_domain, chip, handle_level_irq); +octeon_irq_set_ciu_mapping (OCTEON_IRQ_IOB ,1 ,21 , + ciu_domain, chip, handle_level_irq); +octeon_irq_set_ciu_mapping (OCTEON_IRQ_FPA ,1 ,22 , + ciu_domain, chip, handle_level_irq); +octeon_irq_set_ciu_mapping (OCTEON_IRQ_POW ,1 ,23 , + ciu_domain, chip, handle_level_irq); +octeon_irq_set_ciu_mapping (OCTEON_IRQ_L2C ,1 ,24 , + ciu_domain, chip, handle_level_irq); +octeon_irq_set_ciu_mapping (OCTEON_IRQ_IPD ,1 ,25 , + ciu_domain, chip, handle_level_irq); +octeon_irq_set_ciu_mapping (OCTEON_IRQ_PIP ,1 ,26 , + ciu_domain, chip, handle_level_irq); +octeon_irq_set_ciu_mapping (OCTEON_IRQ_PKO ,1 ,27 , + ciu_domain, chip, handle_level_irq); +octeon_irq_set_ciu_mapping (OCTEON_IRQ_ZIP ,1 ,28 , + ciu_domain, chip, handle_level_irq); +octeon_irq_set_ciu_mapping (OCTEON_IRQ_TIM ,1 ,29 , + ciu_domain, chip, handle_level_irq); +octeon_irq_set_ciu_mapping (OCTEON_IRQ_RAD ,1 ,30 , + ciu_domain, chip, handle_level_irq); +octeon_irq_set_ciu_mapping (OCTEON_IRQ_KEY ,1 ,31 , + ciu_domain, chip, handle_level_irq); +octeon_irq_set_ciu_mapping (OCTEON_IRQ_DFA ,1 ,32 , + ciu_domain, chip, handle_level_irq); +octeon_irq_set_ciu_mapping (OCTEON_IRQ_USBCTL ,1 ,33 , + ciu_domain, chip, handle_level_irq); +octeon_irq_set_ciu_mapping (OCTEON_IRQ_SLI ,1 ,34 , + ciu_domain, chip, handle_level_irq); +octeon_irq_set_ciu_mapping (OCTEON_IRQ_DPI ,1 ,35 , + ciu_domain, chip, handle_level_irq); + +octeon_irq_set_ciu_mapping (OCTEON_IRQ_AGX0 ,1 ,36 , + ciu_domain, chip, handle_level_irq); + +octeon_irq_set_ciu_mapping (OCTEON_IRQ_AGL ,1 ,46 , + ciu_domain, chip, handle_level_irq); + +octeon_irq_set_ciu_mapping (OCTEON_IRQ_PTP ,1 ,47 , + ciu_domain, chip_edge, handle_edge_irq); + +octeon_irq_set_ciu_mapping (OCTEON_IRQ_PEM0 ,1 ,48 , + ciu_domain, chip, handle_level_irq); +octeon_irq_set_ciu_mapping (OCTEON_IRQ_PEM1 ,1 ,49 , + ciu_domain, chip, handle_level_irq); +octeon_irq_set_ciu_mapping (OCTEON_IRQ_SRIO0 ,1 ,50 , + ciu_domain, chip, handle_level_irq); +octeon_irq_set_ciu_mapping (OCTEON_IRQ_SRIO1 ,1 ,51 , + ciu_domain, chip, handle_level_irq); +octeon_irq_set_ciu_mapping (OCTEON_IRQ_LMC0 ,1 ,52 , + ciu_domain, chip, handle_level_irq); +octeon_irq_set_ciu_mapping (OCTEON_IRQ_DFM ,1 ,56 , + ciu_domain, chip, handle_level_irq); +octeon_irq_set_ciu_mapping (OCTEON_IRQ_RST ,1 ,63 , + ciu_domain, chip, handle_level_irq);/* Enable the CIU lines */ set_c0_status (STATUSF_IP3 |STATUSF_IP2 );Signature · 1 line
1.7.2.3
Signature · 1 line
email sent from notmuch.vim plugin
PATCH v6 5/5 MIPS: Octeon: Initialize and fixup device tree.
In reply to David DaneyFrom: David Daney <[email protected]>
--- arch/mips/Kconfig | 2 + arch/mips/cavium-octeon/Makefile | 3 + arch/mips/cavium-octeon/octeon-platform.c | 523 ++++++++++++++++++++++++++++- arch/mips/cavium-octeon/setup.c | 45 +++ 4 files changed, 572 insertions(+), 1 deletions(-)
arch/mips/Kconfig +2 -0
@@ -1433,6 +1433,8 @@ config CPU_CAVIUM_OCTEON select CPU_SUPPORTS_HIGHMEM select CPU_SUPPORTS_HUGEPAGES select IRQ_DOMAIN + select USE_OF + select LIBFDT help The Cavium Octeon processor is a highly integrated chip containing many ethernet hardware widgets for networking tasks. The processor
arch/mips/cavium-octeon/Makefile +3 -0
@@ -9,6 +9,9 @@ # Copyright (C) 2005-2009 Cavium Networks # +CFLAGS_octeon-platform.o = -I$(src)/../../../scripts/dtc/libfdt +CFLAGS_setup.o = -I$(src)/../../../scripts/dtc/libfdt + obj-y := cpu.o setup.o serial.o octeon-platform.o octeon-irq.o csrc-octeon.o obj-y += dma-octeon.o flash_setup.o obj-y += octeon-memcpy.o
arch/mips/cavium-octeon/octeon-platform.c +522 -1
545 lines not on this page · raw message
arch/mips/cavium-octeon/setup.c +45 -0
54 lines not on this page · raw message
Signature · 1 line
1.7.2.3