Skip to content

Commit

Permalink
davinci: add spi devices on tnetv107x evm
Browse files Browse the repository at this point in the history
This patch adds definitions for spi devices on the tnetv107x evm platform.

Signed-off-by: Cyril Chemparathy <cyril@ti.com>
Signed-off-by: Sekhar Nori <nsekhar@ti.com>
Signed-off-by: Kevin Hilman <khilman@ti.com>
  • Loading branch information
Cyril Chemparathy authored and Kevin Hilman committed Mar 15, 2011
1 parent 08e0e1d commit f6e5306
Showing 1 changed file with 43 additions and 0 deletions.
43 changes: 43 additions & 0 deletions arch/arm/mach-davinci/board-tnetv107x-evm.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#include <linux/mtd/partitions.h>
#include <linux/input.h>
#include <linux/input/matrix_keypad.h>
#include <linux/spi/spi.h>

#include <asm/mach/arch.h>
#include <asm/mach-types.h>
Expand All @@ -37,6 +38,7 @@

#define EVM_MMC_WP_GPIO 21
#define EVM_MMC_CD_GPIO 24
#define EVM_SPI_CS_GPIO 54

static int initialize_gpio(int gpio, char *desc)
{
Expand Down Expand Up @@ -202,9 +204,45 @@ static struct matrix_keypad_platform_data keypad_config = {
.no_autorepeat = 0,
};

static void spi_select_device(int cs)
{
static int gpio;

if (!gpio) {
int ret;
ret = gpio_request(EVM_SPI_CS_GPIO, "spi chipsel");
if (ret < 0) {
pr_err("cannot open spi chipsel gpio\n");
gpio = -ENOSYS;
return;
} else {
gpio = EVM_SPI_CS_GPIO;
gpio_direction_output(gpio, 0);
}
}

if (gpio < 0)
return;

return gpio_set_value(gpio, cs ? 1 : 0);
}

static struct ti_ssp_spi_data spi_master_data = {
.num_cs = 2,
.select = spi_select_device,
.iosel = SSP_PIN_SEL(0, SSP_CLOCK) | SSP_PIN_SEL(1, SSP_DATA) |
SSP_PIN_SEL(2, SSP_CHIPSEL) | SSP_PIN_SEL(3, SSP_IN) |
SSP_INPUT_SEL(3),
};

static struct ti_ssp_data ssp_config = {
.out_clock = 250 * 1000,
.dev_data = {
[1] = {
.dev_name = "ti-ssp-spi",
.pdata = &spi_master_data,
.pdata_size = sizeof(spi_master_data),
},
},
};

Expand All @@ -216,13 +254,18 @@ static struct tnetv107x_device_info evm_device_info __initconst = {
.ssp_config = &ssp_config,
};

static struct spi_board_info spi_info[] __initconst = {
};

static __init void tnetv107x_evm_board_init(void)
{
davinci_cfg_reg_list(sdio1_pins);
davinci_cfg_reg_list(uart1_pins);
davinci_cfg_reg_list(ssp_pins);

tnetv107x_devices_init(&evm_device_info);

spi_register_board_info(spi_info, ARRAY_SIZE(spi_info));
}

#ifdef CONFIG_SERIAL_8250_CONSOLE
Expand Down

0 comments on commit f6e5306

Please sign in to comment.