MIPS: OCTEON: irq handling improvements.
cover MIPS: OCTEON: irq handling improvements.
From: David Daney <[email protected]>
These three patches are prerequisites for the follow-on device tree patches, although they don't touch or use any device tree functionality.
1/3: Handle GPIO interrupts and their triggering.
2/3: Remove a bunch of unused OCTEON_IRQ_ symbols.
3/3: Remove some duplicate definitions.
David Daney (3):
MIPS: Octeon: Add irq handlers for GPIO interrupts.
MIPS: OCTEON: Remove unneeded OCTEON_IRQ_* defines.
MIPS: OCTEON: Consolidate the edge and level irq_chip structures.
arch/mips/cavium-octeon/octeon-irq.c | 175 ++++++++++++++---------- arch/mips/include/asm/mach-cavium-octeon/irq.h | 40 +----- 2 files changed, 105 insertions(+), 110 deletions(-)
Signature · 1 line
1.7.2.3
PATCH 1/3 MIPS: Octeon: Add irq handlers for GPIO interrupts.
From: 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 | 102 +++++++++++++++++++++++++++++++++- 1 files changed, 101 insertions(+), 1 deletions(-)
arch/mips/cavium-octeon/octeon-irq.c +101 -1
@@ -505,6 +505,76 @@ 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_BOTH ) !=0 ; + cfg.s.rx_xor = (t & (IRQ_TYPE_LEVEL_LOW |IRQ_TYPE_EDGE_FALLING )) !=0 ; + +/* 140 nS 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) +{ +irqd_set_trigger_type (data, t); +octeon_irq_gpio_setup (data); + +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); +} + +static void octeon_irq_handle_gpio (unsigned int irq,struct irq_desc *desc) +{ +if (irqd_get_trigger_type (irq_desc_get_irq_data (desc)) &IRQ_TYPE_EDGE_BOTH ) +handle_edge_irq (irq, desc); +else +handle_level_irq (irq, desc); +} +#ifdef CONFIG_SMP static void octeon_irq_cpu_offline_ciu (struct irq_data *data)
@@ -717,6 +787,33 @@ 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 + .flags =IRQCHIP_SET_TYPE_MASKED , +}; + +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 + .flags =IRQCHIP_SET_TYPE_MASKED , +}; +/* * Watchdog interrupts are special. They are associated with a single * core, so we hardwire the affinity to that core.
@@ -890,6 +987,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 +1002,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 +1010,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 +1021,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, octeon_irq_handle_gpio);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 2/3 MIPS: OCTEON: Remove unneeded OCTEON_IRQ_* defines.
In reply to David DaneyFrom: David Daney <[email protected]>
The follow-on patch to add irq_domain support will be the supported method for using these irq lines, so get these defines out of the way in preperation for that.
--- arch/mips/cavium-octeon/octeon-irq.c | 43 ------------------------ arch/mips/include/asm/mach-cavium-octeon/irq.h | 40 +--------------------- 2 files changed, 2 insertions(+), 81 deletions(-)
arch/mips/cavium-octeon/octeon-irq.c +0 -43
@@ -1036,23 +1036,11 @@ static void __init octeon_irq_init_ciu(void)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); - -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 (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); -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);
@@ -1063,37 +1051,6 @@ static void __init octeon_irq_init_ciu(void)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);/* Enable the CIU lines */ set_c0_status (STATUSF_IP3 |STATUSF_IP2 );
arch/mips/include/asm/mach-cavium-octeon/irq.h +2 -38
@@ -41,56 +41,20 @@ enum octeon_irq {OCTEON_IRQ_TWSI ,OCTEON_IRQ_TWSI2 ,OCTEON_IRQ_RML , -OCTEON_IRQ_TRACE0 , -OCTEON_IRQ_GMX_DRP0 =OCTEON_IRQ_TRACE0 +4 , -OCTEON_IRQ_IPD_DRP =OCTEON_IRQ_GMX_DRP0 +5 , -OCTEON_IRQ_KEY_ZERO ,OCTEON_IRQ_TIMER0 ,OCTEON_IRQ_TIMER1 ,OCTEON_IRQ_TIMER2 ,OCTEON_IRQ_TIMER3 ,OCTEON_IRQ_USB0 ,OCTEON_IRQ_USB1 , -OCTEON_IRQ_PCM , -OCTEON_IRQ_MPI , -OCTEON_IRQ_POWIQ , -OCTEON_IRQ_IPDPPTHR ,OCTEON_IRQ_MII0 ,OCTEON_IRQ_MII1 , OCTEON_IRQ_BOOTDMA, - -OCTEON_IRQ_NAND , -OCTEON_IRQ_MIO ,/* Summary of MIO_BOOT_ERR */ -OCTEON_IRQ_IOB ,/* Summary of IOB_INT_SUM */ -OCTEON_IRQ_FPA ,/* Summary of FPA_INT_SUM */ -OCTEON_IRQ_POW ,/* Summary of POW_ECC_ERR */ -OCTEON_IRQ_L2C ,/* Summary of L2C_INT_STAT */ -OCTEON_IRQ_IPD ,/* Summary of IPD_INT_SUM */ -OCTEON_IRQ_PIP ,/* Summary of PIP_INT_REG */ -OCTEON_IRQ_PKO ,/* Summary of PKO_REG_ERROR */ -OCTEON_IRQ_ZIP ,/* Summary of ZIP_ERROR */ -OCTEON_IRQ_TIM ,/* Summary of TIM_REG_ERROR */ -OCTEON_IRQ_RAD ,/* Summary of RAD_REG_ERROR */ -OCTEON_IRQ_KEY ,/* Summary of KEY_INT_SUM */ -OCTEON_IRQ_DFA ,/* Summary of DFA */ -OCTEON_IRQ_USBCTL ,/* Summary of USBN0_INT_SUM */ -OCTEON_IRQ_SLI ,/* Summary of SLI_INT_SUM */ -OCTEON_IRQ_DPI ,/* Summary of DPI_INT_SUM */ -OCTEON_IRQ_AGX0 ,/* Summary of GMX0*+PCS0_INT*_REG */ -OCTEON_IRQ_AGL =OCTEON_IRQ_AGX0 +5 , -OCTEON_IRQ_PTP , -OCTEON_IRQ_PEM0 , -OCTEON_IRQ_PEM1 , -OCTEON_IRQ_SRIO0 , -OCTEON_IRQ_SRIO1 , -OCTEON_IRQ_LMC0 , -OCTEON_IRQ_DFM =OCTEON_IRQ_LMC0 +4 ,/* Summary of DFM */ - OCTEON_IRQ_RST, };#ifdef CONFIG_PCI_MSI -/* 152 - 407 represent the MSI interrupts 0-255 */ -#define OCTEON_IRQ_MSI_BIT0 (OCTEON_IRQ_RST + 1) +/* 256 - 511 represent the MSI interrupts 0-255 */ +#define OCTEON_IRQ_MSI_BIT0 (256)#define OCTEON_IRQ_MSI_LAST (OCTEON_IRQ_MSI_BIT0 + 255)#define OCTEON_IRQ_LAST (OCTEON_IRQ_MSI_LAST + 1)
Signature · 1 line
1.7.2.3
PATCH 3/3 MIPS: OCTEON: Consolidate the edge and level irq_chip structures.
In reply to David DaneyFrom: David Daney <[email protected]>
We can consolidate octeon_irq_chip_ciu_edge and octeon_irq_chip_ciu as they only differ in the .irq_ack element, and that is unused by the level handler. This gets rid of a bunch of duplicate definitions.
--- arch/mips/cavium-octeon/octeon-irq.c | 30 ++---------------------------- 1 files changed, 2 insertions(+), 28 deletions(-)
arch/mips/cavium-octeon/octeon-irq.c +2 -28
@@ -720,18 +720,6 @@ static struct irq_chip octeon_irq_chip_ciu_v2 = { .name = "CIU", .irq_enable = octeon_irq_ciu_enable_v2, .irq_disable = octeon_irq_ciu_disable_all_v2, - .irq_mask = octeon_irq_ciu_disable_local_v2, - .irq_unmask = octeon_irq_ciu_enable_v2, -#ifdef CONFIG_SMP - .irq_set_affinity = octeon_irq_ciu_set_affinity_v2, - .irq_cpu_offline = octeon_irq_cpu_offline_ciu, -#endif -}; - -static struct irq_chip octeon_irq_chip_ciu_edge_v2 = { - .name ="CIU-E" , - .irq_enable = octeon_irq_ciu_enable_v2, - .irq_disable = octeon_irq_ciu_disable_all_v2, .irq_ack = octeon_irq_ciu_ack, .irq_mask = octeon_irq_ciu_disable_local_v2, .irq_unmask = octeon_irq_ciu_enable_v2,
@@ -745,19 +733,8 @@ static struct irq_chip octeon_irq_chip_ciu = { .name = "CIU", .irq_enable = octeon_irq_ciu_enable, .irq_disable = octeon_irq_ciu_disable_all, - .irq_mask = octeon_irq_dummy_mask, -#ifdef CONFIG_SMP - .irq_set_affinity = octeon_irq_ciu_set_affinity, - .irq_cpu_offline = octeon_irq_cpu_offline_ciu, -#endif -}; - -static struct irq_chip octeon_irq_chip_ciu_edge = { - .name ="CIU-E" , - .irq_enable = octeon_irq_ciu_enable, - .irq_disable = octeon_irq_ciu_disable_all, - .irq_mask = octeon_irq_dummy_mask, .irq_ack = octeon_irq_ciu_ack, + .irq_mask = octeon_irq_dummy_mask, #ifdef CONFIG_SMP .irq_set_affinity = octeon_irq_ciu_set_affinity, .irq_cpu_offline = octeon_irq_cpu_offline_ciu,
@@ -984,7 +961,6 @@ static void __init octeon_irq_init_ciu(void) {unsigned int i;struct irq_chip *chip; -struct irq_chip *chip_edge;struct irq_chip *chip_mbox;struct irq_chip *chip_wd;struct irq_chip *chip_gpio;
@@ -999,7 +975,6 @@ static void __init octeon_irq_init_ciu(void) octeon_irq_ip2 = octeon_irq_ip2_v2; octeon_irq_ip3 = octeon_irq_ip3_v2; chip = &octeon_irq_chip_ciu_v2; - 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;
@@ -1007,7 +982,6 @@ static void __init octeon_irq_init_ciu(void) octeon_irq_ip2 = octeon_irq_ip2_v1; octeon_irq_ip3 = octeon_irq_ip3_v1; chip = &octeon_irq_chip_ciu; - 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;
@@ -1037,7 +1011,7 @@ static void __init octeon_irq_init_ciu(void)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);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 (i +OCTEON_IRQ_TIMER0 ,0 , i +52 , chip, handle_edge_irq);octeon_irq_set_ciu_mapping (OCTEON_IRQ_USB0 ,0 ,56 , chip, handle_level_irq);octeon_irq_set_ciu_mapping (OCTEON_IRQ_TWSI2 ,0 ,59 , chip, handle_level_irq);
Signature · 1 line
1.7.2.3