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 --- a/arch/arm/boot/dts/bcm2708-rpi-b.dts
35 +++ b/arch/arm/boot/dts/bcm2708-rpi-b.dts
38 compatible = "brcm,bcm2708";
39 model = "Raspberry Pi";
47 + spi0_pins: spi0_pins {
48 + brcm,pins = <7 8 9 10 11>;
49 + brcm,function = <4>; /* alt0 */
54 + pinctrl-names = "default";
55 + pinctrl-0 = <&spi0_pins>;
58 + compatible = "spidev";
59 + reg = <0>; /* CE0 */
60 + #address-cells = <1>;
62 + spi-max-frequency = <500000>;
66 + compatible = "spidev";
67 + reg = <1>; /* CE1 */
68 + #address-cells = <1>;
70 + spi-max-frequency = <500000>;
73 --- a/arch/arm/boot/dts/bcm2708.dtsi
74 +++ b/arch/arm/boot/dts/bcm2708.dtsi
77 #interrupt-cells = <2>;
80 + spi0: spi@7e204000 {
81 + compatible = "brcm,bcm2708-spi";
82 + reg = <0x7e204000 0x1000>;
83 + interrupts = <2 22>;
84 + clocks = <&clk_spi>;
85 + #address-cells = <1>;
87 + status = "disabled";
92 compatible = "simple-bus";
97 + compatible = "fixed-clock";
100 + clock-output-names = "spi";
101 + clock-frequency = <250000000>;
105 --- a/arch/arm/mach-bcm2708/bcm2708.c
106 +++ b/arch/arm/mach-bcm2708/bcm2708.c
107 @@ -486,6 +486,7 @@ static struct platform_device bcm2708_al
112 static struct resource bcm2708_spi_resources[] = {
115 @@ -509,6 +510,7 @@ static struct platform_device bcm2708_sp
116 .dma_mask = &bcm2708_spi_dmamask,
117 .coherent_dma_mask = DMA_BIT_MASK(DMA_MASK_BITS_COMMON)},
121 #ifdef CONFIG_BCM2708_SPIDEV
122 static struct spi_board_info bcm2708_spi_devices[] = {
123 @@ -670,6 +672,16 @@ int __init bcm_register_device(struct pl
128 + * Use this macro for platform devices that are present in the Device Tree.
129 + * This way the device is only added on non-DT builds.
132 +#define bcm_register_device_dt(pdev)
134 +#define bcm_register_device_dt(pdev) bcm_register_device(pdev)
137 int calc_rsts(int partition)
140 @@ -784,7 +796,7 @@ void __init bcm2708_init(void)
141 for (i = 0; i < ARRAY_SIZE(bcm2708_alsa_devices); i++)
142 bcm_register_device(&bcm2708_alsa_devices[i]);
144 - bcm_register_device(&bcm2708_spi_device);
145 + bcm_register_device_dt(&bcm2708_spi_device);
146 bcm_register_device(&bcm2708_bsc0_device);
147 bcm_register_device(&bcm2708_bsc1_device);
149 @@ -824,8 +836,9 @@ void __init bcm2708_init(void)
150 system_serial_low = serial;
152 #ifdef CONFIG_BCM2708_SPIDEV
153 - spi_register_board_info(bcm2708_spi_devices,
154 - ARRAY_SIZE(bcm2708_spi_devices));
156 + spi_register_board_info(bcm2708_spi_devices,
157 + ARRAY_SIZE(bcm2708_spi_devices));
161 --- a/drivers/spi/Kconfig
162 +++ b/drivers/spi/Kconfig
163 @@ -77,7 +77,7 @@ config SPI_ATMEL
166 tristate "BCM2835 SPI controller"
167 - depends on ARCH_BCM2835 || COMPILE_TEST
168 + depends on ARCH_BCM2835 || ARCH_BCM2708 || COMPILE_TEST
170 This selects a driver for the Broadcom BCM2835 SPI master.
172 --- a/drivers/spi/spi-bcm2708.c
173 +++ b/drivers/spi/spi-bcm2708.c
174 @@ -512,6 +512,7 @@ static int bcm2708_spi_probe(struct plat
175 master->setup = bcm2708_spi_setup;
176 master->transfer = bcm2708_spi_transfer;
177 master->cleanup = bcm2708_spi_cleanup;
178 + master->dev.of_node = pdev->dev.of_node;
179 platform_set_drvdata(pdev, master);
181 bs = spi_master_get_devdata(master);
182 @@ -596,10 +597,17 @@ static int bcm2708_spi_remove(struct pla
186 +static const struct of_device_id bcm2708_spi_match[] = {
187 + { .compatible = "brcm,bcm2708-spi", },
190 +MODULE_DEVICE_TABLE(of, bcm2708_spi_match);
192 static struct platform_driver bcm2708_spi_driver = {
195 .owner = THIS_MODULE,
196 + .of_match_table = bcm2708_spi_match,
198 .probe = bcm2708_spi_probe,
199 .remove = bcm2708_spi_remove,