Commit 7c4ef094 authored by Sonic Zhang's avatar Sonic Zhang Committed by Linus Torvalds

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: default avatarSonic Zhang <sonic.zhang@analog.com>
Signed-off-by: default avatarBryan Wu <bryan.wu@analog.com>
Signed-off-by: default avatarDavid Brownell <dbrownell@users.sourceforge.net>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent a32c691d
...@@ -209,17 +209,26 @@ static void cs_deactive(struct chip_data *chip) ...@@ -209,17 +209,26 @@ static void cs_deactive(struct chip_data *chip)
write_FLAG(flag); write_FLAG(flag);
} }
#define MAX_SPI0_SSEL 7 #define MAX_SPI_SSEL 7
/* stop controller and re-config current chip*/ /* stop controller and re-config current chip*/
static int restore_state(struct driver_data *drv_data) static int restore_state(struct driver_data *drv_data)
{ {
struct chip_data *chip = drv_data->cur_chip; struct chip_data *chip = drv_data->cur_chip;
int ret = 0; int ret = 0;
u16 ssel[MAX_SPI0_SSEL] = {P_SPI0_SSEL1, P_SPI0_SSEL2, P_SPI0_SSEL3, u16 ssel[3][MAX_SPI_SSEL] = {
P_SPI0_SSEL4, P_SPI0_SSEL5, {P_SPI0_SSEL1, P_SPI0_SSEL2, P_SPI0_SSEL3,
P_SPI0_SSEL6, P_SPI0_SSEL7,}; P_SPI0_SSEL4, P_SPI0_SSEL5,
P_SPI0_SSEL6, P_SPI0_SSEL7},
{P_SPI1_SSEL1, P_SPI1_SSEL2, P_SPI1_SSEL3,
P_SPI1_SSEL4, P_SPI1_SSEL5,
P_SPI1_SSEL6, P_SPI1_SSEL7},
{P_SPI2_SSEL1, P_SPI2_SSEL2, P_SPI2_SSEL3,
P_SPI2_SSEL4, P_SPI2_SSEL5,
P_SPI2_SSEL6, P_SPI2_SSEL7},
};
/* Clear status and disable clock */ /* Clear status and disable clock */
write_STAT(BIT_STAT_CLR); write_STAT(BIT_STAT_CLR);
bfin_spi_disable(drv_data); bfin_spi_disable(drv_data);
...@@ -234,9 +243,9 @@ static int restore_state(struct driver_data *drv_data) ...@@ -234,9 +243,9 @@ static int restore_state(struct driver_data *drv_data)
int i = chip->chip_select_num; int i = chip->chip_select_num;
dev_dbg(&drv_data->pdev->dev, "chip select number is %d\n", i); dev_dbg(&drv_data->pdev->dev, "chip select number is %d\n", i);
if ((i > 0) && (i <= MAX_SPI_SSEL))
if ((i > 0) && (i <= MAX_SPI0_SSEL)) ret = peripheral_request(
ret = peripheral_request(ssel[i-1], DRV_NAME); ssel[drv_data->master->bus_num][i-1], DRV_NAME);
chip->chip_select_requested = 1; chip->chip_select_requested = 1;
} }
...@@ -329,7 +338,6 @@ static void u8_reader(struct driver_data *drv_data) ...@@ -329,7 +338,6 @@ static void u8_reader(struct driver_data *drv_data)
write_TDBR(0xFFFF); write_TDBR(0xFFFF);
dummy_read(); dummy_read();
while (drv_data->rx < drv_data->rx_end - 1) { while (drv_data->rx < drv_data->rx_end - 1) {
while (!(read_STAT() & BIT_STAT_RXS)) while (!(read_STAT() & BIT_STAT_RXS))
continue; continue;
...@@ -640,7 +648,6 @@ static void pump_transfers(unsigned long data) ...@@ -640,7 +648,6 @@ static void pump_transfers(unsigned long data)
message = drv_data->cur_msg; message = drv_data->cur_msg;
transfer = drv_data->cur_transfer; transfer = drv_data->cur_transfer;
chip = drv_data->cur_chip; chip = drv_data->cur_chip;
/* /*
* if msg is error or done, report it back using complete() callback * if msg is error or done, report it back using complete() callback
*/ */
...@@ -1206,16 +1213,20 @@ static inline int destroy_queue(struct driver_data *drv_data) ...@@ -1206,16 +1213,20 @@ static inline int destroy_queue(struct driver_data *drv_data)
return 0; return 0;
} }
static int setup_pin_mux(int action) static int setup_pin_mux(int action, int bus_num)
{ {
u16 pin_req[] = {P_SPI0_SCK, P_SPI0_MISO, P_SPI0_MOSI, 0}; u16 pin_req[3][4] = {
{P_SPI0_SCK, P_SPI0_MISO, P_SPI0_MOSI, 0},
{P_SPI1_SCK, P_SPI1_MISO, P_SPI1_MOSI, 0},
{P_SPI2_SCK, P_SPI2_MISO, P_SPI2_MOSI, 0},
};
if (action) { if (action) {
if (peripheral_request_list(pin_req, DRV_NAME)) if (peripheral_request_list(pin_req[bus_num], DRV_NAME))
return -EFAULT; return -EFAULT;
} else { } else {
peripheral_free_list(pin_req); peripheral_free_list(pin_req[bus_num]);
} }
return 0; return 0;
...@@ -1239,11 +1250,6 @@ static int __init bfin5xx_spi_probe(struct platform_device *pdev) ...@@ -1239,11 +1250,6 @@ static int __init bfin5xx_spi_probe(struct platform_device *pdev)
return -ENOMEM; return -ENOMEM;
} }
if (setup_pin_mux(1)) {
dev_err(&pdev->dev, ": Requesting Peripherals failed\n");
goto out_error;
}
drv_data = spi_master_get_devdata(master); drv_data = spi_master_get_devdata(master);
drv_data->master = master; drv_data->master = master;
drv_data->master_info = platform_info; drv_data->master_info = platform_info;
...@@ -1298,6 +1304,11 @@ static int __init bfin5xx_spi_probe(struct platform_device *pdev) ...@@ -1298,6 +1304,11 @@ static int __init bfin5xx_spi_probe(struct platform_device *pdev)
goto out_error_queue_alloc; goto out_error_queue_alloc;
} }
if (setup_pin_mux(1, master->bus_num)) {
dev_err(&pdev->dev, ": Requesting Peripherals failed\n");
goto out_error;
}
dev_info(dev, "%s, Version %s, regs_base @ 0x%08x\n", dev_info(dev, "%s, Version %s, regs_base @ 0x%08x\n",
DRV_DESC, DRV_VERSION, spi_regs_base); DRV_DESC, DRV_VERSION, spi_regs_base);
return status; return status;
...@@ -1340,7 +1351,7 @@ static int __devexit bfin5xx_spi_remove(struct platform_device *pdev) ...@@ -1340,7 +1351,7 @@ static int __devexit bfin5xx_spi_remove(struct platform_device *pdev)
/* Disconnect from the SPI framework */ /* Disconnect from the SPI framework */
spi_unregister_master(drv_data->master); spi_unregister_master(drv_data->master);
setup_pin_mux(0); setup_pin_mux(0, drv_data->master->bus_num);
/* Prevent double remove */ /* Prevent double remove */
platform_set_drvdata(pdev, NULL); platform_set_drvdata(pdev, NULL);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment