]> Pileus Git - ~andy/linux/blob - arch/arm/mach-kirkwood/board-dt.c
9bd35ac730b357f3d1f34c526b47f299bb84c442
[~andy/linux] / arch / arm / mach-kirkwood / board-dt.c
1 /*
2  * Copyright 2012 (C), Jason Cooper <jason@lakedaemon.net>
3  *
4  * arch/arm/mach-kirkwood/board-dt.c
5  *
6  * Marvell DreamPlug Reference Board Setup
7  *
8  * This file is licensed under the terms of the GNU General Public
9  * License version 2.  This program is licensed "as is" without any
10  * warranty of any kind, whether express or implied.
11  */
12
13 #include <linux/kernel.h>
14 #include <linux/init.h>
15 #include <linux/platform_device.h>
16 #include <linux/mtd/partitions.h>
17 #include <linux/ata_platform.h>
18 #include <linux/mv643xx_eth.h>
19 #include <linux/of.h>
20 #include <linux/of_address.h>
21 #include <linux/of_fdt.h>
22 #include <linux/of_irq.h>
23 #include <linux/of_platform.h>
24 #include <linux/gpio.h>
25 #include <linux/leds.h>
26 #include <linux/mtd/physmap.h>
27 #include <linux/spi/flash.h>
28 #include <linux/spi/spi.h>
29 #include <linux/spi/orion_spi.h>
30 #include <asm/mach-types.h>
31 #include <asm/mach/arch.h>
32 #include <asm/mach/map.h>
33 #include <mach/kirkwood.h>
34 #include <mach/bridge-regs.h>
35 #include <plat/mvsdio.h>
36 #include "common.h"
37 #include "mpp.h"
38
39 static struct of_device_id kirkwood_dt_match_table[] __initdata = {
40         { .compatible = "simple-bus", },
41         { }
42 };
43
44 struct mtd_partition dreamplug_partitions[] = {
45         {
46                 .name   = "u-boot",
47                 .size   = SZ_512K,
48                 .offset = 0,
49         },
50         {
51                 .name   = "u-boot env",
52                 .size   = SZ_64K,
53                 .offset = SZ_512K + SZ_512K,
54         },
55         {
56                 .name   = "dtb",
57                 .size   = SZ_64K,
58                 .offset = SZ_512K + SZ_512K + SZ_512K,
59         },
60 };
61
62 static const struct flash_platform_data dreamplug_spi_slave_data = {
63         .type           = "mx25l1606e",
64         .name           = "spi_flash",
65         .parts          = dreamplug_partitions,
66         .nr_parts       = ARRAY_SIZE(dreamplug_partitions),
67 };
68
69 static struct spi_board_info __initdata dreamplug_spi_slave_info[] = {
70         {
71                 .modalias       = "m25p80",
72                 .platform_data  = &dreamplug_spi_slave_data,
73                 .irq            = -1,
74                 .max_speed_hz   = 50000000,
75                 .bus_num        = 0,
76                 .chip_select    = 0,
77         },
78 };
79
80 static struct mv643xx_eth_platform_data dreamplug_ge00_data = {
81         .phy_addr       = MV643XX_ETH_PHY_ADDR(0),
82 };
83
84 static struct mv643xx_eth_platform_data dreamplug_ge01_data = {
85         .phy_addr       = MV643XX_ETH_PHY_ADDR(1),
86 };
87
88 static struct mv_sata_platform_data dreamplug_sata_data = {
89         .n_ports        = 1,
90 };
91
92 static struct mvsdio_platform_data dreamplug_mvsdio_data = {
93         /* unfortunately the CD signal has not been connected */
94 };
95
96 static struct gpio_led dreamplug_led_pins[] = {
97         {
98                 .name                   = "dreamplug:blue:bluetooth",
99                 .gpio                   = 47,
100                 .active_low             = 1,
101         },
102         {
103                 .name                   = "dreamplug:green:wifi",
104                 .gpio                   = 48,
105                 .active_low             = 1,
106         },
107         {
108                 .name                   = "dreamplug:green:wifi_ap",
109                 .gpio                   = 49,
110                 .active_low             = 1,
111         },
112 };
113
114 static struct gpio_led_platform_data dreamplug_led_data = {
115         .leds           = dreamplug_led_pins,
116         .num_leds       = ARRAY_SIZE(dreamplug_led_pins),
117 };
118
119 static struct platform_device dreamplug_leds = {
120         .name   = "leds-gpio",
121         .id     = -1,
122         .dev    = {
123                 .platform_data  = &dreamplug_led_data,
124         }
125 };
126
127 static unsigned int dreamplug_mpp_config[] __initdata = {
128         MPP0_SPI_SCn,
129         MPP1_SPI_MOSI,
130         MPP2_SPI_SCK,
131         MPP3_SPI_MISO,
132         MPP47_GPIO,     /* Bluetooth LED */
133         MPP48_GPIO,     /* Wifi LED */
134         MPP49_GPIO,     /* Wifi AP LED */
135         0
136 };
137
138 static void __init dreamplug_init(void)
139 {
140         /*
141          * Basic setup. Needs to be called early.
142          */
143         kirkwood_mpp_conf(dreamplug_mpp_config);
144
145         spi_register_board_info(dreamplug_spi_slave_info,
146                                 ARRAY_SIZE(dreamplug_spi_slave_info));
147         kirkwood_spi_init();
148
149         kirkwood_ehci_init();
150         kirkwood_ge00_init(&dreamplug_ge00_data);
151         kirkwood_ge01_init(&dreamplug_ge01_data);
152         kirkwood_sata_init(&dreamplug_sata_data);
153         kirkwood_sdio_init(&dreamplug_mvsdio_data);
154
155         platform_device_register(&dreamplug_leds);
156 }
157
158 static void __init kirkwood_dt_init(void)
159 {
160         pr_info("Kirkwood: %s, TCLK=%d.\n", kirkwood_id(), kirkwood_tclk);
161
162         /*
163          * Disable propagation of mbus errors to the CPU local bus,
164          * as this causes mbus errors (which can occur for example
165          * for PCI aborts) to throw CPU aborts, which we're not set
166          * up to deal with.
167          */
168         writel(readl(CPU_CONFIG) & ~CPU_CONFIG_ERROR_PROP, CPU_CONFIG);
169
170         kirkwood_setup_cpu_mbus();
171
172 #ifdef CONFIG_CACHE_FEROCEON_L2
173         kirkwood_l2_init();
174 #endif
175
176         /* internal devices that every board has */
177         kirkwood_rtc_init();
178         kirkwood_wdt_init();
179         kirkwood_xor0_init();
180         kirkwood_xor1_init();
181         kirkwood_crypto_init();
182
183 #ifdef CONFIG_KEXEC
184         kexec_reinit = kirkwood_enable_pcie;
185 #endif
186
187         if (of_machine_is_compatible("globalscale,dreamplug"))
188                 dreamplug_init();
189
190         of_platform_populate(NULL, kirkwood_dt_match_table, NULL, NULL);
191 }
192
193 static const char *kirkwood_dt_board_compat[] = {
194         "globalscale,dreamplug",
195         NULL
196 };
197
198 DT_MACHINE_START(KIRKWOOD_DT, "Marvell Kirkwood (Flattened Device Tree)")
199         /* Maintainer: Jason Cooper <jason@lakedaemon.net> */
200         .map_io         = kirkwood_map_io,
201         .init_early     = kirkwood_init_early,
202         .init_irq       = kirkwood_init_irq,
203         .timer          = &kirkwood_timer,
204         .init_machine   = kirkwood_dt_init,
205         .restart        = kirkwood_restart,
206         .dt_compat      = kirkwood_dt_board_compat,
207 MACHINE_END