Commit 9a8d141d authored by Mark Brown's avatar Mark Brown

Merge remote-tracking branches 'spi/topic/ath79', 'spi/topic/atmel' and...

Merge remote-tracking branches 'spi/topic/ath79', 'spi/topic/atmel' and 'spi/topic/davinci' into spi-next
Binding for Qualcomm Atheros AR7xxx/AR9xxx SPI controller
Required properties:
- compatible: has to be "qca,<soc-type>-spi", "qca,ar7100-spi" as fallback.
- reg: Base address and size of the controllers memory area
- clocks: phandle to the AHB clock.
- clock-names: has to be "ahb".
- #address-cells: <1>, as required by generic SPI binding.
- #size-cells: <0>, also as required by generic SPI binding.
Child nodes as per the generic SPI binding.
Example:
spi@1F000000 {
compatible = "qca,ar9132-spi", "qca,ar7100-spi";
reg = <0x1F000000 0x10>;
clocks = <&pll 2>;
clock-names = "ahb";
#address-cells = <1>;
#size-cells = <0>;
};
...@@ -4,11 +4,16 @@ Required properties: ...@@ -4,11 +4,16 @@ Required properties:
- compatible : should be "atmel,at91rm9200-spi". - compatible : should be "atmel,at91rm9200-spi".
- reg: Address and length of the register set for the device - reg: Address and length of the register set for the device
- interrupts: Should contain spi interrupt - interrupts: Should contain spi interrupt
- cs-gpios: chipselects - cs-gpios: chipselects (optional for SPI controller version >= 2 with the
Chip Select Active After Transfer feature).
- clock-names: tuple listing input clock names. - clock-names: tuple listing input clock names.
Required elements: "spi_clk" Required elements: "spi_clk"
- clocks: phandles to input clocks. - clocks: phandles to input clocks.
Optional properties:
- atmel,fifo-size: maximum number of data the RX and TX FIFOs can store for FIFO
capable SPI controllers.
Example: Example:
spi1: spi@fffcc000 { spi1: spi@fffcc000 {
...@@ -20,6 +25,7 @@ spi1: spi@fffcc000 { ...@@ -20,6 +25,7 @@ spi1: spi@fffcc000 {
clocks = <&spi1_clk>; clocks = <&spi1_clk>;
clock-names = "spi_clk"; clock-names = "spi_clk";
cs-gpios = <&pioB 3 0>; cs-gpios = <&pioB 3 0>;
atmel,fifo-size = <32>;
status = "okay"; status = "okay";
mmc-slot@0 { mmc-slot@0 {
......
...@@ -16,8 +16,4 @@ struct ath79_spi_platform_data { ...@@ -16,8 +16,4 @@ struct ath79_spi_platform_data {
unsigned num_chipselect; unsigned num_chipselect;
}; };
struct ath79_spi_controller_data {
unsigned gpio;
};
#endif /* _ATH79_SPI_PLATFORM_H */ #endif /* _ATH79_SPI_PLATFORM_H */
...@@ -79,10 +79,8 @@ static void ath79_spi_chipselect(struct spi_device *spi, int is_active) ...@@ -79,10 +79,8 @@ static void ath79_spi_chipselect(struct spi_device *spi, int is_active)
} }
if (spi->chip_select) { if (spi->chip_select) {
struct ath79_spi_controller_data *cdata = spi->controller_data;
/* SPI is normally active-low */ /* SPI is normally active-low */
gpio_set_value(cdata->gpio, cs_high); gpio_set_value(spi->cs_gpio, cs_high);
} else { } else {
if (cs_high) if (cs_high)
sp->ioc_base |= AR71XX_SPI_IOC_CS0; sp->ioc_base |= AR71XX_SPI_IOC_CS0;
...@@ -117,11 +115,10 @@ static void ath79_spi_disable(struct ath79_spi *sp) ...@@ -117,11 +115,10 @@ static void ath79_spi_disable(struct ath79_spi *sp)
static int ath79_spi_setup_cs(struct spi_device *spi) static int ath79_spi_setup_cs(struct spi_device *spi)
{ {
struct ath79_spi_controller_data *cdata; struct ath79_spi *sp = ath79_spidev_to_sp(spi);
int status; int status;
cdata = spi->controller_data; if (spi->chip_select && !gpio_is_valid(spi->cs_gpio))
if (spi->chip_select && !cdata)
return -EINVAL; return -EINVAL;
status = 0; status = 0;
...@@ -134,8 +131,15 @@ static int ath79_spi_setup_cs(struct spi_device *spi) ...@@ -134,8 +131,15 @@ static int ath79_spi_setup_cs(struct spi_device *spi)
else else
flags |= GPIOF_INIT_HIGH; flags |= GPIOF_INIT_HIGH;
status = gpio_request_one(cdata->gpio, flags, status = gpio_request_one(spi->cs_gpio, flags,
dev_name(&spi->dev)); dev_name(&spi->dev));
} else {
if (spi->mode & SPI_CS_HIGH)
sp->ioc_base &= ~AR71XX_SPI_IOC_CS0;
else
sp->ioc_base |= AR71XX_SPI_IOC_CS0;
ath79_spi_wr(sp, AR71XX_SPI_REG_IOC, sp->ioc_base);
} }
return status; return status;
...@@ -144,8 +148,7 @@ static int ath79_spi_setup_cs(struct spi_device *spi) ...@@ -144,8 +148,7 @@ static int ath79_spi_setup_cs(struct spi_device *spi)
static void ath79_spi_cleanup_cs(struct spi_device *spi) static void ath79_spi_cleanup_cs(struct spi_device *spi)
{ {
if (spi->chip_select) { if (spi->chip_select) {
struct ath79_spi_controller_data *cdata = spi->controller_data; gpio_free(spi->cs_gpio);
gpio_free(cdata->gpio);
} }
} }
...@@ -217,6 +220,7 @@ static int ath79_spi_probe(struct platform_device *pdev) ...@@ -217,6 +220,7 @@ static int ath79_spi_probe(struct platform_device *pdev)
} }
sp = spi_master_get_devdata(master); sp = spi_master_get_devdata(master);
master->dev.of_node = pdev->dev.of_node;
platform_set_drvdata(pdev, sp); platform_set_drvdata(pdev, sp);
pdata = dev_get_platdata(&pdev->dev); pdata = dev_get_platdata(&pdev->dev);
...@@ -253,7 +257,7 @@ static int ath79_spi_probe(struct platform_device *pdev) ...@@ -253,7 +257,7 @@ static int ath79_spi_probe(struct platform_device *pdev)
goto err_put_master; goto err_put_master;
} }
ret = clk_enable(sp->clk); ret = clk_prepare_enable(sp->clk);
if (ret) if (ret)
goto err_put_master; goto err_put_master;
...@@ -277,7 +281,7 @@ static int ath79_spi_probe(struct platform_device *pdev) ...@@ -277,7 +281,7 @@ static int ath79_spi_probe(struct platform_device *pdev)
err_disable: err_disable:
ath79_spi_disable(sp); ath79_spi_disable(sp);
err_clk_disable: err_clk_disable:
clk_disable(sp->clk); clk_disable_unprepare(sp->clk);
err_put_master: err_put_master:
spi_master_put(sp->bitbang.master); spi_master_put(sp->bitbang.master);
...@@ -290,7 +294,7 @@ static int ath79_spi_remove(struct platform_device *pdev) ...@@ -290,7 +294,7 @@ static int ath79_spi_remove(struct platform_device *pdev)
spi_bitbang_stop(&sp->bitbang); spi_bitbang_stop(&sp->bitbang);
ath79_spi_disable(sp); ath79_spi_disable(sp);
clk_disable(sp->clk); clk_disable_unprepare(sp->clk);
spi_master_put(sp->bitbang.master); spi_master_put(sp->bitbang.master);
return 0; return 0;
...@@ -301,12 +305,18 @@ static void ath79_spi_shutdown(struct platform_device *pdev) ...@@ -301,12 +305,18 @@ static void ath79_spi_shutdown(struct platform_device *pdev)
ath79_spi_remove(pdev); ath79_spi_remove(pdev);
} }
static const struct of_device_id ath79_spi_of_match[] = {
{ .compatible = "qca,ar7100-spi", },
{ },
};
static struct platform_driver ath79_spi_driver = { static struct platform_driver ath79_spi_driver = {
.probe = ath79_spi_probe, .probe = ath79_spi_probe,
.remove = ath79_spi_remove, .remove = ath79_spi_remove,
.shutdown = ath79_spi_shutdown, .shutdown = ath79_spi_shutdown,
.driver = { .driver = {
.name = DRV_NAME, .name = DRV_NAME,
.of_match_table = ath79_spi_of_match,
}, },
}; };
module_platform_driver(ath79_spi_driver); module_platform_driver(ath79_spi_driver);
......
This diff is collapsed.
...@@ -265,7 +265,7 @@ static inline int davinci_spi_get_prescale(struct davinci_spi *dspi, ...@@ -265,7 +265,7 @@ static inline int davinci_spi_get_prescale(struct davinci_spi *dspi,
ret = DIV_ROUND_UP(clk_get_rate(dspi->clk), max_speed_hz); ret = DIV_ROUND_UP(clk_get_rate(dspi->clk), max_speed_hz);
if (ret < 3 || ret > 256) if (ret < 1 || ret > 256)
return -EINVAL; return -EINVAL;
return ret - 1; return ret - 1;
......
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