Skip to content

Commit

Permalink
[ARM] 4559/1: pxa: make PXA_LAST_GPIO a run-time variable
Browse files Browse the repository at this point in the history
This definition produces processor specific code in generic function
pxa_gpio_mode(), thus creating inconsistencies for support of pxa25x
and pxa27x in a single zImage.

As David Brownell suggests, make it a run-time variable and initialize
at run-time according to the number of GPIOs on the processor. For now
the initialization happens in pxa_init_irq_gpio(),  since there is
already a parameter for that, besides, this is and MUST be earlier
than any subsequent calls to pxa_gpio_mode().

Signed-off-by: eric miao <eric.y.miao@gmail.com>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
  • Loading branch information
eric miao authored and Russell King committed Oct 12, 2007
1 parent 37c2f77 commit 30f0b40
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 7 deletions.
3 changes: 2 additions & 1 deletion arch/arm/mach-pxa/generic.c
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ EXPORT_SYMBOL(get_memclk_frequency_10khz);
/*
* Handy function to set GPIO alternate functions
*/
int pxa_last_gpio;

int pxa_gpio_mode(int gpio_mode)
{
Expand All @@ -79,7 +80,7 @@ int pxa_gpio_mode(int gpio_mode)
int fn = (gpio_mode & GPIO_MD_MASK_FN) >> 8;
int gafr;

if (gpio > PXA_LAST_GPIO)
if (gpio > pxa_last_gpio)
return -EINVAL;

local_irq_save(flags);
Expand Down
1 change: 1 addition & 0 deletions arch/arm/mach-pxa/generic.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ extern void __init pxa27x_init_irq(void);
extern void __init pxa_map_io(void);

extern unsigned int get_clk_frequency_khz(int info);
extern int pxa_last_gpio;

#define SET_BANK(__nr,__start,__size) \
mi->bank[__nr].start = (__start), \
Expand Down
2 changes: 2 additions & 0 deletions arch/arm/mach-pxa/irq.c
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,8 @@ void __init pxa_init_irq_gpio(int gpio_nr)
{
int irq, i;

pxa_last_gpio = gpio_nr - 1;

/* clear all GPIO edge detects */
for (i = 0; i < gpio_nr; i += 32) {
GFER(i) = 0;
Expand Down
6 changes: 0 additions & 6 deletions include/asm-arm/arch-pxa/irqs.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,6 @@
#define IRQ_TO_GPIO_2_x(i) ((i) - PXA_GPIO_IRQ_BASE)
#define IRQ_TO_GPIO(i) (((i) < IRQ_GPIO(2)) ? ((i) - IRQ_GPIO0) : IRQ_TO_GPIO_2_x(i))

#if defined(CONFIG_PXA25x)
#define PXA_LAST_GPIO 84
#elif defined(CONFIG_PXA27x)
#define PXA_LAST_GPIO 127
#endif

/*
* The next 16 interrupts are for board specific purposes. Since
* the kernel can only run on one machine at a time, we can re-use
Expand Down

0 comments on commit 30f0b40

Please sign in to comment.