at91: add spi device ressources
Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
This commit is contained in:
parent
be11d8ef35
commit
d816bb4cc0
|
@ -153,6 +153,38 @@ void __init at91_add_device_nand(struct atmel_nand_data *data)
|
|||
void __init at91_add_device_nand(struct atmel_nand_data *data) {}
|
||||
#endif
|
||||
|
||||
/* --------------------------------------------------------------------
|
||||
* SPI
|
||||
* -------------------------------------------------------------------- */
|
||||
|
||||
#if defined(CONFIG_DRIVER_SPI_ATMEL)
|
||||
void at91_add_device_spi(int spi_id, struct at91_spi_platform_data *pdata)
|
||||
{
|
||||
int i;
|
||||
int cs_pin;
|
||||
|
||||
BUG_ON(spi_id > 0);
|
||||
|
||||
for (i = 0; i < pdata->num_chipselect; i++) {
|
||||
cs_pin = pdata->chipselect[i];
|
||||
|
||||
/* enable chip-select pin */
|
||||
if (cs_pin > 0)
|
||||
at91_set_gpio_output(cs_pin, 1);
|
||||
}
|
||||
|
||||
at91_set_A_periph(AT91_PIN_PA0, 0); /* MISO */
|
||||
at91_set_A_periph(AT91_PIN_PA1, 0); /* MOSI */
|
||||
at91_set_A_periph(AT91_PIN_PA2, 0); /* SPCK */
|
||||
|
||||
add_generic_device("atmel_spi", spi_id, NULL, AT91RM9200_BASE_SPI,
|
||||
SZ_16K, IORESOURCE_MEM, pdata);
|
||||
}
|
||||
#else
|
||||
void __init at91_add_device_spi(int spi_id, struct at91_spi_platform_data *pdata) {}
|
||||
#endif
|
||||
|
||||
|
||||
/* --------------------------------------------------------------------
|
||||
* UART
|
||||
* -------------------------------------------------------------------- */
|
||||
|
|
|
@ -150,6 +150,50 @@ void at91_add_device_nand(struct atmel_nand_data *data)
|
|||
void at91_add_device_nand(struct atmel_nand_data *data) {}
|
||||
#endif
|
||||
|
||||
/* --------------------------------------------------------------------
|
||||
* SPI
|
||||
* -------------------------------------------------------------------- */
|
||||
|
||||
#if defined(CONFIG_DRIVER_SPI_ATMEL)
|
||||
void __init at91_add_device_spi(int spi_id, struct at91_spi_platform_data *pdata)
|
||||
{
|
||||
int i;
|
||||
int cs_pin;
|
||||
resource_size_t start = ~0;
|
||||
|
||||
BUG_ON(spi_id > 1);
|
||||
|
||||
for (i = 0; i < pdata->num_chipselect; i++) {
|
||||
cs_pin = pdata->chipselect[i];
|
||||
|
||||
/* enable chip-select pin */
|
||||
if (cs_pin > 0)
|
||||
at91_set_gpio_output(cs_pin, 1);
|
||||
}
|
||||
|
||||
/* Configure SPI bus(es) */
|
||||
switch (spi_id) {
|
||||
case 0:
|
||||
start = AT91SAM9260_BASE_SPI0;
|
||||
at91_set_A_periph(AT91_PIN_PA0, 0); /* SPI0_MISO */
|
||||
at91_set_A_periph(AT91_PIN_PA1, 0); /* SPI0_MOSI */
|
||||
at91_set_A_periph(AT91_PIN_PA2, 0); /* SPI1_SPCK */
|
||||
break;
|
||||
case 1:
|
||||
start = AT91SAM9260_BASE_SPI1;
|
||||
at91_set_A_periph(AT91_PIN_PB0, 0); /* SPI1_MISO */
|
||||
at91_set_A_periph(AT91_PIN_PB1, 0); /* SPI1_MOSI */
|
||||
at91_set_A_periph(AT91_PIN_PB2, 0); /* SPI1_SPCK */
|
||||
break;
|
||||
}
|
||||
|
||||
add_generic_device("atmel_spi", spi_id, NULL, start, SZ_16K,
|
||||
IORESOURCE_MEM, pdata);
|
||||
}
|
||||
#else
|
||||
void __init at91_add_device_spi(int spi_id, struct at91_spi_platform_data *pdata) {}
|
||||
#endif
|
||||
|
||||
static inline void configure_dbgu_pins(void)
|
||||
{
|
||||
at91_set_A_periph(AT91_PIN_PB14, 0); /* DRXD */
|
||||
|
|
|
@ -102,6 +102,50 @@ void at91_add_device_nand(struct atmel_nand_data *data)
|
|||
void at91_add_device_nand(struct atmel_nand_data *data) {}
|
||||
#endif
|
||||
|
||||
/* --------------------------------------------------------------------
|
||||
* SPI
|
||||
* -------------------------------------------------------------------- */
|
||||
|
||||
#if defined(CONFIG_DRIVER_SPI_ATMEL)
|
||||
void at91_add_device_spi(int spi_id, struct at91_spi_platform_data *pdata)
|
||||
{
|
||||
int i;
|
||||
int cs_pin;
|
||||
resource_size_t start = ~0;
|
||||
|
||||
BUG_ON(spi_id > 1);
|
||||
|
||||
for (i = 0; i < pdata->num_chipselect; i++) {
|
||||
cs_pin = pdata->chipselect[i];
|
||||
|
||||
/* enable chip-select pin */
|
||||
if (cs_pin > 0)
|
||||
at91_set_gpio_output(cs_pin, 1);
|
||||
}
|
||||
|
||||
/* Configure SPI bus(es) */
|
||||
switch (spi_id) {
|
||||
case 0:
|
||||
start = AT91SAM9261_BASE_SPI0;
|
||||
at91_set_A_periph(AT91_PIN_PA0, 0); /* SPI0_MISO */
|
||||
at91_set_A_periph(AT91_PIN_PA1, 0); /* SPI0_MOSI */
|
||||
at91_set_A_periph(AT91_PIN_PA2, 0); /* SPI0_SPCK */
|
||||
break;
|
||||
case 1:
|
||||
start = AT91SAM9213_BASE_SPI1;
|
||||
at91_set_A_periph(AT91_PIN_PB30, 0); /* SPI1_MISO */
|
||||
at91_set_A_periph(AT91_PIN_PB31, 0); /* SPI1_MOSI */
|
||||
at91_set_A_periph(AT91_PIN_PB29, 0); /* SPI1_SPCK */
|
||||
break;
|
||||
}
|
||||
|
||||
add_generic_device("atmel_spi", spi_id, NULL, start, SZ_16K,
|
||||
IORESOURCE_MEM, pdata);
|
||||
}
|
||||
#else
|
||||
void __init at91_add_device_spi(int spi_id, struct at91_spi_platform_data *pdata) {}
|
||||
#endif
|
||||
|
||||
static inline void configure_dbgu_pins(void)
|
||||
{
|
||||
at91_set_A_periph(AT91_PIN_PA9, 0); /* DRXD */
|
||||
|
|
|
@ -152,6 +152,50 @@ void at91_add_device_nand(struct atmel_nand_data *data)
|
|||
void at91_add_device_nand(struct atmel_nand_data *data) {}
|
||||
#endif
|
||||
|
||||
/* --------------------------------------------------------------------
|
||||
* SPI
|
||||
* -------------------------------------------------------------------- */
|
||||
|
||||
#if defined(CONFIG_DRIVER_SPI_ATMEL)
|
||||
void at91_add_device_spi(int spi_id, struct at91_spi_platform_data *pdata)
|
||||
{
|
||||
int i;
|
||||
int cs_pin;
|
||||
resource_size_t start = ~0;
|
||||
|
||||
BUG_ON(spi_id > 1);
|
||||
|
||||
for (i = 0; i < pdata->num_chipselect; i++) {
|
||||
cs_pin = pdata->chipselect[i];
|
||||
|
||||
/* enable chip-select pin */
|
||||
if (cs_pin > 0)
|
||||
at91_set_gpio_output(cs_pin, 1);
|
||||
}
|
||||
|
||||
/* Configure SPI bus(es) */
|
||||
switch (spi_id) {
|
||||
case 0:
|
||||
start = AT91SAM9263_BASE_SPI0;
|
||||
at91_set_B_periph(AT91_PIN_PA0, 0); /* SPI0_MISO */
|
||||
at91_set_B_periph(AT91_PIN_PA1, 0); /* SPI0_MOSI */
|
||||
at91_set_B_periph(AT91_PIN_PA2, 0); /* SPI0_SPCK */
|
||||
break;
|
||||
case 1:
|
||||
start = AT91SAM9263_BASE_SPI1;
|
||||
at91_set_A_periph(AT91_PIN_PB12, 0); /* SPI1_MISO */
|
||||
at91_set_A_periph(AT91_PIN_PB13, 0); /* SPI1_MOSI */
|
||||
at91_set_A_periph(AT91_PIN_PB14, 0); /* SPI1_SPCK */
|
||||
break;
|
||||
}
|
||||
|
||||
add_generic_device("atmel_spi", spi_id, NULL, start, SZ_16K,
|
||||
IORESOURCE_MEM, pdata);
|
||||
}
|
||||
#else
|
||||
void __init at91_add_device_spi(int spi_id, struct at91_spi_platform_data *pdata) {}
|
||||
#endif
|
||||
|
||||
static inline void configure_dbgu_pins(void)
|
||||
{
|
||||
at91_set_A_periph(AT91_PIN_PC30, 0); /* DRXD */
|
||||
|
@ -284,3 +328,4 @@ void at91_add_device_mci(short mmc_id, struct atmel_mci_platform_data *data)
|
|||
#else
|
||||
void at91_add_device_mci(short mmc_id, struct atmel_mci_platform_data *data) {}
|
||||
#endif
|
||||
|
||||
|
|
|
@ -299,7 +299,9 @@ void at91_add_device_spi(int spi_id, struct at91_spi_platform_data *pdata)
|
|||
{
|
||||
int i;
|
||||
int cs_pin;
|
||||
resource_size_t start;
|
||||
resource_size_t start = ~0;
|
||||
|
||||
BUG_ON(spi_id > 1);
|
||||
|
||||
for (i = 0; i < pdata->num_chipselect; i++) {
|
||||
cs_pin = pdata->chipselect[i];
|
||||
|
@ -310,27 +312,24 @@ void at91_add_device_spi(int spi_id, struct at91_spi_platform_data *pdata)
|
|||
}
|
||||
|
||||
/* Configure SPI bus(es) */
|
||||
if (spi_id == 0) {
|
||||
switch (spi_id) {
|
||||
case 0:
|
||||
start = AT91SAM9G45_BASE_SPI0;
|
||||
at91_set_A_periph(AT91_PIN_PB0, 0); /* SPI0_MISO */
|
||||
at91_set_A_periph(AT91_PIN_PB1, 0); /* SPI0_MOSI */
|
||||
at91_set_A_periph(AT91_PIN_PB2, 0); /* SPI0_SPCK */
|
||||
|
||||
add_generic_device("atmel_spi", spi_id, NULL, start, SZ_16K,
|
||||
IORESOURCE_MEM, pdata);
|
||||
}
|
||||
|
||||
else if (spi_id == 1) {
|
||||
break;
|
||||
case 1:
|
||||
start = AT91SAM9G45_BASE_SPI1;
|
||||
at91_set_A_periph(AT91_PIN_PB14, 0); /* SPI1_MISO */
|
||||
at91_set_A_periph(AT91_PIN_PB15, 0); /* SPI1_MOSI */
|
||||
at91_set_A_periph(AT91_PIN_PB16, 0); /* SPI1_SPCK */
|
||||
|
||||
add_generic_device("atmel_spi", spi_id, NULL, start, SZ_16K,
|
||||
IORESOURCE_MEM, pdata);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
add_generic_device("atmel_spi", spi_id, NULL, start, SZ_16K,
|
||||
IORESOURCE_MEM, pdata);
|
||||
}
|
||||
#else
|
||||
void at91_add_device_spi(int spi_id, struct at91_spi_platform_data *pdata) {}
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue