Skip to content

Commit

Permalink
ARM: pxa: change gpio to platform device
Browse files Browse the repository at this point in the history
Remove most gpio macros and change gpio driver to platform driver.

Signed-off-by: Haojian Zhuang <haojian.zhuang@marvell.com>
  • Loading branch information
Haojian Zhuang authored and Haojian Zhuang committed Nov 15, 2011
1 parent 9bf448c commit 157d264
Show file tree
Hide file tree
Showing 33 changed files with 271 additions and 233 deletions.
2 changes: 2 additions & 0 deletions arch/arm/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -591,6 +591,7 @@ config ARCH_MMP
select ARCH_REQUIRE_GPIOLIB
select CLKDEV_LOOKUP
select GENERIC_CLOCKEVENTS
select GPIO_PXA
select HAVE_SCHED_CLOCK
select TICK_ONESHOT
select PLAT_PXA
Expand Down Expand Up @@ -673,6 +674,7 @@ config ARCH_PXA
select CLKSRC_MMIO
select ARCH_REQUIRE_GPIOLIB
select GENERIC_CLOCKEVENTS
select GPIO_PXA
select HAVE_SCHED_CLOCK
select TICK_ONESHOT
select PLAT_PXA
Expand Down
1 change: 1 addition & 0 deletions arch/arm/mach-mmp/aspenite.c
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,7 @@ static void __init common_init(void)
pxa168_add_nand(&aspenite_nand_info);
pxa168_add_fb(&aspenite_lcd_info);
pxa168_add_keypad(&aspenite_keypad_info);
platform_device_register(&pxa168_device_gpio);

/* off-chip devices */
platform_device_register(&smc91x_device);
Expand Down
1 change: 1 addition & 0 deletions arch/arm/mach-mmp/avengers_lite.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ static void __init avengers_lite_init(void)

/* on-chip devices */
pxa168_add_uart(2);
platform_device_register(&pxa168_device_gpio);
}

MACHINE_START(AVENGERS_LITE, "PXA168 Avengers lite Development Platform")
Expand Down
1 change: 1 addition & 0 deletions arch/arm/mach-mmp/brownstone.c
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,7 @@ static void __init brownstone_init(void)
/* on-chip devices */
mmp2_add_uart(1);
mmp2_add_uart(3);
platform_device_register(&mmp2_device_gpio);
mmp2_add_twsi(1, NULL, ARRAY_AND_SIZE(brownstone_twsi1_info));
mmp2_add_sdhost(0, &mmp2_sdh_platdata_mmc0); /* SD/MMC */
mmp2_add_sdhost(2, &mmp2_sdh_platdata_mmc2); /* eMMC */
Expand Down
1 change: 1 addition & 0 deletions arch/arm/mach-mmp/flint.c
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ static void __init flint_init(void)
/* on-chip devices */
mmp2_add_uart(1);
mmp2_add_uart(2);
platform_device_register(&mmp2_device_gpio);

/* off-chip devices */
platform_device_register(&smc91x_device);
Expand Down
1 change: 1 addition & 0 deletions arch/arm/mach-mmp/gplugd.c
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@ static void __init gplugd_init(void)
pxa168_add_uart(3);
pxa168_add_ssp(0);
pxa168_add_twsi(0, NULL, ARRAY_AND_SIZE(gplugd_i2c_board_info));
platform_device_register(&pxa168_device_gpio);

pxa168_add_eth(&gplugd_eth_platform_data);
}
Expand Down
3 changes: 1 addition & 2 deletions arch/arm/mach-mmp/include/mach/gpio.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

#include <asm-generic/gpio.h>

#define __gpio_is_inverted(gpio) (0)
#define __gpio_is_occupied(gpio) (0)
#include <mach/cputype.h>

