Skip to content

Commit

Permalink
[ARM] pxa: update pxa2xx_spi_chip initialization to use .gpio_cs field
Browse files Browse the repository at this point in the history
Signed-off-by: Mike Rapoport <mike@compulab.co.il>
Signed-off-by: Eric Miao <eric.miao@marvell.com>
  • Loading branch information
Mike Rapoport authored and Eric Miao committed Jun 5, 2009
1 parent a27ba76 commit 46580c0
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 139 deletions.
45 changes: 3 additions & 42 deletions arch/arm/mach-pxa/corgi.c
Original file line number Diff line number Diff line change
Expand Up @@ -445,13 +445,8 @@ static struct ads7846_platform_data corgi_ads7846_info = {
.wait_for_sync = corgi_wait_for_hsync,
};

static void corgi_ads7846_cs(u32 command)
{
gpio_set_value(CORGI_GPIO_ADS7846_CS, !(command == PXA2XX_CS_ASSERT));
}

static struct pxa2xx_spi_chip corgi_ads7846_chip = {
.cs_control = corgi_ads7846_cs,
.gpio_cs = CORGI_GPIO_ADS7846_CS,
};

static void corgi_bl_kick_battery(void)
Expand All @@ -475,22 +470,12 @@ static struct corgi_lcd_platform_data corgi_lcdcon_info = {
.kick_battery = corgi_bl_kick_battery,
};

static void corgi_lcdcon_cs(u32 command)
{
gpio_set_value(CORGI_GPIO_LCDCON_CS, !(command == PXA2XX_CS_ASSERT));
}

static struct pxa2xx_spi_chip corgi_lcdcon_chip = {
.cs_control = corgi_lcdcon_cs,
.gpio_cs = CORGI_GPIO_LCDCON_CS,
};

static void corgi_max1111_cs(u32 command)
{
gpio_set_value(CORGI_GPIO_MAX1111_CS, !(command == PXA2XX_CS_ASSERT));
}

static struct pxa2xx_spi_chip corgi_max1111_chip = {
.cs_control = corgi_max1111_cs,
.gpio_cs = CORGI_GPIO_MAX1111_CS,
};

