diff options
Diffstat (limited to 'drivers/spi')
-rw-r--r-- | drivers/spi/pxa2xx_spi.c | 5 | ||||
-rw-r--r-- | drivers/spi/spi.c | 23 | ||||
-rw-r--r-- | drivers/spi/spi_s3c24xx.c | 28 |
3 files changed, 31 insertions, 25 deletions
diff --git a/drivers/spi/pxa2xx_spi.c b/drivers/spi/pxa2xx_spi.c index 6ed3f1da9296..8b41f9cc2560 100644 --- a/drivers/spi/pxa2xx_spi.c +++ b/drivers/spi/pxa2xx_spi.c | |||
@@ -1169,8 +1169,9 @@ static int setup(struct spi_device *spi) | |||
1169 | spi->bits_per_word - 16 : spi->bits_per_word) | 1169 | spi->bits_per_word - 16 : spi->bits_per_word) |
1170 | | SSCR0_SSE | 1170 | | SSCR0_SSE |
1171 | | (spi->bits_per_word > 16 ? SSCR0_EDSS : 0); | 1171 | | (spi->bits_per_word > 16 ? SSCR0_EDSS : 0); |
1172 | chip->cr1 |= (((spi->mode & SPI_CPHA) != 0) << 4) | 1172 | chip->cr1 &= ~(SSCR1_SPO | SSCR1_SPH); |
1173 | | (((spi->mode & SPI_CPOL) != 0) << 3); | 1173 | chip->cr1 |= (((spi->mode & SPI_CPHA) != 0) ? SSCR1_SPH : 0) |
1174 | | (((spi->mode & SPI_CPOL) != 0) ? SSCR1_SPO : 0); | ||
1174 | 1175 | ||
1175 | /* NOTE: PXA25x_SSP _could_ use external clocking ... */ | 1176 | /* NOTE: PXA25x_SSP _could_ use external clocking ... */ |
1176 | if (drv_data->ssp_type != PXA25x_SSP) | 1177 | if (drv_data->ssp_type != PXA25x_SSP) |
diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c index 270e6211c2e3..6307428d2c94 100644 --- a/drivers/spi/spi.c +++ b/drivers/spi/spi.c | |||
@@ -366,7 +366,6 @@ spi_alloc_master(struct device *dev, unsigned size) | |||
366 | 366 | ||
367 | class_device_initialize(&master->cdev); | 367 | class_device_initialize(&master->cdev); |
368 | master->cdev.class = &spi_master_class; | 368 | master->cdev.class = &spi_master_class; |
369 | kobj_set_kset_s(&master->cdev, spi_master_class.subsys); | ||
370 | master->cdev.dev = get_device(dev); | 369 | master->cdev.dev = get_device(dev); |
371 | spi_master_set_devdata(master, &master[1]); | 370 | spi_master_set_devdata(master, &master[1]); |
372 | 371 | ||
@@ -466,14 +465,20 @@ EXPORT_SYMBOL_GPL(spi_unregister_master); | |||
466 | */ | 465 | */ |
467 | struct spi_master *spi_busnum_to_master(u16 bus_num) | 466 | struct spi_master *spi_busnum_to_master(u16 bus_num) |
468 | { | 467 | { |
469 | char name[9]; | 468 | struct class_device *cdev; |
470 | struct kobject *bus; | 469 | struct spi_master *master = NULL; |
471 | 470 | struct spi_master *m; | |
472 | snprintf(name, sizeof name, "spi%u", bus_num); | 471 | |
473 | bus = kset_find_obj(&spi_master_class.subsys.kset, name); | 472 | down(&spi_master_class.sem); |
474 | if (bus) | 473 | list_for_each_entry(cdev, &spi_master_class.children, node) { |
475 | return container_of(bus, struct spi_master, cdev.kobj); | 474 | m = container_of(cdev, struct spi_master, cdev); |
476 | return NULL; | 475 | if (m->bus_num == bus_num) { |
476 | master = spi_master_get(m); | ||
477 | break; | ||
478 | } | ||
479 | } | ||
480 | up(&spi_master_class.sem); | ||
481 | return master; | ||
477 | } | 482 | } |
478 | EXPORT_SYMBOL_GPL(spi_busnum_to_master); | 483 | EXPORT_SYMBOL_GPL(spi_busnum_to_master); |
479 | 484 | ||
diff --git a/drivers/spi/spi_s3c24xx.c b/drivers/spi/spi_s3c24xx.c index 8ca08713528e..651379c51ae6 100644 --- a/drivers/spi/spi_s3c24xx.c +++ b/drivers/spi/spi_s3c24xx.c | |||
@@ -10,9 +10,6 @@ | |||
10 | * | 10 | * |
11 | */ | 11 | */ |
12 | 12 | ||
13 | |||
14 | //#define DEBUG | ||
15 | |||
16 | #include <linux/init.h> | 13 | #include <linux/init.h> |
17 | #include <linux/spinlock.h> | 14 | #include <linux/spinlock.h> |
18 | #include <linux/workqueue.h> | 15 | #include <linux/workqueue.h> |
@@ -44,6 +41,9 @@ struct s3c24xx_spi { | |||
44 | int len; | 41 | int len; |
45 | int count; | 42 | int count; |
46 | 43 | ||
44 | int (*set_cs)(struct s3c2410_spi_info *spi, | ||
45 | int cs, int pol); | ||
46 | |||
47 | /* data buffers */ | 47 | /* data buffers */ |
48 | const unsigned char *tx; | 48 | const unsigned char *tx; |
49 | unsigned char *rx; | 49 | unsigned char *rx; |
@@ -64,6 +64,11 @@ static inline struct s3c24xx_spi *to_hw(struct spi_device *sdev) | |||
64 | return spi_master_get_devdata(sdev->master); | 64 | return spi_master_get_devdata(sdev->master); |
65 | } | 65 | } |
66 | 66 | ||
67 | static void s3c24xx_spi_gpiocs(struct s3c2410_spi_info *spi, int cs, int pol) | ||
68 | { | ||
69 | s3c2410_gpio_setpin(spi->pin_cs, pol); | ||
70 | } | ||
71 | |||
67 | static void s3c24xx_spi_chipsel(struct spi_device *spi, int value) | 72 | static void s3c24xx_spi_chipsel(struct spi_device *spi, int value) |
68 | { | 73 | { |
69 | struct s3c24xx_spi *hw = to_hw(spi); | 74 | struct s3c24xx_spi *hw = to_hw(spi); |
@@ -72,10 +77,7 @@ static void s3c24xx_spi_chipsel(struct spi_device *spi, int value) | |||
72 | 77 | ||
73 | switch (value) { | 78 | switch (value) { |
74 | case BITBANG_CS_INACTIVE: | 79 | case BITBANG_CS_INACTIVE: |
75 | if (hw->pdata->set_cs) | 80 | hw->pdata->set_cs(hw->pdata, spi->chip_select, cspol^1); |
76 | hw->pdata->set_cs(hw->pdata, value, cspol); | ||
77 | else | ||
78 | s3c2410_gpio_setpin(hw->pdata->pin_cs, cspol ^ 1); | ||
79 | break; | 81 | break; |
80 | 82 | ||
81 | case BITBANG_CS_ACTIVE: | 83 | case BITBANG_CS_ACTIVE: |
@@ -96,14 +98,9 @@ static void s3c24xx_spi_chipsel(struct spi_device *spi, int value) | |||
96 | /* write new configration */ | 98 | /* write new configration */ |
97 | 99 | ||
98 | writeb(spcon, hw->regs + S3C2410_SPCON); | 100 | writeb(spcon, hw->regs + S3C2410_SPCON); |
99 | 101 | hw->pdata->set_cs(hw->pdata, spi->chip_select, cspol); | |
100 | if (hw->pdata->set_cs) | ||
101 | hw->pdata->set_cs(hw->pdata, value, cspol); | ||
102 | else | ||
103 | s3c2410_gpio_setpin(hw->pdata->pin_cs, cspol); | ||
104 | 102 | ||
105 | break; | 103 | break; |
106 | |||
107 | } | 104 | } |
108 | } | 105 | } |
109 | 106 | ||
@@ -330,9 +327,12 @@ static int s3c24xx_spi_probe(struct platform_device *pdev) | |||
330 | /* setup any gpio we can */ | 327 | /* setup any gpio we can */ |
331 | 328 | ||
332 | if (!hw->pdata->set_cs) { | 329 | if (!hw->pdata->set_cs) { |
330 | hw->set_cs = s3c24xx_spi_gpiocs; | ||
331 | |||
333 | s3c2410_gpio_setpin(hw->pdata->pin_cs, 1); | 332 | s3c2410_gpio_setpin(hw->pdata->pin_cs, 1); |
334 | s3c2410_gpio_cfgpin(hw->pdata->pin_cs, S3C2410_GPIO_OUTPUT); | 333 | s3c2410_gpio_cfgpin(hw->pdata->pin_cs, S3C2410_GPIO_OUTPUT); |
335 | } | 334 | } else |
335 | hw->set_cs = hw->pdata->set_cs; | ||
336 | 336 | ||
337 | /* register our spi controller */ | 337 | /* register our spi controller */ |
338 | 338 | ||