diff options
author | Sonic Zhang <sonic.zhang@analog.com> | 2007-12-05 02:45:16 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2007-12-05 12:21:19 -0500 |
commit | 12e17c4267a5b2a5ba77bd53a62388be641534b8 (patch) | |
tree | 4c45477c323808523b071b25f4e8446ccec13f41 /drivers/spi | |
parent | 7c4ef09449ca382da2e39b93ca9d03e3dbd5c17c (diff) |
spi: spi_bfin, rearrange portmux calls
Move pin muxing to setup and cleanup methods.
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')
-rw-r--r-- | drivers/spi/spi_bfin5xx.c | 53 |
1 files changed, 28 insertions, 25 deletions
diff --git a/drivers/spi/spi_bfin5xx.c b/drivers/spi/spi_bfin5xx.c index 045d3ecf459..4496ed158e6 100644 --- a/drivers/spi/spi_bfin5xx.c +++ b/drivers/spi/spi_bfin5xx.c | |||
@@ -136,7 +136,6 @@ struct chip_data { | |||
136 | u16 flag; | 136 | u16 flag; |
137 | 137 | ||
138 | u8 chip_select_num; | 138 | u8 chip_select_num; |
139 | u8 chip_select_requested; | ||
140 | u8 n_bytes; | 139 | u8 n_bytes; |
141 | u8 width; /* 0 or 1 */ | 140 | u8 width; /* 0 or 1 */ |
142 | u8 enable_dma; | 141 | u8 enable_dma; |
@@ -216,19 +215,7 @@ static int restore_state(struct driver_data *drv_data) | |||
216 | { | 215 | { |
217 | struct chip_data *chip = drv_data->cur_chip; | 216 | struct chip_data *chip = drv_data->cur_chip; |
218 | int ret = 0; | 217 | int ret = 0; |
219 | u16 ssel[3][MAX_SPI_SSEL] = { | 218 | |
220 | {P_SPI0_SSEL1, P_SPI0_SSEL2, P_SPI0_SSEL3, | ||
221 | P_SPI0_SSEL4, P_SPI0_SSEL5, | ||
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 | }; | ||
232 | /* Clear status and disable clock */ | 219 | /* Clear status and disable clock */ |
233 | write_STAT(BIT_STAT_CLR); | 220 | write_STAT(BIT_STAT_CLR); |
234 | bfin_spi_disable(drv_data); | 221 | bfin_spi_disable(drv_data); |
@@ -239,17 +226,6 @@ static int restore_state(struct driver_data *drv_data) | |||
239 | write_BAUD(chip->baud); | 226 | write_BAUD(chip->baud); |
240 | cs_active(chip); | 227 | cs_active(chip); |
241 | 228 | ||
242 | if (!chip->chip_select_requested) { | ||
243 | int i = chip->chip_select_num; | ||
244 | |||
245 | dev_dbg(&drv_data->pdev->dev, "chip select number is %d\n", i); | ||
246 | if ((i > 0) && (i <= MAX_SPI_SSEL)) | ||
247 | ret = peripheral_request( | ||
248 | ssel[drv_data->master->bus_num][i-1], DRV_NAME); | ||
249 | |||
250 | chip->chip_select_requested = 1; | ||
251 | } | ||
252 | |||
253 | if (ret) | 229 | if (ret) |
254 | dev_dbg(&drv_data->pdev->dev, | 230 | dev_dbg(&drv_data->pdev->dev, |
255 | ": request chip select number %d failed\n", | 231 | ": request chip select number %d failed\n", |
@@ -983,6 +959,22 @@ static int transfer(struct spi_device *spi, struct spi_message *msg) | |||
983 | return 0; | 959 | return 0; |
984 | } | 960 | } |
985 | 961 | ||
962 | #define MAX_SPI_SSEL 7 | ||
963 | |||
964 | static u16 ssel[3][MAX_SPI_SSEL] = { | ||
965 | {P_SPI0_SSEL1, P_SPI0_SSEL2, P_SPI0_SSEL3, | ||
966 | P_SPI0_SSEL4, P_SPI0_SSEL5, | ||
967 | P_SPI0_SSEL6, P_SPI0_SSEL7}, | ||
968 | |||
969 | {P_SPI1_SSEL1, P_SPI1_SSEL2, P_SPI1_SSEL3, | ||
970 | P_SPI1_SSEL4, P_SPI1_SSEL5, | ||
971 | P_SPI1_SSEL6, P_SPI1_SSEL7}, | ||
972 | |||
973 | {P_SPI2_SSEL1, P_SPI2_SSEL2, P_SPI2_SSEL3, | ||
974 | P_SPI2_SSEL4, P_SPI2_SSEL5, | ||
975 | P_SPI2_SSEL6, P_SPI2_SSEL7}, | ||
976 | }; | ||
977 | |||
986 | /* first setup for new devices */ | 978 | /* first setup for new devices */ |
987 | static int setup(struct spi_device *spi) | 979 | static int setup(struct spi_device *spi) |
988 | { | 980 | { |
@@ -1113,6 +1105,12 @@ static int setup(struct spi_device *spi) | |||
1113 | 1105 | ||
1114 | spi_set_ctldata(spi, chip); | 1106 | spi_set_ctldata(spi, chip); |
1115 | 1107 | ||
1108 | dev_dbg(&spi->dev, "chip select number is %d\n", chip->chip_select_num); | ||
1109 | if ((chip->chip_select_num > 0) | ||
1110 | && (chip->chip_select_num <= spi->master->num_chipselect)) | ||
1111 | peripheral_request(ssel[spi->master->bus_num] | ||
1112 | [chip->chip_select_num-1], DRV_NAME); | ||
1113 | |||
1116 | return 0; | 1114 | return 0; |
1117 | } | 1115 | } |
1118 | 1116 | ||
@@ -1124,6 +1122,11 @@ static void cleanup(struct spi_device *spi) | |||
1124 | { | 1122 | { |
1125 | struct chip_data *chip = spi_get_ctldata(spi); | 1123 | struct chip_data *chip = spi_get_ctldata(spi); |
1126 | 1124 | ||
1125 | if ((chip->chip_select_num > 0) | ||
1126 | && (chip->chip_select_num <= spi->master->num_chipselect)) | ||
1127 | peripheral_free(ssel[spi->master->bus_num] | ||
1128 | [chip->chip_select_num-1]); | ||
1129 | |||
1127 | kfree(chip); | 1130 | kfree(chip); |
1128 | } | 1131 | } |
1129 | 1132 | ||