static struct spi_board_info corgi_spi_devices[] = {
Expand Down Expand Up @@ -520,32 +505,8 @@ static struct spi_board_info corgi_spi_devices[] = {

static void __init corgi_init_spi(void)
{
int err;

err = gpio_request(CORGI_GPIO_ADS7846_CS, "ADS7846_CS");
if (err)
return;

err = gpio_request(CORGI_GPIO_LCDCON_CS, "LCDCON_CS");
if (err)
goto err_free_1;

err = gpio_request(CORGI_GPIO_MAX1111_CS, "MAX1111_CS");
if (err)
goto err_free_2;

gpio_direction_output(CORGI_GPIO_ADS7846_CS, 1);
gpio_direction_output(CORGI_GPIO_LCDCON_CS, 1);
gpio_direction_output(CORGI_GPIO_MAX1111_CS, 1);

pxa2xx_set_spi_info(1, &corgi_spi_info);
spi_register_board_info(ARRAY_AND_SIZE(corgi_spi_devices));
return;

err_free_2:
gpio_free(CORGI_GPIO_LCDCON_CS);
err_free_1:
gpio_free(CORGI_GPIO_ADS7846_CS);
}
#else
static inline void corgi_init_spi(void) {}
Expand Down
19 changes: 2 additions & 17 deletions arch/arm/mach-pxa/imote2.c
Original file line number Diff line number Diff line change
Expand Up @@ -456,33 +456,20 @@ static struct pxa2xx_spi_master pxa_ssp_master_2_info = {
.num_chipselect = 1,
};

/* Patch posted by Eric Miao <eric.miao@marvell.com> will remove
* the need for these functions.
*/
static void spi1control(u32 command)
{
gpio_set_value(24, command & PXA2XX_CS_ASSERT ? 0 : 1);
};

static void spi3control(u32 command)
{
gpio_set_value(39, command & PXA2XX_CS_ASSERT ? 0 : 1);
};

static struct pxa2xx_spi_chip staccel_chip_info = {
.tx_threshold = 8,
.rx_threshold = 8,
.dma_burst_size = 8,
.timeout = 235,
.cs_control = spi1control,
.gpio_cs = 24,
};

static struct pxa2xx_spi_chip cc2420_info = {
.tx_threshold = 8,
.rx_threshold = 8,
.dma_burst_size = 8,
.timeout = 235,
.cs_control = spi3control,
.gpio_cs = 39,
};

static struct spi_board_info spi_board_info[] __initdata = {
Expand Down Expand Up @@ -538,8 +525,6 @@ static void __init imote2_init(void)
/* SPI chip select directions - all other directions should
* be handled by drivers.*/
gpio_direction_output(37, 0);
gpio_direction_output(24, 0);
gpio_direction_output(39, 0);

platform_add_devices(imote2_devices, ARRAY_SIZE(imote2_devices));

Expand Down
17 changes: 1 addition & 16 deletions arch/arm/mach-pxa/littleton.c
Original file line number Diff line number Diff line change
Expand Up @@ -179,15 +179,10 @@ static struct pxa2xx_spi_master littleton_spi_info = {
.num_chipselect = 1,
};

static void littleton_tdo24m_cs(u32 cmd)
{
gpio_set_value(LITTLETON_GPIO_LCD_CS, !(cmd == PXA2XX_CS_ASSERT));
}

static struct pxa2xx_spi_chip littleton_tdo24m_chip = {
.rx_threshold = 1,
.tx_threshold = 1,
.cs_control = littleton_tdo24m_cs,
.gpio_cs = LITTLETON_GPIO_LCD_CS,
};

static struct spi_board_info littleton_spi_devices[] __initdata = {
Expand All @@ -202,16 +197,6 @@ static struct spi_board_info littleton_spi_devices[] __initdata = {

static void __init littleton_init_spi(void)
{
int err;

err = gpio_request(LITTLETON_GPIO_LCD_CS, "LCD_CS");
if (err) {
pr_warning("failed to request GPIO for LCS CS\n");
return;
}

gpio_direction_output(LITTLETON_GPIO_LCD_CS, 1);

pxa2xx_set_spi_info(2, &littleton_spi_info);
spi_register_board_info(ARRAY_AND_SIZE(littleton_spi_devices));
}
Expand Down
15 changes: 1 addition & 14 deletions arch/arm/mach-pxa/poodle.c
Original file line number Diff line number Diff line change
Expand Up @@ -214,13 +214,8 @@ static struct ads7846_platform_data poodle_ads7846_info = {
.gpio_pendown = POODLE_GPIO_TP_INT,
};

static void ads7846_cs(u32 command)
{
gpio_set_value(POODLE_GPIO_TP_CS, !(command == PXA2XX_CS_ASSERT));
}

static struct pxa2xx_spi_chip poodle_ads7846_chip = {
.cs_control = ads7846_cs,
.gpio_cs = POODLE_GPIO_TP_CS,
};

static struct spi_board_info poodle_spi_devices[] = {
Expand All @@ -236,14 +231,6 @@ static struct spi_board_info poodle_spi_devices[] = {

static void __init poodle_init_spi(void)
{
int err;

err = gpio_request(POODLE_GPIO_TP_CS, "ADS7846_CS");
if (err)
return;

gpio_direction_output(POODLE_GPIO_TP_CS, 1);

pxa2xx_set_spi_info(1, &poodle_spi_info);
spi_register_board_info(ARRAY_AND_SIZE(poodle_spi_devices));
}
Expand Down
53 changes: 3 additions & 50 deletions arch/arm/mach-pxa/spitz.c
Original file line number Diff line number Diff line change
Expand Up @@ -317,13 +317,8 @@ static struct ads7846_platform_data spitz_ads7846_info = {
.wait_for_sync = spitz_wait_for_hsync,
};

static void spitz_ads7846_cs(u32 command)
{
gpio_set_value(SPITZ_GPIO_ADS7846_CS, !(command == PXA2XX_CS_ASSERT));
}

static struct pxa2xx_spi_chip spitz_ads7846_chip = {
.cs_control = spitz_ads7846_cs,
.gpio_cs = SPITZ_GPIO_ADS7846_CS,
};

static void spitz_bl_kick_battery(void)
Expand All @@ -347,22 +342,12 @@ static struct corgi_lcd_platform_data spitz_lcdcon_info = {
.kick_battery = spitz_bl_kick_battery,
};

static void spitz_lcdcon_cs(u32 command)
{
gpio_set_value(SPITZ_GPIO_LCDCON_CS, !(command == PXA2XX_CS_ASSERT));
}

static struct pxa2xx_spi_chip spitz_lcdcon_chip = {
.cs_control = spitz_lcdcon_cs,
.gpio_cs = SPITZ_GPIO_LCDCON_CS,
};

static void spitz_max1111_cs(u32 command)
{
gpio_set_value(SPITZ_GPIO_MAX1111_CS, !(command == PXA2XX_CS_ASSERT));
}

static struct pxa2xx_spi_chip spitz_max1111_chip = {
.cs_control = spitz_max1111_cs,
.gpio_cs = SPITZ_GPIO_MAX1111_CS,
};

static struct spi_board_info spitz_spi_devices[] = {
Expand Down Expand Up @@ -392,45 +377,13 @@ static struct spi_board_info spitz_spi_devices[] = {

static void __init spitz_init_spi(void)
{
int err;

err = gpio_request(SPITZ_GPIO_ADS7846_CS, "ADS7846_CS");
if (err)
return;

err = gpio_request(SPITZ_GPIO_LCDCON_CS, "LCDCON_CS");
if (err)
goto err_free_1;

err = gpio_request(SPITZ_GPIO_MAX1111_CS, "MAX1111_CS");
if (err)
goto err_free_2;

err = gpio_direction_output(SPITZ_GPIO_ADS7846_CS, 1);
if (err)
goto err_free_3;
err = gpio_direction_output(SPITZ_GPIO_LCDCON_CS, 1);
if (err)
goto err_free_3;
err = gpio_direction_output(SPITZ_GPIO_MAX1111_CS, 1);
if (err)
goto err_free_3;

if (machine_is_akita()) {
spitz_lcdcon_info.gpio_backlight_cont = AKITA_GPIO_BACKLIGHT_CONT;
spitz_lcdcon_info.gpio_backlight_on = AKITA_GPIO_BACKLIGHT_ON;
}

pxa2xx_set_spi_info(2, &spitz_spi_info);
spi_register_board_info(ARRAY_AND_SIZE(spitz_spi_devices));
return;

err_free_3:
gpio_free(SPITZ_GPIO_MAX1111_CS);
err_free_2:
gpio_free(SPITZ_GPIO_LCDCON_CS);
err_free_1:
gpio_free(SPITZ_GPIO_ADS7846_CS);
}
#else
static inline void spitz_init_spi(void) {}
Expand Down

0 comments on commit 46580c0

Please sign in to comment.