Commit 1c20c200 authored by Thomas Abraham's avatar Thomas Abraham Committed by Kukjin Kim

spi: s3c64xx: Remove the 'set_level' callback from controller data

The set_level callback in the controller data, which is used to configure
the slave select line, cannot be supported when migrating the driver to
device tree based discovery. Since all the platforms currently use gpio
as the slave select line, this callback can be removed from the
controller data and replaced with call to gpio_set_value in the driver.
Signed-off-by: default avatarThomas Abraham <thomas.abraham@linaro.org>
Acked-by: default avatarJaswinder Singh <jaswinder.singh@linaro.org>
Acked-by: default avatarGrant Likely <grant.likely@secretlab.ca>
Signed-off-by: default avatarKukjin Kim <kgene.kim@samsung.com>
parent 4d0efdd5
...@@ -18,7 +18,6 @@ struct platform_device; ...@@ -18,7 +18,6 @@ struct platform_device;
* @fb_delay: Slave specific feedback delay. * @fb_delay: Slave specific feedback delay.
* Refer to FB_CLK_SEL register definition in SPI chapter. * Refer to FB_CLK_SEL register definition in SPI chapter.
* @line: Custom 'identity' of the CS line. * @line: Custom 'identity' of the CS line.
* @set_level: CS line control.
* *
* This is per SPI-Slave Chipselect information. * This is per SPI-Slave Chipselect information.
* Allocate and initialize one in machine init code and make the * Allocate and initialize one in machine init code and make the
...@@ -27,7 +26,6 @@ struct platform_device; ...@@ -27,7 +26,6 @@ struct platform_device;
struct s3c64xx_spi_csinfo { struct s3c64xx_spi_csinfo {
u8 fb_delay; u8 fb_delay;
unsigned line; unsigned line;
void (*set_level)(unsigned line_id, int lvl);
}; };
/** /**
......
...@@ -27,6 +27,7 @@ ...@@ -27,6 +27,7 @@
#include <linux/platform_device.h> #include <linux/platform_device.h>
#include <linux/pm_runtime.h> #include <linux/pm_runtime.h>
#include <linux/spi/spi.h> #include <linux/spi/spi.h>
#include <linux/gpio.h>
#include <mach/dma.h> #include <mach/dma.h>
#include <plat/s3c64xx-spi.h> #include <plat/s3c64xx-spi.h>
...@@ -411,14 +412,14 @@ static inline void enable_cs(struct s3c64xx_spi_driver_data *sdd, ...@@ -411,14 +412,14 @@ static inline void enable_cs(struct s3c64xx_spi_driver_data *sdd,
if (sdd->tgl_spi != spi) { /* if last mssg on diff device */ if (sdd->tgl_spi != spi) { /* if last mssg on diff device */
/* Deselect the last toggled device */ /* Deselect the last toggled device */
cs = sdd->tgl_spi->controller_data; cs = sdd->tgl_spi->controller_data;
cs->set_level(cs->line, gpio_set_value(cs->line,
spi->mode & SPI_CS_HIGH ? 0 : 1); spi->mode & SPI_CS_HIGH ? 0 : 1);
} }
sdd->tgl_spi = NULL; sdd->tgl_spi = NULL;
} }
cs = spi->controller_data; cs = spi->controller_data;
cs->set_level(cs->line, spi->mode & SPI_CS_HIGH ? 1 : 0); gpio_set_value(cs->line, spi->mode & SPI_CS_HIGH ? 1 : 0);
} }
static int wait_for_xfer(struct s3c64xx_spi_driver_data *sdd, static int wait_for_xfer(struct s3c64xx_spi_driver_data *sdd,
...@@ -504,7 +505,7 @@ static inline void disable_cs(struct s3c64xx_spi_driver_data *sdd, ...@@ -504,7 +505,7 @@ static inline void disable_cs(struct s3c64xx_spi_driver_data *sdd,
if (sdd->tgl_spi == spi) if (sdd->tgl_spi == spi)
sdd->tgl_spi = NULL; sdd->tgl_spi = NULL;
cs->set_level(cs->line, spi->mode & SPI_CS_HIGH ? 0 : 1); gpio_set_value(cs->line, spi->mode & SPI_CS_HIGH ? 0 : 1);
} }
static void s3c64xx_spi_config(struct s3c64xx_spi_driver_data *sdd) static void s3c64xx_spi_config(struct s3c64xx_spi_driver_data *sdd)
...@@ -833,11 +834,21 @@ static int s3c64xx_spi_setup(struct spi_device *spi) ...@@ -833,11 +834,21 @@ static int s3c64xx_spi_setup(struct spi_device *spi)
unsigned long flags; unsigned long flags;
int err = 0; int err = 0;
if (cs == NULL || cs->set_level == NULL) { if (cs == NULL) {
dev_err(&spi->dev, "No CS for SPI(%d)\n", spi->chip_select); dev_err(&spi->dev, "No CS for SPI(%d)\n", spi->chip_select);
return -ENODEV; return -ENODEV;
} }
if (!spi_get_ctldata(spi)) {
err = gpio_request(cs->line, dev_name(&spi->dev));
if (err) {
dev_err(&spi->dev, "request for slave select gpio "
"line [%d] failed\n", cs->line);
return -EBUSY;
}
spi_set_ctldata(spi, cs);
}
sdd = spi_master_get_devdata(spi->master); sdd = spi_master_get_devdata(spi->master);
sci = sdd->cntrlr_info; sci = sdd->cntrlr_info;
...@@ -908,6 +919,15 @@ static int s3c64xx_spi_setup(struct spi_device *spi) ...@@ -908,6 +919,15 @@ static int s3c64xx_spi_setup(struct spi_device *spi)
return err; return err;
} }
static void s3c64xx_spi_cleanup(struct spi_device *spi)
{
struct s3c64xx_spi_csinfo *cs = spi_get_ctldata(spi);
if (cs)
gpio_free(cs->line);
spi_set_ctldata(spi, NULL);
}
static irqreturn_t s3c64xx_spi_irq(int irq, void *data) static irqreturn_t s3c64xx_spi_irq(int irq, void *data)
{ {
struct s3c64xx_spi_driver_data *sdd = data; struct s3c64xx_spi_driver_data *sdd = data;
...@@ -1049,6 +1069,7 @@ static int __init s3c64xx_spi_probe(struct platform_device *pdev) ...@@ -1049,6 +1069,7 @@ static int __init s3c64xx_spi_probe(struct platform_device *pdev)
master->bus_num = sdd->port_id; master->bus_num = sdd->port_id;
master->setup = s3c64xx_spi_setup; master->setup = s3c64xx_spi_setup;
master->cleanup = s3c64xx_spi_cleanup;
master->prepare_transfer_hardware = s3c64xx_spi_prepare_transfer; master->prepare_transfer_hardware = s3c64xx_spi_prepare_transfer;
master->transfer_one_message = s3c64xx_spi_transfer_one_message; master->transfer_one_message = s3c64xx_spi_transfer_one_message;
master->unprepare_transfer_hardware = s3c64xx_spi_unprepare_transfer; master->unprepare_transfer_hardware = s3c64xx_spi_unprepare_transfer;
......
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