plat-orion multi purpose pins problem for mv78200
Subsystems (5)
Nicola, Lennert -
There's a problem in 3.0-rc5 when calling mv78xx0_mpp_conf() on the MV78200 processor. This processor has 49 multi purpose pins but only 31 GPIOs. MPP[31:0] map directly to GPIO[31:0] but the next 17 are a little more complex:
MPP[39:32] = GPIO[7:0]
MPP[46:40] = GPIO[23:17]
MPP[47] = GPIO[16]
MPP[48] = GPIO[8]
MPP[49] = GPIO[9]
See arch/arm/plat-orion/mpp.c. Inside orion_mpp_conf() the array gets processed by calling MPP_NUM() then calling orion_gpio_set_valid(). As demonstrated above, the MPP number and GPIO number are not interchangeable and on the MV78200 that's a problem when trying to setup any MPP > 31.
So we need to map each MPP to a given GPIO -- I don't know how the mapping will differ across processors. We also need to keep-clear which functions are called with an MPP number and which functions are called with a GPIO number.
Followup question -- Marvell has several SoC families, but Linux uess plat-orion for everything. For example MV78200 isn't an Orion it's a Discovery Innovation series. Would it make more sense to have separate plat-* code for the separate families?
-joey
It looks like there's a second problem here. Imagine you're calling mv78xx0_mpp_conf() and the array has these entries:
MPP16_GPIOMPP47_UNUSED
These are separate MPP pins that can each bring out the same GPIO resource. Notice that as the code stands today, the second call is going to clobber the values valid_input and valid_output for GPIO[16]. The logic for orion_gpio_is_valid() needs to check if a given GPIO is brought-out on any MPP pin.
In the short term, it might be worth disabling the check in orion_gpio_is_valid() to avoid the bug.
-joey
Quoted 36 lines · Joey Oravec
Nicola, Lennert -
There's a problem in 3.0-rc5 when calling
mv78xx0_mpp_conf()on the MV78200 processor. This processor has 49 multi purpose pins but only 31 GPIOs. MPP[31:0] map directly to GPIO[31:0] but the next 17 are a little more complex:MPP[39:32] = GPIO[7:0]
MPP[46:40] = GPIO[23:17]
MPP[47] = GPIO[16]
MPP[48] = GPIO[8]
MPP[49] = GPIO[9]See
arch/arm/plat-orion/mpp.c. Insideorion_mpp_conf()the array gets processed by callingMPP_NUM()then callingorion_gpio_set_valid(). As demonstrated above, the MPP number and GPIO number are not interchangeable and on the MV78200 that's a problem when trying to setup any MPP > 31.So we need to map each MPP to a given GPIO -- I don't know how the mapping will differ across processors. We also need to keep-clear which functions are called with an MPP number and which functions are called with a GPIO number.
Followup question -- Marvell has several SoC families, but Linux uess plat-orion for everything. For example MV78200 isn't an Orion it's a Discovery Innovation series. Would it make more sense to have separate plat-* code for the separate families?
-joey
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel at lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Hi Joey,
Quoted 7 lines · Joey Oravec
Nicola, Lennert -
There's a problem in 3.0-rc5 when calling
mv78xx0_mpp_conf()on the MV78200 processor. This processor has 49 multi purpose pins but only 31 GPIOs. MPP[31:0] map directly to GPIO[31:0] but the next 17 are a little more complex:
Quoted 5 lines
MPP[39:32] = GPIO[7:0]
MPP[46:40] = GPIO[23:17]
MPP[47] = GPIO[16]
MPP[48] = GPIO[8]
MPP[49] = GPIO[9]
It doesn't seems the code was behaving differently before 3.0-rc. I mean before the MPP and GPIO consolidation work. It was ?
Quoted 11 lines
See
arch/arm/plat-orion/mpp.c. Insideorion_mpp_conf()the array gets processed by callingMPP_NUM()then callingorion_gpio_set_valid(). As demonstrated above, the MPP number and GPIO number are not interchangeable and on the MV78200 that's a problem when trying to setup any MPP > 31.So we need to map each MPP to a given GPIO -- I don't know how the mapping will differ across processors. We also need to keep-clear which functions are called with an MPP number and which functions are called with a GPIO number.
As I don't have access to either a MV78200 device or his specification document, let me ask you a few questions.
Does hardware allows a configuration like MPP0_GE0_COL and MPP32_GPIO simultaneously ?
If not (and only if not), the problem is simply mapping a MPP number on the correct GPIO number. Isn't it ?
In that case, what about using the MPPxx_GPIO definitions (found in mach-mv78xx0/mpp.h) to map the right GPIO number ?
For example:
#define MPP32_GPIO MPP(32, 0x1, 1, 1, 1)
could be replaced by:
#define MPP32_GPIO MPP(0, 0x1, 1, 1, 1)
Quoted 5 lines
Followup question -- Marvell has several SoC families, but Linux uess plat-orion for everything. For example MV78200 isn't an Orion it's a Discovery Innovation series. Would it make more sense to have separate plat-* code for the separate families?
As far as possible, we have to share code between the SoCs families.
Regards,
Simon
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20110702/c00680b4/attachment.sig>
Quoted 10 lines · Simon Guinot
Hi Joey,
Quoted 7 lines · Joey Oravec
Nicola, Lennert -
There's a problem in 3.0-rc5 when calling
mv78xx0_mpp_conf()on the MV78200 processor. This processor has 49 multi purpose pins but only 31 GPIOs. MPP[31:0] map directly to GPIO[31:0] but the next 17 are a little more complex:
Quoted 8 lines
Quoted 5 lines
MPP[39:32] = GPIO[7:0]
MPP[46:40] = GPIO[23:17]
MPP[47] = GPIO[16]
MPP[48] = GPIO[8]
MPP[49] = GPIO[9]It doesn't seems the code was behaving differently before 3.0-rc. I mean before the MPP and GPIO consolidation work. It was ?
that's right, this issue was before the consolidation work.
Quoted 13 lines
Quoted 8 lines
See
arch/arm/plat-orion/mpp.c. Insideorion_mpp_conf()the array gets processed by callingMPP_NUM()then callingorion_gpio_set_valid(). As demonstrated above, the MPP number and GPIO number are not interchangeable and on the MV78200 that's a problem when trying to setup any MPP > 31.Quoted 4 lines
So we need to map each MPP to a given GPIO -- I don't know how the mapping will differ across processors. We also need to keep-clear which functions are called with an MPP number and which functions are called with a GPIO number.
Quoted 5 lines
As I don't have access to either a MV78200 device or his specification document, let me ask you a few questions.
Does hardware allows a configuration like
MPP0_GE0_COLandMPP32_GPIOsimultaneously ?
yes, this is possible.
Quoted 7 lines
If not (and only if not), the problem is simply mapping a MPP number on the correct GPIO number. Isn't it ?
In that case, what about using the
MPPxx_GPIOdefinitions (found inmach-mv78xx0/mpp.h) to map the right GPIO number ?
Quoted 7 lines
For example:
#define
MPP32_GPIO? ? ? ?MPP(32,0x1, 1, 1, 1)could be replaced by:
#define
MPP32_GPIO? ? ? ?MPP(0,0x1, 1, 1, 1)
that won't work because the num (first number) is used as the mpp index. see orion_mpp_conf() implementation.
I think the solution is to extend the MPP define to include the explicit gpio number, so it will look like:
#define MPP(_num, _gpio _sel, _in, _out, _78100_A0)
saeed
PATCH v2 1/1 genirq: replace irq_gc_ack() with {set,clr}_bit variants
From: Simon Guinot <[email protected]>
Depending on the device, interrupts acknowledgement is done by setting or by clearing a dedicated register. Replace irq_gc_ack() with some {set,clr}_bit variants allows to handle both cases.
Note that this patch affects the following SoCs: Davinci, Samsung and Orion. Except for this last, the change is minor: irq_gc_ack() is just renamed into irq_gc_ack_set_bit().
For the Orion SoCs, the edge GPIO interrupts support is currently broken. irq_gc_ack() try to acknowledge a such interrupt by setting the corresponding cause register bit. The Orion GPIO device expect the opposite. To fix this issue, the irq_gc_ack_clr_bit() variant is used.
Tested on Network Space v2.
---
Changes for v2: update patch description (mention the affected SoCs).
arch/arm/mach-davinci/irq.c | 2 +- arch/arm/plat-orion/gpio.c | 2 +- arch/arm/plat-s5p/irq-gpioint.c | 2 +- arch/arm/plat-samsung/irq-uart.c | 2 +- include/linux/irq.h | 3 ++- kernel/irq/generic-chip.c | 18 ++++++++++++++++-- 6 files changed, 22 insertions(+), 7 deletions(-)
arch/arm/mach-davinci/irq.c +1 -1
@@ -53,7 +53,7 @@ davinci_alloc_gc(void __iomem *base, unsigned int irq_start, unsigned int num) gc =irq_alloc_generic_chip ("AINTC" ,1 , irq_start, base, handle_edge_irq); ct = gc->chip_types; - ct->chip.irq_ack = irq_gc_ack; + ct->chip.irq_ack = irq_gc_ack_set_bit; ct->chip.irq_mask = irq_gc_mask_clr_bit; ct->chip.irq_unmask = irq_gc_mask_set_bit;
arch/arm/plat-orion/gpio.c +1 -1
@@ -432,7 +432,7 @@ void __init orion_gpio_init(int gpio_base, int ngpio, ct->regs.mask = ochip->mask_offset +GPIO_EDGE_MASK_OFF ; ct->regs.ack =GPIO_EDGE_CAUSE_OFF ; ct->type =IRQ_TYPE_EDGE_RISING |IRQ_TYPE_EDGE_FALLING ; - ct->chip.irq_ack = irq_gc_ack; + ct->chip.irq_ack = irq_gc_ack_clr_bit; ct->chip.irq_mask = irq_gc_mask_clr_bit; ct->chip.irq_unmask = irq_gc_mask_set_bit; ct->chip.irq_set_type = gpio_irq_set_type;
arch/arm/plat-s5p/irq-gpioint.c +1 -1
@@ -152,7 +152,7 @@ static __init int s5p_gpioint_add(struct s3c_gpio_chip *chip)if (!gc)return -ENOMEM ; ct = gc->chip_types; - ct->chip.irq_ack = irq_gc_ack; + ct->chip.irq_ack = irq_gc_ack_set_bit; ct->chip.irq_mask = irq_gc_mask_set_bit; ct->chip.irq_unmask = irq_gc_mask_clr_bit; ct->chip.irq_set_type = s5p_gpioint_set_type,
arch/arm/plat-samsung/irq-uart.c +1 -1
@@ -55,7 +55,7 @@ static void __init s3c_init_uart_irq(struct s3c_uart_irq *uirq) gc =irq_alloc_generic_chip ("s3c-uart" ,1 , uirq->base_irq, reg_base, handle_level_irq); ct = gc->chip_types; - ct->chip.irq_ack = irq_gc_ack; + ct->chip.irq_ack = irq_gc_ack_set_bit; ct->chip.irq_mask = irq_gc_mask_set_bit; ct->chip.irq_unmask = irq_gc_mask_clr_bit; ct->regs.ack =S3C64XX_UINTP ;
include/linux/irq.h +2 -1
@@ -676,7 +676,8 @@ void irq_gc_mask_disable_reg(struct irq_data *d);void irq_gc_mask_set_bit (struct irq_data *d);void irq_gc_mask_clr_bit (struct irq_data *d);void irq_gc_unmask_enable_reg (struct irq_data *d); -void irq_gc_ack (struct irq_data *d); +void irq_gc_ack_set_bit (struct irq_data *d); +void irq_gc_ack_clr_bit (struct irq_data *d);void irq_gc_mask_disable_reg_and_ack (struct irq_data *d);void irq_gc_eoi (struct irq_data *d);int irq_gc_set_wake (struct irq_data *d,unsigned int on);
kernel/irq/generic-chip.c +16 -2
@@ -101,10 +101,10 @@ void irq_gc_unmask_enable_reg(struct irq_data *d) }/** -* irq_gc_ack - Ack pending interrupt +* irq_gc_ack_set_bit - Ack pending interrupt via setting bit * @d: irq_data */ -void irq_gc_ack (struct irq_data *d) +void irq_gc_ack_set_bit (struct irq_data *d) {struct irq_chip_generic *gc =irq_data_get_irq_chip_data (d);u32 mask =1 << (d->irq - gc->irq_base);
@@ -115,6 +115,20 @@ void irq_gc_ack(struct irq_data *d) }/** +* irq_gc_ack_clr_bit - Ack pending interrupt via clearing bit +* @d: irq_data +*/ +void irq_gc_ack_clr_bit (struct irq_data *d) +{ +struct irq_chip_generic *gc =irq_data_get_irq_chip_data (d); +u32 mask = ~(1 << (d->irq - gc->irq_base)); + +irq_gc_lock (gc); +irq_reg_writel (mask, gc->reg_base +cur_regs (d)->ack); +irq_gc_unlock (gc); +} + +/** * irq_gc_mask_disable_reg_and_ack- Mask and ack pending interrupt * @d: irq_data */
Signature · 1 line
1.7.5.1
PATCH v2 1/1 genirq: replace irq_gc_ack() with {set, clr}_bit variants
Quoted 15 lines · Simon Guinot
From: Simon Guinot <[email protected]>
Depending on the device, interrupts acknowledgement is done by setting or by clearing a dedicated register. Replace
irq_gc_ack()with some {set,clr}_bit variants allows to handle both cases.Note that this patch affects the following SoCs: Davinci, Samsung and Orion. Except for this last, the change is minor:
irq_gc_ack()is just renamed intoirq_gc_ack_set_bit().For the Orion SoCs, the edge GPIO interrupts support is currently broken.
irq_gc_ack()try to acknowledge a such interrupt by setting the corresponding cause register bit. The Orion GPIO device expect the opposite. To fix this issue, theirq_gc_ack_clr_bit()variant is used.
Quoted 4 lines
Tested on Network Space v2.
Reported-by Joey Oravec <[email protected]>Signed-off-by Simon Guinot <[email protected]>
Quoted 118 lines
---
Changes for v2: update patch description (mention the affected SoCs).arch/arm/mach-davinci/irq.c | 2 +- arch/arm/plat-orion/gpio.c | 2 +- arch/arm/plat-s5p/irq-gpioint.c | 2 +- arch/arm/plat-samsung/irq-uart.c | 2 +- include/linux/irq.h | 3 ++- kernel/irq/generic-chip.c | 18 ++++++++++++++++-- 6 files changed, 22 insertions(+), 7 deletions(-)arch/arm/mach-davinci/irq.c +1
-1@@ -53,7 +53,7 @@ davinci_alloc_gc(void __iomem *base, unsigned int irq_start, unsigned int num) gc =irq_alloc_generic_chip ("AINTC" ,1 , irq_start, base, handle_edge_irq); ct = gc->chip_types; - ct->chip.irq_ack = irq_gc_ack; + ct->chip.irq_ack = irq_gc_ack_set_bit; ct->chip.irq_mask = irq_gc_mask_clr_bit; ct->chip.irq_unmask = irq_gc_mask_set_bit;arch/arm/plat-orion/gpio.c +1
-1@@ -432,7 +432,7 @@ void __init orion_gpio_init(int gpio_base, int ngpio, ct->regs.mask = ochip->mask_offset +GPIO_EDGE_MASK_OFF ; ct->regs.ack =GPIO_EDGE_CAUSE_OFF ; ct->type =IRQ_TYPE_EDGE_RISING |IRQ_TYPE_EDGE_FALLING ; - ct->chip.irq_ack = irq_gc_ack; + ct->chip.irq_ack = irq_gc_ack_clr_bit; ct->chip.irq_mask = irq_gc_mask_clr_bit; ct->chip.irq_unmask = irq_gc_mask_set_bit; ct->chip.irq_set_type = gpio_irq_set_type;arch/arm/plat-s5p/irq-gpioint.c +1
-1@@ -152,7 +152,7 @@ static __init int s5p_gpioint_add(struct s3c_gpio_chip *chip)if (!gc)return -ENOMEM ; ct = gc->chip_types; - ct->chip.irq_ack = irq_gc_ack; + ct->chip.irq_ack = irq_gc_ack_set_bit; ct->chip.irq_mask = irq_gc_mask_set_bit; ct->chip.irq_unmask = irq_gc_mask_clr_bit; ct->chip.irq_set_type = s5p_gpioint_set_type,arch/arm/plat-samsung/irq-uart.c +1
-1@@ -55,7 +55,7 @@ static void __init s3c_init_uart_irq(struct s3c_uart_irq *uirq) gc =irq_alloc_generic_chip ("s3c-uart" ,1 , uirq->base_irq, reg_base, handle_level_irq); ct = gc->chip_types; - ct->chip.irq_ack = irq_gc_ack; + ct->chip.irq_ack = irq_gc_ack_set_bit; ct->chip.irq_mask = irq_gc_mask_set_bit; ct->chip.irq_unmask = irq_gc_mask_clr_bit; ct->regs.ack =S3C64XX_UINTP ;include/linux/irq.h +2
-1@@ -676,7 +676,8 @@ void irq_gc_mask_disable_reg(struct irq_data *d);void irq_gc_mask_set_bit (struct irq_data *d);void irq_gc_mask_clr_bit (struct irq_data *d);void irq_gc_unmask_enable_reg (struct irq_data *d); -void irq_gc_ack (struct irq_data *d); +void irq_gc_ack_set_bit (struct irq_data *d); +void irq_gc_ack_clr_bit (struct irq_data *d);void irq_gc_mask_disable_reg_and_ack (struct irq_data *d);void irq_gc_eoi (struct irq_data *d);int irq_gc_set_wake (struct irq_data *d,unsigned int on);kernel/irq/generic-chip.c +16
-2@@ -101,10 +101,10 @@ void irq_gc_unmask_enable_reg(struct irq_data *d) }/** -* irq_gc_ack - Ack pending interrupt +* irq_gc_ack_set_bit - Ack pending interrupt via setting bit * @d: irq_data */ -void irq_gc_ack (struct irq_data *d) +void irq_gc_ack_set_bit (struct irq_data *d) {struct irq_chip_generic *gc =irq_data_get_irq_chip_data (d);u32 mask =1 << (d->irq - gc->irq_base);@@ -115,6 +115,20 @@ void irq_gc_ack(struct irq_data *d) }/** +* irq_gc_ack_clr_bit - Ack pending interrupt via clearing bit +* @d: irq_data +*/ +void irq_gc_ack_clr_bit (struct irq_data *d) +{ +struct irq_chip_generic *gc =irq_data_get_irq_chip_data (d); +u32 mask = ~(1 << (d->irq - gc->irq_base)); + +irq_gc_lock (gc); +irq_reg_writel (mask, gc->reg_base +cur_regs (d)->ack); +irq_gc_unlock (gc); +} + +/** * irq_gc_mask_disable_reg_and_ack- Mask and ack pending interrupt * @d: irq_data */ Signature · 1 line
1.7.5.1
PATCH v2 1/1 genirq: replace irq_gc_ack() with {set, clr}_bit variants
Quoted 18 lines · Nicolas Pitre
Quoted 15 lines · Simon Guinot
From: Simon Guinot <[email protected]>
Depending on the device, interrupts acknowledgement is done by setting or by clearing a dedicated register. Replace
irq_gc_ack()with some {set,clr}_bit variants allows to handle both cases.Note that this patch affects the following SoCs: Davinci, Samsung and Orion. Except for this last, the change is minor:
irq_gc_ack()is just renamed intoirq_gc_ack_set_bit().For the Orion SoCs, the edge GPIO interrupts support is currently broken.
irq_gc_ack()try to acknowledge a such interrupt by setting the corresponding cause register bit. The Orion GPIO device expect the opposite. To fix this issue, theirq_gc_ack_clr_bit()variant is used.
Quoted 7 lines
Quoted 4 lines
Tested on Network Space v2.
Reported-by Joey Oravec <[email protected]>Signed-off-by Simon Guinot <[email protected]>Acked-by Nicolas Pitre <[email protected]>
Sorry for late response...
If required,
Thanks.
Best regards,
Kgene.
--
Kukjin Kim <[email protected]>, Senior Engineer, SW Solution Development Team, Samsung Electronics Co., Ltd.
Quoted 12 lines
Quoted 12 lines
---
Changes for v2: update patch description (mention the affected SoCs).arch/arm/mach-davinci/irq.c | 2 +- arch/arm/plat-orion/gpio.c | 2 +- arch/arm/plat-s5p/irq-gpioint.c | 2 +- arch/arm/plat-samsung/irq-uart.c | 2 +- include/linux/irq.h | 3 ++- kernel/irq/generic-chip.c | 18 ++++++++++++++++-- 6 files changed, 22 insertions(+), 7 deletions(-)
Quoted 8 lines
arch/arm/mach-davinci/irq.c davinci_alloc_gc(void __iomem *base, unsigned int
Quoted 5 lines
arch/arm/mach-davinci/irq.c +0
-0@@ -53,7 +53,7 @@ davinci_alloc_gc(void __iomem *base, unsigned int
irq_start, unsigned int num)Quoted 2 lines
arch/arm/mach-davinci/irq.c +0
-0gc = irq_alloc_generic_chip("AINTC", 1, irq_start, base,
handle_edge_irq);
Quoted 11 lines
arch/arm/plat-orion/gpio.c void __init orion_gpio_init(int gpio_base, int
Quoted 11 lines
arch/arm/mach-davinci/irq.c +1
-1ct = gc->chip_types; - ct->chip.irq_ack = irq_gc_ack; + ct->chip.irq_ack = irq_gc_ack_set_bit; ct->chip.irq_mask = irq_gc_mask_clr_bit; ct->chip.irq_unmask = irq_gc_mask_set_bit;arch/arm/plat-orion/gpio.c +0
-0@@ -432,7 +432,7 @@ void __init orion_gpio_init(int gpio_base, int
ngpio,
Quoted 9 lines
Review
Quoted 9 lines
arch/arm/plat-orion/gpio.c +1
-1ct->regs.mask = ochip->mask_offset +GPIO_EDGE_MASK_OFF ; ct->regs.ack =GPIO_EDGE_CAUSE_OFF ; ct->type =IRQ_TYPE_EDGE_RISING |IRQ_TYPE_EDGE_FALLING ; - ct->chip.irq_ack = irq_gc_ack; + ct->chip.irq_ack = irq_gc_ack_clr_bit; ct->chip.irq_mask = irq_gc_mask_clr_bit; ct->chip.irq_unmask = irq_gc_mask_set_bit; ct->chip.irq_set_type = gpio_irq_set_type;(quoted diff) +0
-0
b/arch/arm/plat-s5p/irq-gpioint.c
Quoted 4 lines
arch/arm/plat-s5p/irq-gpioint.c static __init int s5p_gpioint_add(struct
Quoted 4 lines
index 135abda..327ab9f 100644
arch/arm/plat-s5p/irq-gpioint.c +0
-0@@ -152,7 +152,7 @@ static __init int s5p_gpioint_add(struct
s3c_gpio_chip
Quoted 10 lines
*chip)
Review
Quoted 9 lines
arch/arm/plat-s5p/irq-gpioint.c +1
-1if (!gc)return -ENOMEM ; ct = gc->chip_types; - ct->chip.irq_ack = irq_gc_ack; + ct->chip.irq_ack = irq_gc_ack_set_bit; ct->chip.irq_mask = irq_gc_mask_set_bit; ct->chip.irq_unmask = irq_gc_mask_clr_bit; ct->chip.irq_set_type = s5p_gpioint_set_type,(quoted diff) +0
-0
b/arch/arm/plat-samsung/irq-uart.c
Quoted 4 lines
arch/arm/plat-samsung/irq-uart.c static void __init s3c_init_uart_irq(struct
Quoted 4 lines
index 32582c0..0e46588 100644
arch/arm/plat-samsung/irq-uart.c +0
-0@@ -55,7 +55,7 @@ static void __init s3c_init_uart_irq(struct
s3c_uart_irq *uirq)
Quoted 63 lines
Quoted 63 lines
arch/arm/plat-samsung/irq-uart.c +1
-1gc =irq_alloc_generic_chip ("s3c-uart" ,1 , uirq->base_irq, reg_base, handle_level_irq); ct = gc->chip_types; - ct->chip.irq_ack = irq_gc_ack; + ct->chip.irq_ack = irq_gc_ack_set_bit; ct->chip.irq_mask = irq_gc_mask_set_bit; ct->chip.irq_unmask = irq_gc_mask_clr_bit; ct->regs.ack =S3C64XX_UINTP ;include/linux/irq.h +2
-1@@ -676,7 +676,8 @@ void irq_gc_mask_disable_reg(struct irq_data *d);void irq_gc_mask_set_bit (struct irq_data *d);void irq_gc_mask_clr_bit (struct irq_data *d);void irq_gc_unmask_enable_reg (struct irq_data *d); -void irq_gc_ack (struct irq_data *d); +void irq_gc_ack_set_bit (struct irq_data *d); +void irq_gc_ack_clr_bit (struct irq_data *d);void irq_gc_mask_disable_reg_and_ack (struct irq_data *d);void irq_gc_eoi (struct irq_data *d);int irq_gc_set_wake (struct irq_data *d,unsigned int on);kernel/irq/generic-chip.c +16
-3@@ -101,10 +101,10 @@ void irq_gc_unmask_enable_reg(struct irq_data *d) }/** -* irq_gc_ack - Ack pending interrupt +* irq_gc_ack_set_bit - Ack pending interrupt via setting bit * @d: irq_data */ -void irq_gc_ack (struct irq_data *d) +void irq_gc_ack_set_bit (struct irq_data *d) {struct irq_chip_generic *gc =irq_data_get_irq_chip_data (d);u32 mask =1 << (d->irq - gc->irq_base);@@ -115,6 +115,20 @@ void irq_gc_ack(struct irq_data *d) }/** +* irq_gc_ack_clr_bit - Ack pending interrupt via clearing bit +* @d: irq_data +*/ +void irq_gc_ack_clr_bit (struct irq_data *d) +{ +struct irq_chip_generic *gc =irq_data_get_irq_chip_data (d); +u32 mask = ~(1 << (d->irq - gc->irq_base)); + +irq_gc_lock (gc); +irq_reg_writel (mask, gc->reg_base +cur_regs (d)->ack); +irq_gc_unlock (gc); +} + +/** * irq_gc_mask_disable_reg_and_ack- Mask and ack pending interrupt * @d: irq_data */ --1.7.5.1
PATCH v2 1/1 genirq: replace irq_gc_ack() with {set,clr}_bit variants
In reply to Simon GuinotHi Thomas,
Quoted 22 lines · Simon Guinot
From: Simon Guinot <[email protected]>
Depending on the device, interrupts acknowledgement is done by setting or by clearing a dedicated register. Replace
irq_gc_ack()with some {set,clr}_bit variants allows to handle both cases.Note that this patch affects the following SoCs: Davinci, Samsung and Orion. Except for this last, the change is minor:
irq_gc_ack()is just renamed intoirq_gc_ack_set_bit().For the Orion SoCs, the edge GPIO interrupts support is currently broken.
irq_gc_ack()try to acknowledge a such interrupt by setting the corresponding cause register bit. The Orion GPIO device expect the opposite. To fix this issue, theirq_gc_ack_clr_bit()variant is used.Tested on Network Space v2.
Reported-by Joey Oravec <[email protected]>Signed-off-by Simon Guinot <[email protected]>---
Changes for v2: update patch description (mention the affected SoCs).
Quoted 7 lines
arch/arm/mach-davinci/irq.c | 2 +- arch/arm/plat-orion/gpio.c | 2 +- arch/arm/plat-s5p/irq-gpioint.c | 2 +- arch/arm/plat-samsung/irq-uart.c | 2 +- include/linux/irq.h | 3 ++- kernel/irq/generic-chip.c | 18 ++++++++++++++++-- 6 files changed, 22 insertions(+), 7 deletions(-)
Please, apply this patch.
Regards,
Simon
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20110706/dd8a0d68/attachment.sig>
Quoted 3 lines · saeed bishara
Quoted 2 lines
It doesn't seems the code was behaving differently before 3.0-rc. I mean before the MPP and GPIO consolidation work. It was ?
that's right, this issue was before the consolidation work.
Agreed. I only meant to say that the MPP code is broken for mv78200 in 3.0-rc5, so the maintainers should consider a short-term fix of disabling the checks in orion_gpio_is_valid().
Quoted 3 lines
Quoted 2 lines
Does hardware allows a configuration like
MPP0_GE0_COLandMPP32_GPIOsimultaneously ?yes, this is possible.
Agreed. MPP is the pin that can be mux'ed to 7 resources. GPIO is just one of those resources. Yes the hardware supports your example. Most resources can be routed to several different pins to allow flexibility in board design.
Since MPP is just a pin-mux, it's possible for Marvell to build an SoC in the future that can route a few different GPIOs onto a given MPP pin. It seems like any solution should account for this.
Quoted 10 lines
Quoted 10 lines
If not (and only if not), the problem is simply mapping a MPP number on the correct GPIO number. Isn't it ?
In that case, what about using the
MPPxx_GPIOdefinitions (found inmach-mv78xx0/mpp.h) to map the right GPIO number ?For example:
#define
MPP32_GPIOMPP(32, 0x1, 1, 1, 1)
Quoted 8 lines
Quoted 3 lines
could be replaced by:
#define
MPP32_GPIOMPP(0, 0x1, 1, 1, 1)that won't work because the num (first number) is used as the mpp index. see
orion_mpp_conf()implementation.
I think the solution is to extend the MPP define to include the explicit gpio number, so it will look like:
#defineMPP(_num, _gpio _sel, _in, _out, _78100_A0)
That could work as long as a value is reserved to mean "not gpio" like:
#define MPP0_GPIO MPP(0, 0, 0x0, 1, 1, 1)
#define MPP0_GE0_COL MPP(0, -1, 0x1, 1, 0, 1)
Note that orion_gpio_set_valid() and orion_gpio_is_valid() would both need rework. The functions need to handle that a GPIO can be mux'ed onto any MPP pin. I described this problem in another email on the thread.
There has been some discussion of a pinmux API. Does this API offer any simpler solution?
-joey
Quoted 7 lines · Joey Oravec
Quoted 3 lines · saeed bishara
Quoted 2 lines
It doesn't seems the code was behaving differently before 3.0-rc. I mean before the MPP and GPIO consolidation work. It was ?
that's right, this issue was before the consolidation work.
Agreed. I only meant to say that the MPP code is broken for mv78200 in 3.0-rc5, so the maintainers should consider a short-term fix of disabling the checks in
orion_gpio_is_valid().
And break code relying on the orion_gpio_is_valid() correctness ? IMHO, this kind of workaround is just not acceptable.
Quoted 31 lines
Quoted 4 lines
Quoted 3 lines
Does hardware allows a configuration like
MPP0_GE0_COLandMPP32_GPIOsimultaneously ?yes, this is possible.
Agreed. MPP is the pin that can be mux'ed to 7 resources. GPIO is just one of those resources. Yes the hardware supports your example. Most resources can be routed to several different pins to allow flexibility in board design.
Since MPP is just a pin-mux, it's possible for Marvell to build an SoC in the future that can route a few different GPIOs onto a given MPP pin. It seems like any solution should account for this.
Quoted 10 lines
Quoted 10 lines
If not (and only if not), the problem is simply mapping a MPP number on the correct GPIO number. Isn't it ?
In that case, what about using the
MPPxx_GPIOdefinitions (found inmach-mv78xx0/mpp.h) to map the right GPIO number ?For example:
#define
MPP32_GPIOMPP(32, 0x1, 1, 1, 1)Quoted 8 lines
Quoted 3 lines
could be replaced by:
#define
MPP32_GPIOMPP(0, 0x1, 1, 1, 1)that won't work because the num (first number) is used as the mpp index. see
orion_mpp_conf()implementation.
I think the solution is to extend the MPP define to include the explicit gpio number, so it will look like:
#defineMPP(_num, _gpio _sel, _in, _out, _78100_A0)
Quoted 4 lines
That could work as long as a value is reserved to mean "not gpio" like:
#define
MPP0_GPIOMPP(0, 0, 0x0, 1, 1, 1)
#defineMPP0_GE0_COLMPP(0, -1, 0x1, 1, 0, 1)
Maybe we could add a function pointer to the parameter list for orion_mpp_conf(). Something like: int (*mpp_to_gpio) (unsigned int num).
If given to orion_mpp_conf(), the function would be used to perform the MPP to GPIO conversion. And if NULL, a 1:1 GPIO to MPP mapping would be used (current code).
A such solution would let almost unchanged the code found in mach-{kirkwood,orion5x,dove}.
Quoted 5 lines
Note that
orion_gpio_set_valid()andorion_gpio_is_valid()would both need rework. The functions need to handle that a GPIO can be mux'ed onto any MPP pin. I described this problem in another email on the thread.
I don't understand what's wrong with the GPIO array.
Simon
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20110706/7c8a4a63/attachment.sig>
Quoted 9 lines
Quoted 6 lines
Quoted 3 lines
Quoted 2 lines
It doesn't seems the code was behaving differently before 3.0-rc. I mean before the MPP and GPIO consolidation work. It was ?
that's right, this issue was before the consolidation work.
Agreed. I only meant to say that the MPP code is broken for mv78200 in 3.0-rc5, so the maintainers should consider a short-term fix of disabling the checks in
orion_gpio_is_valid().And break code relying on the
orion_gpio_is_valid()correctness ? IMHO, this kind of workaround is just not acceptable.
agree
Quoted 9 lines
Quoted 8 lines
Quoted 4 lines
I think the solution is to extend the MPP define to include the explicit gpio number, so it will look like:
#defineMPP(_num, _gpio _sel, _in, _out, _78100_A0)That could work as long as a value is reserved to mean "not gpio" like:
#define
MPP0_GPIO? ? ? ?MPP(0, 0,0x0, 1, 1, 1) #defineMPP0_GE0_COL? ? ? ?MPP(0, -1,0x1, 1, 0, 1)
Quoted 6 lines
Maybe we could add a function pointer to the parameter list for
orion_mpp_conf(). Something like: int (*mpp_to_gpio) (unsigned int num).If given to
orion_mpp_conf(), the function would be used to perform the MPP to GPIO conversion. And if NULL, a 1:1 GPIO to MPP mapping would be used (current code).
this is not enough, because for each mpp element of the mpp_list, we have to know whether the mpp is selected for gpio mode or not. saeed
Quoted 5 lines · Simon Guinot
Quoted 4 lines
Note that
orion_gpio_set_valid()andorion_gpio_is_valid()would both need rework. The functions need to handle that a GPIO can be mux'ed onto any MPP pin. I described this problem in another email on the thread.I don't understand what's wrong with the GPIO array.
I tried to describe the case in my reply:
http://lists.arm.linux.org.uk/lurker/message/20110701.215657.7efe0a42.en.html
Assume that we've solved the mpp_to_gpio mapping. Then imagine you pass a large array to mv78xx0_mpp_conf() that includes:
MPP16_GPIO (this mpp corresponds to GPIO16)MPP47_UNUSED (this mpp corresponds to GPIO16)
The code today processes the array in-order. When it processes MPP16_GPIO it will mark the GPIO16 valid. When it processes MPP47_UNUSED it would currently mark GPIO16 invalid. This is a problem because it still assumes a 1:1 relationship.
-joey
Quoted 15 lines · Joey Oravec
Quoted 7 lines · Simon Guinot
Quoted 5 lines
Note that
orion_gpio_set_valid()andorion_gpio_is_valid()would both need rework. The functions need to handle that a GPIO can be mux'ed onto any MPP pin. I described this problem in another email on the thread.I don't understand what's wrong with the GPIO array.
I tried to describe the case in my reply:
http://lists.arm.linux.org.uk/lurker/message/20110701.215657.7efe0a42.en.htmlAssume that we've solved the
mpp_to_gpiomapping. Then imagine you pass a large array tomv78xx0_mpp_conf()that includes:
Quoted 7 lines
MPP16_GPIO(this mpp corresponds to GPIO16)MPP47_UNUSED(this mpp corresponds to GPIO16)The code today processes the array in-order. When it processes
MPP16_GPIOit will mark the GPIO16 valid. When it processesMPP47_UNUSEDit would currently mark GPIO16 invalid. This is a problem because it still assumes a 1:1 relationship.
I agree, this is why we need some method to make the orion_mpp_conf() know which mpps are gpios, when that done, then the gpio of MPP47 in your case will not be set as invalid.
one option to do that is to assume that mpp with _in == out_ == 0 is not a gpio. so the orion_mpp_conf() will look like this:
arch/arm/plat-orion/mpp.c +0 -0
@@ -41,6 +41,7 @@ void __init orion_mpp_conf(unsigned int *mpp_list,
unsigned int variant_mask,
for ( ; *mpp_list; mpp_list++) {
unsigned int num = MPP_NUM(*mpp_list);
unsigned int sel = MPP_SEL(*mpp_list);
+ unsigned int gpio_num = MPP_GPIO(*mpp_list);
int shift, gpio_mode;
if (num > mpp_max) {
@@ -64,9 +65,8 @@ void __init orion_mpp_conf(unsigned int *mpp_list,
unsigned int variant_mask,
gpio_mode |= GPIO_INPUT_OK;
if (*mpp_list & MPP_OUTPUT_MASK)
gpio_mode |= GPIO_OUTPUT_OK;- if (sel != 0)
- gpio_mode = 0;
- orion_gpio_set_valid(num, gpio_mode);
+ if (gpio_mode != 0)
+ orion_gpio_set_valid(gpio_num, gpio_mode);
}and of course this will require that any non gpio mpp will have to have the _in and _out set to 0.
saeed
Quoted 47 lines · saeed bishara
Quoted 11 lines
Quoted 5 lines
Quoted 4 lines
Note that
orion_gpio_set_valid()andorion_gpio_is_valid()would both need rework. The functions need to handle that a GPIO can be mux'ed onto any MPP pin. I described this problem in another email on the thread.I don't understand what's wrong with the GPIO array.
I tried to describe the case in my reply:
http://lists.arm.linux.org.uk/lurker/message/20110701.215657.7efe0a42.en.htmlAssume that we've solved the
mpp_to_gpiomapping. Then imagine you pass a large array tomv78xx0_mpp_conf()that includes:Quoted 7 lines
MPP16_GPIO(this mpp corresponds to GPIO16)MPP47_UNUSED(this mpp corresponds to GPIO16)The code today processes the array in-order. When it processes
MPP16_GPIOit will mark the GPIO16 valid. When it processesMPP47_UNUSEDit would currently mark GPIO16 invalid. This is a problem because it still assumes a 1:1 relationship.I agree, this is why we need some method to make the
orion_mpp_conf()know which mpps are gpios, when that done, then the gpio of MPP47 in your case will not be set as invalid.
one option to do that is to assume that mpp with_in==out_== 0 is not a gpio. so theorion_mpp_conf()will look like this:arch/arm/plat-orion/mpp.c +1
-0@@ -41,6 +41,7 @@ void __init orion_mpp_conf(unsigned int *mpp_list,unsigned int variant_mask, for ( ; *mpp_list; mpp_list++) {unsigned int num =MPP_NUM (*mpp_list);unsigned int sel =MPP_SEL (*mpp_list); +unsigned int gpio_num =MPP_GPIO (*mpp_list);int shift, gpio_mode;if (num> mpp_max) {arch/arm/plat-orion/mpp.c +2
-3@@ -64,9 +65,8 @@ void __init orion_mpp_conf(unsigned int *mpp_list,unsigned int variant_mask, gpio_mode |= GPIO_INPUT_OK;if (*mpp_list&MPP_OUTPUT_MASK ) gpio_mode |=GPIO_OUTPUT_OK ; -if (sel !=0 ) - gpio_mode =0 ; -orion_gpio_set_valid (num, gpio_mode); +if (gpio_mode !=0 ) +orion_gpio_set_valid (gpio_num, gpio_mode); }
Quoted 2 lines
and of course this will require that any non gpio mpp will have to have the
_inand_outset to 0.
Yes this proposal is better for mv78xx0 than the current code, but it may fail if you call orion_mpp_conf() multiple times. Imagine you setup the MPP16_GPIO as described, then a subsequent call wants to configure differently and sets:
MPP16_UNUSED (this mpp corresponds to GPIO16)
Note orion_gpio_set_valid() contains code to mark GPIOs as valid or invalid, but proposed change will only make a call to mark a GPIO as valid. This example would reconfigure the MPP but leave the GPIO marked valid.
Eventually, we would need to handle this example to implement the proposed pinmux API. Right?
-joey
Quoted 55 lines · Joey Oravec
Quoted 54 lines · saeed bishara
Quoted 18 lines
Quoted 7 lines
Quoted 5 lines
Note that
orion_gpio_set_valid()andorion_gpio_is_valid()would both need rework. The functions need to handle that a GPIO can be mux'ed onto any MPP pin. I described this problem in another email on the thread.I don't understand what's wrong with the GPIO array.
I tried to describe the case in my reply:
http://lists.arm.linux.org.uk/lurker/message/20110701.215657.7efe0a42.en.html
Assume that we've solved the
mpp_to_gpiomapping. Then imagine you pass a large array tomv78xx0_mpp_conf()that includes:
MPP16_GPIO(this mpp corresponds to GPIO16)MPP47_UNUSED(this mpp corresponds to GPIO16)Quoted 6 lines
The code today processes the array in-order. When it processes
MPP16_GPIOit
will mark the GPIO16 valid. When it processesMPP47_UNUSEDit would currently mark GPIO16 invalid. This is a problem because it still assumes a
1:1 relationship.I agree, this is why we need some method to make the
orion_mpp_conf()know which mpps are gpios, when that done, then the gpio of MPP47 in your case will not be set as invalid.
one option to do that is to assume that mpp with_in==out_== 0 is not a gpio. so theorion_mpp_conf()will look like this:arch/arm/plat-orion/mpp.c +1
-0@@ -41,6 +41,7 @@ void __init orion_mpp_conf(unsigned int *mpp_list, unsigned int variant_mask, ? ? ? ? for ( ; *mpp_list; mpp_list++) { ? ? ? ? ? ? ? ? unsigned int num = MPP_NUM(*mpp_list); ? ? ? ? ? ? ? ? unsigned int sel = MPP_SEL(*mpp_list); + ? ? ? ? ? ? ? unsigned int gpio_num = MPP_GPIO(*mpp_list); ? ? ? ? ? ? ? ? int shift, gpio_mode;? ? ? ? ? ? ? ? if (num> ?mpp_max) {
arch/arm/plat-orion/mpp.c +2
-3@@ -64,9 +65,8 @@ void __init orion_mpp_conf(unsigned int *mpp_list,unsigned int variant_mask, ? ? ? ? ? ? ? ? ? ? ? ? gpio_mode |= GPIO_INPUT_OK; ? ? ? ? ? ? ? ? if (*mpp_list& ?MPP_OUTPUT_MASK) ? ? ? ? ? ? ? ? ? ? ? ? gpio_mode |= GPIO_OUTPUT_OK; - ? ? ? ? ? ? ? if (sel != 0) - ? ? ? ? ? ? ? ? ? ? ? gpio_mode = 0; - ? ? ? ? ? ? ? orion_gpio_set_valid(num, gpio_mode); + ? ? ? ? ? ? ? if (gpio_mode != 0) + ? ? ? ? ? ? ? ? ? ? ? orion_gpio_set_valid(gpio_num, gpio_mode); ? ? ? ? }
Quoted 7 lines
Quoted 2 lines
and of course this will require that any non gpio mpp will have to have the
_inand_outset to 0.Yes this proposal is better for mv78xx0 than the current code, but it may fail if you call
orion_mpp_conf()multiple times. Imagine you setup theMPP16_GPIOas described, then a subsequent call wants to configure differently and sets:
the issue that you're describing is theoretical and doesn't happen at least in the boards that supported by the kernel.
I don't think it deserve to complicate our code.
Quoted 9 lines
MPP16_UNUSED(this mpp corresponds to GPIO16)Note
orion_gpio_set_valid()contains code to mark GPIOs as valid or invalid, but proposed change will only make a call to mark a GPIO as valid. This example would reconfigure the MPP but leave the GPIO marked valid.Eventually, we would need to handle this example to implement the proposed pinmux API. Right?
it makes sense. have you tried it?
Quoted 3 lines
-joey
Quoted 35 lines · saeed bishara
Quoted 29 lines
Quoted 29 lines
I agree, this is why we need some method to make the
orion_mpp_conf()know which mpps are gpios, when that done, then the gpio of MPP47 in your case will not be set as invalid.
one option to do that is to assume that mpp with_in==out_== 0 is not a gpio. so theorion_mpp_conf()will look like this:arch/arm/plat-orion/mpp.c +1
-0@@ -41,6 +41,7 @@ void __init orion_mpp_conf(unsigned int *mpp_list,unsigned int variant_mask, for ( ; *mpp_list; mpp_list++) {unsigned int num =MPP_NUM (*mpp_list);unsigned int sel =MPP_SEL (*mpp_list); +unsigned int gpio_num =MPP_GPIO (*mpp_list);int shift, gpio_mode;if (num> mpp_max) {arch/arm/plat-orion/mpp.c +2
-3@@ -64,9 +65,8 @@ void __init orion_mpp_conf(unsigned int *mpp_list,unsigned int variant_mask, gpio_mode |= GPIO_INPUT_OK;if (*mpp_list&MPP_OUTPUT_MASK ) gpio_mode |=GPIO_OUTPUT_OK ; -if (sel !=0 ) - gpio_mode =0 ; -orion_gpio_set_valid (num, gpio_mode); +if (gpio_mode !=0 ) +orion_gpio_set_valid (gpio_num, gpio_mode); }Quoted 6 lines
Quoted 2 lines
and of course this will require that any non gpio mpp will have to have the
_inand_outset to 0.Yes this proposal is better for mv78xx0 than the current code, but it may fail if you call
orion_mpp_conf()multiple times. Imagine you setup theMPP16_GPIOas described, then a subsequent call wants to configure differently and sets:
Quoted 3 lines
the issue that you're describing is theoretical and doesn't happen at least in the boards that supported by the kernel.
I don't think it deserve to complicate our code.
I agree no boards are currently doing this, especially since the functions are marked __init and the code is not capable of it today. But it's reasonable that a driver would want to switch MPPs between a peripheral and a high-impedance state, for example during suspend/resume.
Quoted 9 lines
Quoted 8 lines
MPP16_UNUSED(this mpp corresponds to GPIO16)Note
orion_gpio_set_valid()contains code to mark GPIOs as valid or invalid, but proposed change will only make a call to mark a GPIO as valid. This example would reconfigure the MPP but leave the GPIO marked valid.Eventually, we would need to handle this example to implement the proposed pinmux API. Right?
it makes sense. have you tried it?
The latest proposal I could find is from June:
http://lists.infradead.org/pipermail/linux-arm-kernel/2011-June/052955.html
I have not tried to implement that API yet. The proposal allows changing mux settings at any time, so it seems like the mv78xx0 should be prepared to do that at some point in the future.
-joey