diff options
Diffstat (limited to 'arch/avr32/mach-at32ap/at32ap700x.c')
-rw-r--r-- | arch/avr32/mach-at32ap/at32ap700x.c | 35 |
1 files changed, 19 insertions, 16 deletions
diff --git a/arch/avr32/mach-at32ap/at32ap700x.c b/arch/avr32/mach-at32ap/at32ap700x.c index b40ff39e0ac8..1aa1ea5e9212 100644 --- a/arch/avr32/mach-at32ap/at32ap700x.c +++ b/arch/avr32/mach-at32ap/at32ap700x.c | |||
@@ -1183,19 +1183,32 @@ static struct resource atmel_spi1_resource[] = { | |||
1183 | DEFINE_DEV(atmel_spi, 1); | 1183 | DEFINE_DEV(atmel_spi, 1); |
1184 | DEV_CLK(spi_clk, atmel_spi1, pba, 1); | 1184 | DEV_CLK(spi_clk, atmel_spi1, pba, 1); |
1185 | 1185 | ||
1186 | static void __init | 1186 | void __init |
1187 | at32_spi_setup_slaves(unsigned int bus_num, struct spi_board_info *b, | 1187 | at32_spi_setup_slaves(unsigned int bus_num, struct spi_board_info *b, unsigned int n) |
1188 | unsigned int n, const u8 *pins) | ||
1189 | { | 1188 | { |
1189 | /* | ||
1190 | * Manage the chipselects as GPIOs, normally using the same pins | ||
1191 | * the SPI controller expects; but boards can use other pins. | ||
1192 | */ | ||
1193 | static u8 __initdata spi_pins[][4] = { | ||
1194 | { GPIO_PIN_PA(3), GPIO_PIN_PA(4), | ||
1195 | GPIO_PIN_PA(5), GPIO_PIN_PA(20) }, | ||
1196 | { GPIO_PIN_PB(2), GPIO_PIN_PB(3), | ||
1197 | GPIO_PIN_PB(4), GPIO_PIN_PA(27) }, | ||
1198 | }; | ||
1190 | unsigned int pin, mode; | 1199 | unsigned int pin, mode; |
1191 | 1200 | ||
1201 | /* There are only 2 SPI controllers */ | ||
1202 | if (bus_num > 1) | ||
1203 | return; | ||
1204 | |||
1192 | for (; n; n--, b++) { | 1205 | for (; n; n--, b++) { |
1193 | b->bus_num = bus_num; | 1206 | b->bus_num = bus_num; |
1194 | if (b->chip_select >= 4) | 1207 | if (b->chip_select >= 4) |
1195 | continue; | 1208 | continue; |
1196 | pin = (unsigned)b->controller_data; | 1209 | pin = (unsigned)b->controller_data; |
1197 | if (!pin) { | 1210 | if (!pin) { |
1198 | pin = pins[b->chip_select]; | 1211 | pin = spi_pins[bus_num][b->chip_select]; |
1199 | b->controller_data = (void *)pin; | 1212 | b->controller_data = (void *)pin; |
1200 | } | 1213 | } |
1201 | mode = AT32_GPIOF_OUTPUT; | 1214 | mode = AT32_GPIOF_OUTPUT; |
@@ -1208,16 +1221,6 @@ at32_spi_setup_slaves(unsigned int bus_num, struct spi_board_info *b, | |||
1208 | struct platform_device *__init | 1221 | struct platform_device *__init |
1209 | at32_add_device_spi(unsigned int id, struct spi_board_info *b, unsigned int n) | 1222 | at32_add_device_spi(unsigned int id, struct spi_board_info *b, unsigned int n) |
1210 | { | 1223 | { |
1211 | /* | ||
1212 | * Manage the chipselects as GPIOs, normally using the same pins | ||
1213 | * the SPI controller expects; but boards can use other pins. | ||
1214 | */ | ||
1215 | static u8 __initdata spi0_pins[] = | ||
1216 | { GPIO_PIN_PA(3), GPIO_PIN_PA(4), | ||
1217 | GPIO_PIN_PA(5), GPIO_PIN_PA(20), }; | ||
1218 | static u8 __initdata spi1_pins[] = | ||
1219 | { GPIO_PIN_PB(2), GPIO_PIN_PB(3), | ||
1220 | GPIO_PIN_PB(4), GPIO_PIN_PA(27), }; | ||
1221 | struct platform_device *pdev; | 1224 | struct platform_device *pdev; |
1222 | u32 pin_mask; | 1225 | u32 pin_mask; |
1223 | 1226 | ||
@@ -1230,7 +1233,7 @@ at32_add_device_spi(unsigned int id, struct spi_board_info *b, unsigned int n) | |||
1230 | select_peripheral(PIOA, (1 << 0), PERIPH_A, AT32_GPIOF_PULLUP); | 1233 | select_peripheral(PIOA, (1 << 0), PERIPH_A, AT32_GPIOF_PULLUP); |
1231 | select_peripheral(PIOA, pin_mask, PERIPH_A, 0); | 1234 | select_peripheral(PIOA, pin_mask, PERIPH_A, 0); |
1232 | 1235 | ||
1233 | at32_spi_setup_slaves(0, b, n, spi0_pins); | 1236 | at32_spi_setup_slaves(0, b, n); |
1234 | break; | 1237 | break; |
1235 | 1238 | ||
1236 | case 1: | 1239 | case 1: |
@@ -1241,7 +1244,7 @@ at32_add_device_spi(unsigned int id, struct spi_board_info *b, unsigned int n) | |||
1241 | select_peripheral(PIOB, (1 << 0), PERIPH_B, AT32_GPIOF_PULLUP); | 1244 | select_peripheral(PIOB, (1 << 0), PERIPH_B, AT32_GPIOF_PULLUP); |
1242 | select_peripheral(PIOB, pin_mask, PERIPH_B, 0); | 1245 | select_peripheral(PIOB, pin_mask, PERIPH_B, 0); |
1243 | 1246 | ||
1244 | at32_spi_setup_slaves(1, b, n, spi1_pins); | 1247 | at32_spi_setup_slaves(1, b, n); |
1245 | break; | 1248 | break; |
1246 | 1249 | ||
1247 | default: | 1250 | default: |