]> Pileus Git - ~andy/linux/blob - arch/arm/mach-ux500/board-mop500.c
ARM: ux500: Disable Snowball's SMSC911x Ethernet when booting with ATAGs
[~andy/linux] / arch / arm / mach-ux500 / board-mop500.c
1 /*
2  * Copyright (C) 2008-2012 ST-Ericsson
3  *
4  * Author: Srinidhi KASAGAR <srinidhi.kasagar@stericsson.com>
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License version 2, as
8  * published by the Free Software Foundation.
9  *
10  */
11 #include <linux/kernel.h>
12 #include <linux/init.h>
13 #include <linux/interrupt.h>
14 #include <linux/platform_device.h>
15 #include <linux/clk.h>
16 #include <linux/io.h>
17 #include <linux/i2c.h>
18 #include <linux/platform_data/i2c-nomadik.h>
19 #include <linux/platform_data/db8500_thermal.h>
20 #include <linux/gpio.h>
21 #include <linux/amba/bus.h>
22 #include <linux/amba/pl022.h>
23 #include <linux/amba/serial.h>
24 #include <linux/spi/spi.h>
25 #include <linux/mfd/abx500/ab8500.h>
26 #include <linux/regulator/ab8500.h>
27 #include <linux/regulator/fixed.h>
28 #include <linux/regulator/driver.h>
29 #include <linux/regulator/gpio-regulator.h>
30 #include <linux/mfd/tc3589x.h>
31 #include <linux/mfd/tps6105x.h>
32 #include <linux/mfd/abx500/ab8500-gpio.h>
33 #include <linux/mfd/abx500/ab8500-codec.h>
34 #include <linux/platform_data/leds-lp55xx.h>
35 #include <linux/input.h>
36 #include <linux/gpio_keys.h>
37 #include <linux/delay.h>
38 #include <linux/leds.h>
39 #include <linux/pinctrl/consumer.h>
40 #include <linux/platform_data/pinctrl-nomadik.h>
41 #include <linux/platform_data/dma-ste-dma40.h>
42
43 #include <asm/mach-types.h>
44
45 #include "setup.h"
46 #include "devices.h"
47 #include "irqs.h"
48 #include <linux/platform_data/crypto-ux500.h>
49
50 #include "ste-dma40-db8500.h"
51 #include "db8500-regs.h"
52 #include "devices-db8500.h"
53 #include "board-mop500.h"
54 #include "board-mop500-regulators.h"
55
56 static struct fixed_voltage_config snowball_gpio_en_3v3_data = {
57        .supply_name            = "EN-3V3",
58        .gpio                   = SNOWBALL_EN_3V3_ETH_GPIO,
59        .microvolts             = 3300000,
60        .enable_high            = 1,
61        .init_data              = &gpio_en_3v3_regulator,
62        .startup_delay          = 5000, /* 1200us */
63 };
64
65 static struct platform_device snowball_gpio_en_3v3_regulator_dev = {
66        .name   = "reg-fixed-voltage",
67        .id     = 1,
68        .dev    = {
69                .platform_data  = &snowball_gpio_en_3v3_data,
70        },
71 };
72
73 /* Dynamically populated. */
74 static struct gpio sdi0_reg_gpios[] = {
75         { 0, GPIOF_OUT_INIT_LOW, "mmci_vsel" },
76 };
77
78 static struct gpio_regulator_state sdi0_reg_states[] = {
79         { .value = 2900000, .gpios = (0 << 0) },
80         { .value = 1800000, .gpios = (1 << 0) },
81 };
82
83 static struct gpio_regulator_config sdi0_reg_info = {
84         .supply_name            = "ext-mmc-level-shifter",
85         .gpios                  = sdi0_reg_gpios,
86         .nr_gpios               = ARRAY_SIZE(sdi0_reg_gpios),
87         .states                 = sdi0_reg_states,
88         .nr_states              = ARRAY_SIZE(sdi0_reg_states),
89         .type                   = REGULATOR_VOLTAGE,
90         .enable_high            = 1,
91         .enabled_at_boot        = 0,
92         .init_data              = &sdi0_reg_init_data,
93         .startup_delay          = 100,
94 };
95
96 static struct platform_device sdi0_regulator = {
97         .name = "gpio-regulator",
98         .id   = -1,
99         .dev  = {
100                 .platform_data = &sdi0_reg_info,
101         },
102 };
103
104 static struct abx500_gpio_platform_data ab8500_gpio_pdata = {
105         .gpio_base              = MOP500_AB8500_PIN_GPIO(1),
106 };
107
108 /* ab8500-codec */
109 static struct ab8500_codec_platform_data ab8500_codec_pdata = {
110         .amics =  {
111                 .mic1_type = AMIC_TYPE_DIFFERENTIAL,
112                 .mic2_type = AMIC_TYPE_DIFFERENTIAL,
113                 .mic1a_micbias = AMIC_MICBIAS_VAMIC1,
114                 .mic1b_micbias = AMIC_MICBIAS_VAMIC1,
115                 .mic2_micbias = AMIC_MICBIAS_VAMIC2
116         },
117         .ear_cmv = EAR_CMV_0_95V
118 };
119
120 struct ab8500_platform_data ab8500_platdata = {
121         .irq_base       = MOP500_AB8500_IRQ_BASE,
122         .regulator      = &ab8500_regulator_plat_data,
123         .gpio           = &ab8500_gpio_pdata,
124         .codec          = &ab8500_codec_pdata,
125 };
126
127 static struct platform_device u8500_cpufreq_cooling_device = {
128         .name           = "db8500-cpufreq-cooling",
129 };
130
131 /*
132  * TC35892
133  */
134
135 static void mop500_tc35892_init(struct tc3589x *tc3589x, unsigned int base)
136 {
137         struct device *parent = NULL;
138 #if 0
139         /* FIXME: Is the sdi actually part of tc3589x? */
140         parent = tc3589x->dev;
141 #endif
142         mop500_sdi_tc35892_init(parent);
143 }
144
145 static struct tc3589x_gpio_platform_data mop500_tc35892_gpio_data = {
146         .gpio_base      = MOP500_EGPIO(0),
147         .setup          = mop500_tc35892_init,
148 };
149
150 static struct tc3589x_platform_data mop500_tc35892_data = {
151         .block          = TC3589x_BLOCK_GPIO,
152         .gpio           = &mop500_tc35892_gpio_data,
153         .irq_base       = MOP500_EGPIO_IRQ_BASE,
154 };
155
156 /* I2C0 devices only available on the first HREF/MOP500 */
157 static struct i2c_board_info __initdata mop500_i2c0_devices[] = {
158         {
159                 I2C_BOARD_INFO("tc3589x", 0x42),
160                 .irq            = NOMADIK_GPIO_TO_IRQ(217),
161                 .platform_data  = &mop500_tc35892_data,
162         },
163 };
164
165 static struct i2c_board_info __initdata mop500_i2c2_devices[] = {
166         {
167                 /* Light sensor Rohm BH1780GLI */
168                 I2C_BOARD_INFO("bh1780", 0x29),
169         },
170 };
171
172 static int __init mop500_i2c_board_init(void)
173 {
174         if (machine_is_u8500())
175                 mop500_uib_i2c_add(0, mop500_i2c0_devices,
176                                    ARRAY_SIZE(mop500_i2c0_devices));
177         mop500_uib_i2c_add(2, mop500_i2c2_devices,
178                            ARRAY_SIZE(mop500_i2c2_devices));
179         return 0;
180 }
181 device_initcall(mop500_i2c_board_init);
182
183 static void __init mop500_i2c_init(struct device *parent)
184 {
185         db8500_add_i2c0(parent, NULL);
186         db8500_add_i2c1(parent, NULL);
187         db8500_add_i2c2(parent, NULL);
188         db8500_add_i2c3(parent, NULL);
189 }
190
191 static struct gpio_keys_button mop500_gpio_keys[] = {
192         {
193                 .desc                   = "SFH7741 Proximity Sensor",
194                 .type                   = EV_SW,
195                 .code                   = SW_FRONT_PROXIMITY,
196                 .active_low             = 0,
197                 .can_disable            = 1,
198         }
199 };
200
201 static struct regulator *prox_regulator;
202 static int mop500_prox_activate(struct device *dev);
203 static void mop500_prox_deactivate(struct device *dev);
204
205 static struct gpio_keys_platform_data mop500_gpio_keys_data = {
206         .buttons        = mop500_gpio_keys,
207         .nbuttons       = ARRAY_SIZE(mop500_gpio_keys),
208         .enable         = mop500_prox_activate,
209         .disable        = mop500_prox_deactivate,
210 };
211
212 static struct platform_device mop500_gpio_keys_device = {
213         .name   = "gpio-keys",
214         .id     = 0,
215         .dev    = {
216                 .platform_data  = &mop500_gpio_keys_data,
217         },
218 };
219
220 static int mop500_prox_activate(struct device *dev)
221 {
222         prox_regulator = regulator_get(&mop500_gpio_keys_device.dev,
223                                                 "vcc");
224         if (IS_ERR(prox_regulator)) {
225                 dev_err(&mop500_gpio_keys_device.dev,
226                         "no regulator\n");
227                 return PTR_ERR(prox_regulator);
228         }
229
230         return regulator_enable(prox_regulator);
231 }
232
233 static void mop500_prox_deactivate(struct device *dev)
234 {
235         regulator_disable(prox_regulator);
236         regulator_put(prox_regulator);
237 }
238
239 static struct cryp_platform_data u8500_cryp1_platform_data = {
240                 .mem_to_engine = {
241                                 .dir = DMA_MEM_TO_DEV,
242                                 .dev_type = DB8500_DMA_DEV48_CAC1,
243                                 .mode = STEDMA40_MODE_LOGICAL,
244                 },
245                 .engine_to_mem = {
246                                 .dir = DMA_DEV_TO_MEM,
247                                 .dev_type = DB8500_DMA_DEV48_CAC1,
248                                 .mode = STEDMA40_MODE_LOGICAL,
249                 }
250 };
251
252 static struct stedma40_chan_cfg u8500_hash_dma_cfg_tx = {
253                 .dir = DMA_MEM_TO_DEV,
254                 .dev_type = DB8500_DMA_DEV50_HAC1_TX,
255                 .mode = STEDMA40_MODE_LOGICAL,
256 };
257
258 static struct hash_platform_data u8500_hash1_platform_data = {
259                 .mem_to_engine = &u8500_hash_dma_cfg_tx,
260                 .dma_filter = stedma40_filter,
261 };
262
263 /* add any platform devices here - TODO */
264 static struct platform_device *mop500_platform_devs[] __initdata = {
265         &mop500_gpio_keys_device,
266         &sdi0_regulator,
267 };
268
269 #ifdef CONFIG_STE_DMA40
270 static struct stedma40_chan_cfg ssp0_dma_cfg_rx = {
271         .mode = STEDMA40_MODE_LOGICAL,
272         .dir = DMA_DEV_TO_MEM,
273         .dev_type = DB8500_DMA_DEV8_SSP0,
274 };
275
276 static struct stedma40_chan_cfg ssp0_dma_cfg_tx = {
277         .mode = STEDMA40_MODE_LOGICAL,
278         .dir = DMA_MEM_TO_DEV,
279         .dev_type = DB8500_DMA_DEV8_SSP0,
280 };
281 #endif
282
283 struct pl022_ssp_controller ssp0_plat = {
284         .bus_id = 0,
285 #ifdef CONFIG_STE_DMA40
286         .enable_dma = 1,
287         .dma_filter = stedma40_filter,
288         .dma_rx_param = &ssp0_dma_cfg_rx,
289         .dma_tx_param = &ssp0_dma_cfg_tx,
290 #else
291         .enable_dma = 0,
292 #endif
293         /* on this platform, gpio 31,142,144,214 &
294          * 224 are connected as chip selects
295          */
296         .num_chipselect = 5,
297 };
298
299 static void __init mop500_spi_init(struct device *parent)
300 {
301         db8500_add_ssp0(parent, &ssp0_plat);
302 }
303
304 #ifdef CONFIG_STE_DMA40
305 static struct stedma40_chan_cfg uart0_dma_cfg_rx = {
306         .mode = STEDMA40_MODE_LOGICAL,
307         .dir = DMA_DEV_TO_MEM,
308         .dev_type = DB8500_DMA_DEV13_UART0,
309 };
310
311 static struct stedma40_chan_cfg uart0_dma_cfg_tx = {
312         .mode = STEDMA40_MODE_LOGICAL,
313         .dir = DMA_MEM_TO_DEV,
314         .dev_type = DB8500_DMA_DEV13_UART0,
315 };
316
317 static struct stedma40_chan_cfg uart1_dma_cfg_rx = {
318         .mode = STEDMA40_MODE_LOGICAL,
319         .dir = DMA_DEV_TO_MEM,
320         .dev_type = DB8500_DMA_DEV12_UART1,
321 };
322
323 static struct stedma40_chan_cfg uart1_dma_cfg_tx = {
324         .mode = STEDMA40_MODE_LOGICAL,
325         .dir = DMA_MEM_TO_DEV,
326         .dev_type = DB8500_DMA_DEV12_UART1,
327 };
328
329 static struct stedma40_chan_cfg uart2_dma_cfg_rx = {
330         .mode = STEDMA40_MODE_LOGICAL,
331         .dir = DMA_DEV_TO_MEM,
332         .dev_type = DB8500_DMA_DEV11_UART2,
333 };
334
335 static struct stedma40_chan_cfg uart2_dma_cfg_tx = {
336         .mode = STEDMA40_MODE_LOGICAL,
337         .dir = DMA_MEM_TO_DEV,
338         .dev_type = DB8500_DMA_DEV11_UART2,
339 };
340 #endif
341
342 struct amba_pl011_data uart0_plat = {
343 #ifdef CONFIG_STE_DMA40
344         .dma_filter = stedma40_filter,
345         .dma_rx_param = &uart0_dma_cfg_rx,
346         .dma_tx_param = &uart0_dma_cfg_tx,
347 #endif
348 };
349
350 struct amba_pl011_data uart1_plat = {
351 #ifdef CONFIG_STE_DMA40
352         .dma_filter = stedma40_filter,
353         .dma_rx_param = &uart1_dma_cfg_rx,
354         .dma_tx_param = &uart1_dma_cfg_tx,
355 #endif
356 };
357
358 struct amba_pl011_data uart2_plat = {
359 #ifdef CONFIG_STE_DMA40
360         .dma_filter = stedma40_filter,
361         .dma_rx_param = &uart2_dma_cfg_rx,
362         .dma_tx_param = &uart2_dma_cfg_tx,
363 #endif
364 };
365
366 static void __init mop500_uart_init(struct device *parent)
367 {
368         db8500_add_uart0(parent, &uart0_plat);
369         db8500_add_uart1(parent, &uart1_plat);
370         db8500_add_uart2(parent, &uart2_plat);
371 }
372
373 static void __init u8500_cryp1_hash1_init(struct device *parent)
374 {
375         db8500_add_cryp1(parent, &u8500_cryp1_platform_data);
376         db8500_add_hash1(parent, &u8500_hash1_platform_data);
377 }
378
379 static struct platform_device *snowball_platform_devs[] __initdata = {
380         &snowball_gpio_en_3v3_regulator_dev,
381         &u8500_cpufreq_cooling_device,
382         &sdi0_regulator,
383 };
384
385 static void __init mop500_init_machine(void)
386 {
387         struct device *parent = NULL;
388         int i;
389
390         platform_device_register(&db8500_prcmu_device);
391         mop500_gpio_keys[0].gpio = GPIO_PROX_SENSOR;
392
393         sdi0_reg_info.enable_gpio = GPIO_SDMMC_EN;
394         sdi0_reg_info.gpios[0].gpio = GPIO_SDMMC_1V8_3V_SEL;
395
396         mop500_pinmaps_init();
397         parent = u8500_init_devices();
398
399         for (i = 0; i < ARRAY_SIZE(mop500_platform_devs); i++)
400                 mop500_platform_devs[i]->dev.parent = parent;
401
402         platform_add_devices(mop500_platform_devs,
403                         ARRAY_SIZE(mop500_platform_devs));
404
405         mop500_i2c_init(parent);
406         mop500_sdi_init(parent);
407         mop500_spi_init(parent);
408         mop500_uart_init(parent);
409         u8500_cryp1_hash1_init(parent);
410
411         /* This board has full regulator constraints */
412         regulator_has_full_constraints();
413 }
414
415
416 static void __init snowball_init_machine(void)
417 {
418         struct device *parent = NULL;
419         int i;
420
421         platform_device_register(&db8500_prcmu_device);
422
423         sdi0_reg_info.enable_gpio = SNOWBALL_SDMMC_EN_GPIO;
424         sdi0_reg_info.gpios[0].gpio = SNOWBALL_SDMMC_1V8_3V_GPIO;
425
426         snowball_pinmaps_init();
427         parent = u8500_init_devices();
428
429         for (i = 0; i < ARRAY_SIZE(snowball_platform_devs); i++)
430                 snowball_platform_devs[i]->dev.parent = parent;
431
432         platform_add_devices(snowball_platform_devs,
433                         ARRAY_SIZE(snowball_platform_devs));
434
435         mop500_i2c_init(parent);
436         snowball_sdi_init(parent);
437         mop500_spi_init(parent);
438         mop500_uart_init(parent);
439
440         u8500_cryp1_hash1_init(parent);
441
442         /* This board has full regulator constraints */
443         regulator_has_full_constraints();
444 }
445
446 static void __init hrefv60_init_machine(void)
447 {
448         struct device *parent = NULL;
449         int i;
450
451         platform_device_register(&db8500_prcmu_device);
452         /*
453          * The HREFv60 board removed a GPIO expander and routed
454          * all these GPIO pins to the internal GPIO controller
455          * instead.
456          */
457         mop500_gpio_keys[0].gpio = HREFV60_PROX_SENSE_GPIO;
458
459         sdi0_reg_info.enable_gpio = HREFV60_SDMMC_EN_GPIO;
460         sdi0_reg_info.gpios[0].gpio = HREFV60_SDMMC_1V8_3V_GPIO;
461
462         hrefv60_pinmaps_init();
463         parent = u8500_init_devices();
464
465         for (i = 0; i < ARRAY_SIZE(mop500_platform_devs); i++)
466                 mop500_platform_devs[i]->dev.parent = parent;
467
468         platform_add_devices(mop500_platform_devs,
469                         ARRAY_SIZE(mop500_platform_devs));
470
471         mop500_i2c_init(parent);
472         hrefv60_sdi_init(parent);
473         mop500_spi_init(parent);
474         mop500_uart_init(parent);
475
476         /* This board has full regulator constraints */
477         regulator_has_full_constraints();
478 }
479
480 MACHINE_START(U8500, "ST-Ericsson MOP500 platform")
481         /* Maintainer: Srinidhi Kasagar <srinidhi.kasagar@stericsson.com> */
482         .atag_offset    = 0x100,
483         .smp            = smp_ops(ux500_smp_ops),
484         .map_io         = u8500_map_io,
485         .init_irq       = ux500_init_irq,
486         /* we re-use nomadik timer here */
487         .init_time      = ux500_timer_init,
488         .init_machine   = mop500_init_machine,
489         .init_late      = ux500_init_late,
490         .restart        = ux500_restart,
491 MACHINE_END
492
493 MACHINE_START(U8520, "ST-Ericsson U8520 Platform HREFP520")
494         .atag_offset    = 0x100,
495         .map_io         = u8500_map_io,
496         .init_irq       = ux500_init_irq,
497         .init_time      = ux500_timer_init,
498         .init_machine   = mop500_init_machine,
499         .init_late      = ux500_init_late,
500         .restart        = ux500_restart,
501 MACHINE_END
502
503 MACHINE_START(HREFV60, "ST-Ericsson U8500 Platform HREFv60+")
504         .atag_offset    = 0x100,
505         .smp            = smp_ops(ux500_smp_ops),
506         .map_io         = u8500_map_io,
507         .init_irq       = ux500_init_irq,
508         .init_time      = ux500_timer_init,
509         .init_machine   = hrefv60_init_machine,
510         .init_late      = ux500_init_late,
511         .restart        = ux500_restart,
512 MACHINE_END
513
514 MACHINE_START(SNOWBALL, "Calao Systems Snowball platform")
515         .atag_offset    = 0x100,
516         .smp            = smp_ops(ux500_smp_ops),
517         .map_io         = u8500_map_io,
518         .init_irq       = ux500_init_irq,
519         /* we re-use nomadik timer here */
520         .init_time      = ux500_timer_init,
521         .init_machine   = snowball_init_machine,
522         .init_late      = NULL,
523         .restart        = ux500_restart,
524 MACHINE_END