arch/arm/common/vic.c: code reorganization
PATCH 1/1 arch/arm/common/vic.c: code reorganization
This reorganizes the vic.c code in anticipation of a future patch to use struct vic_device as the data stored in set_irq_chip_data().
The new code has the following flow:
1) struct vic_device definition, static variables, and to_vic() moved to the start of the code.
2) vic power management callbacks
3) vic power management initialization/registration
4) irq_chip callbacks
5) vendor specific vic initialization
6) vic initialization
In addition the typo vik_init_st is fixed (vic_init_st).
---
I originally sent this to the wrong list...
V2 - rebased to current git tree
arch/arm/common/vic.c +131 -133
@@ -27,48 +27,6 @@#include <asm/mach/irq.h> #include <asm/hardware/vic.h> -static void vic_ack_irq (unsigned int irq) -{ -void __iomem *base =get_irq_chip_data (irq); - irq &=31 ; -writel (1 << irq, base +VIC_INT_ENABLE_CLEAR ); -/* moreover, clear the soft-triggered, in case it was the reason */ -writel (1 << irq, base +VIC_INT_SOFT_CLEAR ); -} - -static void vic_mask_irq (unsigned int irq) -{ -void __iomem *base =get_irq_chip_data (irq); - irq &=31 ; -writel (1 << irq, base +VIC_INT_ENABLE_CLEAR ); -} - -static void vic_unmask_irq (unsigned int irq) -{ -void __iomem *base =get_irq_chip_data (irq); - irq &=31 ; -writel (1 << irq, base +VIC_INT_ENABLE ); -} - -/** -* vic_init2 - common initialisation code -* @base: Base of the VIC. -* -* Common initialisation code for registeration -* and resume. -*/ -static void vic_init2 (void __iomem *base) -{ -int i; - -for (i =0 ; i <16 ; i++) { -void __iomem *reg = base +VIC_VECT_CNTL0 + (i *4 ); -writel (VIC_VECT_CNTL_ENABLE | i, reg); - } - -writel (32 , base +VIC_PL190_DEF_VECT_ADDR ); -} -#if defined(CONFIG_PM )/** * struct vic_device - VIC PM device
@@ -98,13 +56,34 @@ struct vic_device {/* we cannot allocate memory when VICs are initially registered */ static struct vic_device vic_devices[CONFIG_ARM_VIC_NR ]; +static int vic_id; +static inline struct vic_device *to_vic (struct sys_device *sys) { return container_of(sys, struct vic_device, sysdev); } +#endif /* CONFIG_PM */ -static int vic_id; +/** +* vic_init2 - common initialisation code +* @base: Base of the VIC. +* +* Common initialisation code for registeration +* and resume. +*/ +static void vic_init2 (void __iomem *base) +{ +int i; + +for (i =0 ; i <16 ; i++) { +void __iomem *reg = base +VIC_VECT_CNTL0 + (i *4 ); +writel (VIC_VECT_CNTL_ENABLE | i, reg); + } +writel (32 , base +VIC_PL190_DEF_VECT_ADDR ); +} + +#if defined(CONFIG_PM )static int vic_class_resume (struct sys_device *dev) {struct vic_device *vic =to_vic (dev);
@@ -158,31 +137,6 @@ struct sysdev_class vic_class = { };/** -* vic_pm_register - Register a VIC for later power management control -* @base: The base address of the VIC. -* @irq: The base IRQ for the VIC. -* @resume_sources: bitmask of interrupts allowed for resume sources. -* -* Register the VIC with the system device tree so that it can be notified -* of suspend and resume requests and ensure that the correct actions are -* taken to re-instate the settings on resume. -*/ -static void __init vic_pm_register (void __iomem *base,unsigned int irq,u32 resume_sources) -{ -struct vic_device *v; - -if (vic_id >=ARRAY_SIZE (vic_devices)) -printk (KERN_ERR "%s: too few VICs, increase CONFIG_ARM_VIC_NR\n" , __func__); -else { - v = &vic_devices[vic_id]; - v->base = base; - v->resume_sources = resume_sources; - v->irq = irq; - vic_id++; - } -} - -/** * vic_pm_init - initicall to register VIC pm * * This is called via late_initcall() to register
@@ -218,9 +172,60 @@ static int __init vic_pm_init(void)return 0 ; } -late_initcall (vic_pm_init); +/** +* vic_pm_register - Register a VIC for later power management control +* @base: The base address of the VIC. +* @irq: The base IRQ for the VIC. +* @resume_sources: bitmask of interrupts allowed for resume sources. +* +* Register the VIC with the system device tree so that it can be notified +* of suspend and resume requests and ensure that the correct actions are +* taken to re-instate the settings on resume. +*/ +static void __init vic_pm_register (void __iomem *base,unsigned int irq,u32 resume_sources) +{ +struct vic_device *v; + +if (vic_id >=ARRAY_SIZE (vic_devices)) +printk (KERN_ERR "%s: too few VICs, increase CONFIG_ARM_VIC_NR\n" , __func__); +else { + v = &vic_devices[vic_id]; + v->base = base; + v->resume_sources = resume_sources; + v->irq = irq; + vic_id++; + } +} +#else +static inline void vic_pm_register (void __iomem *base,unsigned int irq,u32 arg1) { } +#endif /* CONFIG_PM */ + +static void vic_ack_irq (unsigned int irq) +{ +void __iomem *base =get_irq_chip_data (irq); + irq &=31 ; +writel (1 << irq, base +VIC_INT_ENABLE_CLEAR ); +/* moreover, clear the soft-triggered, in case it was the reason */ +writel (1 << irq, base +VIC_INT_SOFT_CLEAR ); +} + +static void vic_mask_irq (unsigned int irq) +{ +void __iomem *base =get_irq_chip_data (irq); + irq &=31 ; +writel (1 << irq, base +VIC_INT_ENABLE_CLEAR ); +} + +static void vic_unmask_irq (unsigned int irq) +{ +void __iomem *base =get_irq_chip_data (irq); + irq &=31 ; +writel (1 << irq, base +VIC_INT_ENABLE ); +} + +#if defined(CONFIG_PM )static struct vic_device *vic_from_irq (unsigned int irq) {struct vic_device *v = vic_devices;
@@ -254,10 +259,7 @@ static int vic_set_wake(unsigned int irq, unsigned int on) return 0; } -#else -static inline void vic_pm_register (void __iomem *base,unsigned int irq,u32 arg1) { } -#define vic_set_wake NULL#endif /* CONFIG_PM */
@@ -269,9 +271,62 @@ static struct irq_chip vic_chip = { .set_wake = vic_set_wake, }; -/* The PL190 cell from ARM has been modified by ST, so handle both here */ -static void vik_init_st (void __iomem *base,unsigned int irq_start, -u32 vic_sources); +/* +* The PL190 cell from ARM has been modified by ST to handle 64 interrupts. +* The original cell has 32 interrupts, while the modified one has 64, +* replocating two blocks 0x00..0x1f in 0x20..0x3f. In that case +* the probe function is called twice, with base set to offset 000 +* and 020 within the page. We call this "second block". +*/ +static void __init vic_init_st (void __iomem *base,unsigned int irq_start, +u32 vic_sources) +{ +unsigned int i; +int vic_2nd_block = ((unsigned long )base & ~PAGE_MASK ) !=0 ; + +/* Disable all interrupts initially. */ + +writel (0 , base +VIC_INT_SELECT ); +writel (0 , base +VIC_INT_ENABLE ); +writel (~0 , base +VIC_INT_ENABLE_CLEAR ); +writel (0 , base +VIC_IRQ_STATUS ); +writel (0 , base +VIC_ITCR ); +writel (~0 , base +VIC_INT_SOFT_CLEAR ); + +/* +* Make sure we clear all existing interrupts. The vector registers +* in this cell are after the second block of general registers, +* so we can address them using standard offsets, but only from +* the second base address, which is 0x20 in the page +*/ +if (vic_2nd_block) { +writel (0 , base +VIC_PL190_VECT_ADDR ); +for (i =0 ; i <19 ; i++) { +unsigned int value; + + value =readl (base +VIC_PL190_VECT_ADDR ); +writel (value, base +VIC_PL190_VECT_ADDR ); + } +/* ST has 16 vectors as well, but we don't enable them by now */ +for (i =0 ; i <16 ; i++) { +void __iomem *reg = base +VIC_VECT_CNTL0 + (i *4 ); +writel (0 , reg); + } + +writel (32 , base +VIC_PL190_DEF_VECT_ADDR ); + } + +for (i =0 ; i <32 ; i++) { +if (vic_sources & (1 << i)) { +unsigned int irq = irq_start + i; + +set_irq_chip (irq, &vic_chip); +set_irq_chip_data (irq, base); +set_irq_handler (irq, handle_level_irq); +set_irq_flags (irq,IRQF_VALID |IRQF_PROBE ); + } + } +}/** * vic_init - initialise a vectored interrupt controller
@@ -298,7 +353,7 @@ void __init vic_init(void __iomem *base, unsigned int irq_start,switch (vendor) {case AMBA_VENDOR_ST : -vik_init_st (base, irq_start, vic_sources); +vic_init_st (base, irq_start, vic_sources);return ;default :printk (KERN_WARNING "VIC: unknown vendor, continuing anyways\n" );
@@ -342,60 +397,3 @@ void __init vic_init(void __iomem *base, unsigned int irq_start,vic_pm_register (base, irq_start, resume_sources); } - -/* -* The PL190 cell from ARM has been modified by ST to handle 64 interrupts. -* The original cell has 32 interrupts, while the modified one has 64, -* replocating two blocks 0x00..0x1f in 0x20..0x3f. In that case -* the probe function is called twice, with base set to offset 000 -* and 020 within the page. We call this "second block". -*/ -static void __init vik_init_st (void __iomem *base,unsigned int irq_start, -u32 vic_sources) -{ -unsigned int i; -int vic_2nd_block = ((unsigned long )base & ~PAGE_MASK ) !=0 ; - -/* Disable all interrupts initially. */ - -writel (0 , base +VIC_INT_SELECT ); -writel (0 , base +VIC_INT_ENABLE ); -writel (~0 , base +VIC_INT_ENABLE_CLEAR ); -writel (0 , base +VIC_IRQ_STATUS ); -writel (0 , base +VIC_ITCR ); -writel (~0 , base +VIC_INT_SOFT_CLEAR ); - -/* -* Make sure we clear all existing interrupts. The vector registers -* in this cell are after the second block of general registers, -* so we can address them using standard offsets, but only from -* the second base address, which is 0x20 in the page -*/ -if (vic_2nd_block) { -writel (0 , base +VIC_PL190_VECT_ADDR ); -for (i =0 ; i <19 ; i++) { -unsigned int value; - - value =readl (base +VIC_PL190_VECT_ADDR ); -writel (value, base +VIC_PL190_VECT_ADDR ); - } -/* ST has 16 vectors as well, but we don't enable them by now */ -for (i =0 ; i <16 ; i++) { -void __iomem *reg = base +VIC_VECT_CNTL0 + (i *4 ); -writel (0 , reg); - } - -writel (32 , base +VIC_PL190_DEF_VECT_ADDR ); - } - -for (i =0 ; i <32 ; i++) { -if (vic_sources & (1 << i)) { -unsigned int irq = irq_start + i; - -set_irq_chip (irq, &vic_chip); -set_irq_chip_data (irq, base); -set_irq_handler (irq, handle_level_irq); -set_irq_flags (irq,IRQF_VALID |IRQF_PROBE ); - } - } -}
PATCH 1/1 arch/arm/common/vic.c: code reorganization
2009/9/17 H Hartley Sweeten <[email protected]>:
Quoted 2 lines
This reorganizes the
vic.ccode in anticipation of a future patch to use structvic_deviceas the data stored inset_irq_chip_data().
This doesn't apply cleanly to -next anymore, can you send an updated version and I'll test it?
Linus Walleij
PATCH 1/1 arch/arm/common/vic.c: code reorganization
Quoted 7 lines · Linus Walleij
2009/9/17 H Hartley Sweeten <[email protected]>:
Quoted 2 lines
This reorganizes the
vic.ccode in anticipation of a future patch to use structvic_deviceas the data stored inset_irq_chip_data().This doesn't apply cleanly to -next anymore, can you send an updated version and I'll test it?
Hmm... Applies fine to -next here.
The only thing I can think of that might keep it from applying is if your -next tree has the patch you posted to include device.h in the driver. That patch is of course needed so that the file will build but I have not seen anything about someone picking it up yet. That patch will fuzz mine by one line.
I was hoping your patch would get merged soon to fix the build. I was then planning on rebasing this patch. I just wanted to get this out now for any comments.
Regards,
Hartley
PATCH 1/1 arch/arm/common/vic.c: code reorganization
Quoted 9 lines · H Hartley Sweeten
The only thing I can think of that might keep it from applying is if your -next tree has the patch you posted to include
device.hin the driver. That patch is of course needed so that the file will build but I have not seen anything about someone picking it up yet. That patch will fuzz mine by one line.I was hoping your patch would get merged soon to fix the build. I was then planning on rebasing this patch. I just wanted to get this out now for any comments.
The patch adding device.h to vic.c is queued for this Saturday's push.
PATCH 1/1 arch/arm/common/vic.c: code reorganization
Quoted 7 lines · Russell King
Quoted 6 lines · H Hartley Sweeten
The only thing I can think of that might keep it from applying is if your -next tree has the patch you posted to include
device.hin the driver. That patch is of course needed so that the file will build but I have not seen anything about someone picking it up yet. That patch will fuzz mine by one line.
Quoted 5 lines
Quoted 3 lines
I was hoping your patch would get merged soon to fix the build. I was then planning on rebasing this patch. I just wanted to get this out now for any comments.
The patch adding
device.htovic.cis queued for this Saturday's push.
Thanks for the update Russell. I will rebase this patch after that.
Regards,
Hartley
PATCH 1/1 arch/arm/common/vic.c: code reorganization
In reply to Russell King - ARM LinuxThis reorganizes the vic.c code in anticipation of a future patch to use struct vic_device as the data stored in set_irq_chip_data().
The new code has the following flow:
1) struct vic_device definition, static variables, and to_vic() moved to the start of the code.
2) vic power management callbacks
3) vic power management initialization/registration
4) irq_chip callbacks
5) vendor specific vic initialization
6) vic initialization
In addition the typo vik_init_st is fixed (vic_init_st).
---
V3 - rebased to 2.6.31-gitcur
arch/arm/common/vic.c +131 -133
@@ -28,48 +28,6 @@#include <asm/mach/irq.h> #include <asm/hardware/vic.h> -static void vic_ack_irq (unsigned int irq) -{ -void __iomem *base =get_irq_chip_data (irq); - irq &=31 ; -writel (1 << irq, base +VIC_INT_ENABLE_CLEAR ); -/* moreover, clear the soft-triggered, in case it was the reason */ -writel (1 << irq, base +VIC_INT_SOFT_CLEAR ); -} - -static void vic_mask_irq (unsigned int irq) -{ -void __iomem *base =get_irq_chip_data (irq); - irq &=31 ; -writel (1 << irq, base +VIC_INT_ENABLE_CLEAR ); -} - -static void vic_unmask_irq (unsigned int irq) -{ -void __iomem *base =get_irq_chip_data (irq); - irq &=31 ; -writel (1 << irq, base +VIC_INT_ENABLE ); -} - -/** -* vic_init2 - common initialisation code -* @base: Base of the VIC. -* -* Common initialisation code for registeration -* and resume. -*/ -static void vic_init2 (void __iomem *base) -{ -int i; - -for (i =0 ; i <16 ; i++) { -void __iomem *reg = base +VIC_VECT_CNTL0 + (i *4 ); -writel (VIC_VECT_CNTL_ENABLE | i, reg); - } - -writel (32 , base +VIC_PL190_DEF_VECT_ADDR ); -} -#if defined(CONFIG_PM )/** * struct vic_device - VIC PM device
@@ -99,13 +57,34 @@ struct vic_device {/* we cannot allocate memory when VICs are initially registered */ static struct vic_device vic_devices[CONFIG_ARM_VIC_NR ]; +static int vic_id; +static inline struct vic_device *to_vic (struct sys_device *sys) { return container_of(sys, struct vic_device, sysdev); } +#endif /* CONFIG_PM */ -static int vic_id; +/** +* vic_init2 - common initialisation code +* @base: Base of the VIC. +* +* Common initialisation code for registeration +* and resume. +*/ +static void vic_init2 (void __iomem *base) +{ +int i; + +for (i =0 ; i <16 ; i++) { +void __iomem *reg = base +VIC_VECT_CNTL0 + (i *4 ); +writel (VIC_VECT_CNTL_ENABLE | i, reg); + } +writel (32 , base +VIC_PL190_DEF_VECT_ADDR ); +} + +#if defined(CONFIG_PM )static int vic_class_resume (struct sys_device *dev) {struct vic_device *vic =to_vic (dev);
@@ -159,31 +138,6 @@ struct sysdev_class vic_class = { };/** -* vic_pm_register - Register a VIC for later power management control -* @base: The base address of the VIC. -* @irq: The base IRQ for the VIC. -* @resume_sources: bitmask of interrupts allowed for resume sources. -* -* Register the VIC with the system device tree so that it can be notified -* of suspend and resume requests and ensure that the correct actions are -* taken to re-instate the settings on resume. -*/ -static void __init vic_pm_register (void __iomem *base,unsigned int irq,u32 resume_sources) -{ -struct vic_device *v; - -if (vic_id >=ARRAY_SIZE (vic_devices)) -printk (KERN_ERR "%s: too few VICs, increase CONFIG_ARM_VIC_NR\n" , __func__); -else { - v = &vic_devices[vic_id]; - v->base = base; - v->resume_sources = resume_sources; - v->irq = irq; - vic_id++; - } -} - -/** * vic_pm_init - initicall to register VIC pm * * This is called via late_initcall() to register
@@ -219,9 +173,60 @@ static int __init vic_pm_init(void)return 0 ; } -late_initcall (vic_pm_init); +/** +* vic_pm_register - Register a VIC for later power management control +* @base: The base address of the VIC. +* @irq: The base IRQ for the VIC. +* @resume_sources: bitmask of interrupts allowed for resume sources. +* +* Register the VIC with the system device tree so that it can be notified +* of suspend and resume requests and ensure that the correct actions are +* taken to re-instate the settings on resume. +*/ +static void __init vic_pm_register (void __iomem *base,unsigned int irq,u32 resume_sources) +{ +struct vic_device *v; + +if (vic_id >=ARRAY_SIZE (vic_devices)) +printk (KERN_ERR "%s: too few VICs, increase CONFIG_ARM_VIC_NR\n" , __func__); +else { + v = &vic_devices[vic_id]; + v->base = base; + v->resume_sources = resume_sources; + v->irq = irq; + vic_id++; + } +} +#else +static inline void vic_pm_register (void __iomem *base,unsigned int irq,u32 arg1) { } +#endif /* CONFIG_PM */ + +static void vic_ack_irq (unsigned int irq) +{ +void __iomem *base =get_irq_chip_data (irq); + irq &=31 ; +writel (1 << irq, base +VIC_INT_ENABLE_CLEAR ); +/* moreover, clear the soft-triggered, in case it was the reason */ +writel (1 << irq, base +VIC_INT_SOFT_CLEAR ); +} + +static void vic_mask_irq (unsigned int irq) +{ +void __iomem *base =get_irq_chip_data (irq); + irq &=31 ; +writel (1 << irq, base +VIC_INT_ENABLE_CLEAR ); +} + +static void vic_unmask_irq (unsigned int irq) +{ +void __iomem *base =get_irq_chip_data (irq); + irq &=31 ; +writel (1 << irq, base +VIC_INT_ENABLE ); +} + +#if defined(CONFIG_PM )static struct vic_device *vic_from_irq (unsigned int irq) {struct vic_device *v = vic_devices;
@@ -255,10 +260,7 @@ static int vic_set_wake(unsigned int irq, unsigned int on) return 0; } -#else -static inline void vic_pm_register (void __iomem *base,unsigned int irq,u32 arg1) { } -#define vic_set_wake NULL#endif /* CONFIG_PM */
@@ -270,9 +272,62 @@ static struct irq_chip vic_chip = { .set_wake = vic_set_wake, }; -/* The PL190 cell from ARM has been modified by ST, so handle both here */ -static void vik_init_st (void __iomem *base,unsigned int irq_start, -u32 vic_sources); +/* +* The PL190 cell from ARM has been modified by ST to handle 64 interrupts. +* The original cell has 32 interrupts, while the modified one has 64, +* replocating two blocks 0x00..0x1f in 0x20..0x3f. In that case +* the probe function is called twice, with base set to offset 000 +* and 020 within the page. We call this "second block". +*/ +static void __init vic_init_st (void __iomem *base,unsigned int irq_start, +u32 vic_sources) +{ +unsigned int i; +int vic_2nd_block = ((unsigned long )base & ~PAGE_MASK ) !=0 ; + +/* Disable all interrupts initially. */ + +writel (0 , base +VIC_INT_SELECT ); +writel (0 , base +VIC_INT_ENABLE ); +writel (~0 , base +VIC_INT_ENABLE_CLEAR ); +writel (0 , base +VIC_IRQ_STATUS ); +writel (0 , base +VIC_ITCR ); +writel (~0 , base +VIC_INT_SOFT_CLEAR ); + +/* +* Make sure we clear all existing interrupts. The vector registers +* in this cell are after the second block of general registers, +* so we can address them using standard offsets, but only from +* the second base address, which is 0x20 in the page +*/ +if (vic_2nd_block) { +writel (0 , base +VIC_PL190_VECT_ADDR ); +for (i =0 ; i <19 ; i++) { +unsigned int value; + + value =readl (base +VIC_PL190_VECT_ADDR ); +writel (value, base +VIC_PL190_VECT_ADDR ); + } +/* ST has 16 vectors as well, but we don't enable them by now */ +for (i =0 ; i <16 ; i++) { +void __iomem *reg = base +VIC_VECT_CNTL0 + (i *4 ); +writel (0 , reg); + } + +writel (32 , base +VIC_PL190_DEF_VECT_ADDR ); + } + +for (i =0 ; i <32 ; i++) { +if (vic_sources & (1 << i)) { +unsigned int irq = irq_start + i; + +set_irq_chip (irq, &vic_chip); +set_irq_chip_data (irq, base); +set_irq_handler (irq, handle_level_irq); +set_irq_flags (irq,IRQF_VALID |IRQF_PROBE ); + } + } +}/** * vic_init - initialise a vectored interrupt controller
@@ -299,7 +354,7 @@ void __init vic_init(void __iomem *base, unsigned int irq_start,switch (vendor) {case AMBA_VENDOR_ST : -vik_init_st (base, irq_start, vic_sources); +vic_init_st (base, irq_start, vic_sources);return ;default :printk (KERN_WARNING "VIC: unknown vendor, continuing anyways\n" );
@@ -343,60 +398,3 @@ void __init vic_init(void __iomem *base, unsigned int irq_start,vic_pm_register (base, irq_start, resume_sources); } - -/* -* The PL190 cell from ARM has been modified by ST to handle 64 interrupts. -* The original cell has 32 interrupts, while the modified one has 64, -* replocating two blocks 0x00..0x1f in 0x20..0x3f. In that case -* the probe function is called twice, with base set to offset 000 -* and 020 within the page. We call this "second block". -*/ -static void __init vik_init_st (void __iomem *base,unsigned int irq_start, -u32 vic_sources) -{ -unsigned int i; -int vic_2nd_block = ((unsigned long )base & ~PAGE_MASK ) !=0 ; - -/* Disable all interrupts initially. */ - -writel (0 , base +VIC_INT_SELECT ); -writel (0 , base +VIC_INT_ENABLE ); -writel (~0 , base +VIC_INT_ENABLE_CLEAR ); -writel (0 , base +VIC_IRQ_STATUS ); -writel (0 , base +VIC_ITCR ); -writel (~0 , base +VIC_INT_SOFT_CLEAR ); - -/* -* Make sure we clear all existing interrupts. The vector registers -* in this cell are after the second block of general registers, -* so we can address them using standard offsets, but only from -* the second base address, which is 0x20 in the page -*/ -if (vic_2nd_block) { -writel (0 , base +VIC_PL190_VECT_ADDR ); -for (i =0 ; i <19 ; i++) { -unsigned int value; - - value =readl (base +VIC_PL190_VECT_ADDR ); -writel (value, base +VIC_PL190_VECT_ADDR ); - } -/* ST has 16 vectors as well, but we don't enable them by now */ -for (i =0 ; i <16 ; i++) { -void __iomem *reg = base +VIC_VECT_CNTL0 + (i *4 ); -writel (0 , reg); - } - -writel (32 , base +VIC_PL190_DEF_VECT_ADDR ); - } - -for (i =0 ; i <32 ; i++) { -if (vic_sources & (1 << i)) { -unsigned int irq = irq_start + i; - -set_irq_chip (irq, &vic_chip); -set_irq_chip_data (irq, base); -set_irq_handler (irq, handle_level_irq); -set_irq_flags (irq,IRQF_VALID |IRQF_PROBE ); - } - } -}
PATCH 1/1 arch/arm/common/vic.c: code reorganization
Ping.. Any comments on this?
Regards,
Hartley
-----Original Message-----
From: [email protected] [mailto:linux-arm-kernel-bounces at lists.infradead.org] On Behalf Of H Hartley Sweeten
Sent: Thursday, September 24, 2009 6:56 PM
To: linux-arm-kernel at lists.infradead.org
Cc: Linus Walleij; rubini-list at gnudd.com; Ben Dooks
Subject: RE: [PATCH] arch/arm/common/vic.c: code reorganization
This reorganizes the vic.c code in anticipation of a future patch to use struct vic_device as the data stored in set_irq_chip_data().
The new code has the following flow:
1) struct vic_device definition, static variables, and to_vic() moved to the start of the code.
2) vic power management callbacks
3) vic power management initialization/registration
4) irq_chip callbacks
5) vendor specific vic initialization
6) vic initialization
In addition the typo vik_init_st is fixed (vic_init_st).
---
V3 - rebased to 2.6.31-gitcur
arch/arm/common/vic.c +131 -133
@@ -28,48 +28,6 @@#include <asm/mach/irq.h> #include <asm/hardware/vic.h> -static void vic_ack_irq (unsigned int irq) -{ -void __iomem *base =get_irq_chip_data (irq); - irq &=31 ; -writel (1 << irq, base +VIC_INT_ENABLE_CLEAR ); -/* moreover, clear the soft-triggered, in case it was the reason */ -writel (1 << irq, base +VIC_INT_SOFT_CLEAR ); -} - -static void vic_mask_irq (unsigned int irq) -{ -void __iomem *base =get_irq_chip_data (irq); - irq &=31 ; -writel (1 << irq, base +VIC_INT_ENABLE_CLEAR ); -} - -static void vic_unmask_irq (unsigned int irq) -{ -void __iomem *base =get_irq_chip_data (irq); - irq &=31 ; -writel (1 << irq, base +VIC_INT_ENABLE ); -} - -/** -* vic_init2 - common initialisation code -* @base: Base of the VIC. -* -* Common initialisation code for registeration -* and resume. -*/ -static void vic_init2 (void __iomem *base) -{ -int i; - -for (i =0 ; i <16 ; i++) { -void __iomem *reg = base +VIC_VECT_CNTL0 + (i *4 ); -writel (VIC_VECT_CNTL_ENABLE | i, reg); - } - -writel (32 , base +VIC_PL190_DEF_VECT_ADDR ); -} -#if defined(CONFIG_PM )/** * struct vic_device - VIC PM device
@@ -99,13 +57,34 @@ struct vic_device {/* we cannot allocate memory when VICs are initially registered */ static struct vic_device vic_devices[CONFIG_ARM_VIC_NR ]; +static int vic_id; +static inline struct vic_device *to_vic (struct sys_device *sys) { return container_of(sys, struct vic_device, sysdev); } +#endif /* CONFIG_PM */ -static int vic_id; +/** +* vic_init2 - common initialisation code +* @base: Base of the VIC. +* +* Common initialisation code for registeration +* and resume. +*/ +static void vic_init2 (void __iomem *base) +{ +int i; + +for (i =0 ; i <16 ; i++) { +void __iomem *reg = base +VIC_VECT_CNTL0 + (i *4 ); +writel (VIC_VECT_CNTL_ENABLE | i, reg); + } +writel (32 , base +VIC_PL190_DEF_VECT_ADDR ); +} + +#if defined(CONFIG_PM )static int vic_class_resume (struct sys_device *dev) {struct vic_device *vic =to_vic (dev);
@@ -159,31 +138,6 @@ struct sysdev_class vic_class = { };/** -* vic_pm_register - Register a VIC for later power management control -* @base: The base address of the VIC. -* @irq: The base IRQ for the VIC. -* @resume_sources: bitmask of interrupts allowed for resume sources. -* -* Register the VIC with the system device tree so that it can be notified -* of suspend and resume requests and ensure that the correct actions are -* taken to re-instate the settings on resume. -*/ -static void __init vic_pm_register (void __iomem *base,unsigned int irq,u32 resume_sources) -{ -struct vic_device *v; - -if (vic_id >=ARRAY_SIZE (vic_devices)) -printk (KERN_ERR "%s: too few VICs, increase CONFIG_ARM_VIC_NR\n" , __func__); -else { - v = &vic_devices[vic_id]; - v->base = base; - v->resume_sources = resume_sources; - v->irq = irq; - vic_id++; - } -} - -/** * vic_pm_init - initicall to register VIC pm * * This is called via late_initcall() to register
@@ -219,9 +173,60 @@ static int __init vic_pm_init(void)return 0 ; } -late_initcall (vic_pm_init); +/** +* vic_pm_register - Register a VIC for later power management control +* @base: The base address of the VIC. +* @irq: The base IRQ for the VIC. +* @resume_sources: bitmask of interrupts allowed for resume sources. +* +* Register the VIC with the system device tree so that it can be notified +* of suspend and resume requests and ensure that the correct actions are +* taken to re-instate the settings on resume. +*/ +static void __init vic_pm_register (void __iomem *base,unsigned int irq,u32 resume_sources) +{ +struct vic_device *v; + +if (vic_id >=ARRAY_SIZE (vic_devices)) +printk (KERN_ERR "%s: too few VICs, increase CONFIG_ARM_VIC_NR\n" , __func__); +else { + v = &vic_devices[vic_id]; + v->base = base; + v->resume_sources = resume_sources; + v->irq = irq; + vic_id++; + } +} +#else +static inline void vic_pm_register (void __iomem *base,unsigned int irq,u32 arg1) { } +#endif /* CONFIG_PM */ + +static void vic_ack_irq (unsigned int irq) +{ +void __iomem *base =get_irq_chip_data (irq); + irq &=31 ; +writel (1 << irq, base +VIC_INT_ENABLE_CLEAR ); +/* moreover, clear the soft-triggered, in case it was the reason */ +writel (1 << irq, base +VIC_INT_SOFT_CLEAR ); +} + +static void vic_mask_irq (unsigned int irq) +{ +void __iomem *base =get_irq_chip_data (irq); + irq &=31 ; +writel (1 << irq, base +VIC_INT_ENABLE_CLEAR ); +} + +static void vic_unmask_irq (unsigned int irq) +{ +void __iomem *base =get_irq_chip_data (irq); + irq &=31 ; +writel (1 << irq, base +VIC_INT_ENABLE ); +} + +#if defined(CONFIG_PM )static struct vic_device *vic_from_irq (unsigned int irq) {struct vic_device *v = vic_devices;
@@ -255,10 +260,7 @@ static int vic_set_wake(unsigned int irq, unsigned int on) return 0; } -#else -static inline void vic_pm_register (void __iomem *base,unsigned int irq,u32 arg1) { } -#define vic_set_wake NULL#endif /* CONFIG_PM */
@@ -270,9 +272,62 @@ static struct irq_chip vic_chip = { .set_wake = vic_set_wake, }; -/* The PL190 cell from ARM has been modified by ST, so handle both here */ -static void vik_init_st (void __iomem *base,unsigned int irq_start, -u32 vic_sources); +/* +* The PL190 cell from ARM has been modified by ST to handle 64 interrupts. +* The original cell has 32 interrupts, while the modified one has 64, +* replocating two blocks 0x00..0x1f in 0x20..0x3f. In that case +* the probe function is called twice, with base set to offset 000 +* and 020 within the page. We call this "second block". +*/ +static void __init vic_init_st (void __iomem *base,unsigned int irq_start, +u32 vic_sources) +{ +unsigned int i; +int vic_2nd_block = ((unsigned long )base & ~PAGE_MASK ) !=0 ; + +/* Disable all interrupts initially. */ + +writel (0 , base +VIC_INT_SELECT ); +writel (0 , base +VIC_INT_ENABLE ); +writel (~0 , base +VIC_INT_ENABLE_CLEAR ); +writel (0 , base +VIC_IRQ_STATUS ); +writel (0 , base +VIC_ITCR ); +writel (~0 , base +VIC_INT_SOFT_CLEAR ); + +/* +* Make sure we clear all existing interrupts. The vector registers +* in this cell are after the second block of general registers, +* so we can address them using standard offsets, but only from +* the second base address, which is 0x20 in the page +*/ +if (vic_2nd_block) { +writel (0 , base +VIC_PL190_VECT_ADDR ); +for (i =0 ; i <19 ; i++) { +unsigned int value; + + value =readl (base +VIC_PL190_VECT_ADDR ); +writel (value, base +VIC_PL190_VECT_ADDR ); + } +/* ST has 16 vectors as well, but we don't enable them by now */ +for (i =0 ; i <16 ; i++) { +void __iomem *reg = base +VIC_VECT_CNTL0 + (i *4 ); +writel (0 , reg); + } + +writel (32 , base +VIC_PL190_DEF_VECT_ADDR ); + } + +for (i =0 ; i <32 ; i++) { +if (vic_sources & (1 << i)) { +unsigned int irq = irq_start + i; + +set_irq_chip (irq, &vic_chip); +set_irq_chip_data (irq, base); +set_irq_handler (irq, handle_level_irq); +set_irq_flags (irq,IRQF_VALID |IRQF_PROBE ); + } + } +}/** * vic_init - initialise a vectored interrupt controller
@@ -299,7 +354,7 @@ void __init vic_init(void __iomem *base, unsigned int irq_start,switch (vendor) {case AMBA_VENDOR_ST : -vik_init_st (base, irq_start, vic_sources); +vic_init_st (base, irq_start, vic_sources);return ;default :printk (KERN_WARNING "VIC: unknown vendor, continuing anyways\n" );
@@ -343,60 +398,3 @@ void __init vic_init(void __iomem *base, unsigned int irq_start,vic_pm_register (base, irq_start, resume_sources); } - -/* -* The PL190 cell from ARM has been modified by ST to handle 64 interrupts. -* The original cell has 32 interrupts, while the modified one has 64, -* replocating two blocks 0x00..0x1f in 0x20..0x3f. In that case -* the probe function is called twice, with base set to offset 000 -* and 020 within the page. We call this "second block". -*/ -static void __init vik_init_st (void __iomem *base,unsigned int irq_start, -u32 vic_sources) -{ -unsigned int i; -int vic_2nd_block = ((unsigned long )base & ~PAGE_MASK ) !=0 ; - -/* Disable all interrupts initially. */ - -writel (0 , base +VIC_INT_SELECT ); -writel (0 , base +VIC_INT_ENABLE ); -writel (~0 , base +VIC_INT_ENABLE_CLEAR ); -writel (0 , base +VIC_IRQ_STATUS ); -writel (0 , base +VIC_ITCR ); -writel (~0 , base +VIC_INT_SOFT_CLEAR ); - -/* -* Make sure we clear all existing interrupts. The vector registers -* in this cell are after the second block of general registers, -* so we can address them using standard offsets, but only from -* the second base address, which is 0x20 in the page -*/ -if (vic_2nd_block) { -writel (0 , base +VIC_PL190_VECT_ADDR ); -for (i =0 ; i <19 ; i++) { -unsigned int value; - - value =readl (base +VIC_PL190_VECT_ADDR ); -writel (value, base +VIC_PL190_VECT_ADDR ); - } -/* ST has 16 vectors as well, but we don't enable them by now */ -for (i =0 ; i <16 ; i++) { -void __iomem *reg = base +VIC_VECT_CNTL0 + (i *4 ); -writel (0 , reg); - } - -writel (32 , base +VIC_PL190_DEF_VECT_ADDR ); - } - -for (i =0 ; i <32 ; i++) { -if (vic_sources & (1 << i)) { -unsigned int irq = irq_start + i; - -set_irq_chip (irq, &vic_chip); -set_irq_chip_data (irq, base); -set_irq_handler (irq, handle_level_irq); -set_irq_flags (irq,IRQF_VALID |IRQF_PROBE ); - } - } -}
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
PATCH 1/1 arch/arm/common/vic.c: code reorganization
This reorganizes the vic.c code in anticipation of a future patch to use struct vic_device as the data stored in set_irq_chip_data().
The new code has the following flow:
1) struct vic_device definition, static variables, and to_vic() moved to the start of the code.
2) vic power management callbacks
3) vic power management initialization/registration
4) irq_chip callbacks
5) vendor specific vic initialization
6) vic initialization
In addition the typo vik_init_st is fixed (vic_init_st).
---
V4 - rebased to 2.6.32-rc3 due to whitespace issue (Alessandro Rubini) V3 - rebased to 2.6.31-gitcur
arch/arm/common/vic.c +130 -133
@@ -28,48 +28,6 @@#include <asm/mach/irq.h> #include <asm/hardware/vic.h> -static void vic_ack_irq (unsigned int irq) -{ -void __iomem *base =get_irq_chip_data (irq); - irq &=31 ; -writel (1 << irq, base +VIC_INT_ENABLE_CLEAR ); -/* moreover, clear the soft-triggered, in case it was the reason */ -writel (1 << irq, base +VIC_INT_SOFT_CLEAR ); -} - -static void vic_mask_irq (unsigned int irq) -{ -void __iomem *base =get_irq_chip_data (irq); - irq &=31 ; -writel (1 << irq, base +VIC_INT_ENABLE_CLEAR ); -} - -static void vic_unmask_irq (unsigned int irq) -{ -void __iomem *base =get_irq_chip_data (irq); - irq &=31 ; -writel (1 << irq, base +VIC_INT_ENABLE ); -} - -/** -* vic_init2 - common initialisation code -* @base: Base of the VIC. -* -* Common initialisation code for registeration -* and resume. -*/ -static void vic_init2 (void __iomem *base) -{ -int i; - -for (i =0 ; i <16 ; i++) { -void __iomem *reg = base +VIC_VECT_CNTL0 + (i *4 ); -writel (VIC_VECT_CNTL_ENABLE | i, reg); - } - -writel (32 , base +VIC_PL190_DEF_VECT_ADDR ); -} -#if defined(CONFIG_PM )/** * struct vic_device - VIC PM device
@@ -99,13 +57,34 @@ struct vic_device {/* we cannot allocate memory when VICs are initially registered */ static struct vic_device vic_devices[CONFIG_ARM_VIC_NR ]; +static int vic_id; +static inline struct vic_device *to_vic (struct sys_device *sys) { return container_of(sys, struct vic_device, sysdev); } +#endif /* CONFIG_PM */ -static int vic_id; +/** +* vic_init2 - common initialisation code +* @base: Base of the VIC. +* +* Common initialisation code for registeration +* and resume. +*/ +static void vic_init2 (void __iomem *base) +{ +int i; + +for (i =0 ; i <16 ; i++) { +void __iomem *reg = base +VIC_VECT_CNTL0 + (i *4 ); +writel (VIC_VECT_CNTL_ENABLE | i, reg); + } + +writel (32 , base +VIC_PL190_DEF_VECT_ADDR ); +} +#if defined(CONFIG_PM )static int vic_class_resume (struct sys_device *dev) {struct vic_device *vic =to_vic (dev);
@@ -159,31 +138,6 @@ struct sysdev_class vic_class = { };/** -* vic_pm_register - Register a VIC for later power management control -* @base: The base address of the VIC. -* @irq: The base IRQ for the VIC. -* @resume_sources: bitmask of interrupts allowed for resume sources. -* -* Register the VIC with the system device tree so that it can be notified -* of suspend and resume requests and ensure that the correct actions are -* taken to re-instate the settings on resume. -*/ -static void __init vic_pm_register (void __iomem *base,unsigned int irq,u32 resume_sources) -{ -struct vic_device *v; - -if (vic_id >=ARRAY_SIZE (vic_devices)) -printk (KERN_ERR "%s: too few VICs, increase CONFIG_ARM_VIC_NR\n" , __func__); -else { - v = &vic_devices[vic_id]; - v->base = base; - v->resume_sources = resume_sources; - v->irq = irq; - vic_id++; - } -} - -/** * vic_pm_init - initicall to register VIC pm * * This is called via late_initcall() to register
@@ -219,9 +173,60 @@ static int __init vic_pm_init(void)return 0 ; } -late_initcall (vic_pm_init); +/** +* vic_pm_register - Register a VIC for later power management control +* @base: The base address of the VIC. +* @irq: The base IRQ for the VIC. +* @resume_sources: bitmask of interrupts allowed for resume sources. +* +* Register the VIC with the system device tree so that it can be notified +* of suspend and resume requests and ensure that the correct actions are +* taken to re-instate the settings on resume. +*/ +static void __init vic_pm_register (void __iomem *base,unsigned int irq,u32 resume_sources) +{ +struct vic_device *v; + +if (vic_id >=ARRAY_SIZE (vic_devices)) +printk (KERN_ERR "%s: too few VICs, increase CONFIG_ARM_VIC_NR\n" , __func__); +else { + v = &vic_devices[vic_id]; + v->base = base; + v->resume_sources = resume_sources; + v->irq = irq; + vic_id++; + } +} +#else +static inline void vic_pm_register (void __iomem *base,unsigned int irq,u32 arg1) { } +#endif /* CONFIG_PM */ + +static void vic_ack_irq (unsigned int irq) +{ +void __iomem *base =get_irq_chip_data (irq); + irq &=31 ; +writel (1 << irq, base +VIC_INT_ENABLE_CLEAR ); +/* moreover, clear the soft-triggered, in case it was the reason */ +writel (1 << irq, base +VIC_INT_SOFT_CLEAR ); +} + +static void vic_mask_irq (unsigned int irq) +{ +void __iomem *base =get_irq_chip_data (irq); + irq &=31 ; +writel (1 << irq, base +VIC_INT_ENABLE_CLEAR ); +} + +static void vic_unmask_irq (unsigned int irq) +{ +void __iomem *base =get_irq_chip_data (irq); + irq &=31 ; +writel (1 << irq, base +VIC_INT_ENABLE ); +} + +#if defined(CONFIG_PM )static struct vic_device *vic_from_irq (unsigned int irq) {struct vic_device *v = vic_devices;
@@ -255,10 +260,7 @@ static int vic_set_wake(unsigned int irq, unsigned int on) return 0; } -#else -static inline void vic_pm_register (void __iomem *base,unsigned int irq,u32 arg1) { } -#define vic_set_wake NULL#endif /* CONFIG_PM */
@@ -270,10 +272,62 @@ static struct irq_chip vic_chip = { .set_wake = vic_set_wake, }; -/* The PL190 cell from ARM has been modified by ST, so handle both here */ -static void vik_init_st (void __iomem *base,unsigned int irq_start, -u32 vic_sources); +/* +* The PL190 cell from ARM has been modified by ST to handle 64 interrupts. +* The original cell has 32 interrupts, while the modified one has 64, +* replocating two blocks 0x00..0x1f in 0x20..0x3f. In that case +* the probe function is called twice, with base set to offset 000 +* and 020 within the page. We call this "second block". +*/ +static void __init vic_init_st (void __iomem *base,unsigned int irq_start, +u32 vic_sources) +{ +unsigned int i; +int vic_2nd_block = ((unsigned long )base & ~PAGE_MASK ) !=0 ; + +/* Disable all interrupts initially. */ + +writel (0 , base +VIC_INT_SELECT ); +writel (0 , base +VIC_INT_ENABLE ); +writel (~0 , base +VIC_INT_ENABLE_CLEAR ); +writel (0 , base +VIC_IRQ_STATUS ); +writel (0 , base +VIC_ITCR ); +writel (~0 , base +VIC_INT_SOFT_CLEAR ); + +/* +* Make sure we clear all existing interrupts. The vector registers +* in this cell are after the second block of general registers, +* so we can address them using standard offsets, but only from +* the second base address, which is 0x20 in the page +*/ +if (vic_2nd_block) { +writel (0 , base +VIC_PL190_VECT_ADDR ); +for (i =0 ; i <19 ; i++) { +unsigned int value; + + value =readl (base +VIC_PL190_VECT_ADDR ); +writel (value, base +VIC_PL190_VECT_ADDR ); + } +/* ST has 16 vectors as well, but we don't enable them by now */ +for (i =0 ; i <16 ; i++) { +void __iomem *reg = base +VIC_VECT_CNTL0 + (i *4 ); +writel (0 , reg); + } + +writel (32 , base +VIC_PL190_DEF_VECT_ADDR ); + } + +for (i =0 ; i <32 ; i++) { +if (vic_sources & (1 << i)) { +unsigned int irq = irq_start + i; +set_irq_chip (irq, &vic_chip); +set_irq_chip_data (irq, base); +set_irq_handler (irq, handle_level_irq); +set_irq_flags (irq,IRQF_VALID |IRQF_PROBE ); + } + } +}/** * vic_init - initialise a vectored interrupt controller * @base: iomem base address
@@ -299,7 +353,7 @@ void __init vic_init(void __iomem *base, unsigned int irq_start,switch (vendor) {case AMBA_VENDOR_ST : -vik_init_st (base, irq_start, vic_sources); +vic_init_st (base, irq_start, vic_sources);return ;default :printk (KERN_WARNING "VIC: unknown vendor, continuing anyways\n" );
@@ -343,60 +397,3 @@ void __init vic_init(void __iomem *base, unsigned int irq_start,vic_pm_register (base, irq_start, resume_sources); } - -/* -* The PL190 cell from ARM has been modified by ST to handle 64 interrupts. -* The original cell has 32 interrupts, while the modified one has 64, -* replocating two blocks 0x00..0x1f in 0x20..0x3f. In that case -* the probe function is called twice, with base set to offset 000 -* and 020 within the page. We call this "second block". -*/ -static void __init vik_init_st (void __iomem *base,unsigned int irq_start, -u32 vic_sources) -{ -unsigned int i; -int vic_2nd_block = ((unsigned long )base & ~PAGE_MASK ) !=0 ; - -/* Disable all interrupts initially. */ - -writel (0 , base +VIC_INT_SELECT ); -writel (0 , base +VIC_INT_ENABLE ); -writel (~0 , base +VIC_INT_ENABLE_CLEAR ); -writel (0 , base +VIC_IRQ_STATUS ); -writel (0 , base +VIC_ITCR ); -writel (~0 , base +VIC_INT_SOFT_CLEAR ); - -/* -* Make sure we clear all existing interrupts. The vector registers -* in this cell are after the second block of general registers, -* so we can address them using standard offsets, but only from -* the second base address, which is 0x20 in the page -*/ -if (vic_2nd_block) { -writel (0 , base +VIC_PL190_VECT_ADDR ); -for (i =0 ; i <19 ; i++) { -unsigned int value; - - value =readl (base +VIC_PL190_VECT_ADDR ); -writel (value, base +VIC_PL190_VECT_ADDR ); - } -/* ST has 16 vectors as well, but we don't enable them by now */ -for (i =0 ; i <16 ; i++) { -void __iomem *reg = base +VIC_VECT_CNTL0 + (i *4 ); -writel (0 , reg); - } - -writel (32 , base +VIC_PL190_DEF_VECT_ADDR ); - } - -for (i =0 ; i <32 ; i++) { -if (vic_sources & (1 << i)) { -unsigned int irq = irq_start + i; - -set_irq_chip (irq, &vic_chip); -set_irq_chip_data (irq, base); -set_irq_handler (irq, handle_level_irq); -set_irq_flags (irq,IRQF_VALID |IRQF_PROBE ); - } - } -}
PATCH 1/1 arch/arm/common/vic.c: code reorganization
2009/10/9 H Hartley Sweeten <[email protected]>:
Quoted 2 lines
This reorganizes the
vic.ccode in anticipation of a future patch to use structvic_deviceas the data stored inset_irq_chip_data().
I've tried to test this but I've got some real mangling problems when I bring up the raw mail, =20 =3D and =<newline> all over the place, I don't know if this is all my own fault, so that gmail mangles it. Can you send me a copy as an attachment that I can test?
Linus Walleij
PATCH 1/1 arch/arm/common/vic.c: code reorganization
Quoted 9 lines · Linus Walleij
2009/10/9 H Hartley Sweeten <[email protected]>:
Quoted 2 lines
This reorganizes the
vic.ccode in anticipation of a future patch to use structvic_deviceas the data stored inset_irq_chip_data().I've tried to test this but I've got some real mangling problems when I bring up the raw mail, =20 =3D and =<newline> all over the place, I don't know if this is all my own fault, so that gmail mangles it. Can you send me a copy as an attachment that I can test?
Hello Linus,
Attached is the patch. Hopefully it's gmail that's screwing it up...
Please see if this applies correctly.
Thanks,
Hartley
-------------- next part --------------
A non-text attachment was scrubbed...
Name: vic_reorg2.patch
Type: application/octet-stream
Size: 9660 bytes
Desc: vic_reorg2.patch
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20091012/3798bda8/attachment-0001.obj>
PATCH 1/1 arch/arm/common/vic.c: code reorganization
[ARM] vic.c: reorganize code
This reorganizes the vic.c code in anticipation of a second patch to use struct vic_device as the data stored in set_irq_chip_data().
The code now has the following flow:
1) struct vic_device definition, static variables, and to_vic() moved to the start of the code.
2) common code (vic_init2)
3) vic power management callbacks
4) vic power management initialization/registration
5) irq_chip callbacks
6) vendor specific vic initialization
7) vic initialization
In addition the typo vik_init_st is fixed (vic_init_st).
There is no functional change with this patch.
---
This patch had merge issues last time I posted it. Hopefully it works now. Rebased on 2.6.33-rc1.
arch/arm/common/vic.c +132 -133
@@ -18,6 +18,7 @@* along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#include <linux/init.h> #include <linux/list.h> #include <linux/io.h>
@@ -28,48 +29,6 @@#include <asm/mach/irq.h> #include <asm/hardware/vic.h> -static void vic_ack_irq (unsigned int irq) -{ -void __iomem *base =get_irq_chip_data (irq); - irq &=31 ; -writel (1 << irq, base +VIC_INT_ENABLE_CLEAR ); -/* moreover, clear the soft-triggered, in case it was the reason */ -writel (1 << irq, base +VIC_INT_SOFT_CLEAR ); -} - -static void vic_mask_irq (unsigned int irq) -{ -void __iomem *base =get_irq_chip_data (irq); - irq &=31 ; -writel (1 << irq, base +VIC_INT_ENABLE_CLEAR ); -} - -static void vic_unmask_irq (unsigned int irq) -{ -void __iomem *base =get_irq_chip_data (irq); - irq &=31 ; -writel (1 << irq, base +VIC_INT_ENABLE ); -} - -/** -* vic_init2 - common initialisation code -* @base: Base of the VIC. -* -* Common initialisation code for registeration -* and resume. -*/ -static void vic_init2 (void __iomem *base) -{ -int i; - -for (i =0 ; i <16 ; i++) { -void __iomem *reg = base +VIC_VECT_CNTL0 + (i *4 ); -writel (VIC_VECT_CNTL_ENABLE | i, reg); - } - -writel (32 , base +VIC_PL190_DEF_VECT_ADDR ); -} -#if defined(CONFIG_PM )/** * struct vic_device - VIC PM device
@@ -99,13 +58,34 @@ struct vic_device {/* we cannot allocate memory when VICs are initially registered */ static struct vic_device vic_devices[CONFIG_ARM_VIC_NR ]; +static int vic_id; +static inline struct vic_device *to_vic (struct sys_device *sys) { return container_of(sys, struct vic_device, sysdev); } +#endif /* CONFIG_PM */ -static int vic_id; +/** +* vic_init2 - common initialisation code +* @base: Base of the VIC. +* +* Common initialisation code for registeration +* and resume. +*/ +static void vic_init2 (void __iomem *base) +{ +int i; + +for (i =0 ; i <16 ; i++) { +void __iomem *reg = base +VIC_VECT_CNTL0 + (i *4 ); +writel (VIC_VECT_CNTL_ENABLE | i, reg); + } + +writel (32 , base +VIC_PL190_DEF_VECT_ADDR ); +} +#if defined(CONFIG_PM )static int vic_class_resume (struct sys_device *dev) {struct vic_device *vic =to_vic (dev);
@@ -159,31 +139,6 @@ struct sysdev_class vic_class = { };/** -* vic_pm_register - Register a VIC for later power management control -* @base: The base address of the VIC. -* @irq: The base IRQ for the VIC. -* @resume_sources: bitmask of interrupts allowed for resume sources. -* -* Register the VIC with the system device tree so that it can be notified -* of suspend and resume requests and ensure that the correct actions are -* taken to re-instate the settings on resume. -*/ -static void __init vic_pm_register (void __iomem *base,unsigned int irq,u32 resume_sources) -{ -struct vic_device *v; - -if (vic_id >=ARRAY_SIZE (vic_devices)) -printk (KERN_ERR "%s: too few VICs, increase CONFIG_ARM_VIC_NR\n" , __func__); -else { - v = &vic_devices[vic_id]; - v->base = base; - v->resume_sources = resume_sources; - v->irq = irq; - vic_id++; - } -} - -/** * vic_pm_init - initicall to register VIC pm * * This is called via late_initcall() to register
@@ -219,9 +174,60 @@ static int __init vic_pm_init(void)return 0 ; } -late_initcall (vic_pm_init); +/** +* vic_pm_register - Register a VIC for later power management control +* @base: The base address of the VIC. +* @irq: The base IRQ for the VIC. +* @resume_sources: bitmask of interrupts allowed for resume sources. +* +* Register the VIC with the system device tree so that it can be notified +* of suspend and resume requests and ensure that the correct actions are +* taken to re-instate the settings on resume. +*/ +static void __init vic_pm_register (void __iomem *base,unsigned int irq,u32 resume_sources) +{ +struct vic_device *v; + +if (vic_id >=ARRAY_SIZE (vic_devices)) +printk (KERN_ERR "%s: too few VICs, increase CONFIG_ARM_VIC_NR\n" , __func__); +else { + v = &vic_devices[vic_id]; + v->base = base; + v->resume_sources = resume_sources; + v->irq = irq; + vic_id++; + } +} +#else +static inline void vic_pm_register (void __iomem *base,unsigned int irq,u32 arg1) { } +#endif /* CONFIG_PM */ + +static void vic_ack_irq (unsigned int irq) +{ +void __iomem *base =get_irq_chip_data (irq); + irq &=31 ; +writel (1 << irq, base +VIC_INT_ENABLE_CLEAR ); +/* moreover, clear the soft-triggered, in case it was the reason */ +writel (1 << irq, base +VIC_INT_SOFT_CLEAR ); +} + +static void vic_mask_irq (unsigned int irq) +{ +void __iomem *base =get_irq_chip_data (irq); + irq &=31 ; +writel (1 << irq, base +VIC_INT_ENABLE_CLEAR ); +} + +static void vic_unmask_irq (unsigned int irq) +{ +void __iomem *base =get_irq_chip_data (irq); + irq &=31 ; +writel (1 << irq, base +VIC_INT_ENABLE ); +} + +#if defined(CONFIG_PM )static struct vic_device *vic_from_irq (unsigned int irq) {struct vic_device *v = vic_devices;
@@ -255,10 +261,7 @@ static int vic_set_wake(unsigned int irq, unsigned int on) return 0; } -#else -static inline void vic_pm_register (void __iomem *base,unsigned int irq,u32 arg1) { } -#define vic_set_wake NULL#endif /* CONFIG_PM */
@@ -270,9 +273,62 @@ static struct irq_chip vic_chip = { .set_wake = vic_set_wake, }; -/* The PL190 cell from ARM has been modified by ST, so handle both here */ -static void vik_init_st (void __iomem *base,unsigned int irq_start, -u32 vic_sources); +/* +* The PL190 cell from ARM has been modified by ST to handle 64 interrupts. +* The original cell has 32 interrupts, while the modified one has 64, +* replocating two blocks 0x00..0x1f in 0x20..0x3f. In that case +* the probe function is called twice, with base set to offset 000 +* and 020 within the page. We call this "second block". +*/ +static void __init vic_init_st (void __iomem *base,unsigned int irq_start, +u32 vic_sources) +{ +unsigned int i; +int vic_2nd_block = ((unsigned long )base & ~PAGE_MASK ) !=0 ; + +/* Disable all interrupts initially. */ + +writel (0 , base +VIC_INT_SELECT ); +writel (0 , base +VIC_INT_ENABLE ); +writel (~0 , base +VIC_INT_ENABLE_CLEAR ); +writel (0 , base +VIC_IRQ_STATUS ); +writel (0 , base +VIC_ITCR ); +writel (~0 , base +VIC_INT_SOFT_CLEAR ); + +/* +* Make sure we clear all existing interrupts. The vector registers +* in this cell are after the second block of general registers, +* so we can address them using standard offsets, but only from +* the second base address, which is 0x20 in the page +*/ +if (vic_2nd_block) { +writel (0 , base +VIC_PL190_VECT_ADDR ); +for (i =0 ; i <19 ; i++) { +unsigned int value; + + value =readl (base +VIC_PL190_VECT_ADDR ); +writel (value, base +VIC_PL190_VECT_ADDR ); + } +/* ST has 16 vectors as well, but we don't enable them by now */ +for (i =0 ; i <16 ; i++) { +void __iomem *reg = base +VIC_VECT_CNTL0 + (i *4 ); +writel (0 , reg); + } + +writel (32 , base +VIC_PL190_DEF_VECT_ADDR ); + } + +for (i =0 ; i <32 ; i++) { +if (vic_sources & (1 << i)) { +unsigned int irq = irq_start + i; + +set_irq_chip (irq, &vic_chip); +set_irq_chip_data (irq, base); +set_irq_handler (irq, handle_level_irq); +set_irq_flags (irq,IRQF_VALID |IRQF_PROBE ); + } + } +}/** * vic_init - initialise a vectored interrupt controller
@@ -299,7 +355,7 @@ void __init vic_init(void __iomem *base, unsigned int irq_start,switch (vendor) {case AMBA_VENDOR_ST : -vik_init_st (base, irq_start, vic_sources); +vic_init_st (base, irq_start, vic_sources);return ;default :printk (KERN_WARNING "VIC: unknown vendor, continuing anyways\n" );
@@ -343,60 +399,3 @@ void __init vic_init(void __iomem *base, unsigned int irq_start,vic_pm_register (base, irq_start, resume_sources); } - -/* -* The PL190 cell from ARM has been modified by ST to handle 64 interrupts. -* The original cell has 32 interrupts, while the modified one has 64, -* replocating two blocks 0x00..0x1f in 0x20..0x3f. In that case -* the probe function is called twice, with base set to offset 000 -* and 020 within the page. We call this "second block". -*/ -static void __init vik_init_st (void __iomem *base,unsigned int irq_start, -u32 vic_sources) -{ -unsigned int i; -int vic_2nd_block = ((unsigned long )base & ~PAGE_MASK ) !=0 ; - -/* Disable all interrupts initially. */ - -writel (0 , base +VIC_INT_SELECT ); -writel (0 , base +VIC_INT_ENABLE ); -writel (~0 , base +VIC_INT_ENABLE_CLEAR ); -writel (0 , base +VIC_IRQ_STATUS ); -writel (0 , base +VIC_ITCR ); -writel (~0 , base +VIC_INT_SOFT_CLEAR ); - -/* -* Make sure we clear all existing interrupts. The vector registers -* in this cell are after the second block of general registers, -* so we can address them using standard offsets, but only from -* the second base address, which is 0x20 in the page -*/ -if (vic_2nd_block) { -writel (0 , base +VIC_PL190_VECT_ADDR ); -for (i =0 ; i <19 ; i++) { -unsigned int value; - - value =readl (base +VIC_PL190_VECT_ADDR ); -writel (value, base +VIC_PL190_VECT_ADDR ); - } -/* ST has 16 vectors as well, but we don't enable them by now */ -for (i =0 ; i <16 ; i++) { -void __iomem *reg = base +VIC_VECT_CNTL0 + (i *4 ); -writel (0 , reg); - } - -writel (32 , base +VIC_PL190_DEF_VECT_ADDR ); - } - -for (i =0 ; i <32 ; i++) { -if (vic_sources & (1 << i)) { -unsigned int irq = irq_start + i; - -set_irq_chip (irq, &vic_chip); -set_irq_chip_data (irq, base); -set_irq_handler (irq, handle_level_irq); -set_irq_flags (irq,IRQF_VALID |IRQF_PROBE ); - } - } -}
PATCH 1/1 arch/arm/common/vic.c: code reorganization
2009/12/21 H Hartley Sweeten <[email protected]>:
Quoted 3 lines
[ARM]
vic.c: reorganize code
This reorganizes thevic.ccode in anticipation of a second patch to use structvic_deviceas the data stored inset_irq_chip_data().
I would love to test this patch but again cannot *for my life* decode this QP stuff, having tried now for half an hour. Can you send it directly as an attachment instead or even put it in Russells patch tracker?
Linus
PATCH 1/1 arch/arm/common/vic.c: code reorganization
Quoted 10 lines · Linus Walleij
2009/12/21 H Hartley Sweeten <[email protected]>:
Quoted 3 lines
[ARM]
vic.c: reorganize code
This reorganizes thevic.ccode in anticipation of a second patch to use structvic_deviceas the data stored inset_irq_chip_data().I would love to test this patch but again cannot *for my life* decode this QP stuff, having tried now for half an hour. Can you send it directly as an attachment instead or even put it in Russells patch tracker?
What QP stuff?
Russell does not like the patch tracker used as a patch review system. I have attached the patch, hopefully you have better results with that.
Regards,
Hartley
-------------- next part --------------
A non-text attachment was scrubbed...
Name: vic_reorg.patch
Type: application/octet-stream
Size: 9765 bytes
Desc: vic_reorg.patch
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20100107/bcfb9b64/attachment-0001.obj>
PATCH 1/1 arch/arm/common/vic.c: code reorganization
2010/1/7 H Hartley Sweeten <[email protected]>:
Quoted 3 lines
[ARM]
vic.c: reorganize code
This reorganizes thevic.ccode in anticipation of a second patch to use structvic_deviceas the data stored inset_irq_chip_data().
Works like a charm on the U300!
Linus Walleij
PATCH 1/1 arch/arm/common/vic.c: code reorganization
Quoted 8 lines · Linus Walleij
2010/1/7 H Hartley Sweeten <[email protected]>:
Quoted 3 lines
[ARM]
vic.c: reorganize code
This reorganizes thevic.ccode in anticipation of a second patch to use structvic_deviceas the data stored inset_irq_chip_data().Works like a charm on the U300!
Tested-by Linus Walleij <[email protected]>
Great, I guess the patch is ready.
PATCH 1/1 arch/arm/common/vic.c: code reorganization
Fine on Nomadik too (the only one that uses 64 irqs in the vic, I suppose). But I confirm the orignal mail doesn't apply. I used the one attached as a non-git patch.
Quoted 1 line
Quoted 1 line
Tested-by Linus Walleij <[email protected]>