]> rtime.felk.cvut.cz Git - can-eth-gw-linux.git/blob - arch/arm/mach-ux500/board-mop500.c
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/signal
[can-eth-gw-linux.git] / 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/io.h>
16 #include <linux/i2c.h>
17 #include <linux/platform_data/i2c-nomadik.h>
18 #include <linux/platform_data/db8500_thermal.h>
19 #include <linux/gpio.h>
20 #include <linux/amba/bus.h>
21 #include <linux/amba/pl022.h>
22 #include <linux/amba/serial.h>
23 #include <linux/spi/spi.h>
24 #include <linux/mfd/abx500/ab8500.h>
25 #include <linux/regulator/ab8500.h>
26 #include <linux/regulator/fixed.h>
27 #include <linux/mfd/tc3589x.h>
28 #include <linux/mfd/tps6105x.h>
29 #include <linux/mfd/abx500/ab8500-gpio.h>
30 #include <linux/mfd/abx500/ab8500-codec.h>
31 #include <linux/leds-lp5521.h>
32 #include <linux/input.h>
33 #include <linux/smsc911x.h>
34 #include <linux/gpio_keys.h>
35 #include <linux/delay.h>
36 #include <linux/of.h>
37 #include <linux/of_platform.h>
38 #include <linux/leds.h>
39 #include <linux/pinctrl/consumer.h>
40 #include <linux/platform_data/pinctrl-nomadik.h>
41
42 #include <asm/mach-types.h>
43 #include <asm/mach/arch.h>
44 #include <asm/hardware/gic.h>
45
46 #include <plat/ste_dma40.h>
47
48 #include <mach/hardware.h>
49 #include <mach/setup.h>
50 #include <mach/devices.h>
51 #include <mach/irqs.h>
52 #include <linux/platform_data/crypto-ux500.h>
53
54 #include "ste-dma40-db8500.h"
55 #include "devices-db8500.h"
56 #include "board-mop500.h"
57 #include "board-mop500-regulators.h"
58
59 static struct gpio_led snowball_led_array[] = {
60         {
61                 .name = "user_led",
62                 .default_trigger = "heartbeat",
63                 .gpio = 142,
64         },
65 };
66
67 static struct gpio_led_platform_data snowball_led_data = {
68         .leds = snowball_led_array,
69         .num_leds = ARRAY_SIZE(snowball_led_array),
70 };
71
72 static struct platform_device snowball_led_dev = {
73         .name = "leds-gpio",
74         .dev = {
75                 .platform_data = &snowball_led_data,
76         },
77 };
78
79 static struct fixed_voltage_config snowball_gpio_en_3v3_data = {
80        .supply_name            = "EN-3V3",
81        .gpio                   = SNOWBALL_EN_3V3_ETH_GPIO,
82        .microvolts             = 3300000,
83        .enable_high            = 1,
84        .init_data              = &gpio_en_3v3_regulator,
85        .startup_delay          = 5000, /* 1200us */
86 };
87
88 static struct platform_device snowball_gpio_en_3v3_regulator_dev = {
89        .name   = "reg-fixed-voltage",
90        .id     = 1,
91        .dev    = {
92                .platform_data  = &snowball_gpio_en_3v3_data,
93        },
94 };
95
96 static struct ab8500_gpio_platform_data ab8500_gpio_pdata = {
97         .gpio_base              = MOP500_AB8500_PIN_GPIO(1),
98         .irq_base               = MOP500_AB8500_VIR_GPIO_IRQ_BASE,
99         /* config_reg is the initial configuration of ab8500 pins.
100          * The pins can be configured as GPIO or alt functions based
101          * on value present in GpioSel1 to GpioSel6 and AlternatFunction
102          * register. This is the array of 7 configuration settings.
103          * One has to compile time decide these settings. Below is the
104          * explanation of these setting
105          * GpioSel1 = 0x00 => Pins GPIO1 to GPIO8 are not used as GPIO
106          * GpioSel2 = 0x1E => Pins GPIO10 to GPIO13 are configured as GPIO
107          * GpioSel3 = 0x80 => Pin GPIO24 is configured as GPIO
108          * GpioSel4 = 0x01 => Pin GPIo25 is configured as GPIO
109          * GpioSel5 = 0x7A => Pins GPIO34, GPIO36 to GPIO39 are conf as GPIO
110          * GpioSel6 = 0x00 => Pins GPIO41 & GPIo42 are not configured as GPIO
111          * AlternaFunction = 0x00 => If Pins GPIO10 to 13 are not configured
112          * as GPIO then this register selectes the alternate fucntions
113          */
114         .config_reg             = {0x00, 0x1E, 0x80, 0x01,
115                                         0x7A, 0x00, 0x00},
116 };
117
118 /* ab8500-codec */
119 static struct ab8500_codec_platform_data ab8500_codec_pdata = {
120         .amics =  {
121                 .mic1_type = AMIC_TYPE_DIFFERENTIAL,
122                 .mic2_type = AMIC_TYPE_DIFFERENTIAL,
123                 .mic1a_micbias = AMIC_MICBIAS_VAMIC1,
124                 .mic1b_micbias = AMIC_MICBIAS_VAMIC1,
125                 .mic2_micbias = AMIC_MICBIAS_VAMIC2
126         },
127         .ear_cmv = EAR_CMV_0_95V
128 };
129
130 static struct gpio_keys_button snowball_key_array[] = {
131         {
132                 .gpio           = 32,
133                 .type           = EV_KEY,
134                 .code           = KEY_1,
135                 .desc           = "userpb",
136                 .active_low     = 1,
137                 .debounce_interval = 50,
138                 .wakeup         = 1,
139         },
140         {
141                 .gpio           = 151,
142                 .type           = EV_KEY,
143                 .code           = KEY_2,
144                 .desc           = "extkb1",
145                 .active_low     = 1,
146                 .debounce_interval = 50,
147                 .wakeup         = 1,
148         },
149         {
150                 .gpio           = 152,
151                 .type           = EV_KEY,
152                 .code           = KEY_3,
153                 .desc           = "extkb2",
154                 .active_low     = 1,
155                 .debounce_interval = 50,
156                 .wakeup         = 1,
157         },
158         {
159                 .gpio           = 161,
160                 .type           = EV_KEY,
161                 .code           = KEY_4,
162                 .desc           = "extkb3",
163                 .active_low     = 1,
164                 .debounce_interval = 50,
165                 .wakeup         = 1,
166         },
167         {
168                 .gpio           = 162,
169                 .type           = EV_KEY,
170                 .code           = KEY_5,
171                 .desc           = "extkb4",
172                 .active_low     = 1,
173                 .debounce_interval = 50,
174                 .wakeup         = 1,
175         },
176 };
177
178 static struct gpio_keys_platform_data snowball_key_data = {
179         .buttons        = snowball_key_array,
180         .nbuttons       = ARRAY_SIZE(snowball_key_array),
181 };
182
183 static struct platform_device snowball_key_dev = {
184         .name           = "gpio-keys",
185         .id             = -1,
186         .dev            = {
187                 .platform_data  = &snowball_key_data,
188         }
189 };
190
191 static struct smsc911x_platform_config snowball_sbnet_cfg = {
192         .irq_polarity = SMSC911X_IRQ_POLARITY_ACTIVE_HIGH,
193         .irq_type = SMSC911X_IRQ_TYPE_PUSH_PULL,
194         .flags = SMSC911X_USE_16BIT | SMSC911X_FORCE_INTERNAL_PHY,
195         .shift = 1,
196 };
197
198 static struct resource sbnet_res[] = {
199         {
200                 .name = "smsc911x-memory",
201                 .start = (0x5000 << 16),
202                 .end  =  (0x5000 << 16) + 0xffff,
203                 .flags = IORESOURCE_MEM,
204         },
205         {
206                 .start = NOMADIK_GPIO_TO_IRQ(140),
207                 .end = NOMADIK_GPIO_TO_IRQ(140),
208                 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE,
209         },
210 };
211
212 static struct platform_device snowball_sbnet_dev = {
213         .name           = "smsc911x",
214         .num_resources  = ARRAY_SIZE(sbnet_res),
215         .resource       = sbnet_res,
216         .dev            = {
217                 .platform_data = &snowball_sbnet_cfg,
218         },
219 };
220
221 static struct ab8500_platform_data ab8500_platdata = {
222         .irq_base       = MOP500_AB8500_IRQ_BASE,
223         .regulator_reg_init = ab8500_regulator_reg_init,
224         .num_regulator_reg_init = ARRAY_SIZE(ab8500_regulator_reg_init),
225         .regulator      = ab8500_regulators,
226         .num_regulator  = ARRAY_SIZE(ab8500_regulators),
227         .gpio           = &ab8500_gpio_pdata,
228         .codec          = &ab8500_codec_pdata,
229 };
230
231 /*
232  * Thermal Sensor
233  */
234
235 static struct resource db8500_thsens_resources[] = {
236         {
237                 .name = "IRQ_HOTMON_LOW",
238                 .start  = IRQ_PRCMU_HOTMON_LOW,
239                 .end    = IRQ_PRCMU_HOTMON_LOW,
240                 .flags  = IORESOURCE_IRQ,
241         },
242         {
243                 .name = "IRQ_HOTMON_HIGH",
244                 .start  = IRQ_PRCMU_HOTMON_HIGH,
245                 .end    = IRQ_PRCMU_HOTMON_HIGH,
246                 .flags  = IORESOURCE_IRQ,
247         },
248 };
249
250 static struct db8500_thsens_platform_data db8500_thsens_data = {
251         .trip_points[0] = {
252                 .temp = 70000,
253                 .type = THERMAL_TRIP_ACTIVE,
254                 .cdev_name = {
255                         [0] = "thermal-cpufreq-0",
256                 },
257         },
258         .trip_points[1] = {
259                 .temp = 75000,
260                 .type = THERMAL_TRIP_ACTIVE,
261                 .cdev_name = {
262                         [0] = "thermal-cpufreq-0",
263                 },
264         },
265         .trip_points[2] = {
266                 .temp = 80000,
267                 .type = THERMAL_TRIP_ACTIVE,
268                 .cdev_name = {
269                         [0] = "thermal-cpufreq-0",
270                 },
271         },
272         .trip_points[3] = {
273                 .temp = 85000,
274                 .type = THERMAL_TRIP_CRITICAL,
275         },
276         .num_trips = 4,
277 };
278
279 static struct platform_device u8500_thsens_device = {
280         .name           = "db8500-thermal",
281         .resource       = db8500_thsens_resources,
282         .num_resources  = ARRAY_SIZE(db8500_thsens_resources),
283         .dev    = {
284                 .platform_data  = &db8500_thsens_data,
285         },
286 };
287
288 static struct platform_device u8500_cpufreq_cooling_device = {
289         .name           = "db8500-cpufreq-cooling",
290 };
291
292 /*
293  * TPS61052
294  */
295
296 static struct tps6105x_platform_data mop500_tps61052_data = {
297         .mode = TPS6105X_MODE_VOLTAGE,
298         .regulator_data = &tps61052_regulator,
299 };
300
301 /*
302  * TC35892
303  */
304
305 static void mop500_tc35892_init(struct tc3589x *tc3589x, unsigned int base)
306 {
307         struct device *parent = NULL;
308 #if 0
309         /* FIXME: Is the sdi actually part of tc3589x? */
310         parent = tc3589x->dev;
311 #endif
312         mop500_sdi_tc35892_init(parent);
313 }
314
315 static struct tc3589x_gpio_platform_data mop500_tc35892_gpio_data = {
316         .gpio_base      = MOP500_EGPIO(0),
317         .setup          = mop500_tc35892_init,
318 };
319
320 static struct tc3589x_platform_data mop500_tc35892_data = {
321         .block          = TC3589x_BLOCK_GPIO,
322         .gpio           = &mop500_tc35892_gpio_data,
323         .irq_base       = MOP500_EGPIO_IRQ_BASE,
324 };
325
326 static struct lp5521_led_config lp5521_pri_led[] = {
327        [0] = {
328                .chan_nr = 0,
329                .led_current = 0x2f,
330                .max_current = 0x5f,
331        },
332        [1] = {
333                .chan_nr = 1,
334                .led_current = 0x2f,
335                .max_current = 0x5f,
336        },
337        [2] = {
338                .chan_nr = 2,
339                .led_current = 0x2f,
340                .max_current = 0x5f,
341        },
342 };
343
344 static struct lp5521_platform_data __initdata lp5521_pri_data = {
345        .label = "lp5521_pri",
346        .led_config     = &lp5521_pri_led[0],
347        .num_channels   = 3,
348        .clock_mode     = LP5521_CLOCK_EXT,
349 };
350
351 static struct lp5521_led_config lp5521_sec_led[] = {
352        [0] = {
353                .chan_nr = 0,
354                .led_current = 0x2f,
355                .max_current = 0x5f,
356        },
357        [1] = {
358                .chan_nr = 1,
359                .led_current = 0x2f,
360                .max_current = 0x5f,
361        },
362        [2] = {
363                .chan_nr = 2,
364                .led_current = 0x2f,
365                .max_current = 0x5f,
366        },
367 };
368
369 static struct lp5521_platform_data __initdata lp5521_sec_data = {
370        .label = "lp5521_sec",
371        .led_config     = &lp5521_sec_led[0],
372        .num_channels   = 3,
373        .clock_mode     = LP5521_CLOCK_EXT,
374 };
375
376 static struct i2c_board_info __initdata mop500_i2c0_devices[] = {
377         {
378                 I2C_BOARD_INFO("tc3589x", 0x42),
379                 .irq            = NOMADIK_GPIO_TO_IRQ(217),
380                 .platform_data  = &mop500_tc35892_data,
381         },
382         /* I2C0 devices only available prior to HREFv60 */
383         {
384                 I2C_BOARD_INFO("tps61052", 0x33),
385                 .platform_data  = &mop500_tps61052_data,
386         },
387 };
388
389 #define NUM_PRE_V60_I2C0_DEVICES 1
390
391 static struct i2c_board_info __initdata mop500_i2c2_devices[] = {
392         {
393                 /* lp5521 LED driver, 1st device */
394                 I2C_BOARD_INFO("lp5521", 0x33),
395                 .platform_data = &lp5521_pri_data,
396         },
397         {
398                 /* lp5521 LED driver, 2st device */
399                 I2C_BOARD_INFO("lp5521", 0x34),
400                 .platform_data = &lp5521_sec_data,
401         },
402         {
403                 /* Light sensor Rohm BH1780GLI */
404                 I2C_BOARD_INFO("bh1780", 0x29),
405         },
406 };
407
408 static void __init mop500_i2c_init(struct device *parent)
409 {
410         db8500_add_i2c0(parent, NULL);
411         db8500_add_i2c1(parent, NULL);
412         db8500_add_i2c2(parent, NULL);
413         db8500_add_i2c3(parent, NULL);
414 }
415
416 static struct gpio_keys_button mop500_gpio_keys[] = {
417         {
418                 .desc                   = "SFH7741 Proximity Sensor",
419                 .type                   = EV_SW,
420                 .code                   = SW_FRONT_PROXIMITY,
421                 .active_low             = 0,
422                 .can_disable            = 1,
423         }
424 };
425
426 static struct regulator *prox_regulator;
427 static int mop500_prox_activate(struct device *dev);
428 static void mop500_prox_deactivate(struct device *dev);
429
430 static struct gpio_keys_platform_data mop500_gpio_keys_data = {
431         .buttons        = mop500_gpio_keys,
432         .nbuttons       = ARRAY_SIZE(mop500_gpio_keys),
433         .enable         = mop500_prox_activate,
434         .disable        = mop500_prox_deactivate,
435 };
436
437 static struct platform_device mop500_gpio_keys_device = {
438         .name   = "gpio-keys",
439         .id     = 0,
440         .dev    = {
441                 .platform_data  = &mop500_gpio_keys_data,
442         },
443 };
444
445 static int mop500_prox_activate(struct device *dev)
446 {
447         prox_regulator = regulator_get(&mop500_gpio_keys_device.dev,
448                                                 "vcc");
449         if (IS_ERR(prox_regulator)) {
450                 dev_err(&mop500_gpio_keys_device.dev,
451                         "no regulator\n");
452                 return PTR_ERR(prox_regulator);
453         }
454         regulator_enable(prox_regulator);
455         return 0;
456 }
457
458 static void mop500_prox_deactivate(struct device *dev)
459 {
460         regulator_disable(prox_regulator);
461         regulator_put(prox_regulator);
462 }
463
464 static struct cryp_platform_data u8500_cryp1_platform_data = {
465                 .mem_to_engine = {
466                                 .dir = STEDMA40_MEM_TO_PERIPH,
467                                 .src_dev_type = STEDMA40_DEV_SRC_MEMORY,
468                                 .dst_dev_type = DB8500_DMA_DEV48_CAC1_TX,
469                                 .src_info.data_width = STEDMA40_WORD_WIDTH,
470                                 .dst_info.data_width = STEDMA40_WORD_WIDTH,
471                                 .mode = STEDMA40_MODE_LOGICAL,
472                                 .src_info.psize = STEDMA40_PSIZE_LOG_4,
473                                 .dst_info.psize = STEDMA40_PSIZE_LOG_4,
474                 },
475                 .engine_to_mem = {
476                                 .dir = STEDMA40_PERIPH_TO_MEM,
477                                 .src_dev_type = DB8500_DMA_DEV48_CAC1_RX,
478                                 .dst_dev_type = STEDMA40_DEV_DST_MEMORY,
479                                 .src_info.data_width = STEDMA40_WORD_WIDTH,
480                                 .dst_info.data_width = STEDMA40_WORD_WIDTH,
481                                 .mode = STEDMA40_MODE_LOGICAL,
482                                 .src_info.psize = STEDMA40_PSIZE_LOG_4,
483                                 .dst_info.psize = STEDMA40_PSIZE_LOG_4,
484                 }
485 };
486
487 static struct stedma40_chan_cfg u8500_hash_dma_cfg_tx = {
488                 .dir = STEDMA40_MEM_TO_PERIPH,
489                 .src_dev_type = STEDMA40_DEV_SRC_MEMORY,
490                 .dst_dev_type = DB8500_DMA_DEV50_HAC1_TX,
491                 .src_info.data_width = STEDMA40_WORD_WIDTH,
492                 .dst_info.data_width = STEDMA40_WORD_WIDTH,
493                 .mode = STEDMA40_MODE_LOGICAL,
494                 .src_info.psize = STEDMA40_PSIZE_LOG_16,
495                 .dst_info.psize = STEDMA40_PSIZE_LOG_16,
496 };
497
498 static struct hash_platform_data u8500_hash1_platform_data = {
499                 .mem_to_engine = &u8500_hash_dma_cfg_tx,
500                 .dma_filter = stedma40_filter,
501 };
502
503 /* add any platform devices here - TODO */
504 static struct platform_device *mop500_platform_devs[] __initdata = {
505         &mop500_gpio_keys_device,
506 };
507
508 #ifdef CONFIG_STE_DMA40
509 static struct stedma40_chan_cfg ssp0_dma_cfg_rx = {
510         .mode = STEDMA40_MODE_LOGICAL,
511         .dir = STEDMA40_PERIPH_TO_MEM,
512         .src_dev_type =  DB8500_DMA_DEV8_SSP0_RX,
513         .dst_dev_type = STEDMA40_DEV_DST_MEMORY,
514         .src_info.data_width = STEDMA40_BYTE_WIDTH,
515         .dst_info.data_width = STEDMA40_BYTE_WIDTH,
516 };
517
518 static struct stedma40_chan_cfg ssp0_dma_cfg_tx = {
519         .mode = STEDMA40_MODE_LOGICAL,
520         .dir = STEDMA40_MEM_TO_PERIPH,
521         .src_dev_type = STEDMA40_DEV_SRC_MEMORY,
522         .dst_dev_type = DB8500_DMA_DEV8_SSP0_TX,
523         .src_info.data_width = STEDMA40_BYTE_WIDTH,
524         .dst_info.data_width = STEDMA40_BYTE_WIDTH,
525 };
526 #endif
527
528 static struct pl022_ssp_controller ssp0_plat = {
529         .bus_id = 0,
530 #ifdef CONFIG_STE_DMA40
531         .enable_dma = 1,
532         .dma_filter = stedma40_filter,
533         .dma_rx_param = &ssp0_dma_cfg_rx,
534         .dma_tx_param = &ssp0_dma_cfg_tx,
535 #else
536         .enable_dma = 0,
537 #endif
538         /* on this platform, gpio 31,142,144,214 &
539          * 224 are connected as chip selects
540          */
541         .num_chipselect = 5,
542 };
543
544 static void __init mop500_spi_init(struct device *parent)
545 {
546         db8500_add_ssp0(parent, &ssp0_plat);
547 }
548
549 #ifdef CONFIG_STE_DMA40
550 static struct stedma40_chan_cfg uart0_dma_cfg_rx = {
551         .mode = STEDMA40_MODE_LOGICAL,
552         .dir = STEDMA40_PERIPH_TO_MEM,
553         .src_dev_type =  DB8500_DMA_DEV13_UART0_RX,
554         .dst_dev_type = STEDMA40_DEV_DST_MEMORY,
555         .src_info.data_width = STEDMA40_BYTE_WIDTH,
556         .dst_info.data_width = STEDMA40_BYTE_WIDTH,
557 };
558
559 static struct stedma40_chan_cfg uart0_dma_cfg_tx = {
560         .mode = STEDMA40_MODE_LOGICAL,
561         .dir = STEDMA40_MEM_TO_PERIPH,
562         .src_dev_type = STEDMA40_DEV_SRC_MEMORY,
563         .dst_dev_type = DB8500_DMA_DEV13_UART0_TX,
564         .src_info.data_width = STEDMA40_BYTE_WIDTH,
565         .dst_info.data_width = STEDMA40_BYTE_WIDTH,
566 };
567
568 static struct stedma40_chan_cfg uart1_dma_cfg_rx = {
569         .mode = STEDMA40_MODE_LOGICAL,
570         .dir = STEDMA40_PERIPH_TO_MEM,
571         .src_dev_type =  DB8500_DMA_DEV12_UART1_RX,
572         .dst_dev_type = STEDMA40_DEV_DST_MEMORY,
573         .src_info.data_width = STEDMA40_BYTE_WIDTH,
574         .dst_info.data_width = STEDMA40_BYTE_WIDTH,
575 };
576
577 static struct stedma40_chan_cfg uart1_dma_cfg_tx = {
578         .mode = STEDMA40_MODE_LOGICAL,
579         .dir = STEDMA40_MEM_TO_PERIPH,
580         .src_dev_type = STEDMA40_DEV_SRC_MEMORY,
581         .dst_dev_type = DB8500_DMA_DEV12_UART1_TX,
582         .src_info.data_width = STEDMA40_BYTE_WIDTH,
583         .dst_info.data_width = STEDMA40_BYTE_WIDTH,
584 };
585
586 static struct stedma40_chan_cfg uart2_dma_cfg_rx = {
587         .mode = STEDMA40_MODE_LOGICAL,
588         .dir = STEDMA40_PERIPH_TO_MEM,
589         .src_dev_type =  DB8500_DMA_DEV11_UART2_RX,
590         .dst_dev_type = STEDMA40_DEV_DST_MEMORY,
591         .src_info.data_width = STEDMA40_BYTE_WIDTH,
592         .dst_info.data_width = STEDMA40_BYTE_WIDTH,
593 };
594
595 static struct stedma40_chan_cfg uart2_dma_cfg_tx = {
596         .mode = STEDMA40_MODE_LOGICAL,
597         .dir = STEDMA40_MEM_TO_PERIPH,
598         .src_dev_type = STEDMA40_DEV_SRC_MEMORY,
599         .dst_dev_type = DB8500_DMA_DEV11_UART2_TX,
600         .src_info.data_width = STEDMA40_BYTE_WIDTH,
601         .dst_info.data_width = STEDMA40_BYTE_WIDTH,
602 };
603 #endif
604
605 static struct amba_pl011_data uart0_plat = {
606 #ifdef CONFIG_STE_DMA40
607         .dma_filter = stedma40_filter,
608         .dma_rx_param = &uart0_dma_cfg_rx,
609         .dma_tx_param = &uart0_dma_cfg_tx,
610 #endif
611 };
612
613 static struct amba_pl011_data uart1_plat = {
614 #ifdef CONFIG_STE_DMA40
615         .dma_filter = stedma40_filter,
616         .dma_rx_param = &uart1_dma_cfg_rx,
617         .dma_tx_param = &uart1_dma_cfg_tx,
618 #endif
619 };
620
621 static struct amba_pl011_data uart2_plat = {
622 #ifdef CONFIG_STE_DMA40
623         .dma_filter = stedma40_filter,
624         .dma_rx_param = &uart2_dma_cfg_rx,
625         .dma_tx_param = &uart2_dma_cfg_tx,
626 #endif
627 };
628
629 static void __init mop500_uart_init(struct device *parent)
630 {
631         db8500_add_uart0(parent, &uart0_plat);
632         db8500_add_uart1(parent, &uart1_plat);
633         db8500_add_uart2(parent, &uart2_plat);
634 }
635
636 static void __init u8500_cryp1_hash1_init(struct device *parent)
637 {
638         db8500_add_cryp1(parent, &u8500_cryp1_platform_data);
639         db8500_add_hash1(parent, &u8500_hash1_platform_data);
640 }
641
642 static struct platform_device *snowball_platform_devs[] __initdata = {
643         &snowball_led_dev,
644         &snowball_key_dev,
645         &snowball_sbnet_dev,
646         &snowball_gpio_en_3v3_regulator_dev,
647         &u8500_thsens_device,
648         &u8500_cpufreq_cooling_device,
649 };
650
651 static void __init mop500_init_machine(void)
652 {
653         struct device *parent = NULL;
654         int i2c0_devs;
655         int i;
656
657         mop500_gpio_keys[0].gpio = GPIO_PROX_SENSOR;
658
659         mop500_pinmaps_init();
660         parent = u8500_init_devices(&ab8500_platdata);
661
662         for (i = 0; i < ARRAY_SIZE(mop500_platform_devs); i++)
663                 mop500_platform_devs[i]->dev.parent = parent;
664
665         platform_add_devices(mop500_platform_devs,
666                         ARRAY_SIZE(mop500_platform_devs));
667
668         mop500_i2c_init(parent);
669         mop500_sdi_init(parent);
670         mop500_spi_init(parent);
671         mop500_audio_init(parent);
672         mop500_uart_init(parent);
673
674         u8500_cryp1_hash1_init(parent);
675
676         i2c0_devs = ARRAY_SIZE(mop500_i2c0_devices);
677
678         i2c_register_board_info(0, mop500_i2c0_devices, i2c0_devs);
679         i2c_register_board_info(2, mop500_i2c2_devices,
680                                 ARRAY_SIZE(mop500_i2c2_devices));
681
682         /* This board has full regulator constraints */
683         regulator_has_full_constraints();
684
685         mop500_uib_init();
686 }
687
688 static void __init snowball_init_machine(void)
689 {
690         struct device *parent = NULL;
691         int i;
692
693         snowball_pinmaps_init();
694         parent = u8500_init_devices(&ab8500_platdata);
695
696         for (i = 0; i < ARRAY_SIZE(snowball_platform_devs); i++)
697                 snowball_platform_devs[i]->dev.parent = parent;
698
699         platform_add_devices(snowball_platform_devs,
700                         ARRAY_SIZE(snowball_platform_devs));
701
702         mop500_i2c_init(parent);
703         snowball_sdi_init(parent);
704         mop500_spi_init(parent);
705         mop500_audio_init(parent);
706         mop500_uart_init(parent);
707
708         /* This board has full regulator constraints */
709         regulator_has_full_constraints();
710 }
711
712 static void __init hrefv60_init_machine(void)
713 {
714         struct device *parent = NULL;
715         int i2c0_devs;
716         int i;
717
718         /*
719          * The HREFv60 board removed a GPIO expander and routed
720          * all these GPIO pins to the internal GPIO controller
721          * instead.
722          */
723         mop500_gpio_keys[0].gpio = HREFV60_PROX_SENSE_GPIO;
724
725         hrefv60_pinmaps_init();
726         parent = u8500_init_devices(&ab8500_platdata);
727
728         for (i = 0; i < ARRAY_SIZE(mop500_platform_devs); i++)
729                 mop500_platform_devs[i]->dev.parent = parent;
730
731         platform_add_devices(mop500_platform_devs,
732                         ARRAY_SIZE(mop500_platform_devs));
733
734         mop500_i2c_init(parent);
735         hrefv60_sdi_init(parent);
736         mop500_spi_init(parent);
737         mop500_audio_init(parent);
738         mop500_uart_init(parent);
739
740         i2c0_devs = ARRAY_SIZE(mop500_i2c0_devices);
741
742         i2c0_devs -= NUM_PRE_V60_I2C0_DEVICES;
743
744         i2c_register_board_info(0, mop500_i2c0_devices, i2c0_devs);
745         i2c_register_board_info(2, mop500_i2c2_devices,
746                                 ARRAY_SIZE(mop500_i2c2_devices));
747
748         /* This board has full regulator constraints */
749         regulator_has_full_constraints();
750
751         mop500_uib_init();
752 }
753
754 MACHINE_START(U8500, "ST-Ericsson MOP500 platform")
755         /* Maintainer: Srinidhi Kasagar <srinidhi.kasagar@stericsson.com> */
756         .atag_offset    = 0x100,
757         .smp            = smp_ops(ux500_smp_ops),
758         .map_io         = u8500_map_io,
759         .init_irq       = ux500_init_irq,
760         /* we re-use nomadik timer here */
761         .timer          = &ux500_timer,
762         .handle_irq     = gic_handle_irq,
763         .init_machine   = mop500_init_machine,
764         .init_late      = ux500_init_late,
765 MACHINE_END
766
767 MACHINE_START(U8520, "ST-Ericsson U8520 Platform HREFP520")
768         .atag_offset    = 0x100,
769         .map_io         = u8500_map_io,
770         .init_irq       = ux500_init_irq,
771         .timer          = &ux500_timer,
772         .handle_irq     = gic_handle_irq,
773         .init_machine   = mop500_init_machine,
774         .init_late      = ux500_init_late,
775 MACHINE_END
776
777 MACHINE_START(HREFV60, "ST-Ericsson U8500 Platform HREFv60+")
778         .atag_offset    = 0x100,
779         .smp            = smp_ops(ux500_smp_ops),
780         .map_io         = u8500_map_io,
781         .init_irq       = ux500_init_irq,
782         .timer          = &ux500_timer,
783         .handle_irq     = gic_handle_irq,
784         .init_machine   = hrefv60_init_machine,
785         .init_late      = ux500_init_late,
786 MACHINE_END
787
788 MACHINE_START(SNOWBALL, "Calao Systems Snowball platform")
789         .atag_offset    = 0x100,
790         .smp            = smp_ops(ux500_smp_ops),
791         .map_io         = u8500_map_io,
792         .init_irq       = ux500_init_irq,
793         /* we re-use nomadik timer here */
794         .timer          = &ux500_timer,
795         .handle_irq     = gic_handle_irq,
796         .init_machine   = snowball_init_machine,
797         .init_late      = ux500_init_late,
798 MACHINE_END
799
800 #ifdef CONFIG_MACH_UX500_DT
801
802 struct of_dev_auxdata u8500_auxdata_lookup[] __initdata = {
803         /* Requires call-back bindings. */
804         OF_DEV_AUXDATA("arm,cortex-a9-pmu", 0, "arm-pmu", &db8500_pmu_platdata),
805         /* Requires DMA and call-back bindings. */
806         OF_DEV_AUXDATA("arm,pl011", 0x80120000, "uart0", &uart0_plat),
807         OF_DEV_AUXDATA("arm,pl011", 0x80121000, "uart1", &uart1_plat),
808         OF_DEV_AUXDATA("arm,pl011", 0x80007000, "uart2", &uart2_plat),
809         /* Requires DMA bindings. */
810         OF_DEV_AUXDATA("arm,pl022", 0x80002000, "ssp0",  &ssp0_plat),
811         OF_DEV_AUXDATA("arm,pl18x", 0x80126000, "sdi0",  &mop500_sdi0_data),
812         OF_DEV_AUXDATA("arm,pl18x", 0x80118000, "sdi1",  &mop500_sdi1_data),
813         OF_DEV_AUXDATA("arm,pl18x", 0x80005000, "sdi2",  &mop500_sdi2_data),
814         OF_DEV_AUXDATA("arm,pl18x", 0x80114000, "sdi4",  &mop500_sdi4_data),
815         /* Requires clock name bindings. */
816         OF_DEV_AUXDATA("st,nomadik-gpio", 0x8012e000, "gpio.0", NULL),
817         OF_DEV_AUXDATA("st,nomadik-gpio", 0x8012e080, "gpio.1", NULL),
818         OF_DEV_AUXDATA("st,nomadik-gpio", 0x8000e000, "gpio.2", NULL),
819         OF_DEV_AUXDATA("st,nomadik-gpio", 0x8000e080, "gpio.3", NULL),
820         OF_DEV_AUXDATA("st,nomadik-gpio", 0x8000e100, "gpio.4", NULL),
821         OF_DEV_AUXDATA("st,nomadik-gpio", 0x8000e180, "gpio.5", NULL),
822         OF_DEV_AUXDATA("st,nomadik-gpio", 0x8011e000, "gpio.6", NULL),
823         OF_DEV_AUXDATA("st,nomadik-gpio", 0x8011e080, "gpio.7", NULL),
824         OF_DEV_AUXDATA("st,nomadik-gpio", 0xa03fe000, "gpio.8", NULL),
825         OF_DEV_AUXDATA("st,nomadik-i2c", 0x80004000, "nmk-i2c.0", NULL),
826         OF_DEV_AUXDATA("st,nomadik-i2c", 0x80122000, "nmk-i2c.1", NULL),
827         OF_DEV_AUXDATA("st,nomadik-i2c", 0x80128000, "nmk-i2c.2", NULL),
828         OF_DEV_AUXDATA("st,nomadik-i2c", 0x80110000, "nmk-i2c.3", NULL),
829         OF_DEV_AUXDATA("st,nomadik-i2c", 0x8012a000, "nmk-i2c.4", NULL),
830         /* Requires device name bindings. */
831         OF_DEV_AUXDATA("stericsson,nmk_pinctrl", 0, "pinctrl-db8500", NULL),
832         /* Requires clock name and DMA bindings. */
833         OF_DEV_AUXDATA("stericsson,ux500-msp-i2s", 0x80123000,
834                 "ux500-msp-i2s.0", &msp0_platform_data),
835         OF_DEV_AUXDATA("stericsson,ux500-msp-i2s", 0x80124000,
836                 "ux500-msp-i2s.1", &msp1_platform_data),
837         OF_DEV_AUXDATA("stericsson,ux500-msp-i2s", 0x80117000,
838                 "ux500-msp-i2s.2", &msp2_platform_data),
839         OF_DEV_AUXDATA("stericsson,ux500-msp-i2s", 0x80125000,
840                 "ux500-msp-i2s.3", &msp3_platform_data),
841         {},
842 };
843
844 static const struct of_device_id u8500_local_bus_nodes[] = {
845         /* only create devices below soc node */
846         { .compatible = "stericsson,db8500", },
847         { .compatible = "stericsson,db8500-prcmu", },
848         { .compatible = "simple-bus"},
849         { },
850 };
851
852 static void __init u8500_init_machine(void)
853 {
854         struct device *parent = NULL;
855         int i2c0_devs;
856         int i;
857
858         /* Pinmaps must be in place before devices register */
859         if (of_machine_is_compatible("st-ericsson,mop500"))
860                 mop500_pinmaps_init();
861         else if (of_machine_is_compatible("calaosystems,snowball-a9500"))
862                 snowball_pinmaps_init();
863         else if (of_machine_is_compatible("st-ericsson,hrefv60+"))
864                 hrefv60_pinmaps_init();
865
866         parent = u8500_of_init_devices();
867
868         for (i = 0; i < ARRAY_SIZE(mop500_platform_devs); i++)
869                 mop500_platform_devs[i]->dev.parent = parent;
870
871         /* automatically probe child nodes of db8500 device */
872         of_platform_populate(NULL, u8500_local_bus_nodes, u8500_auxdata_lookup, parent);
873
874         if (of_machine_is_compatible("st-ericsson,mop500")) {
875                 mop500_gpio_keys[0].gpio = GPIO_PROX_SENSOR;
876
877                 platform_add_devices(mop500_platform_devs,
878                                 ARRAY_SIZE(mop500_platform_devs));
879
880                 mop500_sdi_init(parent);
881                 mop500_audio_init(parent);
882                 i2c0_devs = ARRAY_SIZE(mop500_i2c0_devices);
883                 i2c_register_board_info(0, mop500_i2c0_devices, i2c0_devs);
884                 i2c_register_board_info(2, mop500_i2c2_devices,
885                                         ARRAY_SIZE(mop500_i2c2_devices));
886
887                 mop500_uib_init();
888
889         } else if (of_machine_is_compatible("calaosystems,snowball-a9500")) {
890                 mop500_of_audio_init(parent);
891         } else if (of_machine_is_compatible("st-ericsson,hrefv60+")) {
892                 /*
893                  * The HREFv60 board removed a GPIO expander and routed
894                  * all these GPIO pins to the internal GPIO controller
895                  * instead.
896                  */
897                 mop500_gpio_keys[0].gpio = HREFV60_PROX_SENSE_GPIO;
898                 platform_add_devices(mop500_platform_devs,
899                                 ARRAY_SIZE(mop500_platform_devs));
900
901                 mop500_uib_init();
902         }
903
904         /* This board has full regulator constraints */
905         regulator_has_full_constraints();
906 }
907
908 static const char * u8500_dt_board_compat[] = {
909         "calaosystems,snowball-a9500",
910         "st-ericsson,hrefv60+",
911         "st-ericsson,u8500",
912         "st-ericsson,mop500",
913         NULL,
914 };
915
916
917 DT_MACHINE_START(U8500_DT, "ST-Ericsson U8500 platform (Device Tree Support)")
918         .smp            = smp_ops(ux500_smp_ops),
919         .map_io         = u8500_map_io,
920         .init_irq       = ux500_init_irq,
921         /* we re-use nomadik timer here */
922         .timer          = &ux500_timer,
923         .handle_irq     = gic_handle_irq,
924         .init_machine   = u8500_init_machine,
925         .init_late      = ux500_init_late,
926         .dt_compat      = u8500_dt_board_compat,
927 MACHINE_END
928 #endif