diff options
Diffstat (limited to 'arch/avr32/mach-at32ap')
-rw-r--r-- | arch/avr32/mach-at32ap/at32ap700x.c | 53 | ||||
-rw-r--r-- | arch/avr32/mach-at32ap/include/mach/atmel-mci.h | 24 | ||||
-rw-r--r-- | arch/avr32/mach-at32ap/include/mach/board.h | 1 |
3 files changed, 57 insertions, 21 deletions
diff --git a/arch/avr32/mach-at32ap/at32ap700x.c b/arch/avr32/mach-at32ap/at32ap700x.c index eb9d4dc2e86d..1aa1ea5e9212 100644 --- a/arch/avr32/mach-at32ap/at32ap700x.c +++ b/arch/avr32/mach-at32ap/at32ap700x.c | |||
@@ -15,6 +15,8 @@ | |||
15 | #include <linux/gpio.h> | 15 | #include <linux/gpio.h> |
16 | #include <linux/spi/spi.h> | 16 | #include <linux/spi/spi.h> |
17 | #include <linux/usb/atmel_usba_udc.h> | 17 | #include <linux/usb/atmel_usba_udc.h> |
18 | |||
19 | #include <mach/atmel-mci.h> | ||
18 | #include <linux/atmel-mci.h> | 20 | #include <linux/atmel-mci.h> |
19 | 21 | ||
20 | #include <asm/io.h> | 22 | #include <asm/io.h> |
@@ -1181,19 +1183,32 @@ static struct resource atmel_spi1_resource[] = { | |||
1181 | DEFINE_DEV(atmel_spi, 1); | 1183 | DEFINE_DEV(atmel_spi, 1); |
1182 | DEV_CLK(spi_clk, atmel_spi1, pba, 1); | 1184 | DEV_CLK(spi_clk, atmel_spi1, pba, 1); |
1183 | 1185 | ||
1184 | static void __init | 1186 | void __init |
1185 | 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) |
1186 | unsigned int n, const u8 *pins) | ||
1187 | { | 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 | }; | ||
1188 | unsigned int pin, mode; | 1199 | unsigned int pin, mode; |
1189 | 1200 | ||
1201 | /* There are only 2 SPI controllers */ | ||
1202 | if (bus_num > 1) | ||
1203 | return; | ||
1204 | |||
1190 | for (; n; n--, b++) { | 1205 | for (; n; n--, b++) { |
1191 | b->bus_num = bus_num; | 1206 | b->bus_num = bus_num; |
1192 | if (b->chip_select >= 4) | 1207 | if (b->chip_select >= 4) |
1193 | continue; | 1208 | continue; |
1194 | pin = (unsigned)b->controller_data; | 1209 | pin = (unsigned)b->controller_data; |
1195 | if (!pin) { | 1210 | if (!pin) { |
1196 | pin = pins[b->chip_select]; | 1211 | pin = spi_pins[bus_num][b->chip_select]; |
1197 | b->controller_data = (void *)pin; | 1212 | b->controller_data = (void *)pin; |
1198 | } | 1213 | } |
1199 | mode = AT32_GPIOF_OUTPUT; | 1214 | mode = AT32_GPIOF_OUTPUT; |
@@ -1206,16 +1221,6 @@ at32_spi_setup_slaves(unsigned int bus_num, struct spi_board_info *b, | |||
1206 | struct platform_device *__init | 1221 | struct platform_device *__init |
1207 | 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) |
1208 | { | 1223 | { |
1209 | /* | ||
1210 | * Manage the chipselects as GPIOs, normally using the same pins | ||
1211 | * the SPI controller expects; but boards can use other pins. | ||
1212 | */ | ||
1213 | static u8 __initdata spi0_pins[] = | ||
1214 | { GPIO_PIN_PA(3), GPIO_PIN_PA(4), | ||
1215 | GPIO_PIN_PA(5), GPIO_PIN_PA(20), }; | ||
1216 | static u8 __initdata spi1_pins[] = | ||
1217 | { GPIO_PIN_PB(2), GPIO_PIN_PB(3), | ||
1218 | GPIO_PIN_PB(4), GPIO_PIN_PA(27), }; | ||
1219 | struct platform_device *pdev; | 1224 | struct platform_device *pdev; |
1220 | u32 pin_mask; | 1225 | u32 pin_mask; |
1221 | 1226 | ||
@@ -1228,7 +1233,7 @@ at32_add_device_spi(unsigned int id, struct spi_board_info *b, unsigned int n) | |||
1228 | select_peripheral(PIOA, (1 << 0), PERIPH_A, AT32_GPIOF_PULLUP); | 1233 | select_peripheral(PIOA, (1 << 0), PERIPH_A, AT32_GPIOF_PULLUP); |
1229 | select_peripheral(PIOA, pin_mask, PERIPH_A, 0); | 1234 | select_peripheral(PIOA, pin_mask, PERIPH_A, 0); |
1230 | 1235 | ||
1231 | at32_spi_setup_slaves(0, b, n, spi0_pins); | 1236 | at32_spi_setup_slaves(0, b, n); |
1232 | break; | 1237 | break; |
1233 | 1238 | ||
1234 | case 1: | 1239 | case 1: |
@@ -1239,7 +1244,7 @@ at32_add_device_spi(unsigned int id, struct spi_board_info *b, unsigned int n) | |||
1239 | select_peripheral(PIOB, (1 << 0), PERIPH_B, AT32_GPIOF_PULLUP); | 1244 | select_peripheral(PIOB, (1 << 0), PERIPH_B, AT32_GPIOF_PULLUP); |
1240 | select_peripheral(PIOB, pin_mask, PERIPH_B, 0); | 1245 | select_peripheral(PIOB, pin_mask, PERIPH_B, 0); |
1241 | 1246 | ||
1242 | at32_spi_setup_slaves(1, b, n, spi1_pins); | 1247 | at32_spi_setup_slaves(1, b, n); |
1243 | break; | 1248 | break; |
1244 | 1249 | ||
1245 | default: | 1250 | default: |
@@ -1320,7 +1325,7 @@ struct platform_device *__init | |||
1320 | at32_add_device_mci(unsigned int id, struct mci_platform_data *data) | 1325 | at32_add_device_mci(unsigned int id, struct mci_platform_data *data) |
1321 | { | 1326 | { |
1322 | struct platform_device *pdev; | 1327 | struct platform_device *pdev; |
1323 | struct dw_dma_slave *dws = &data->dma_slave; | 1328 | struct mci_dma_slave *slave; |
1324 | u32 pioa_mask; | 1329 | u32 pioa_mask; |
1325 | u32 piob_mask; | 1330 | u32 piob_mask; |
1326 | 1331 | ||
@@ -1339,13 +1344,17 @@ at32_add_device_mci(unsigned int id, struct mci_platform_data *data) | |||
1339 | ARRAY_SIZE(atmel_mci0_resource))) | 1344 | ARRAY_SIZE(atmel_mci0_resource))) |
1340 | goto fail; | 1345 | goto fail; |
1341 | 1346 | ||
1342 | dws->dma_dev = &dw_dmac0_device.dev; | 1347 | slave = kzalloc(sizeof(struct mci_dma_slave), GFP_KERNEL); |
1343 | dws->reg_width = DW_DMA_SLAVE_WIDTH_32BIT; | 1348 | |
1344 | dws->cfg_hi = (DWC_CFGH_SRC_PER(0) | 1349 | slave->sdata.dma_dev = &dw_dmac0_device.dev; |
1350 | slave->sdata.reg_width = DW_DMA_SLAVE_WIDTH_32BIT; | ||
1351 | slave->sdata.cfg_hi = (DWC_CFGH_SRC_PER(0) | ||
1345 | | DWC_CFGH_DST_PER(1)); | 1352 | | DWC_CFGH_DST_PER(1)); |
1346 | dws->cfg_lo &= ~(DWC_CFGL_HS_DST_POL | 1353 | slave->sdata.cfg_lo &= ~(DWC_CFGL_HS_DST_POL |
1347 | | DWC_CFGL_HS_SRC_POL); | 1354 | | DWC_CFGL_HS_SRC_POL); |
1348 | 1355 | ||
1356 | data->dma_slave = slave; | ||
1357 | |||
1349 | if (platform_device_add_data(pdev, data, | 1358 | if (platform_device_add_data(pdev, data, |
1350 | sizeof(struct mci_platform_data))) | 1359 | sizeof(struct mci_platform_data))) |
1351 | goto fail; | 1360 | goto fail; |
@@ -1411,6 +1420,8 @@ at32_add_device_mci(unsigned int id, struct mci_platform_data *data) | |||
1411 | return pdev; | 1420 | return pdev; |
1412 | 1421 | ||
1413 | fail: | 1422 | fail: |
1423 | data->dma_slave = NULL; | ||
1424 | kfree(slave); | ||
1414 | platform_device_put(pdev); | 1425 | platform_device_put(pdev); |
1415 | return NULL; | 1426 | return NULL; |
1416 | } | 1427 | } |
diff --git a/arch/avr32/mach-at32ap/include/mach/atmel-mci.h b/arch/avr32/mach-at32ap/include/mach/atmel-mci.h new file mode 100644 index 000000000000..a9b38967f703 --- /dev/null +++ b/arch/avr32/mach-at32ap/include/mach/atmel-mci.h | |||
@@ -0,0 +1,24 @@ | |||
1 | #ifndef __MACH_ATMEL_MCI_H | ||
2 | #define __MACH_ATMEL_MCI_H | ||
3 | |||
4 | #include <linux/dw_dmac.h> | ||
5 | |||
6 | /** | ||
7 | * struct mci_dma_data - DMA data for MCI interface | ||
8 | */ | ||
9 | struct mci_dma_data { | ||
10 | struct dw_dma_slave sdata; | ||
11 | }; | ||
12 | |||
13 | /* accessor macros */ | ||
14 | #define slave_data_ptr(s) (&(s)->sdata) | ||
15 | #define find_slave_dev(s) ((s)->sdata.dma_dev) | ||
16 | |||
17 | #define setup_dma_addr(s, t, r) do { \ | ||
18 | if (s) { \ | ||
19 | (s)->sdata.tx_reg = (t); \ | ||
20 | (s)->sdata.rx_reg = (r); \ | ||
21 | } \ | ||
22 | } while (0) | ||
23 | |||
24 | #endif /* __MACH_ATMEL_MCI_H */ | ||
diff --git a/arch/avr32/mach-at32ap/include/mach/board.h b/arch/avr32/mach-at32ap/include/mach/board.h index ddedb471f33e..c7f25bb1d068 100644 --- a/arch/avr32/mach-at32ap/include/mach/board.h +++ b/arch/avr32/mach-at32ap/include/mach/board.h | |||
@@ -49,6 +49,7 @@ at32_add_device_eth(unsigned int id, struct eth_platform_data *data); | |||
49 | struct spi_board_info; | 49 | struct spi_board_info; |
50 | struct platform_device * | 50 | struct platform_device * |
51 | at32_add_device_spi(unsigned int id, struct spi_board_info *b, unsigned int n); | 51 | at32_add_device_spi(unsigned int id, struct spi_board_info *b, unsigned int n); |
52 | void at32_spi_setup_slaves(unsigned int bus_num, struct spi_board_info *b, unsigned int n); | ||
52 | 53 | ||
53 | struct atmel_lcdfb_info; | 54 | struct atmel_lcdfb_info; |
54 | struct platform_device * | 55 | struct platform_device * |