diff options
-rw-r--r-- | drivers/spi/spi-s3c64xx.c | 37 |
1 files changed, 11 insertions, 26 deletions
diff --git a/drivers/spi/spi-s3c64xx.c b/drivers/spi/spi-s3c64xx.c index 75a56968b14c..b1e26f00cd05 100644 --- a/drivers/spi/spi-s3c64xx.c +++ b/drivers/spi/spi-s3c64xx.c | |||
@@ -197,7 +197,6 @@ struct s3c64xx_spi_driver_data { | |||
197 | struct s3c64xx_spi_dma_data tx_dma; | 197 | struct s3c64xx_spi_dma_data tx_dma; |
198 | struct s3c64xx_spi_port_config *port_conf; | 198 | struct s3c64xx_spi_port_config *port_conf; |
199 | unsigned int port_id; | 199 | unsigned int port_id; |
200 | bool cs_gpio; | ||
201 | }; | 200 | }; |
202 | 201 | ||
203 | static void flush_fifo(struct s3c64xx_spi_driver_data *sdd) | 202 | static void flush_fifo(struct s3c64xx_spi_driver_data *sdd) |
@@ -754,10 +753,8 @@ static struct s3c64xx_spi_csinfo *s3c64xx_get_slave_ctrldata( | |||
754 | { | 753 | { |
755 | struct s3c64xx_spi_csinfo *cs; | 754 | struct s3c64xx_spi_csinfo *cs; |
756 | struct device_node *slave_np, *data_np = NULL; | 755 | struct device_node *slave_np, *data_np = NULL; |
757 | struct s3c64xx_spi_driver_data *sdd; | ||
758 | u32 fb_delay = 0; | 756 | u32 fb_delay = 0; |
759 | 757 | ||
760 | sdd = spi_master_get_devdata(spi->master); | ||
761 | slave_np = spi->dev.of_node; | 758 | slave_np = spi->dev.of_node; |
762 | if (!slave_np) { | 759 | if (!slave_np) { |
763 | dev_err(&spi->dev, "device node not found\n"); | 760 | dev_err(&spi->dev, "device node not found\n"); |
@@ -776,10 +773,7 @@ static struct s3c64xx_spi_csinfo *s3c64xx_get_slave_ctrldata( | |||
776 | return ERR_PTR(-ENOMEM); | 773 | return ERR_PTR(-ENOMEM); |
777 | } | 774 | } |
778 | 775 | ||
779 | /* The CS line is asserted/deasserted by the gpio pin */ | 776 | cs->line = of_get_named_gpio(data_np, "cs-gpio", 0); |
780 | if (sdd->cs_gpio) | ||
781 | cs->line = of_get_named_gpio(data_np, "cs-gpio", 0); | ||
782 | |||
783 | if (!gpio_is_valid(cs->line)) { | 777 | if (!gpio_is_valid(cs->line)) { |
784 | dev_err(&spi->dev, "chip select gpio is not specified or invalid\n"); | 778 | dev_err(&spi->dev, "chip select gpio is not specified or invalid\n"); |
785 | kfree(cs); | 779 | kfree(cs); |
@@ -818,20 +812,17 @@ static int s3c64xx_spi_setup(struct spi_device *spi) | |||
818 | } | 812 | } |
819 | 813 | ||
820 | if (!spi_get_ctldata(spi)) { | 814 | if (!spi_get_ctldata(spi)) { |
821 | /* Request gpio only if cs line is asserted by gpio pins */ | 815 | err = gpio_request_one(cs->line, GPIOF_OUT_INIT_HIGH, |
822 | if (sdd->cs_gpio) { | 816 | dev_name(&spi->dev)); |
823 | err = gpio_request_one(cs->line, GPIOF_OUT_INIT_HIGH, | 817 | if (err) { |
824 | dev_name(&spi->dev)); | 818 | dev_err(&spi->dev, |
825 | if (err) { | 819 | "Failed to get /CS gpio [%d]: %d\n", |
826 | dev_err(&spi->dev, | 820 | cs->line, err); |
827 | "Failed to get /CS gpio [%d]: %d\n", | 821 | goto err_gpio_req; |
828 | cs->line, err); | ||
829 | goto err_gpio_req; | ||
830 | } | ||
831 | |||
832 | spi->cs_gpio = cs->line; | ||
833 | } | 822 | } |
834 | 823 | ||
824 | spi->cs_gpio = cs->line; | ||
825 | |||
835 | spi_set_ctldata(spi, cs); | 826 | spi_set_ctldata(spi, cs); |
836 | } | 827 | } |
837 | 828 | ||
@@ -897,10 +888,8 @@ err_gpio_req: | |||
897 | static void s3c64xx_spi_cleanup(struct spi_device *spi) | 888 | static void s3c64xx_spi_cleanup(struct spi_device *spi) |
898 | { | 889 | { |
899 | struct s3c64xx_spi_csinfo *cs = spi_get_ctldata(spi); | 890 | struct s3c64xx_spi_csinfo *cs = spi_get_ctldata(spi); |
900 | struct s3c64xx_spi_driver_data *sdd; | ||
901 | 891 | ||
902 | sdd = spi_master_get_devdata(spi->master); | 892 | if (cs) { |
903 | if (spi->cs_gpio) { | ||
904 | gpio_free(spi->cs_gpio); | 893 | gpio_free(spi->cs_gpio); |
905 | if (spi->dev.of_node) | 894 | if (spi->dev.of_node) |
906 | kfree(cs); | 895 | kfree(cs); |
@@ -1075,11 +1064,7 @@ static int s3c64xx_spi_probe(struct platform_device *pdev) | |||
1075 | sdd->cntrlr_info = sci; | 1064 | sdd->cntrlr_info = sci; |
1076 | sdd->pdev = pdev; | 1065 | sdd->pdev = pdev; |
1077 | sdd->sfr_start = mem_res->start; | 1066 | sdd->sfr_start = mem_res->start; |
1078 | sdd->cs_gpio = true; | ||
1079 | if (pdev->dev.of_node) { | 1067 | if (pdev->dev.of_node) { |
1080 | if (!of_find_property(pdev->dev.of_node, "cs-gpio", NULL)) | ||
1081 | sdd->cs_gpio = false; | ||
1082 | |||
1083 | ret = of_alias_get_id(pdev->dev.of_node, "spi"); | 1068 | ret = of_alias_get_id(pdev->dev.of_node, "spi"); |
1084 | if (ret < 0) { | 1069 | if (ret < 0) { |
1085 | dev_err(&pdev->dev, "failed to get alias id, errno %d\n", | 1070 | dev_err(&pdev->dev, "failed to get alias id, errno %d\n", |