aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/spi/spi_bfin5xx.c
diff options
context:
space:
mode:
authorSonic Zhang <sonic.zhang@analog.com>2007-12-05 02:45:16 -0500
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2007-12-05 12:21:19 -0500
commit7c4ef09449ca382da2e39b93ca9d03e3dbd5c17c (patch)
treea5f902ec6b20486cfd32f9d9331a5d798b0c0e48 /drivers/spi/spi_bfin5xx.c
parenta32c691d7cf5c37af753255ef4843b18a31935b9 (diff)
spi: spi_bfin uses portmux for additional busses
Use portmux mechanism to support SPI busses 1 and 2, instead of just the original bus 0. Signed-off-by: Sonic Zhang <sonic.zhang@analog.com> Signed-off-by: Bryan Wu <bryan.wu@analog.com> Signed-off-by: David Brownell <dbrownell@users.sourceforge.net> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/spi/spi_bfin5xx.c')
-rw-r--r--drivers/spi/spi_bfin5xx.c51
1 files changed, 31 insertions, 20 deletions
diff --git a/drivers/spi/spi_bfin5xx.c b/drivers/spi/spi_bfin5xx.c
index a8311a83ae96..045d3ecf459d 100644
--- a/drivers/spi/spi_bfin5xx.c
+++ b/drivers/spi/spi_bfin5xx.c
@@ -209,17 +209,26 @@ static void cs_deactive(struct chip_data *chip)
209 write_FLAG(flag); 209 write_FLAG(flag);
210} 210}
211 211
212#define MAX_SPI0_SSEL 7 212#define MAX_SPI_SSEL 7
213 213
214/* stop controller and re-config current chip*/ 214/* stop controller and re-config current chip*/
215static int restore_state(struct driver_data *drv_data) 215static int restore_state(struct driver_data *drv_data)
216{ 216{
217 struct chip_data *chip = drv_data->cur_chip; 217 struct chip_data *chip = drv_data->cur_chip;
218 int ret = 0; 218 int ret = 0;
219 u16 ssel[MAX_SPI0_SSEL] = {P_SPI0_SSEL1, P_SPI0_SSEL2, P_SPI0_SSEL3, 219 u16 ssel[3][MAX_SPI_SSEL] = {
220 P_SPI0_SSEL4, P_SPI0_SSEL5, 220 {P_SPI0_SSEL1, P_SPI0_SSEL2, P_SPI0_SSEL3,
221 P_SPI0_SSEL6, P_SPI0_SSEL7,}; 221 P_SPI0_SSEL4, P_SPI0_SSEL5,
222 222 P_SPI0_SSEL6, P_SPI0_SSEL7},
223
224 {P_SPI1_SSEL1, P_SPI1_SSEL2, P_SPI1_SSEL3,
225 P_SPI1_SSEL4, P_SPI1_SSEL5,
226 P_SPI1_SSEL6, P_SPI1_SSEL7},
227
228 {P_SPI2_SSEL1, P_SPI2_SSEL2, P_SPI2_SSEL3,
229 P_SPI2_SSEL4, P_SPI2_SSEL5,
230 P_SPI2_SSEL6, P_SPI2_SSEL7},
231 };
223 /* Clear status and disable clock */ 232 /* Clear status and disable clock */
224 write_STAT(BIT_STAT_CLR); 233 write_STAT(BIT_STAT_CLR);
225 bfin_spi_disable(drv_data); 234 bfin_spi_disable(drv_data);
@@ -234,9 +243,9 @@ static int restore_state(struct driver_data *drv_data)
234 int i = chip->chip_select_num; 243 int i = chip->chip_select_num;
235 244
236 dev_dbg(&drv_data->pdev->dev, "chip select number is %d\n", i); 245 dev_dbg(&drv_data->pdev->dev, "chip select number is %d\n", i);
237 246 if ((i > 0) && (i <= MAX_SPI_SSEL))
238 if ((i > 0) && (i <= MAX_SPI0_SSEL)) 247 ret = peripheral_request(
239 ret = peripheral_request(ssel[i-1], DRV_NAME); 248 ssel[drv_data->master->bus_num][i-1], DRV_NAME);
240 249
241 chip->chip_select_requested = 1; 250 chip->chip_select_requested = 1;
242 } 251 }
@@ -329,7 +338,6 @@ static void u8_reader(struct driver_data *drv_data)
329 write_TDBR(0xFFFF); 338 write_TDBR(0xFFFF);
330 339
331 dummy_read(); 340 dummy_read();
332
333 while (drv_data->rx < drv_data->rx_end - 1) { 341 while (drv_data->rx < drv_data->rx_end - 1) {
334 while (!(read_STAT() & BIT_STAT_RXS)) 342 while (!(read_STAT() & BIT_STAT_RXS))
335 continue; 343 continue;
@@ -640,7 +648,6 @@ static void pump_transfers(unsigned long data)
640 message = drv_data->cur_msg; 648 message = drv_data->cur_msg;
641 transfer = drv_data->cur_transfer; 649 transfer = drv_data->cur_transfer;
642 chip = drv_data->cur_chip; 650 chip = drv_data->cur_chip;
643
644 /* 651 /*
645 * if msg is error or done, report it back using complete() callback 652 * if msg is error or done, report it back using complete() callback
646 */ 653 */
@@ -1206,16 +1213,20 @@ static inline int destroy_queue(struct driver_data *drv_data)
1206 return 0; 1213 return 0;
1207} 1214}
1208 1215
1209static int setup_pin_mux(int action) 1216static int setup_pin_mux(int action, int bus_num)
1210{ 1217{
1211 1218
1212 u16 pin_req[] = {P_SPI0_SCK, P_SPI0_MISO, P_SPI0_MOSI, 0}; 1219 u16 pin_req[3][4] = {
1220 {P_SPI0_SCK, P_SPI0_MISO, P_SPI0_MOSI, 0},
1221 {P_SPI1_SCK, P_SPI1_MISO, P_SPI1_MOSI, 0},
1222 {P_SPI2_SCK, P_SPI2_MISO, P_SPI2_MOSI, 0},
1223 };
1213 1224
1214 if (action) { 1225 if (action) {
1215 if (peripheral_request_list(pin_req, DRV_NAME)) 1226 if (peripheral_request_list(pin_req[bus_num], DRV_NAME))
1216 return -EFAULT; 1227 return -EFAULT;
1217 } else { 1228 } else {
1218 peripheral_free_list(pin_req); 1229 peripheral_free_list(pin_req[bus_num]);
1219 } 1230 }
1220 1231
1221 return 0; 1232 return 0;
@@ -1239,11 +1250,6 @@ static int __init bfin5xx_spi_probe(struct platform_device *pdev)
1239 return -ENOMEM; 1250 return -ENOMEM;
1240 } 1251 }
1241 1252
1242 if (setup_pin_mux(1)) {
1243 dev_err(&pdev->dev, ": Requesting Peripherals failed\n");
1244 goto out_error;
1245 }
1246
1247 drv_data = spi_master_get_devdata(master); 1253 drv_data = spi_master_get_devdata(master);
1248 drv_data->master = master; 1254 drv_data->master = master;
1249 drv_data->master_info = platform_info; 1255 drv_data->master_info = platform_info;
@@ -1298,6 +1304,11 @@ static int __init bfin5xx_spi_probe(struct platform_device *pdev)
1298 goto out_error_queue_alloc; 1304 goto out_error_queue_alloc;
1299 } 1305 }
1300 1306
1307 if (setup_pin_mux(1, master->bus_num)) {
1308 dev_err(&pdev->dev, ": Requesting Peripherals failed\n");
1309 goto out_error;
1310 }
1311
1301 dev_info(dev, "%s, Version %s, regs_base @ 0x%08x\n", 1312 dev_info(dev, "%s, Version %s, regs_base @ 0x%08x\n",
1302 DRV_DESC, DRV_VERSION, spi_regs_base); 1313 DRV_DESC, DRV_VERSION, spi_regs_base);
1303 return status; 1314 return status;
@@ -1340,7 +1351,7 @@ static int __devexit bfin5xx_spi_remove(struct platform_device *pdev)
1340 /* Disconnect from the SPI framework */ 1351 /* Disconnect from the SPI framework */
1341 spi_unregister_master(drv_data->master); 1352 spi_unregister_master(drv_data->master);
1342 1353
1343 setup_pin_mux(0); 1354 setup_pin_mux(0, drv_data->master->bus_num);
1344 1355
1345 /* Prevent double remove */ 1356 /* Prevent double remove */
1346 platform_set_drvdata(pdev, NULL); 1357 platform_set_drvdata(pdev, NULL);