Modified: trunk/arch/blackfin/include/asm/bfin5xx_spi.h (7831 => 7832)
--- trunk/arch/blackfin/include/asm/bfin5xx_spi.h 2009-11-17 06:24:51 UTC (rev 7831)
+++ trunk/arch/blackfin/include/asm/bfin5xx_spi.h 2009-11-17 09:45:59 UTC (rev 7832)
@@ -109,6 +109,7 @@
#define CMD_SPI_GET_SYSTEMCLOCK 25
#define CMD_SPI_SET_WRITECONTINUOUS 26
+#define USE_GPIO_CS 0x8000
/* device.platform_data for SSP controller devices */
struct bfin5xx_spi_master {
u16 num_chipselect;
Modified: trunk/arch/blackfin/mach-bf537/boards/stamp.c (7831 => 7832)
--- trunk/arch/blackfin/mach-bf537/boards/stamp.c 2009-11-17 06:24:51 UTC (rev 7831)
+++ trunk/arch/blackfin/mach-bf537/boards/stamp.c 2009-11-17 09:45:59 UTC (rev 7832)
@@ -987,7 +987,7 @@
.max_speed_hz = 20000000, /* max spi clock (SCK) speed in HZ */
.irq = IRQ_PF6,
.bus_num = 0,
- .chip_select = 0, /* GPIO controlled SSEL */
+ .chip_select = GPIO_PF10 | USE_GPIO_CS, /* GPIO controlled SSEL */
.controller_data = &enc28j60_spi_chip_info,
.mode = SPI_MODE_0,
},
@@ -1009,7 +1009,7 @@
.modalias = "adf702x",
.max_speed_hz = 16000000, /* max spi clock (SCK) speed in HZ */
.bus_num = 0,
- .chip_select = 0, /* GPIO controlled SSEL */
+ .chip_select = GPIO_PF10 | USE_GPIO_CS, /* GPIO controlled SSEL */
.controller_data = &adf7021_spi_chip_info,
.platform_data = &adf7021_platform_data,
.mode = SPI_MODE_0,
Modified: trunk/drivers/spi/spi_bfin5xx.c (7831 => 7832)
--- trunk/drivers/spi/spi_bfin5xx.c 2009-11-17 06:24:51 UTC (rev 7831)
+++ trunk/drivers/spi/spi_bfin5xx.c 2009-11-17 09:45:59 UTC (rev 7832)
@@ -185,7 +185,7 @@
/* Chip select operation functions for cs_change flag */
static void bfin_spi_cs_active(struct master_data *drv_data, struct slave_data *chip)
{
- if (likely(chip->chip_select_num)) {
+ if (likely(!(chip->chip_select_num & USE_GPIO_CS))) {
u16 flag = read_FLAG(drv_data);
flag &= ~chip->flag;
@@ -198,7 +198,7 @@
static void bfin_spi_cs_deactive(struct master_data *drv_data, struct slave_data *chip)
{
- if (likely(chip->chip_select_num)) {
+ if (likely(!(chip->chip_select_num & USE_GPIO_CS))) {
u16 flag = read_FLAG(drv_data);
flag |= chip->flag;
@@ -216,20 +216,24 @@
/* enable or disable the pin muxed by GPIO and SPI CS to work as SPI CS */
static inline void bfin_spi_cs_enable(struct master_data *drv_data, struct slave_data *chip)
{
- u16 flag = read_FLAG(drv_data);
+ if (!(chip->chip_select_num & USE_GPIO_CS)) {
+ u16 flag = read_FLAG(drv_data);
- flag |= (chip->flag >> 8);
+ flag |= (chip->flag >> 8);
- write_FLAG(drv_data, flag);
+ write_FLAG(drv_data, flag);
+ }
}
static inline void bfin_spi_cs_disable(struct master_data *drv_data, struct slave_data *chip)
{
- u16 flag = read_FLAG(drv_data);
+ if (!(chip->chip_select_num & USE_GPIO_CS)) {
+ u16 flag = read_FLAG(drv_data);
- flag &= ~(chip->flag >> 8);
+ flag &= ~(chip->flag >> 8);
- write_FLAG(drv_data, flag);
+ write_FLAG(drv_data, flag);
+ }
}
/* stop controller and re-config current chip*/
@@ -1124,7 +1128,7 @@
* SPI_BAUD, not the real baudrate
*/
chip->baud = hz_to_spi_baud(spi->max_speed_hz);
- chip->flag = (1 << (spi->chip_select)) << 8;
+ chip->flag = (1 << (spi->chip_select & ~USE_GPIO_CS)) << 8;
chip->chip_select_num = spi->chip_select;
switch (chip->bits_per_word) {
@@ -1186,7 +1190,7 @@
disable_irq(drv_data->spi_irq);
}
- if (chip->chip_select_num == 0) {
+ if (chip->chip_select_num & USE_GPIO_CS) {
ret = gpio_request(chip->cs_gpio, spi->modalias);
if (ret) {
dev_err(&spi->dev, "gpio_request() error\n");
@@ -1203,7 +1207,7 @@
spi_set_ctldata(spi, chip);
dev_dbg(&spi->dev, "chip select number is %d\n", chip->chip_select_num);
- if (chip->chip_select_num > 0 &&
+ if ((!(chip->chip_select_num & USE_GPIO_CS)) &&
chip->chip_select_num <= spi->master->num_chipselect) {
ret = peripheral_request(ssel[spi->master->bus_num]
[chip->chip_select_num-1], spi->modalias);
@@ -1219,7 +1223,7 @@
return 0;
pin_error:
- if (chip->chip_select_num == 0)
+ if (chip->chip_select_num & USE_GPIO_CS)
gpio_free(chip->cs_gpio);
else
peripheral_free(ssel[spi->master->bus_num]
@@ -1250,14 +1254,14 @@
if (!chip)
return;
- if ((chip->chip_select_num > 0)
+ if ((!(chip->chip_select_num & USE_GPIO_CS))
&& (chip->chip_select_num <= spi->master->num_chipselect)) {
peripheral_free(ssel[spi->master->bus_num]
[chip->chip_select_num-1]);
bfin_spi_cs_disable(drv_data, chip);
}
- if (chip->chip_select_num == 0)
+ if (chip->chip_select_num & USE_GPIO_CS)
gpio_free(chip->cs_gpio);
kfree(chip);