Commit 8331c49c authored by Mark Brown's avatar Mark Brown

Merge remote-tracking branches 'spi/fix/s3c64xx', 'spi/fix/samsung' and...

Merge remote-tracking branches 'spi/fix/s3c64xx', 'spi/fix/samsung' and 'spi/fix/xilinx' into spi-linus
...@@ -18,14 +18,11 @@ Required SoC Specific Properties: ...@@ -18,14 +18,11 @@ Required SoC Specific Properties:
- interrupts: The interrupt number to the cpu. The interrupt specifier format - interrupts: The interrupt number to the cpu. The interrupt specifier format
depends on the interrupt controller. depends on the interrupt controller.
[PRELIMINARY: the dma channel allocation will change once there are - dmas : Two or more DMA channel specifiers following the convention outlined
official DMA bindings] in bindings/dma/dma.txt
- tx-dma-channel: The dma channel specifier for tx operations. The format of - dma-names: Names for the dma channels. There must be at least one channel
the dma specifier depends on the dma controller. named "tx" for transmit and named "rx" for receive.
- rx-dma-channel: The dma channel specifier for rx operations. The format of
the dma specifier depends on the dma controller.
Required Board Specific Properties: Required Board Specific Properties:
...@@ -42,15 +39,13 @@ Optional Board Specific Properties: ...@@ -42,15 +39,13 @@ Optional Board Specific Properties:
- num-cs: Specifies the number of chip select lines supported. If - num-cs: Specifies the number of chip select lines supported. If
not specified, the default number of chip select lines is set to 1. not specified, the default number of chip select lines is set to 1.
- cs-gpios: should specify GPIOs used for chipselects (see spi-bus.txt)
SPI Controller specific data in SPI slave nodes: SPI Controller specific data in SPI slave nodes:
- The spi slave nodes should provide the following information which is required - The spi slave nodes should provide the following information which is required
by the spi controller. by the spi controller.
- cs-gpio: A gpio specifier that specifies the gpio line used as
the slave select line by the spi controller. The format of the gpio
specifier depends on the gpio controller.
- samsung,spi-feedback-delay: The sampling phase shift to be applied on the - samsung,spi-feedback-delay: The sampling phase shift to be applied on the
miso line (to account for any lag in the miso line). The following are the miso line (to account for any lag in the miso line). The following are the
valid values. valid values.
...@@ -74,8 +69,11 @@ Example: ...@@ -74,8 +69,11 @@ Example:
compatible = "samsung,exynos4210-spi"; compatible = "samsung,exynos4210-spi";
reg = <0x12d20000 0x100>; reg = <0x12d20000 0x100>;
interrupts = <0 66 0>; interrupts = <0 66 0>;
tx-dma-channel = <&pdma0 5>; dmas = <&pdma0 5
rx-dma-channel = <&pdma0 4>; &pdma0 4>;
dma-names = "tx", "rx";
#address-cells = <1>;
#size-cells = <0>;
}; };
- Board Specific Portion: - Board Specific Portion:
...@@ -85,6 +83,7 @@ Example: ...@@ -85,6 +83,7 @@ Example:
#size-cells = <0>; #size-cells = <0>;
pinctrl-names = "default"; pinctrl-names = "default";
pinctrl-0 = <&spi0_bus>; pinctrl-0 = <&spi0_bus>;
cs-gpios = <&gpa2 5 0>;
w25q80bw@0 { w25q80bw@0 {
#address-cells = <1>; #address-cells = <1>;
...@@ -94,7 +93,6 @@ Example: ...@@ -94,7 +93,6 @@ Example:
spi-max-frequency = <10000>; spi-max-frequency = <10000>;
controller-data { controller-data {
cs-gpio = <&gpa2 5 1 0 3>;
samsung,spi-feedback-delay = <0>; samsung,spi-feedback-delay = <0>;
}; };
......
...@@ -168,6 +168,7 @@ eeprom@52 { ...@@ -168,6 +168,7 @@ eeprom@52 {
}; };
spi_2: spi@13940000 { spi_2: spi@13940000 {
cs-gpios = <&gpc1 2 0>;
status = "okay"; status = "okay";
w25x80@0 { w25x80@0 {
...@@ -178,7 +179,6 @@ w25x80@0 { ...@@ -178,7 +179,6 @@ w25x80@0 {
spi-max-frequency = <1000000>; spi-max-frequency = <1000000>;
controller-data { controller-data {
cs-gpio = <&gpc1 2 0>;
samsung,spi-feedback-delay = <0>; samsung,spi-feedback-delay = <0>;
}; };
......
...@@ -589,6 +589,7 @@ cm36651@18 { ...@@ -589,6 +589,7 @@ cm36651@18 {
spi_1: spi@13930000 { spi_1: spi@13930000 {
pinctrl-names = "default"; pinctrl-names = "default";
pinctrl-0 = <&spi1_bus>; pinctrl-0 = <&spi1_bus>;
cs-gpios = <&gpb 5 0>;
status = "okay"; status = "okay";
s5c73m3_spi: s5c73m3 { s5c73m3_spi: s5c73m3 {
...@@ -596,7 +597,6 @@ s5c73m3_spi: s5c73m3 { ...@@ -596,7 +597,6 @@ s5c73m3_spi: s5c73m3 {
spi-max-frequency = <50000000>; spi-max-frequency = <50000000>;
reg = <0>; reg = <0>;
controller-data { controller-data {
cs-gpio = <&gpb 5 0>;
samsung,spi-feedback-delay = <2>; samsung,spi-feedback-delay = <2>;
}; };
}; };
......
...@@ -316,6 +316,7 @@ slot@0 { ...@@ -316,6 +316,7 @@ slot@0 {
}; };
spi_1: spi@12d30000 { spi_1: spi@12d30000 {
cs-gpios = <&gpa2 5 0>;
status = "okay"; status = "okay";
w25q80bw@0 { w25q80bw@0 {
...@@ -326,7 +327,6 @@ w25q80bw@0 { ...@@ -326,7 +327,6 @@ w25q80bw@0 {
spi-max-frequency = <1000000>; spi-max-frequency = <1000000>;
controller-data { controller-data {
cs-gpio = <&gpa2 5 0>;
samsung,spi-feedback-delay = <0>; samsung,spi-feedback-delay = <0>;
}; };
......
...@@ -197,7 +197,6 @@ struct s3c64xx_spi_driver_data { ...@@ -197,7 +197,6 @@ struct s3c64xx_spi_driver_data {
struct s3c64xx_spi_dma_data tx_dma; struct s3c64xx_spi_dma_data tx_dma;
struct s3c64xx_spi_port_config *port_conf; struct s3c64xx_spi_port_config *port_conf;
unsigned int port_id; unsigned int port_id;
bool cs_gpio;
}; };
static void flush_fifo(struct s3c64xx_spi_driver_data *sdd) static void flush_fifo(struct s3c64xx_spi_driver_data *sdd)
...@@ -754,10 +753,8 @@ static struct s3c64xx_spi_csinfo *s3c64xx_get_slave_ctrldata( ...@@ -754,10 +753,8 @@ static struct s3c64xx_spi_csinfo *s3c64xx_get_slave_ctrldata(
{ {
struct s3c64xx_spi_csinfo *cs; struct s3c64xx_spi_csinfo *cs;
struct device_node *slave_np, *data_np = NULL; struct device_node *slave_np, *data_np = NULL;
struct s3c64xx_spi_driver_data *sdd;
u32 fb_delay = 0; u32 fb_delay = 0;
sdd = spi_master_get_devdata(spi->master);
slave_np = spi->dev.of_node; slave_np = spi->dev.of_node;
if (!slave_np) { if (!slave_np) {
dev_err(&spi->dev, "device node not found\n"); dev_err(&spi->dev, "device node not found\n");
...@@ -776,17 +773,6 @@ static struct s3c64xx_spi_csinfo *s3c64xx_get_slave_ctrldata( ...@@ -776,17 +773,6 @@ static struct s3c64xx_spi_csinfo *s3c64xx_get_slave_ctrldata(
return ERR_PTR(-ENOMEM); return ERR_PTR(-ENOMEM);
} }
/* The CS line is asserted/deasserted by the gpio pin */
if (sdd->cs_gpio)
cs->line = of_get_named_gpio(data_np, "cs-gpio", 0);
if (!gpio_is_valid(cs->line)) {
dev_err(&spi->dev, "chip select gpio is not specified or invalid\n");
kfree(cs);
of_node_put(data_np);
return ERR_PTR(-EINVAL);
}
of_property_read_u32(data_np, "samsung,spi-feedback-delay", &fb_delay); of_property_read_u32(data_np, "samsung,spi-feedback-delay", &fb_delay);
cs->fb_delay = fb_delay; cs->fb_delay = fb_delay;
of_node_put(data_np); of_node_put(data_np);
...@@ -807,9 +793,16 @@ static int s3c64xx_spi_setup(struct spi_device *spi) ...@@ -807,9 +793,16 @@ static int s3c64xx_spi_setup(struct spi_device *spi)
int err; int err;
sdd = spi_master_get_devdata(spi->master); sdd = spi_master_get_devdata(spi->master);
if (!cs && spi->dev.of_node) { if (spi->dev.of_node) {
cs = s3c64xx_get_slave_ctrldata(spi); cs = s3c64xx_get_slave_ctrldata(spi);
spi->controller_data = cs; spi->controller_data = cs;
} else if (cs) {
/* On non-DT platforms the SPI core will set spi->cs_gpio
* to -ENOENT. The GPIO pin used to drive the chip select
* is defined by using platform data so spi->cs_gpio value
* has to be override to have the proper GPIO pin number.
*/
spi->cs_gpio = cs->line;
} }
if (IS_ERR_OR_NULL(cs)) { if (IS_ERR_OR_NULL(cs)) {
...@@ -818,18 +811,15 @@ static int s3c64xx_spi_setup(struct spi_device *spi) ...@@ -818,18 +811,15 @@ static int s3c64xx_spi_setup(struct spi_device *spi)
} }
if (!spi_get_ctldata(spi)) { if (!spi_get_ctldata(spi)) {
/* Request gpio only if cs line is asserted by gpio pins */ if (gpio_is_valid(spi->cs_gpio)) {
if (sdd->cs_gpio) { err = gpio_request_one(spi->cs_gpio, GPIOF_OUT_INIT_HIGH,
err = gpio_request_one(cs->line, GPIOF_OUT_INIT_HIGH,
dev_name(&spi->dev)); dev_name(&spi->dev));
if (err) { if (err) {
dev_err(&spi->dev, dev_err(&spi->dev,
"Failed to get /CS gpio [%d]: %d\n", "Failed to get /CS gpio [%d]: %d\n",
cs->line, err); spi->cs_gpio, err);
goto err_gpio_req; goto err_gpio_req;
} }
spi->cs_gpio = cs->line;
} }
spi_set_ctldata(spi, cs); spi_set_ctldata(spi, cs);
...@@ -884,7 +874,8 @@ static int s3c64xx_spi_setup(struct spi_device *spi) ...@@ -884,7 +874,8 @@ static int s3c64xx_spi_setup(struct spi_device *spi)
/* setup() returns with device de-selected */ /* setup() returns with device de-selected */
writel(S3C64XX_SPI_SLAVE_SIG_INACT, sdd->regs + S3C64XX_SPI_SLAVE_SEL); writel(S3C64XX_SPI_SLAVE_SIG_INACT, sdd->regs + S3C64XX_SPI_SLAVE_SEL);
gpio_free(cs->line); if (gpio_is_valid(spi->cs_gpio))
gpio_free(spi->cs_gpio);
spi_set_ctldata(spi, NULL); spi_set_ctldata(spi, NULL);
err_gpio_req: err_gpio_req:
...@@ -897,14 +888,21 @@ static int s3c64xx_spi_setup(struct spi_device *spi) ...@@ -897,14 +888,21 @@ static int s3c64xx_spi_setup(struct spi_device *spi)
static void s3c64xx_spi_cleanup(struct spi_device *spi) static void s3c64xx_spi_cleanup(struct spi_device *spi)
{ {
struct s3c64xx_spi_csinfo *cs = spi_get_ctldata(spi); struct s3c64xx_spi_csinfo *cs = spi_get_ctldata(spi);
struct s3c64xx_spi_driver_data *sdd;
sdd = spi_master_get_devdata(spi->master); if (gpio_is_valid(spi->cs_gpio)) {
if (spi->cs_gpio) {
gpio_free(spi->cs_gpio); gpio_free(spi->cs_gpio);
if (spi->dev.of_node) if (spi->dev.of_node)
kfree(cs); kfree(cs);
else {
/* On non-DT platforms, the SPI core sets
* spi->cs_gpio to -ENOENT and .setup()
* overrides it with the GPIO pin value
* passed using platform data.
*/
spi->cs_gpio = -ENOENT;
}
} }
spi_set_ctldata(spi, NULL); spi_set_ctldata(spi, NULL);
} }
...@@ -1075,11 +1073,7 @@ static int s3c64xx_spi_probe(struct platform_device *pdev) ...@@ -1075,11 +1073,7 @@ static int s3c64xx_spi_probe(struct platform_device *pdev)
sdd->cntrlr_info = sci; sdd->cntrlr_info = sci;
sdd->pdev = pdev; sdd->pdev = pdev;
sdd->sfr_start = mem_res->start; sdd->sfr_start = mem_res->start;
sdd->cs_gpio = true;
if (pdev->dev.of_node) { if (pdev->dev.of_node) {
if (!of_find_property(pdev->dev.of_node, "cs-gpio", NULL))
sdd->cs_gpio = false;
ret = of_alias_get_id(pdev->dev.of_node, "spi"); ret = of_alias_get_id(pdev->dev.of_node, "spi");
if (ret < 0) { if (ret < 0) {
dev_err(&pdev->dev, "failed to get alias id, errno %d\n", dev_err(&pdev->dev, "failed to get alias id, errno %d\n",
......
...@@ -369,7 +369,7 @@ static int xilinx_spi_probe(struct platform_device *pdev) ...@@ -369,7 +369,7 @@ static int xilinx_spi_probe(struct platform_device *pdev)
goto put_master; goto put_master;
} }
master->bus_num = pdev->dev.id; master->bus_num = pdev->id;
master->num_chipselect = num_cs; master->num_chipselect = num_cs;
master->dev.of_node = pdev->dev.of_node; master->dev.of_node = pdev->dev.of_node;
......
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