of/MIPS/i2c/net: Convert OCTEON to use device-tree
Subsystems (11)
cover of/MIPS/i2c/net: Convert OCTEON to use device-tree
From: David Daney <[email protected]>
This series touches several different drivers, but since OCTEON is a MIPS based SOC, we may want to merge the whole series via Ralf's linux-mips.org tree.
Summary of the patches:
1) Template device trees to be patched in early boot for legacy boards that do not supply a device tree.
2) Get rid of some garbage.
3) Interrupt mapping support.
4) Patch/fix-up device tree for lagacy boards.
5) I2C bus driver.
6) MDIO bus driver.
7,8) Ethernet drivers.
David Daney (8):
MIPS: Octeon: Add device tree source files.
MIPS: Prune some target specific code out of prom.c
MIPS: Octeon: Add irq_create_of_mapping() and GPIO interrupts.
MIPS: Octeon: Initialize and fixup device tree.
i2c: Convert i2c-octeon.c to use device tree.
netdev: mdio-octeon.c: Convert to use device tree.
netdev: octeon_mgmt: Convert to use device tree.
staging: octeon_ethernet: Convert to use 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 | 1 + arch/mips/cavium-octeon/.gitignore | 2 + arch/mips/cavium-octeon/Makefile | 16 + arch/mips/cavium-octeon/octeon-irq.c | 188 ++++++- arch/mips/cavium-octeon/octeon-platform.c | 699 +++++++++++++++----- 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/include/asm/octeon/octeon.h | 5 - arch/mips/kernel/prom.c | 50 -- drivers/i2c/busses/i2c-octeon.c | 94 ++-- drivers/net/ethernet/octeon/octeon_mgmt.c | 312 ++++++--- drivers/net/phy/mdio-octeon.c | 89 ++- drivers/staging/octeon/ethernet-mdio.c | 28 +- drivers/staging/octeon/ethernet.c | 91 ++- drivers/staging/octeon/octeon-ethernet.h | 3 + 28 files changed, 2901 insertions(+), 461 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 1/8 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 + $(call cmd,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 2/8 MIPS: Prune some target specific code out of prom.c
In reply to [email protected]From: David Daney <david.daney-YGCgFSpz5w/[email protected]>
This code is not common enough to be in a shared file. It is also not used by any existing boards, so just remove it.
--- arch/mips/kernel/prom.c | 50 ----------------------------------------------- 1 files changed, 0 insertions(+), 50 deletions(-)
arch/mips/kernel/prom.c +0 -50
@@ -59,53 +59,3 @@ void __init early_init_dt_setup_initrd_arch(unsigned long start, initrd_below_start_ok = 1; }#endif - -/* -* irq_create_of_mapping - Hook to resolve OF irq specifier into a Linux irq# -* -* Currently the mapping mechanism is trivial; simple flat hwirq numbers are -* mapped 1:1 onto Linux irq numbers. Cascaded irq controllers are not -* supported. -*/ -unsigned int irq_create_of_mapping (struct device_node *controller, -const u32 *intspec,unsigned int intsize) -{ -return intspec[0 ]; -} -EXPORT_SYMBOL_GPL (irq_create_of_mapping); - -void __init early_init_devtree (void *params) -{ -/* Setup flat device-tree pointer */ - initial_boot_params = params; - -/* Retrieve various informations from the /chosen node of the -* device-tree, including the platform type, initrd location and -* size, and more ... -*/ -of_scan_flat_dt (early_init_dt_scan_chosen, arcs_cmdline); - - -/* Scan memory nodes */ -of_scan_flat_dt (early_init_dt_scan_root,NULL ); -of_scan_flat_dt (early_init_dt_scan_memory_arch,NULL ); -} - -void __init device_tree_init (void ) -{ -unsigned long base, size; - -if (!initial_boot_params) -return ; - - base =virt_to_phys ((void *)initial_boot_params); - size =be32_to_cpu (initial_boot_params->totalsize); - -/* Before we do anything, lets reserve the dt blob */ -reserve_mem_mach (base, size); - -unflatten_device_tree (); - -/* free the space reserved for the dt blob */ -free_mem_mach (base, size); -}
Signature · 1 line
1.7.2.3
PATCH 3/8 MIPS: Octeon: Add irq_create_of_mapping() and GPIO interrupts.
In reply to [email protected]From: David Daney <[email protected]>
This is needed for Octeon to use the Device Tree.
The GPIO interrupts are configured based on Device Tree properties
--- arch/mips/cavium-octeon/octeon-irq.c | 188 +++++++++++++++++++++++++++++++++- 1 files changed, 187 insertions(+), 1 deletions(-)
arch/mips/cavium-octeon/octeon-irq.c +187 -1
@@ -8,11 +8,14 @@#include <linux/interrupt.h> #include <linux/bitops.h> +#include <linux/module.h> #include <linux/percpu.h> +#include <linux/of_irq.h> #include <linux/irq.h> #include <linux/smp.h> #include <asm/octeon/octeon.h> +#include <asm/octeon/cvmx-gpio-defs.h> static DEFINE_RAW_SPINLOCK (octeon_irq_ciu0_lock);static DEFINE_RAW_SPINLOCK (octeon_irq_ciu1_lock);
@@ -58,6 +61,95 @@ static void __init octeon_irq_set_ciu_mapping(int irq, int line, int bit, octeon_irq_ciu_to_irq[line][bit] = irq; } +static unsigned int octeon_irq_gpio_mapping (struct device_node *controller, +const u32 *intspec, +unsigned int intsize) +{ +struct of_irq oirq; +int i; +unsigned int irq =0 ; +unsigned int type; +unsigned int ciu =0 , bit =0 ; +unsigned int pin =be32_to_cpup (intspec); +unsigned int trigger =be32_to_cpup (intspec +1 ); +bool set_edge_handler = false; + +if (pin >=16 ) + goto err; + i =of_irq_map_one (controller,0 , &oirq); +if (i) + goto err; +if (oirq.size !=2 ) + goto err_put; + + ciu = oirq.specifier[0 ]; + bit = oirq.specifier[1 ] + pin; + +if (ciu >=8 || bit >=64 ) + goto err_put; + + irq = octeon_irq_ciu_to_irq[ciu][bit]; +if (!irq) + goto err_put; + +switch (trigger &0xf ) { +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: Invalid irq trigger specification: %x\n" , + trigger); + type =IRQ_TYPE_LEVEL_LOW ; +break ; + } + +irq_set_irq_type (irq, type); + +if (set_edge_handler) +__irq_set_handler (irq, handle_edge_irq,0 ,NULL ); + +err_put: +of_node_put (oirq.controller); +err: +return irq; +} + +/* +* irq_create_of_mapping - Hook to resolve OF irq specifier into a Linux irq# +* +* Octeon irq maps are a pair of indexes. The first selects either +* ciu0 or ciu1, the second is the bit within the ciu register. +*/ +unsigned int irq_create_of_mapping (struct device_node *controller, +const u32 *intspec,unsigned int intsize) +{ +unsigned int irq =0 ; +unsigned int ciu, bit; + +if (of_device_is_compatible (controller,"cavium,octeon-3860-gpio" )) +return octeon_irq_gpio_mapping (controller, intspec, intsize); + + ciu =be32_to_cpup (intspec); + bit =be32_to_cpup (intspec +1 ); + +if (ciu <8 && bit <64 ) + irq = octeon_irq_ciu_to_irq[ciu][bit]; + +return irq; +} +EXPORT_SYMBOL_GPL (irq_create_of_mapping); +static int octeon_coreid_for_cpu (int cpu) {#ifdef CONFIG_SMP
@@ -505,6 +597,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 +875,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 +1073,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 +1088,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 +1096,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 +1107,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 4/8 MIPS: Octeon: Initialize and fixup device tree.
In reply to [email protected]From: David Daney <david.daney-YGCgFSpz5w/[email protected]>
--- arch/mips/Kconfig | 1 + arch/mips/cavium-octeon/Makefile | 3 + arch/mips/cavium-octeon/octeon-platform.c | 523 ++++++++++++++++++++++++++++- arch/mips/cavium-octeon/setup.c | 45 +++ 4 files changed, 571 insertions(+), 1 deletions(-)
arch/mips/Kconfig +1 -0
@@ -1404,6 +1404,7 @@ config CPU_CAVIUM_OCTEON select WEAK_ORDERING select CPU_SUPPORTS_HIGHMEM select CPU_SUPPORTS_HUGEPAGES + 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
PATCH 5/8 i2c: Convert i2c-octeon.c to use device tree.
In reply to [email protected]From: David Daney <david.daney-YGCgFSpz5w/[email protected]>
--- arch/mips/cavium-octeon/octeon-platform.c | 84 ------------------------- arch/mips/include/asm/octeon/octeon.h | 5 -- drivers/i2c/busses/i2c-octeon.c | 94 ++++++++++++++++------------- 3 files changed, 52 insertions(+), 131 deletions(-)
arch/mips/cavium-octeon/octeon-platform.c +0 -84
@@ -168,90 +168,6 @@ out: }device_initcall (octeon_rng_device_init); -static struct i2c_board_info __initdata octeon_i2c_devices[] = { - { -I2C_BOARD_INFO ("ds1337" ,0x68 ), - }, -}; - -static int __init octeon_i2c_devices_init (void ) -{ -return i2c_register_board_info (0 , octeon_i2c_devices, -ARRAY_SIZE (octeon_i2c_devices)); -} -arch_initcall (octeon_i2c_devices_init); - -#define OCTEON_I2C_IO_BASE 0x1180000001000ull -#define OCTEON_I2C_IO_UNIT_OFFSET 0x200 - -static struct octeon_i2c_data octeon_i2c_data[2 ]; - -static int __init octeon_i2c_device_init (void ) -{ -struct platform_device *pd; -int ret =0 ; -int port, num_ports; - -struct resource i2c_resources[] = { - { - .flags =IORESOURCE_MEM , - }, { - .flags =IORESOURCE_IRQ , - } - }; - -if (OCTEON_IS_MODEL (OCTEON_CN56XX ) ||OCTEON_IS_MODEL (OCTEON_CN52XX )) - num_ports =2 ; -else - num_ports =1 ; - -for (port =0 ; port < num_ports; port++) { - octeon_i2c_data[port].sys_freq =octeon_get_io_clock_rate (); -/*FIXME: should be examined. At the moment is set for 100Khz */ - octeon_i2c_data[port].i2c_freq =100000 ; - - pd =platform_device_alloc ("i2c-octeon" , port); -if (!pd) { - ret = -ENOMEM ; - goto out; - } - - pd->dev.platform_data = octeon_i2c_data + port; - - i2c_resources[0 ].start = -OCTEON_I2C_IO_BASE + (port *OCTEON_I2C_IO_UNIT_OFFSET ); - i2c_resources[0 ].end = i2c_resources[0 ].start +0x1f ; -switch (port) { -case 0 : - i2c_resources[1 ].start =OCTEON_IRQ_TWSI ; - i2c_resources[1 ].end =OCTEON_IRQ_TWSI ; -break ; -case 1 : - i2c_resources[1 ].start =OCTEON_IRQ_TWSI2 ; - i2c_resources[1 ].end =OCTEON_IRQ_TWSI2 ; -break ; -default : -BUG (); - } - - ret =platform_device_add_resources (pd, - i2c_resources, -ARRAY_SIZE (i2c_resources)); -if (ret) - goto fail; - - ret =platform_device_add (pd); -if (ret) - goto fail; - } -return ret; -fail: -platform_device_put (pd); -out: -return ret; -} -device_initcall (octeon_i2c_device_init); -/* Octeon SMI/MDIO interface. */ static int __init octeon_mdiobus_device_init (void ) {
arch/mips/include/asm/octeon/octeon.h +0 -5
@@ -215,11 +215,6 @@ struct octeon_cf_data {int dma_engine;/* -1 for no DMA */ }; -struct octeon_i2c_data { -unsigned int sys_freq; -unsigned int i2c_freq; -}; -extern void octeon_write_lcd (const char *s);extern void octeon_check_cpu_bist (void );extern int octeon_get_boot_debug_flag (void );
drivers/i2c/busses/i2c-octeon.c +52 -42
206 lines not on this page · raw message
Signature · 1 line
1.7.2.3
PATCH 6/8 netdev: mdio-octeon.c: Convert to use device tree.
In reply to [email protected]From: David Daney <david.daney-YGCgFSpz5w/[email protected]>
Get the MDIO bus controller addresses from the device tree.
--- arch/mips/cavium-octeon/octeon-platform.c | 30 ---------- drivers/net/phy/mdio-octeon.c | 89 +++++++++++++++++++---------- 2 files changed, 58 insertions(+), 61 deletions(-)
arch/mips/cavium-octeon/octeon-platform.c +0 -30
@@ -168,36 +168,6 @@ out: }device_initcall (octeon_rng_device_init); -/* Octeon SMI/MDIO interface. */ -static int __init octeon_mdiobus_device_init (void ) -{ -struct platform_device *pd; -int ret =0 ; - -if (octeon_is_simulation ()) -return 0 ;/* No mdio in the simulator. */ - -/* The bus number is the platform_device id. */ - pd =platform_device_alloc ("mdio-octeon" ,0 ); -if (!pd) { - ret = -ENOMEM ; - goto out; - } - - ret =platform_device_add (pd); -if (ret) - goto fail; - -return ret; -fail: -platform_device_put (pd); - -out: -return ret; - -} -device_initcall (octeon_mdiobus_device_init); -/* Octeon mgmt port Ethernet interface. */ static int __init octeon_mgmt_device_init (void ) {
drivers/net/phy/mdio-octeon.c +58 -31
187 lines not on this page · raw message
Signature · 1 line
1.7.2.3
PATCH 7/8 netdev: octeon_mgmt: Convert to use device tree.
In reply to [email protected]From: David Daney <[email protected]>
The device tree will supply the register bank base addresses, make register addressing relative to those. PHY connection is now described by the device tree.
--- arch/mips/cavium-octeon/octeon-platform.c | 62 ------ drivers/net/ethernet/octeon/octeon_mgmt.c | 312 +++++++++++++++++++---------- 2 files changed, 207 insertions(+), 167 deletions(-)
arch/mips/cavium-octeon/octeon-platform.c +0 -62
@@ -168,68 +168,6 @@ out: }device_initcall (octeon_rng_device_init); -/* Octeon mgmt port Ethernet interface. */ -static int __init octeon_mgmt_device_init (void ) -{ -struct platform_device *pd; -int ret =0 ; -int port, num_ports; - -struct resource mgmt_port_resource = { - .flags =IORESOURCE_IRQ , - .start =-1 , - .end =-1 - }; - -if (!OCTEON_IS_MODEL (OCTEON_CN56XX ) && !OCTEON_IS_MODEL (OCTEON_CN52XX )) -return 0 ; - -if (OCTEON_IS_MODEL (OCTEON_CN56XX )) - num_ports =1 ; -else - num_ports =2 ; - -for (port =0 ; port < num_ports; port++) { - pd =platform_device_alloc ("octeon_mgmt" , port); -if (!pd) { - ret = -ENOMEM ; - goto out; - } -/* No DMA restrictions */ - pd->dev.coherent_dma_mask =DMA_BIT_MASK (64 ); - pd->dev.dma_mask = &pd->dev.coherent_dma_mask; - -switch (port) { -case 0 : - mgmt_port_resource.start =OCTEON_IRQ_MII0 ; -break ; -case 1 : - mgmt_port_resource.start =OCTEON_IRQ_MII1 ; -break ; -default : -BUG (); - } - mgmt_port_resource.end = mgmt_port_resource.start; - - ret =platform_device_add_resources (pd, &mgmt_port_resource,1 ); - -if (ret) - goto fail; - - ret =platform_device_add (pd); -if (ret) - goto fail; - } -return ret; -fail: -platform_device_put (pd); - -out: -return ret; - -} -device_initcall (octeon_mgmt_device_init); -#ifdef CONFIG_USB static int __init octeon_ehci_device_init (void )
drivers/net/ethernet/octeon/octeon_mgmt.c +207 -105
651 lines not on this page · raw message
Signature · 1 line
1.7.2.3
PATCH 8/8 staging: octeon_ethernet: Convert to use device tree.
In reply to [email protected]From: David Daney <[email protected]>
Get MAC address and PHY connection from the device tree.
--- drivers/staging/octeon/ethernet-mdio.c | 28 +++++---- drivers/staging/octeon/ethernet.c | 91 ++++++++++++++++++------------ drivers/staging/octeon/octeon-ethernet.h | 3 + 3 files changed, 72 insertions(+), 50 deletions(-)
drivers/staging/octeon/ethernet-mdio.c +15 -13
@@ -28,6 +28,7 @@#include <linux/ethtool.h> #include <linux/phy.h> #include <linux/ratelimit.h> +#include <linux/of_mdio.h> #include <net/dst.h>
@@ -161,22 +162,23 @@ static void cvm_oct_adjust_link(struct net_device *dev)int cvm_oct_phy_setup_device (struct net_device *dev) {struct octeon_ethernet *priv =netdev_priv (dev); +struct device_node *phy_node; -int phy_addr =cvmx_helper_board_get_mii_address (priv->port); -if (phy_addr !=-1 ) { -char phy_id[20 ]; +if (!priv->of_node) +return 0 ; -snprintf (phy_id,sizeof (phy_id),PHY_ID_FMT ,"0" , phy_addr); + phy_node =of_parse_phandle (priv->of_node,"phy-handle" ,0 ); +if (!phy_node) +return 0 ; - priv->phydev =phy_connect (dev, phy_id, cvm_oct_adjust_link,0 , -PHY_INTERFACE_MODE_GMII ); + priv->phydev =of_phy_connect (dev, phy_node, cvm_oct_adjust_link,0 , +PHY_INTERFACE_MODE_GMII ); + +if (priv->phydev ==NULL ) +return -ENODEV ; + + priv->last_link =0 ; +phy_start_aneg (priv->phydev); -if (IS_ERR (priv->phydev)) { - priv->phydev =NULL ; -return -1 ; - } - priv->last_link =0 ; -phy_start_aneg (priv->phydev); - }return 0 ; }
drivers/staging/octeon/ethernet.c +54 -37
139 lines not on this page · raw message
drivers/staging/octeon/octeon-ethernet.h +3 -0
@@ -31,6 +31,8 @@#ifndef OCTEON_ETHERNET_H #define OCTEON_ETHERNET_H +#include <linux/of.h> +/** * This is the definition of the Ethernet driver's private * driver state stored in netdev_priv(dev).
@@ -59,6 +61,7 @@ struct octeon_ethernet {void (*poll) (struct net_device *dev);struct delayed_work port_periodic_work;struct work_struct port_work;/* may be unused. */ +struct device_node *of_node; };int cvm_oct_free_work (void *work_queue_entry);
Signature · 1 line
1.7.2.3
Re: [PATCH 3/8] MIPS: Octeon: Add irq_create_of_mapping() and GPIO interrupts.
In reply to [email protected]Quoted 112 lines · On 11/10/2011 08:21 PM, [email protected]…
From: David Daney <david.daney-YGCgFSpz5w/[email protected]>
This is needed for Octeon to use the Device Tree.
The GPIO interrupts are configured based on Device Tree properties
Signed-off-by David Daney <david.daney-YGCgFSpz5w/[email protected]>--- arch/mips/cavium-octeon/octeon-irq.c | 188 +++++++++++++++++++++++++++++++++- 1 files changed, 187 insertions(+), 1 deletions(-)arch/mips/cavium-octeon/octeon-irq.c +81
-0@@ -8,11 +8,14 @@#include <linux/interrupt.h> #include <linux/bitops.h> +#include <linux/module.h> #include <linux/percpu.h> +#include <linux/of_irq.h> #include <linux/irq.h> #include <linux/smp.h> #include <asm/octeon/octeon.h> +#include <asm/octeon/cvmx-gpio-defs.h> static DEFINE_RAW_SPINLOCK (octeon_irq_ciu0_lock);static DEFINE_RAW_SPINLOCK (octeon_irq_ciu1_lock);@@ -58,6 +61,95 @@ static void __init octeon_irq_set_ciu_mapping(int irq, int line, int bit, octeon_irq_ciu_to_irq[line][bit] = irq; } +static unsigned int octeon_irq_gpio_mapping (struct device_node *controller, +const u32 *intspec, +unsigned int intsize) +{ +struct of_irq oirq; +int i; +unsigned int irq =0 ; +unsigned int type; +unsigned int ciu =0 , bit =0 ; +unsigned int pin =be32_to_cpup (intspec); +unsigned int trigger =be32_to_cpup (intspec +1 ); +bool set_edge_handler = false; + +if (pin >=16 ) + goto err; + i =of_irq_map_one (controller,0 , &oirq); +if (i) + goto err; +if (oirq.size !=2 ) + goto err_put; + + ciu = oirq.specifier[0 ]; + bit = oirq.specifier[1 ] + pin; + +if (ciu >=8 || bit >=64 ) + goto err_put; + + irq = octeon_irq_ciu_to_irq[ciu][bit]; +if (!irq) + goto err_put; + +switch (trigger &0xf ) { +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: Invalid irq trigger specification: %x\n" , + trigger); + type =IRQ_TYPE_LEVEL_LOW ; +break ; + } + +irq_set_irq_type (irq, type); + +if (set_edge_handler) +__irq_set_handler (irq, handle_edge_irq,0 ,NULL ); + +err_put: +of_node_put (oirq.controller); +err: +return irq; +} + +/* +* irq_create_of_mapping - Hook to resolve OF irq specifier into a Linux irq# +* +* Octeon irq maps are a pair of indexes. The first selects either +* ciu0 or ciu1, the second is the bit within the ciu register. +*/ +unsigned int irq_create_of_mapping (struct device_node *controller, +const u32 *intspec,unsigned int intsize) +{ +unsigned int irq =0 ; +unsigned int ciu, bit; + +if (of_device_is_compatible (controller,"cavium,octeon-3860-gpio" )) +return octeon_irq_gpio_mapping (controller, intspec, intsize);
arch/mips/cavium-octeon/octeon-irq.c static void __init octeon_irq_set_ciu_mapping(int irq, int line, int bit, · line 151
Quoted 10 lines
arch/mips/cavium-octeon/octeon-irq.c +10
-0+ + ciu =be32_to_cpup (intspec); + bit =be32_to_cpup (intspec +1 ); + +if (ciu <8 && bit <64 ) + irq = octeon_irq_ciu_to_irq[ciu][bit]; + +return irq; +} +EXPORT_SYMBOL_GPL (irq_create_of_mapping);
Have you looked at irq_domains (kernel/irq/irqdomain.c)? That is what you should be using for your (gpio) interrupt controller and then use the common irq_create_of_mapping.
Rob
Quoted 142 lines
arch/mips/cavium-octeon/octeon-irq.c +96
-1+static int octeon_coreid_for_cpu (int cpu) {#ifdef CONFIG_SMP @@ -505,6 +597,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 +875,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 +1073,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 +1088,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 +1096,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 +1107,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);
Re: [PATCH 3/8] MIPS: Octeon: Add irq_create_of_mapping() and GPIO interrupts.
Quoted 119 lines · Rob Herring
Quoted 118 lines · On 11/10/2011 08:21 PM, [email protected]…
From: David Daney<david.daney-YGCgFSpz5w/[email protected]>
This is needed for Octeon to use the Device Tree.
The GPIO interrupts are configured based on Device Tree properties
Signed-off-by David Daney<david.daney-YGCgFSpz5w/[email protected]>--- arch/mips/cavium-octeon/octeon-irq.c | 188 +++++++++++++++++++++++++++++++++- 1 files changed, 187 insertions(+), 1 deletions(-)arch/mips/cavium-octeon/octeon-irq.c +87
-0@@ -8,11 +8,14 @@#include <linux/interrupt.h> #include <linux/bitops.h> +#include <linux/module.h> #include <linux/percpu.h> +#include <linux/of_irq.h> #include <linux/irq.h> #include <linux/smp.h> #include <asm/octeon/octeon.h> +#include <asm/octeon/cvmx-gpio-defs.h> static DEFINE_RAW_SPINLOCK (octeon_irq_ciu0_lock);static DEFINE_RAW_SPINLOCK (octeon_irq_ciu1_lock);@@ -58,6 +61,95 @@ static void __init octeon_irq_set_ciu_mapping(int irq, int line, int bit, octeon_irq_ciu_to_irq[line][bit] = irq; } +static unsigned int octeon_irq_gpio_mapping (struct device_node *controller, +const u32 *intspec, +unsigned int intsize) +{ +struct of_irq oirq; +int i; +unsigned int irq =0 ; +unsigned int type; +unsigned int ciu =0 , bit =0 ; +unsigned int pin =be32_to_cpup (intspec); +unsigned int trigger =be32_to_cpup (intspec +1 ); +bool set_edge_handler = false; + +if (pin>=16 ) + goto err; + i =of_irq_map_one (controller,0 ,&oirq); +if (i) + goto err; +if (oirq.size !=2 ) + goto err_put; + + ciu = oirq.specifier[0 ]; + bit = oirq.specifier[1 ] + pin; + +if (ciu>=8 || bit>=64 ) + goto err_put; + + irq = octeon_irq_ciu_to_irq[ciu][bit]; +if (!irq) + goto err_put; + +switch (trigger&0xf ) { +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: Invalid irq trigger specification: %x\n" , + trigger); + type =IRQ_TYPE_LEVEL_LOW ; +break ; + } + +irq_set_irq_type (irq, type); + +if (set_edge_handler) +__irq_set_handler (irq, handle_edge_irq,0 ,NULL ); + +err_put: +of_node_put (oirq.controller); +err: +return irq; +} + +/* +* irq_create_of_mapping - Hook to resolve OF irq specifier into a Linux irq# +* +* Octeon irq maps are a pair of indexes. The first selects either +* ciu0 or ciu1, the second is the bit within the ciu register. +*/ +unsigned int irq_create_of_mapping (struct device_node *controller, +const u32 *intspec,unsigned int intsize) +{ +unsigned int irq =0 ; +unsigned int ciu, bit; + +if (of_device_is_compatible (controller,"cavium,octeon-3860-gpio" )) +return octeon_irq_gpio_mapping (controller, intspec, intsize); + + ciu =be32_to_cpup (intspec); + bit =be32_to_cpup (intspec +1 ); + +if (ciu<8 && bit<64 ) + irq = octeon_irq_ciu_to_irq[ciu][bit];
Quoted 9 lines
arch/mips/cavium-octeon/octeon-irq.c static void __init octeon_irq_set_ciu_mapping(int irq, int line, int bit, · line 151
Quoted 4 lines
arch/mips/cavium-octeon/octeon-irq.c +4
-0+ +return irq; +} +EXPORT_SYMBOL_GPL (irq_create_of_mapping);Have you looked at
irq_domains(kernel/irq/irqdomain.c)? That is what you should be using for your (gpio) interrupt controller and then use the commonirq_create_of_mapping.
Unfortunatly, although a good idea, kernel/irq/irqdomain.c makes a bunch of assumptions that don't hold for Octeon. We may be able to improve it so that it flexible enough to suit us.
Here are the problems I see:
1) It is assumed that there is some sort of linear correspondence between 'hwirq' and 'irq', and that the range of valid values is contiguous.
2) It is assumed that the concepts of nr_irq, irq_base and hwirq_base have easy to determin values and you can do iteration over their ranges by adding indexes to the bases.
I think we can fix this by adding iteration helper functions to struct irq_domain. If these are present, we would just ignore the irq_base, nr_irq and hwirq_base elements of the structure. irq_domain_for_each_hwirq() and irq_domain_for_each_irq() would be modified to use the iteration helper functions.
David Daney
Re: [PATCH 3/8] MIPS: Octeon: Add irq_create_of_mapping() and GPIO interrupts.
David,
Quoted 140 lines · David Daney
Quoted 124 lines · Rob Herring
Quoted 123 lines · On 11/10/2011 08:21 PM, [email protected]…
From: David Daney<david.daney-YGCgFSpz5w/[email protected]>
This is needed for Octeon to use the Device Tree.
The GPIO interrupts are configured based on Device Tree properties
Signed-off-by David Daney<david.daney-YGCgFSpz5w/[email protected]>--- arch/mips/cavium-octeon/octeon-irq.c | 188 +++++++++++++++++++++++++++++++++- 1 files changed, 187 insertions(+), 1 deletions(-)arch/mips/cavium-octeon/octeon-irq.c +69
-0@@ -8,11 +8,14 @@#include <linux/interrupt.h> #include <linux/bitops.h> +#include <linux/module.h> #include <linux/percpu.h> +#include <linux/of_irq.h> #include <linux/irq.h> #include <linux/smp.h> #include <asm/octeon/octeon.h> +#include <asm/octeon/cvmx-gpio-defs.h> static DEFINE_RAW_SPINLOCK (octeon_irq_ciu0_lock);static DEFINE_RAW_SPINLOCK (octeon_irq_ciu1_lock);@@ -58,6 +61,95 @@ static void __init octeon_irq_set_ciu_mapping(int irq, int line, int bit, octeon_irq_ciu_to_irq[line][bit] = irq; } +static unsigned int octeon_irq_gpio_mapping (struct device_node *controller, +const u32 *intspec, +unsigned int intsize) +{ +struct of_irq oirq; +int i; +unsigned int irq =0 ; +unsigned int type; +unsigned int ciu =0 , bit =0 ; +unsigned int pin =be32_to_cpup (intspec); +unsigned int trigger =be32_to_cpup (intspec +1 ); +bool set_edge_handler = false; + +if (pin>=16 ) + goto err; + i =of_irq_map_one (controller,0 ,&oirq); +if (i) + goto err; +if (oirq.size !=2 ) + goto err_put; + + ciu = oirq.specifier[0 ]; + bit = oirq.specifier[1 ] + pin; + +if (ciu>=8 || bit>=64 ) + goto err_put; + + irq = octeon_irq_ciu_to_irq[ciu][bit]; +if (!irq) + goto err_put; + +switch (trigger&0xf ) { +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: Invalid irq trigger specification: %x\n" , + trigger); + type =IRQ_TYPE_LEVEL_LOW ; +break ; + } + +irq_set_irq_type (irq, type); + +if (set_edge_handler) +__irq_set_handler (irq, handle_edge_irq,0 ,NULL ); + +err_put: +of_node_put (oirq.controller); +err: +return irq; +} + +/* +* irq_create_of_mapping - Hook to resolve OF irq specifier into a Linux irq#
+ *
+ * Octeon irq maps are a pair of indexes. The first selects either
+ * ciu0 or ciu1, the second is the bit within the ciu register.
+ */arch/mips/cavium-octeon/octeon-irq.c +14
-0+unsigned int irq_create_of_mapping (struct device_node *controller, +const u32 *intspec,unsigned int intsize) +{ +unsigned int irq =0 ; +unsigned int ciu, bit; + +if (of_device_is_compatible (controller,"cavium,octeon-3860-gpio" )) +return octeon_irq_gpio_mapping (controller, intspec, intsize); + + ciu =be32_to_cpup (intspec); + bit =be32_to_cpup (intspec +1 ); + +if (ciu<8 && bit<64 ) + irq = octeon_irq_ciu_to_irq[ciu][bit];Quoted 9 lines
arch/mips/cavium-octeon/octeon-irq.c static void __init octeon_irq_set_ciu_mapping(int irq, int line, int bit, · line 151
Quoted 4 lines
arch/mips/cavium-octeon/octeon-irq.c +4
-0+ +return irq; +} +EXPORT_SYMBOL_GPL (irq_create_of_mapping);Have you looked at
irq_domains(kernel/irq/irqdomain.c)? That is what you should be using for your (gpio) interrupt controller and then use the commonirq_create_of_mapping.Unfortunatly, although a good idea,
kernel/irq/irqdomain.cmakes a bunch of assumptions that don't hold for Octeon. We may be able to improve it so that it flexible enough to suit us.
Quoted 5 lines
Here are the problems I see:
1) It is assumed that there is some sort of linear correspondence between 'hwirq' and 'irq', and that the range of valid values is contiguous.
That's not true if you implement .to_irq for your domain.
Quoted 3 lines
2) It is assumed that the concepts of
nr_irq,irq_baseandhwirq_basehave easy to determin values and you can do iteration over their ranges by adding indexes to the bases.
That's true for hwirq numbering, but not for Linux irq numbering. irq_base is only used if you don't provide .to_irq. hwirq_base is just to allow a linear range that doesn't start with 0.
Quoted 5 lines
I think we can fix this by adding iteration helper functions to struct
irq_domain. If these are present, we would just ignore theirq_base,nr_irqandhwirq_baseelements of the structure.irq_domain_for_each_hwirq()andirq_domain_for_each_irq()would be modified to use the iteration helper functions.
Expanding irqdomain is certainly the intention and right direction.
It seems to me you just need something different than an irq. controller with a linear range of irq lines. Perhaps sparsely allocated hwirq's? Can you describe the h/w?
Also, you could have a different domain per irqdesc if you really needed to.
Rob
Re: [PATCH 3/8] MIPS: Octeon: Add irq_create_of_mapping() and GPIO interrupts.
Quoted 143 lines · Rob Herring
David,
Quoted 140 lines · David Daney
Quoted 124 lines · Rob Herring
Quoted 123 lines · On 11/10/2011 08:21 PM, [email protected]…
From: David Daney<david.daney-YGCgFSpz5w/[email protected]>
This is needed for Octeon to use the Device Tree.
The GPIO interrupts are configured based on Device Tree properties
Signed-off-by David Daney<david.daney-YGCgFSpz5w/[email protected]>--- arch/mips/cavium-octeon/octeon-irq.c | 188 +++++++++++++++++++++++++++++++++- 1 files changed, 187 insertions(+), 1 deletions(-)arch/mips/cavium-octeon/octeon-irq.c +69
-0@@ -8,11 +8,14 @@#include <linux/interrupt.h> #include <linux/bitops.h> +#include <linux/module.h> #include <linux/percpu.h> +#include <linux/of_irq.h> #include <linux/irq.h> #include <linux/smp.h> #include <asm/octeon/octeon.h> +#include <asm/octeon/cvmx-gpio-defs.h> static DEFINE_RAW_SPINLOCK (octeon_irq_ciu0_lock);static DEFINE_RAW_SPINLOCK (octeon_irq_ciu1_lock);@@ -58,6 +61,95 @@ static void __init octeon_irq_set_ciu_mapping(int irq, int line, int bit, octeon_irq_ciu_to_irq[line][bit] = irq; } +static unsigned int octeon_irq_gpio_mapping (struct device_node *controller, +const u32 *intspec, +unsigned int intsize) +{ +struct of_irq oirq; +int i; +unsigned int irq =0 ; +unsigned int type; +unsigned int ciu =0 , bit =0 ; +unsigned int pin =be32_to_cpup (intspec); +unsigned int trigger =be32_to_cpup (intspec +1 ); +bool set_edge_handler = false; + +if (pin>=16 ) + goto err; + i =of_irq_map_one (controller,0 ,&oirq); +if (i) + goto err; +if (oirq.size !=2 ) + goto err_put; + + ciu = oirq.specifier[0 ]; + bit = oirq.specifier[1 ] + pin; + +if (ciu>=8 || bit>=64 ) + goto err_put; + + irq = octeon_irq_ciu_to_irq[ciu][bit]; +if (!irq) + goto err_put; + +switch (trigger&0xf ) { +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: Invalid irq trigger specification: %x\n" , + trigger); + type =IRQ_TYPE_LEVEL_LOW ; +break ; + } + +irq_set_irq_type (irq, type); + +if (set_edge_handler) +__irq_set_handler (irq, handle_edge_irq,0 ,NULL ); + +err_put: +of_node_put (oirq.controller); +err: +return irq; +} + +/* +* irq_create_of_mapping - Hook to resolve OF irq specifier into a Linux irq#
+ *
+ * Octeon irq maps are a pair of indexes. The first selects either
+ * ciu0 or ciu1, the second is the bit within the ciu register.
+ */arch/mips/cavium-octeon/octeon-irq.c +14
-0+unsigned int irq_create_of_mapping (struct device_node *controller, +const u32 *intspec,unsigned int intsize) +{ +unsigned int irq =0 ; +unsigned int ciu, bit; + +if (of_device_is_compatible (controller,"cavium,octeon-3860-gpio" )) +return octeon_irq_gpio_mapping (controller, intspec, intsize); + + ciu =be32_to_cpup (intspec); + bit =be32_to_cpup (intspec +1 ); + +if (ciu<8 && bit<64 ) + irq = octeon_irq_ciu_to_irq[ciu][bit];Quoted 9 lines
arch/mips/cavium-octeon/octeon-irq.c static void __init octeon_irq_set_ciu_mapping(int irq, int line, int bit, · line 151
Quoted 4 lines
arch/mips/cavium-octeon/octeon-irq.c +4
-0+ +return irq; +} +EXPORT_SYMBOL_GPL (irq_create_of_mapping);Have you looked at
irq_domains(kernel/irq/irqdomain.c)? That is what you should be using for your (gpio) interrupt controller and then use the commonirq_create_of_mapping.Unfortunatly, although a good idea,
kernel/irq/irqdomain.cmakes a bunch of assumptions that don't hold for Octeon. We may be able to improve it so that it flexible enough to suit us.
Quoted 7 lines
Quoted 5 lines
Here are the problems I see:
1) It is assumed that there is some sort of linear correspondence between 'hwirq' and 'irq', and that the range of valid values is contiguous.
That's not true if you implement .to_irq for your domain.
It is true. irq_domain_add() iterates.
Quoted 9 lines
Quoted 4 lines
2) It is assumed that the concepts of
nr_irq,irq_baseandhwirq_basehave easy to determin values and you can do iteration over their ranges by adding indexes to the bases.That's true for hwirq numbering, but not for Linux irq numbering.
irq_baseis only used if you don't provide .to_irq.hwirq_baseis just to allow a linear range that doesn't start with 0.
Quoted 7 lines
Quoted 5 lines
I think we can fix this by adding iteration helper functions to struct
irq_domain. If these are present, we would just ignore theirq_base,nr_irqandhwirq_baseelements of the structure.irq_domain_for_each_hwirq()andirq_domain_for_each_irq()would be modified to use the iteration helper functions.Expanding irqdomain is certainly the intention and right direction.
I have a patch. It should be ready in a couple of hours.
Quoted 7 lines
It seems to me you just need something different than an irq. controller with a linear range of irq lines. Perhaps sparsely allocated hwirq's? Can you describe the h/w?
Also, you could have a different domain per irqdesc if you really needed to.
Too ugly.
David Daney
Re: [PATCH 8/8] staging: octeon_ethernet: Convert to use device tree.
In reply to [email protected]Quoted 7 lines · On Thu, Nov 10, 2011 at 06:22:04PM -0800, [email protected] wrote:
From: David Daney <[email protected]>
Get MAC address and PHY connection from the device tree.
Cc "David S. Miller" <[email protected]>Cc Greg Kroah-Hartman <[email protected]>
This usually goes through the MIPS tree, so I'll let Ralf take it.
thanks,
greg k-h