1 From 5de6baef9b5d9e3a84e0c3752cfb7eaef2eb1a0f Mon Sep 17 00:00:00 2001
2 From: notro <notro@tronnes.org>
3 Date: Sun, 27 Jul 2014 20:12:58 +0200
4 Subject: [PATCH 052/114] spi: bcm2708: add device tree support
6 Add DT support to driver and add to .dtsi file.
7 Setup pins and spidev in .dts file.
8 SPI is disabled by default.
10 Signed-off-by: Noralf Tronnes <notro@tronnes.org>
12 BCM2708: don't register SPI controller when using DT
14 The device for the SPI controller is in the Device Tree.
15 Only register the device when not using DT.
17 Signed-off-by: Noralf Tronnes <notro@tronnes.org>
19 spi: bcm2835: make driver available on ARCH_BCM2708
21 Make this driver available on ARCH_BCM2708
23 Signed-off-by: Noralf Tronnes <notro@tronnes.org>
25 bcm2708: Remove the prohibition on mixing SPIDEV and DT
27 arch/arm/boot/dts/bcm2708-rpi-b.dts | 32 ++++++++++++++++++++++++++++++++
28 arch/arm/boot/dts/bcm2708.dtsi | 18 ++++++++++++++++++
29 arch/arm/mach-bcm2708/bcm2708.c | 19 ++++++++++++++++---
30 drivers/spi/Kconfig | 2 +-
31 drivers/spi/spi-bcm2708.c | 8 ++++++++
32 5 files changed, 75 insertions(+), 4 deletions(-)
34 diff --git a/arch/arm/boot/dts/bcm2708-rpi-b.dts b/arch/arm/boot/dts/bcm2708-rpi-b.dts
35 index e319c8e..30107fb 100644
36 --- a/arch/arm/boot/dts/bcm2708-rpi-b.dts
37 +++ b/arch/arm/boot/dts/bcm2708-rpi-b.dts
40 compatible = "brcm,bcm2708";
41 model = "Raspberry Pi";
49 + spi0_pins: spi0_pins {
50 + brcm,pins = <7 8 9 10 11>;
51 + brcm,function = <4>; /* alt0 */
56 + pinctrl-names = "default";
57 + pinctrl-0 = <&spi0_pins>;
60 + compatible = "spidev";
61 + reg = <0>; /* CE0 */
62 + #address-cells = <1>;
64 + spi-max-frequency = <500000>;
68 + compatible = "spidev";
69 + reg = <1>; /* CE1 */
70 + #address-cells = <1>;
72 + spi-max-frequency = <500000>;
75 diff --git a/arch/arm/boot/dts/bcm2708.dtsi b/arch/arm/boot/dts/bcm2708.dtsi
76 index b2920c8..e90bf4c 100644
77 --- a/arch/arm/boot/dts/bcm2708.dtsi
78 +++ b/arch/arm/boot/dts/bcm2708.dtsi
81 #interrupt-cells = <2>;
84 + spi0: spi@7e204000 {
85 + compatible = "brcm,bcm2708-spi";
86 + reg = <0x7e204000 0x1000>;
87 + interrupts = <2 22>;
88 + clocks = <&clk_spi>;
89 + #address-cells = <1>;
91 + status = "disabled";
96 compatible = "simple-bus";
101 + compatible = "fixed-clock";
103 + #clock-cells = <0>;
104 + clock-output-names = "spi";
105 + clock-frequency = <250000000>;
109 diff --git a/arch/arm/mach-bcm2708/bcm2708.c b/arch/arm/mach-bcm2708/bcm2708.c
110 index 0e5bd43..a2069f8 100644
111 --- a/arch/arm/mach-bcm2708/bcm2708.c
112 +++ b/arch/arm/mach-bcm2708/bcm2708.c
113 @@ -486,6 +486,7 @@ static struct platform_device bcm2708_alsa_devices[] = {
118 static struct resource bcm2708_spi_resources[] = {
121 @@ -509,6 +510,7 @@ static struct platform_device bcm2708_spi_device = {
122 .dma_mask = &bcm2708_spi_dmamask,
123 .coherent_dma_mask = DMA_BIT_MASK(DMA_MASK_BITS_COMMON)},
127 #ifdef CONFIG_BCM2708_SPIDEV
128 static struct spi_board_info bcm2708_spi_devices[] = {
129 @@ -670,6 +672,16 @@ int __init bcm_register_device(struct platform_device *pdev)
134 + * Use this macro for platform devices that are present in the Device Tree.
135 + * This way the device is only added on non-DT builds.
138 +#define bcm_register_device_dt(pdev)
140 +#define bcm_register_device_dt(pdev) bcm_register_device(pdev)
143 int calc_rsts(int partition)
146 @@ -784,7 +796,7 @@ void __init bcm2708_init(void)
147 for (i = 0; i < ARRAY_SIZE(bcm2708_alsa_devices); i++)
148 bcm_register_device(&bcm2708_alsa_devices[i]);
150 - bcm_register_device(&bcm2708_spi_device);
151 + bcm_register_device_dt(&bcm2708_spi_device);
152 bcm_register_device(&bcm2708_bsc0_device);
153 bcm_register_device(&bcm2708_bsc1_device);
155 @@ -824,8 +836,9 @@ void __init bcm2708_init(void)
156 system_serial_low = serial;
158 #ifdef CONFIG_BCM2708_SPIDEV
159 - spi_register_board_info(bcm2708_spi_devices,
160 - ARRAY_SIZE(bcm2708_spi_devices));
162 + spi_register_board_info(bcm2708_spi_devices,
163 + ARRAY_SIZE(bcm2708_spi_devices));
167 diff --git a/drivers/spi/Kconfig b/drivers/spi/Kconfig
168 index 71b4741..a5238ab 100644
169 --- a/drivers/spi/Kconfig
170 +++ b/drivers/spi/Kconfig
171 @@ -77,7 +77,7 @@ config SPI_ATMEL
174 tristate "BCM2835 SPI controller"
175 - depends on ARCH_BCM2835 || COMPILE_TEST
176 + depends on ARCH_BCM2835 || ARCH_BCM2708 || COMPILE_TEST
178 This selects a driver for the Broadcom BCM2835 SPI master.
180 diff --git a/drivers/spi/spi-bcm2708.c b/drivers/spi/spi-bcm2708.c
181 index 349d21f..041b5e2 100644
182 --- a/drivers/spi/spi-bcm2708.c
183 +++ b/drivers/spi/spi-bcm2708.c
184 @@ -512,6 +512,7 @@ static int bcm2708_spi_probe(struct platform_device *pdev)
185 master->setup = bcm2708_spi_setup;
186 master->transfer = bcm2708_spi_transfer;
187 master->cleanup = bcm2708_spi_cleanup;
188 + master->dev.of_node = pdev->dev.of_node;
189 platform_set_drvdata(pdev, master);
191 bs = spi_master_get_devdata(master);
192 @@ -596,10 +597,17 @@ static int bcm2708_spi_remove(struct platform_device *pdev)
196 +static const struct of_device_id bcm2708_spi_match[] = {
197 + { .compatible = "brcm,bcm2708-spi", },
200 +MODULE_DEVICE_TABLE(of, bcm2708_spi_match);
202 static struct platform_driver bcm2708_spi_driver = {
205 .owner = THIS_MODULE,
206 + .of_match_table = bcm2708_spi_match,
208 .probe = bcm2708_spi_probe,
209 .remove = bcm2708_spi_remove,