summaryrefslogtreecommitdiffstats
path: root/drivers/spi/spi-ath79.c
diff options
context:
space:
mode:
authorAlban Bedel <albeu@free.fr>2015-04-24 10:19:22 -0400
committerMark Brown <broonie@kernel.org>2015-04-27 10:44:56 -0400
commit85f62476fc44e6915787f832371400cbdd7d8bff (patch)
tree02cbab3b185e4b87e5d23ad41109cb6baaac8407 /drivers/spi/spi-ath79.c
parent76426aacabc7bb0bafdcad48f5facabe83ebc451 (diff)
spi: spi-ath79: Add device tree support
Set the OF node of the spi controller and use the generic GPIO based chip select instead of the custom controller data. As the controller data isn't used by any board just drop it. Signed-off-by: Alban Bedel <albeu@free.fr> Signed-off-by: Mark Brown <broonie@kernel.org>
Diffstat (limited to 'drivers/spi/spi-ath79.c')
-rw-r--r--drivers/spi/spi-ath79.c20
1 files changed, 11 insertions, 9 deletions
diff --git a/drivers/spi/spi-ath79.c b/drivers/spi/spi-ath79.c
index b02eb4ac0218..239bc31d6791 100644
--- a/drivers/spi/spi-ath79.c
+++ b/drivers/spi/spi-ath79.c
@@ -79,10 +79,8 @@ static void ath79_spi_chipselect(struct spi_device *spi, int is_active)
79 } 79 }
80 80
81 if (spi->chip_select) { 81 if (spi->chip_select) {
82 struct ath79_spi_controller_data *cdata = spi->controller_data;
83
84 /* SPI is normally active-low */ 82 /* SPI is normally active-low */
85 gpio_set_value(cdata->gpio, cs_high); 83 gpio_set_value(spi->cs_gpio, cs_high);
86 } else { 84 } else {
87 if (cs_high) 85 if (cs_high)
88 sp->ioc_base |= AR71XX_SPI_IOC_CS0; 86 sp->ioc_base |= AR71XX_SPI_IOC_CS0;
@@ -117,11 +115,9 @@ static void ath79_spi_disable(struct ath79_spi *sp)
117 115
118static int ath79_spi_setup_cs(struct spi_device *spi) 116static int ath79_spi_setup_cs(struct spi_device *spi)
119{ 117{
120 struct ath79_spi_controller_data *cdata;
121 int status; 118 int status;
122 119
123 cdata = spi->controller_data; 120 if (spi->chip_select && !gpio_is_valid(spi->cs_gpio))
124 if (spi->chip_select && !cdata)
125 return -EINVAL; 121 return -EINVAL;
126 122
127 status = 0; 123 status = 0;
@@ -134,7 +130,7 @@ static int ath79_spi_setup_cs(struct spi_device *spi)
134 else 130 else
135 flags |= GPIOF_INIT_HIGH; 131 flags |= GPIOF_INIT_HIGH;
136 132
137 status = gpio_request_one(cdata->gpio, flags, 133 status = gpio_request_one(spi->cs_gpio, flags,
138 dev_name(&spi->dev)); 134 dev_name(&spi->dev));
139 } 135 }
140 136
@@ -144,8 +140,7 @@ static int ath79_spi_setup_cs(struct spi_device *spi)
144static void ath79_spi_cleanup_cs(struct spi_device *spi) 140static void ath79_spi_cleanup_cs(struct spi_device *spi)
145{ 141{
146 if (spi->chip_select) { 142 if (spi->chip_select) {
147 struct ath79_spi_controller_data *cdata = spi->controller_data; 143 gpio_free(spi->cs_gpio);
148 gpio_free(cdata->gpio);
149 } 144 }
150} 145}
151 146
@@ -217,6 +212,7 @@ static int ath79_spi_probe(struct platform_device *pdev)
217 } 212 }
218 213
219 sp = spi_master_get_devdata(master); 214 sp = spi_master_get_devdata(master);
215 master->dev.of_node = pdev->dev.of_node;
220 platform_set_drvdata(pdev, sp); 216 platform_set_drvdata(pdev, sp);
221 217
222 pdata = dev_get_platdata(&pdev->dev); 218 pdata = dev_get_platdata(&pdev->dev);
@@ -301,12 +297,18 @@ static void ath79_spi_shutdown(struct platform_device *pdev)
301 ath79_spi_remove(pdev); 297 ath79_spi_remove(pdev);
302} 298}
303 299
300static const struct of_device_id ath79_spi_of_match[] = {
301 { .compatible = "qca,ar7100-spi", },
302 { },
303};
304
304static struct platform_driver ath79_spi_driver = { 305static struct platform_driver ath79_spi_driver = {
305 .probe = ath79_spi_probe, 306 .probe = ath79_spi_probe,
306 .remove = ath79_spi_remove, 307 .remove = ath79_spi_remove,
307 .shutdown = ath79_spi_shutdown, 308 .shutdown = ath79_spi_shutdown,
308 .driver = { 309 .driver = {
309 .name = DRV_NAME, 310 .name = DRV_NAME,
311 .of_match_table = ath79_spi_of_match,
310 }, 312 },
311}; 313};
312module_platform_driver(ath79_spi_driver); 314module_platform_driver(ath79_spi_driver);