#endif /* __ASM_MACH_GPIO_H */
2 changes: 2 additions & 0 deletions arch/arm/mach-mmp/include/mach/mmp2.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ extern struct pxa_device_desc mmp2_device_sdh3;
extern struct pxa_device_desc mmp2_device_asram;
extern struct pxa_device_desc mmp2_device_isram;

extern struct platform_device mmp2_device_gpio;

static inline int mmp2_add_uart(int id)
{
struct pxa_device_desc *d = NULL;
Expand Down
2 changes: 2 additions & 0 deletions arch/arm/mach-mmp/include/mach/pxa168.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ struct pxa168_usb_pdata {
/* pdata can be NULL */
int __init pxa168_add_usb_host(struct pxa168_usb_pdata *pdata);

extern struct platform_device pxa168_device_gpio;

static inline int pxa168_add_uart(int id)
{
struct pxa_device_desc *d = NULL;
Expand Down
2 changes: 2 additions & 0 deletions arch/arm/mach-mmp/include/mach/pxa910.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ extern struct pxa_device_desc pxa910_device_pwm3;
extern struct pxa_device_desc pxa910_device_pwm4;
extern struct pxa_device_desc pxa910_device_nand;

extern struct platform_device pxa910_device_gpio;

static inline int pxa910_add_uart(int id)
{
struct pxa_device_desc *d = NULL;
Expand Down
28 changes: 19 additions & 9 deletions arch/arm/mach-mmp/mmp2.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include <linux/kernel.h>
#include <linux/init.h>
#include <linux/io.h>
#include <linux/platform_device.h>

#include <asm/hardware/cache-tauros2.h>

Expand All @@ -24,7 +25,6 @@
#include <mach/irqs.h>
#include <mach/dma.h>
#include <mach/mfp.h>
#include <mach/gpio-pxa.h>
#include <mach/devices.h>
#include <mach/mmp2.h>

Expand All @@ -33,8 +33,6 @@

#define MFPR_VIRT_BASE (APB_VIRT_BASE + 0x1e000)

#define APMASK(i) (GPIO_REGS_VIRT + BANK_OFF(i) + 0x9c)

static struct mfp_addr_map mmp2_addr_map[] __initdata = {

MFP_ADDR_X(GPIO0, GPIO58, 0x54),
Expand Down Expand Up @@ -101,12 +99,6 @@ static void __init mmp2_init_gpio(void)

/* enable GPIO clock */
__raw_writel(APBC_APBCLK | APBC_FNCLK, APBC_MMP2_GPIO);

/* unmask GPIO edge detection for all 6 banks -- APMASKx */
for (i = 0; i < 6; i++)
__raw_writel(0xffffffff, APMASK(i));

pxa_init_gpio(IRQ_MMP2_GPIO, 0, 167, NULL);
}

void __init mmp2_init_irq(void)
Expand Down Expand Up @@ -230,3 +222,21 @@ MMP2_DEVICE(asram, "asram", -1, NONE, 0xe0000000, 0x4000);
/* 0xd1000000 ~ 0xd101ffff is reserved for secure processor */
MMP2_DEVICE(isram, "isram", -1, NONE, 0xd1020000, 0x18000);

struct resource mmp2_resource_gpio[] = {
{
.start = 0xd4019000,
.end = 0xd4019fff,
.flags = IORESOURCE_MEM,
}, {
.start = IRQ_MMP2_GPIO,
.end = IRQ_MMP2_GPIO,
.flags = IORESOURCE_IRQ,
},
};

struct platform_device mmp2_device_gpio = {
.name = "pxa-gpio",
.id = -1,
.num_resources = ARRAY_SIZE(mmp2_resource_gpio),
.resource = mmp2_resource_gpio,
};
29 changes: 20 additions & 9 deletions arch/arm/mach-mmp/pxa168.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@
#include <linux/list.h>
#include <linux/io.h>
#include <linux/clk.h>
#include <linux/platform_device.h>

#include <asm/mach/time.h>
#include <mach/addr-map.h>
#include <mach/cputype.h>
#include <mach/regs-apbc.h>
#include <mach/regs-apmu.h>
#include <mach/irqs.h>
#include <mach/gpio-pxa.h>
#include <mach/dma.h>
#include <mach/devices.h>
#include <mach/mfp.h>
Expand All @@ -43,20 +43,12 @@ static struct mfp_addr_map pxa168_mfp_addr_map[] __initdata =
MFP_ADDR_END,
};

#define APMASK(i) (GPIO_REGS_VIRT + BANK_OFF(i) + 0x09c)

static void __init pxa168_init_gpio(void)
{
int i;

/* enable GPIO clock */
__raw_writel(APBC_APBCLK | APBC_FNCLK, APBC_PXA168_GPIO);

/* unmask GPIO edge detection for all 4 banks - APMASKx */
for (i = 0; i < 4; i++)
__raw_writel(0xffffffff, APMASK(i));

pxa_init_gpio(IRQ_PXA168_GPIOX, 0, 127, NULL);
}

void __init pxa168_init_irq(void)
Expand Down Expand Up @@ -174,6 +166,25 @@ PXA168_DEVICE(fb, "pxa168-fb", -1, LCD, 0xd420b000, 0x1c8);
PXA168_DEVICE(keypad, "pxa27x-keypad", -1, KEYPAD, 0xd4012000, 0x4c);
PXA168_DEVICE(eth, "pxa168-eth", -1, MFU, 0xc0800000, 0x0fff);

struct resource pxa168_resource_gpio[] = {
{
.start = 0xd4019000,
.end = 0xd4019fff,
.flags = IORESOURCE_MEM,
}, {
.start = IRQ_PXA168_GPIOX,
.end = IRQ_PXA168_GPIOX,
.flags = IORESOURCE_IRQ,
},
};

struct platform_device pxa168_device_gpio = {
.name = "pxa-gpio",
.id = -1,
.num_resources = ARRAY_SIZE(pxa168_resource_gpio),
.resource = pxa168_resource_gpio,
};

struct resource pxa168_usb_host_resources[] = {
/* USB Host conroller register base */
[0] = {
Expand Down
29 changes: 20 additions & 9 deletions arch/arm/mach-mmp/pxa910.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@
#include <linux/init.h>
#include <linux/list.h>
#include <linux/io.h>
#include <linux/platform_device.h>

#include <asm/mach/time.h>
#include <mach/addr-map.h>
#include <mach/regs-apbc.h>
#include <mach/regs-apmu.h>
#include <mach/cputype.h>
#include <mach/irqs.h>
#include <mach/gpio-pxa.h>
#include <mach/dma.h>
#include <mach/mfp.h>
#include <mach/devices.h>
Expand Down Expand Up @@ -77,20 +77,12 @@ static struct mfp_addr_map pxa910_mfp_addr_map[] __initdata =
MFP_ADDR_END,
};

#define APMASK(i) (GPIO_REGS_VIRT + BANK_OFF(i) + 0x09c)

static void __init pxa910_init_gpio(void)
{
int i;

/* enable GPIO clock */
__raw_writel(APBC_APBCLK | APBC_FNCLK, APBC_PXA910_GPIO);

/* unmask GPIO edge detection for all 4 banks - APMASKx */
for (i = 0; i < 4; i++)
__raw_writel(0xffffffff, APMASK(i));

pxa_init_gpio(IRQ_PXA910_AP_GPIO, 0, 127, NULL);
}

void __init pxa910_init_irq(void)
Expand Down Expand Up @@ -179,3 +171,22 @@ PXA910_DEVICE(pwm2, "pxa910-pwm", 1, NONE, 0xd401a400, 0x10);
PXA910_DEVICE(pwm3, "pxa910-pwm", 2, NONE, 0xd401a800, 0x10);
PXA910_DEVICE(pwm4, "pxa910-pwm", 3, NONE, 0xd401ac00, 0x10);
PXA910_DEVICE(nand, "pxa3xx-nand", -1, NAND, 0xd4283000, 0x80, 97, 99);

struct resource pxa910_resource_gpio[] = {
{
.start = 0xd4019000,
.end = 0xd4019fff,
.flags = IORESOURCE_MEM,
}, {
.start = IRQ_PXA910_AP_GPIO,
.end = IRQ_PXA910_AP_GPIO,
.flags = IORESOURCE_IRQ,
},
};

struct platform_device pxa910_device_gpio = {
.name = "pxa-gpio",
.id = -1,
.num_resources = ARRAY_SIZE(pxa910_resource_gpio),
.resource = pxa910_resource_gpio,
};
1 change: 1 addition & 0 deletions arch/arm/mach-mmp/tavorevb.c
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ static void __init tavorevb_init(void)

/* on-chip devices */
pxa910_add_uart(1);
platform_device_register(&pxa910_device_gpio);

/* off-chip devices */
platform_device_register(&smc91x_device);
Expand Down
1 change: 1 addition & 0 deletions arch/arm/mach-mmp/teton_bga.c
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ static void __init teton_bga_init(void)
pxa168_add_uart(1);
pxa168_add_keypad(&teton_bga_keypad_info);
pxa168_add_twsi(0, NULL, ARRAY_AND_SIZE(teton_bga_i2c_info));
platform_device_register(&pxa168_device_gpio);
}

MACHINE_START(TETON_BGA, "PXA168-based Teton BGA Development Platform")
Expand Down
1 change: 1 addition & 0 deletions arch/arm/mach-mmp/ttc_dkb.c
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ static struct platform_device ttc_dkb_device_onenand = {
};

static struct platform_device *ttc_dkb_devices[] = {
&pxa910_device_gpio,
&ttc_dkb_device_onenand,
};

Expand Down
30 changes: 30 additions & 0 deletions arch/arm/mach-pxa/devices.c
Original file line number Diff line number Diff line change
Expand Up @@ -1051,6 +1051,36 @@ struct platform_device pxa3xx_device_ssp4 = {
};
#endif /* CONFIG_PXA3xx || CONFIG_PXA95x */

struct resource pxa_resource_gpio[] = {
{
.start = 0x40e00000,
.end = 0x40e0ffff,
.flags = IORESOURCE_MEM,
}, {
.start = IRQ_GPIO0,
.end = IRQ_GPIO0,
.name = "gpio0",
.flags = IORESOURCE_IRQ,
}, {
.start = IRQ_GPIO1,
.end = IRQ_GPIO1,
.name = "gpio1",
.flags = IORESOURCE_IRQ,
}, {
.start = IRQ_GPIO_2_x,
.end = IRQ_GPIO_2_x,
.name = "gpio_mux",
.flags = IORESOURCE_IRQ,
},
};

struct platform_device pxa_device_gpio = {
.name = "pxa-gpio",
.id = -1,
.num_resources = ARRAY_SIZE(pxa_resource_gpio),
.resource = pxa_resource_gpio,
};

/* pxa2xx-spi platform-device ID equals respective SSP platform-device ID + 1.
* See comment in arch/arm/mach-pxa/ssp.c::ssp_probe() */
void __init pxa2xx_set_spi_info(unsigned id, struct pxa2xx_spi_master *info)
Expand Down
1 change: 1 addition & 0 deletions arch/arm/mach-pxa/devices.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ extern struct platform_device pxa_device_ficp;
extern struct platform_device sa1100_device_rtc;
extern struct platform_device pxa_device_rtc;
extern struct platform_device pxa_device_ac97;
extern struct platform_device pxa_device_gpio;

extern struct platform_device pxa27x_device_i2c_power;
extern struct platform_device pxa27x_device_ohci;
Expand Down
Loading

0 comments on commit 157d264

Please sign in to comment.