blob: 77d03c1fbd04551982dd97dcf055ef520ca664ea [file] [log] [blame]
Srinidhi Kasagaraa44ef42009-11-28 08:17:18 +01001/*
2 * Copyright (C) 2008-2009 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>
Rabin Vincentb8410a12010-08-09 19:18:17 +053016#include <linux/i2c.h>
Rabin Vincentea05a572010-06-03 07:58:42 +010017#include <linux/gpio.h>
Srinidhi Kasagaraa44ef42009-11-28 08:17:18 +010018#include <linux/amba/bus.h>
19#include <linux/amba/pl022.h>
Linus Walleij5d7b8462010-10-14 13:57:59 +020020#include <linux/amba/serial.h>
Srinidhi Kasagaraa44ef42009-11-28 08:17:18 +010021#include <linux/spi/spi.h>
Linus Walleijee66e652011-12-02 14:16:33 +010022#include <linux/mfd/abx500/ab8500.h>
Bengt Jonsson79568b92011-03-11 11:54:46 +010023#include <linux/regulator/ab8500.h>
Sundar Iyer20406eb2010-12-13 09:33:14 +053024#include <linux/mfd/tc3589x.h>
Linus Walleijfe67dfc2011-03-07 11:48:15 +010025#include <linux/mfd/tps6105x.h>
Linus Walleijee66e652011-12-02 14:16:33 +010026#include <linux/mfd/abx500/ab8500-gpio.h>
Philippe Langlaisdd7b2a02011-01-12 11:26:20 +010027#include <linux/leds-lp5521.h>
Philippe Langlaisa71b8192011-01-14 10:53:59 +010028#include <linux/input.h>
Robert Marklund350abe02011-06-20 15:55:46 +020029#include <linux/smsc911x.h>
Philippe Langlaisa71b8192011-01-14 10:53:59 +010030#include <linux/gpio_keys.h>
Shreshtha Kumar Sahu1a7d4362011-06-13 10:11:44 +020031#include <linux/delay.h>
Srinidhi Kasagaraa44ef42009-11-28 08:17:18 +010032
Arnd Bergmann2d334292012-03-07 15:04:07 +000033#include <linux/of.h>
34#include <linux/of_platform.h>
35
Robert Marklund350abe02011-06-20 15:55:46 +020036#include <linux/leds.h>
Srinidhi Kasagaraa44ef42009-11-28 08:17:18 +010037#include <asm/mach-types.h>
38#include <asm/mach/arch.h>
Marc Zyngierbbf5f382011-09-06 10:23:45 +010039#include <asm/hardware/gic.h>
Srinidhi Kasagaraa44ef42009-11-28 08:17:18 +010040
Srinidhi Kasagard48a41c2010-02-03 13:02:48 +010041#include <plat/i2c.h>
Linus Walleij5d7b8462010-10-14 13:57:59 +020042#include <plat/ste_dma40.h>
Shreshtha Kumar Sahu1a7d4362011-06-13 10:11:44 +020043#include <plat/pincfg.h>
Linus Walleij0f332862011-08-22 08:33:30 +010044#include <plat/gpio-nomadik.h>
Srinidhi Kasagaraa44ef42009-11-28 08:17:18 +010045
46#include <mach/hardware.h>
47#include <mach/setup.h>
Rabin Vincent9e4e7fe2010-05-03 08:03:52 +010048#include <mach/devices.h>
Linus Walleij29aeb3c2010-09-06 22:15:08 +010049#include <mach/irqs.h>
Srinidhi Kasagaraa44ef42009-11-28 08:17:18 +010050
Shreshtha Kumar Sahu1a7d4362011-06-13 10:11:44 +020051#include "pins-db8500.h"
Linus Walleij5d7b8462010-10-14 13:57:59 +020052#include "ste-dma40-db8500.h"
Rabin Vincentfbf1ead2010-09-29 19:46:32 +053053#include "devices-db8500.h"
Hanumath Prasad008f8a22010-08-19 12:06:32 +010054#include "board-mop500.h"
Bengt Jonssona1e516e2010-12-10 11:08:48 +010055#include "board-mop500-regulators.h"
Rabin Vincentea05a572010-06-03 07:58:42 +010056
Robert Marklund350abe02011-06-20 15:55:46 +020057static struct gpio_led snowball_led_array[] = {
58 {
59 .name = "user_led",
60 .default_trigger = "none",
61 .gpio = 142,
62 },
63};
64
65static struct gpio_led_platform_data snowball_led_data = {
66 .leds = snowball_led_array,
67 .num_leds = ARRAY_SIZE(snowball_led_array),
68};
69
70static struct platform_device snowball_led_dev = {
71 .name = "leds-gpio",
72 .dev = {
73 .platform_data = &snowball_led_data,
74 },
75};
76
Bibek Basu3ef374a2011-02-15 12:56:16 +053077static struct ab8500_gpio_platform_data ab8500_gpio_pdata = {
Philippe Langlaisa1524ee2012-02-13 10:52:25 +010078 .gpio_base = MOP500_AB8500_PIN_GPIO(1),
Bibek Basu3ef374a2011-02-15 12:56:16 +053079 .irq_base = MOP500_AB8500_VIR_GPIO_IRQ_BASE,
80 /* config_reg is the initial configuration of ab8500 pins.
81 * The pins can be configured as GPIO or alt functions based
82 * on value present in GpioSel1 to GpioSel6 and AlternatFunction
83 * register. This is the array of 7 configuration settings.
84 * One has to compile time decide these settings. Below is the
Lucas De Marchi25985ed2011-03-30 22:57:33 -030085 * explanation of these setting
Bibek Basu3ef374a2011-02-15 12:56:16 +053086 * GpioSel1 = 0x00 => Pins GPIO1 to GPIO8 are not used as GPIO
87 * GpioSel2 = 0x1E => Pins GPIO10 to GPIO13 are configured as GPIO
88 * GpioSel3 = 0x80 => Pin GPIO24 is configured as GPIO
89 * GpioSel4 = 0x01 => Pin GPIo25 is configured as GPIO
90 * GpioSel5 = 0x7A => Pins GPIO34, GPIO36 to GPIO39 are conf as GPIO
91 * GpioSel6 = 0x00 => Pins GPIO41 & GPIo42 are not configured as GPIO
92 * AlternaFunction = 0x00 => If Pins GPIO10 to 13 are not configured
93 * as GPIO then this register selectes the alternate fucntions
94 */
95 .config_reg = {0x00, 0x1E, 0x80, 0x01,
96 0x7A, 0x00, 0x00},
97};
98
Robert Marklund350abe02011-06-20 15:55:46 +020099static struct gpio_keys_button snowball_key_array[] = {
100 {
101 .gpio = 32,
102 .type = EV_KEY,
103 .code = KEY_1,
104 .desc = "userpb",
105 .active_low = 1,
106 .debounce_interval = 50,
107 .wakeup = 1,
108 },
109 {
110 .gpio = 151,
111 .type = EV_KEY,
112 .code = KEY_2,
113 .desc = "extkb1",
114 .active_low = 1,
115 .debounce_interval = 50,
116 .wakeup = 1,
117 },
118 {
119 .gpio = 152,
120 .type = EV_KEY,
121 .code = KEY_3,
122 .desc = "extkb2",
123 .active_low = 1,
124 .debounce_interval = 50,
125 .wakeup = 1,
126 },
127 {
128 .gpio = 161,
129 .type = EV_KEY,
130 .code = KEY_4,
131 .desc = "extkb3",
132 .active_low = 1,
133 .debounce_interval = 50,
134 .wakeup = 1,
135 },
136 {
137 .gpio = 162,
138 .type = EV_KEY,
139 .code = KEY_5,
140 .desc = "extkb4",
141 .active_low = 1,
142 .debounce_interval = 50,
143 .wakeup = 1,
144 },
145};
146
147static struct gpio_keys_platform_data snowball_key_data = {
148 .buttons = snowball_key_array,
149 .nbuttons = ARRAY_SIZE(snowball_key_array),
150};
151
152static struct platform_device snowball_key_dev = {
153 .name = "gpio-keys",
154 .id = -1,
155 .dev = {
156 .platform_data = &snowball_key_data,
157 }
158};
159
160static struct smsc911x_platform_config snowball_sbnet_cfg = {
161 .irq_polarity = SMSC911X_IRQ_POLARITY_ACTIVE_HIGH,
162 .irq_type = SMSC911X_IRQ_TYPE_PUSH_PULL,
163 .flags = SMSC911X_USE_16BIT | SMSC911X_FORCE_INTERNAL_PHY,
164 .shift = 1,
165};
166
167static struct resource sbnet_res[] = {
168 {
169 .name = "smsc911x-memory",
170 .start = (0x5000 << 16),
171 .end = (0x5000 << 16) + 0xffff,
172 .flags = IORESOURCE_MEM,
173 },
174 {
175 .start = NOMADIK_GPIO_TO_IRQ(140),
176 .end = NOMADIK_GPIO_TO_IRQ(140),
177 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE,
178 },
179};
180
181static struct platform_device snowball_sbnet_dev = {
182 .name = "smsc911x",
183 .num_resources = ARRAY_SIZE(sbnet_res),
184 .resource = sbnet_res,
185 .dev = {
186 .platform_data = &snowball_sbnet_cfg,
187 },
188};
189
Rabin Vincent39ae7022010-07-26 11:12:15 +0100190static struct ab8500_platform_data ab8500_platdata = {
191 .irq_base = MOP500_AB8500_IRQ_BASE,
Bengt Jonssondfa3a822011-03-09 13:34:17 +0100192 .regulator_reg_init = ab8500_regulator_reg_init,
193 .num_regulator_reg_init = ARRAY_SIZE(ab8500_regulator_reg_init),
Bengt Jonssona1e516e2010-12-10 11:08:48 +0100194 .regulator = ab8500_regulators,
195 .num_regulator = ARRAY_SIZE(ab8500_regulators),
Bibek Basu3ef374a2011-02-15 12:56:16 +0530196 .gpio = &ab8500_gpio_pdata,
Rabin Vincent39ae7022010-07-26 11:12:15 +0100197};
198
Linus Walleij29aeb3c2010-09-06 22:15:08 +0100199static struct resource ab8500_resources[] = {
200 [0] = {
Rabin Vincent22039b72010-12-08 11:07:56 +0530201 .start = IRQ_DB8500_AB8500,
202 .end = IRQ_DB8500_AB8500,
203 .flags = IORESOURCE_IRQ
Linus Walleij29aeb3c2010-09-06 22:15:08 +0100204 }
205};
206
207struct platform_device ab8500_device = {
208 .name = "ab8500-i2c",
209 .id = 0,
210 .dev = {
211 .platform_data = &ab8500_platdata,
212 },
213 .num_resources = 1,
214 .resource = ab8500_resources,
215};
216
Rabin Vincentb8410a12010-08-09 19:18:17 +0530217/*
Linus Walleijfe67dfc2011-03-07 11:48:15 +0100218 * TPS61052
219 */
220
221static struct tps6105x_platform_data mop500_tps61052_data = {
222 .mode = TPS6105X_MODE_VOLTAGE,
223 .regulator_data = &tps61052_regulator,
224};
225
226/*
Rabin Vincentb8410a12010-08-09 19:18:17 +0530227 * TC35892
228 */
229
Sundar Iyer20406eb2010-12-13 09:33:14 +0530230static void mop500_tc35892_init(struct tc3589x *tc3589x, unsigned int base)
Rabin Vincentb8410a12010-08-09 19:18:17 +0530231{
Lee Jones18403422012-02-06 11:22:21 -0800232 struct device *parent = NULL;
233#if 0
234 /* FIXME: Is the sdi actually part of tc3589x? */
235 parent = tc3589x->dev;
236#endif
237 mop500_sdi_tc35892_init(parent);
Rabin Vincentb8410a12010-08-09 19:18:17 +0530238}
239
Sundar Iyer20406eb2010-12-13 09:33:14 +0530240static struct tc3589x_gpio_platform_data mop500_tc35892_gpio_data = {
Rabin Vincentb8410a12010-08-09 19:18:17 +0530241 .gpio_base = MOP500_EGPIO(0),
242 .setup = mop500_tc35892_init,
243};
244
Sundar Iyer20406eb2010-12-13 09:33:14 +0530245static struct tc3589x_platform_data mop500_tc35892_data = {
Sundar Iyer611b7592010-12-13 09:33:15 +0530246 .block = TC3589x_BLOCK_GPIO,
Rabin Vincentb8410a12010-08-09 19:18:17 +0530247 .gpio = &mop500_tc35892_gpio_data,
248 .irq_base = MOP500_EGPIO_IRQ_BASE,
249};
250
Philippe Langlaisdd7b2a02011-01-12 11:26:20 +0100251static struct lp5521_led_config lp5521_pri_led[] = {
252 [0] = {
253 .chan_nr = 0,
254 .led_current = 0x2f,
255 .max_current = 0x5f,
256 },
257 [1] = {
258 .chan_nr = 1,
259 .led_current = 0x2f,
260 .max_current = 0x5f,
261 },
262 [2] = {
263 .chan_nr = 2,
264 .led_current = 0x2f,
265 .max_current = 0x5f,
266 },
267};
268
269static struct lp5521_platform_data __initdata lp5521_pri_data = {
270 .label = "lp5521_pri",
271 .led_config = &lp5521_pri_led[0],
272 .num_channels = 3,
273 .clock_mode = LP5521_CLOCK_EXT,
274};
275
276static struct lp5521_led_config lp5521_sec_led[] = {
277 [0] = {
278 .chan_nr = 0,
279 .led_current = 0x2f,
280 .max_current = 0x5f,
281 },
282 [1] = {
283 .chan_nr = 1,
284 .led_current = 0x2f,
285 .max_current = 0x5f,
286 },
287 [2] = {
288 .chan_nr = 2,
289 .led_current = 0x2f,
290 .max_current = 0x5f,
291 },
292};
293
294static struct lp5521_platform_data __initdata lp5521_sec_data = {
295 .label = "lp5521_sec",
296 .led_config = &lp5521_sec_led[0],
297 .num_channels = 3,
298 .clock_mode = LP5521_CLOCK_EXT,
299};
300
Linus Walleijfe67dfc2011-03-07 11:48:15 +0100301static struct i2c_board_info __initdata mop500_i2c0_devices[] = {
Rabin Vincentb8410a12010-08-09 19:18:17 +0530302 {
Sundar Iyer20406eb2010-12-13 09:33:14 +0530303 I2C_BOARD_INFO("tc3589x", 0x42),
Philippe Langlaisdd7b2a02011-01-12 11:26:20 +0100304 .irq = NOMADIK_GPIO_TO_IRQ(217),
Rabin Vincentb8410a12010-08-09 19:18:17 +0530305 .platform_data = &mop500_tc35892_data,
306 },
Linus Walleijcf568c52011-03-30 14:31:42 +0200307 /* I2C0 devices only available prior to HREFv60 */
Linus Walleijfe67dfc2011-03-07 11:48:15 +0100308 {
309 I2C_BOARD_INFO("tps61052", 0x33),
310 .platform_data = &mop500_tps61052_data,
311 },
312};
313
Linus Walleijcf568c52011-03-30 14:31:42 +0200314#define NUM_PRE_V60_I2C0_DEVICES 1
315
Philippe Langlaisdd7b2a02011-01-12 11:26:20 +0100316static struct i2c_board_info __initdata mop500_i2c2_devices[] = {
317 {
318 /* lp5521 LED driver, 1st device */
319 I2C_BOARD_INFO("lp5521", 0x33),
320 .platform_data = &lp5521_pri_data,
321 },
322 {
323 /* lp5521 LED driver, 2st device */
324 I2C_BOARD_INFO("lp5521", 0x34),
325 .platform_data = &lp5521_sec_data,
326 },
Lee Jonesbb3b2182011-01-13 14:41:22 +0000327 {
328 /* Light sensor Rohm BH1780GLI */
329 I2C_BOARD_INFO("bh1780", 0x29),
330 },
Philippe Langlaisdd7b2a02011-01-12 11:26:20 +0100331};
332
Linus Walleij2b030bd2011-05-13 12:31:13 +0200333#define U8500_I2C_CONTROLLER(id, _slsu, _tft, _rft, clk, t_out, _sm) \
Rabin Vincentf9faf232010-05-03 08:24:37 +0100334static struct nmk_i2c_controller u8500_i2c##id##_data = { \
Srinidhi Kasagard48a41c2010-02-03 13:02:48 +0100335 /* \
336 * slave data setup time, which is \
337 * 250 ns,100ns,10ns which is 14,6,2 \
338 * respectively for a 48 Mhz \
339 * i2c clock \
340 */ \
341 .slsu = _slsu, \
342 /* Tx FIFO threshold */ \
343 .tft = _tft, \
344 /* Rx FIFO threshold */ \
345 .rft = _rft, \
346 /* std. mode operation */ \
347 .clk_freq = clk, \
Linus Walleij2b030bd2011-05-13 12:31:13 +0200348 /* Slave response timeout(ms) */\
349 .timeout = t_out, \
Srinidhi Kasagard48a41c2010-02-03 13:02:48 +0100350 .sm = _sm, \
351}
352
353/*
354 * The board uses 4 i2c controllers, initialize all of
355 * them with slave data setup time of 250 ns,
Linus Walleij2b030bd2011-05-13 12:31:13 +0200356 * Tx & Rx FIFO threshold values as 8 and standard
Srinidhi Kasagard48a41c2010-02-03 13:02:48 +0100357 * mode of operation
358 */
Linus Walleij2b030bd2011-05-13 12:31:13 +0200359U8500_I2C_CONTROLLER(0, 0xe, 1, 8, 100000, 200, I2C_FREQ_MODE_FAST);
360U8500_I2C_CONTROLLER(1, 0xe, 1, 8, 100000, 200, I2C_FREQ_MODE_FAST);
361U8500_I2C_CONTROLLER(2, 0xe, 1, 8, 100000, 200, I2C_FREQ_MODE_FAST);
362U8500_I2C_CONTROLLER(3, 0xe, 1, 8, 100000, 200, I2C_FREQ_MODE_FAST);
Srinidhi Kasagard48a41c2010-02-03 13:02:48 +0100363
Lee Jones18403422012-02-06 11:22:21 -0800364static void __init mop500_i2c_init(struct device *parent)
Rabin Vincentfbf1ead2010-09-29 19:46:32 +0530365{
Lee Jones18403422012-02-06 11:22:21 -0800366 db8500_add_i2c0(parent, &u8500_i2c0_data);
367 db8500_add_i2c1(parent, &u8500_i2c1_data);
368 db8500_add_i2c2(parent, &u8500_i2c2_data);
369 db8500_add_i2c3(parent, &u8500_i2c3_data);
Rabin Vincentfbf1ead2010-09-29 19:46:32 +0530370}
Srinidhi Kasagaraa44ef42009-11-28 08:17:18 +0100371
Philippe Langlaisa71b8192011-01-14 10:53:59 +0100372static struct gpio_keys_button mop500_gpio_keys[] = {
373 {
374 .desc = "SFH7741 Proximity Sensor",
375 .type = EV_SW,
376 .code = SW_FRONT_PROXIMITY,
Philippe Langlaisa71b8192011-01-14 10:53:59 +0100377 .active_low = 0,
378 .can_disable = 1,
379 }
380};
381
382static struct regulator *prox_regulator;
383static int mop500_prox_activate(struct device *dev);
384static void mop500_prox_deactivate(struct device *dev);
385
386static struct gpio_keys_platform_data mop500_gpio_keys_data = {
387 .buttons = mop500_gpio_keys,
388 .nbuttons = ARRAY_SIZE(mop500_gpio_keys),
389 .enable = mop500_prox_activate,
390 .disable = mop500_prox_deactivate,
391};
392
393static struct platform_device mop500_gpio_keys_device = {
394 .name = "gpio-keys",
395 .id = 0,
396 .dev = {
397 .platform_data = &mop500_gpio_keys_data,
398 },
399};
400
401static int mop500_prox_activate(struct device *dev)
402{
403 prox_regulator = regulator_get(&mop500_gpio_keys_device.dev,
404 "vcc");
405 if (IS_ERR(prox_regulator)) {
406 dev_err(&mop500_gpio_keys_device.dev,
407 "no regulator\n");
408 return PTR_ERR(prox_regulator);
409 }
410 regulator_enable(prox_regulator);
411 return 0;
412}
413
414static void mop500_prox_deactivate(struct device *dev)
415{
416 regulator_disable(prox_regulator);
417 regulator_put(prox_regulator);
418}
419
Srinidhi Kasagard48a41c2010-02-03 13:02:48 +0100420/* add any platform devices here - TODO */
Robert Marklund350abe02011-06-20 15:55:46 +0200421static struct platform_device *mop500_platform_devs[] __initdata = {
Philippe Langlaisa71b8192011-01-14 10:53:59 +0100422 &mop500_gpio_keys_device,
Robert Marklund350abe02011-06-20 15:55:46 +0200423 &ab8500_device,
Srinidhi Kasagard48a41c2010-02-03 13:02:48 +0100424};
425
Linus Walleij5d7b8462010-10-14 13:57:59 +0200426#ifdef CONFIG_STE_DMA40
427static struct stedma40_chan_cfg ssp0_dma_cfg_rx = {
428 .mode = STEDMA40_MODE_LOGICAL,
429 .dir = STEDMA40_PERIPH_TO_MEM,
430 .src_dev_type = DB8500_DMA_DEV8_SSP0_RX,
431 .dst_dev_type = STEDMA40_DEV_DST_MEMORY,
432 .src_info.data_width = STEDMA40_BYTE_WIDTH,
433 .dst_info.data_width = STEDMA40_BYTE_WIDTH,
434};
435
436static struct stedma40_chan_cfg ssp0_dma_cfg_tx = {
437 .mode = STEDMA40_MODE_LOGICAL,
438 .dir = STEDMA40_MEM_TO_PERIPH,
439 .src_dev_type = STEDMA40_DEV_SRC_MEMORY,
440 .dst_dev_type = DB8500_DMA_DEV8_SSP0_TX,
441 .src_info.data_width = STEDMA40_BYTE_WIDTH,
442 .dst_info.data_width = STEDMA40_BYTE_WIDTH,
443};
444#endif
445
Lee Jones15daf692012-03-15 16:47:11 +0000446static struct pl022_ssp_controller ssp0_plat = {
Linus Walleij5d7b8462010-10-14 13:57:59 +0200447 .bus_id = 0,
448#ifdef CONFIG_STE_DMA40
449 .enable_dma = 1,
450 .dma_filter = stedma40_filter,
451 .dma_rx_param = &ssp0_dma_cfg_rx,
452 .dma_tx_param = &ssp0_dma_cfg_tx,
453#else
454 .enable_dma = 0,
455#endif
456 /* on this platform, gpio 31,142,144,214 &
457 * 224 are connected as chip selects
458 */
459 .num_chipselect = 5,
460};
461
Lee Jones18403422012-02-06 11:22:21 -0800462static void __init mop500_spi_init(struct device *parent)
Rabin Vincentfbf1ead2010-09-29 19:46:32 +0530463{
Lee Jones15daf692012-03-15 16:47:11 +0000464 db8500_add_ssp0(parent, &ssp0_plat);
Rabin Vincentfbf1ead2010-09-29 19:46:32 +0530465}
466
Linus Walleij5d7b8462010-10-14 13:57:59 +0200467#ifdef CONFIG_STE_DMA40
468static struct stedma40_chan_cfg uart0_dma_cfg_rx = {
469 .mode = STEDMA40_MODE_LOGICAL,
470 .dir = STEDMA40_PERIPH_TO_MEM,
471 .src_dev_type = DB8500_DMA_DEV13_UART0_RX,
472 .dst_dev_type = STEDMA40_DEV_DST_MEMORY,
473 .src_info.data_width = STEDMA40_BYTE_WIDTH,
474 .dst_info.data_width = STEDMA40_BYTE_WIDTH,
475};
476
477static struct stedma40_chan_cfg uart0_dma_cfg_tx = {
478 .mode = STEDMA40_MODE_LOGICAL,
479 .dir = STEDMA40_MEM_TO_PERIPH,
480 .src_dev_type = STEDMA40_DEV_SRC_MEMORY,
481 .dst_dev_type = DB8500_DMA_DEV13_UART0_TX,
482 .src_info.data_width = STEDMA40_BYTE_WIDTH,
483 .dst_info.data_width = STEDMA40_BYTE_WIDTH,
484};
485
486static struct stedma40_chan_cfg uart1_dma_cfg_rx = {
487 .mode = STEDMA40_MODE_LOGICAL,
488 .dir = STEDMA40_PERIPH_TO_MEM,
489 .src_dev_type = DB8500_DMA_DEV12_UART1_RX,
490 .dst_dev_type = STEDMA40_DEV_DST_MEMORY,
491 .src_info.data_width = STEDMA40_BYTE_WIDTH,
492 .dst_info.data_width = STEDMA40_BYTE_WIDTH,
493};
494
495static struct stedma40_chan_cfg uart1_dma_cfg_tx = {
496 .mode = STEDMA40_MODE_LOGICAL,
497 .dir = STEDMA40_MEM_TO_PERIPH,
498 .src_dev_type = STEDMA40_DEV_SRC_MEMORY,
499 .dst_dev_type = DB8500_DMA_DEV12_UART1_TX,
500 .src_info.data_width = STEDMA40_BYTE_WIDTH,
501 .dst_info.data_width = STEDMA40_BYTE_WIDTH,
502};
503
504static struct stedma40_chan_cfg uart2_dma_cfg_rx = {
505 .mode = STEDMA40_MODE_LOGICAL,
506 .dir = STEDMA40_PERIPH_TO_MEM,
507 .src_dev_type = DB8500_DMA_DEV11_UART2_RX,
508 .dst_dev_type = STEDMA40_DEV_DST_MEMORY,
509 .src_info.data_width = STEDMA40_BYTE_WIDTH,
510 .dst_info.data_width = STEDMA40_BYTE_WIDTH,
511};
512
513static struct stedma40_chan_cfg uart2_dma_cfg_tx = {
514 .mode = STEDMA40_MODE_LOGICAL,
515 .dir = STEDMA40_MEM_TO_PERIPH,
516 .src_dev_type = STEDMA40_DEV_SRC_MEMORY,
517 .dst_dev_type = DB8500_DMA_DEV11_UART2_TX,
518 .src_info.data_width = STEDMA40_BYTE_WIDTH,
519 .dst_info.data_width = STEDMA40_BYTE_WIDTH,
520};
521#endif
522
Shreshtha Kumar Sahu1a7d4362011-06-13 10:11:44 +0200523
524static pin_cfg_t mop500_pins_uart0[] = {
525 GPIO0_U0_CTSn | PIN_INPUT_PULLUP,
526 GPIO1_U0_RTSn | PIN_OUTPUT_HIGH,
527 GPIO2_U0_RXD | PIN_INPUT_PULLUP,
528 GPIO3_U0_TXD | PIN_OUTPUT_HIGH,
529};
530
531#define PRCC_K_SOFTRST_SET 0x18
532#define PRCC_K_SOFTRST_CLEAR 0x1C
533static void ux500_uart0_reset(void)
534{
535 void __iomem *prcc_rst_set, *prcc_rst_clr;
536
537 prcc_rst_set = (void __iomem *)IO_ADDRESS(U8500_CLKRST1_BASE +
538 PRCC_K_SOFTRST_SET);
539 prcc_rst_clr = (void __iomem *)IO_ADDRESS(U8500_CLKRST1_BASE +
540 PRCC_K_SOFTRST_CLEAR);
541
542 /* Activate soft reset PRCC_K_SOFTRST_CLEAR */
543 writel((readl(prcc_rst_clr) | 0x1), prcc_rst_clr);
544 udelay(1);
545
546 /* Release soft reset PRCC_K_SOFTRST_SET */
547 writel((readl(prcc_rst_set) | 0x1), prcc_rst_set);
548 udelay(1);
549}
550
551static void ux500_uart0_init(void)
552{
553 int ret;
554
555 ret = nmk_config_pins(mop500_pins_uart0,
556 ARRAY_SIZE(mop500_pins_uart0));
557 if (ret < 0)
558 pr_err("pl011: uart pins_enable failed\n");
559}
560
561static void ux500_uart0_exit(void)
562{
563 int ret;
564
565 ret = nmk_config_pins_sleep(mop500_pins_uart0,
566 ARRAY_SIZE(mop500_pins_uart0));
567 if (ret < 0)
568 pr_err("pl011: uart pins_disable failed\n");
569}
570
Linus Walleij5d7b8462010-10-14 13:57:59 +0200571static struct amba_pl011_data uart0_plat = {
572#ifdef CONFIG_STE_DMA40
573 .dma_filter = stedma40_filter,
574 .dma_rx_param = &uart0_dma_cfg_rx,
575 .dma_tx_param = &uart0_dma_cfg_tx,
576#endif
Shreshtha Kumar Sahu1a7d4362011-06-13 10:11:44 +0200577 .init = ux500_uart0_init,
578 .exit = ux500_uart0_exit,
579 .reset = ux500_uart0_reset,
Linus Walleij5d7b8462010-10-14 13:57:59 +0200580};
581
582static struct amba_pl011_data uart1_plat = {
583#ifdef CONFIG_STE_DMA40
584 .dma_filter = stedma40_filter,
585 .dma_rx_param = &uart1_dma_cfg_rx,
586 .dma_tx_param = &uart1_dma_cfg_tx,
587#endif
588};
589
590static struct amba_pl011_data uart2_plat = {
591#ifdef CONFIG_STE_DMA40
592 .dma_filter = stedma40_filter,
593 .dma_rx_param = &uart2_dma_cfg_rx,
594 .dma_tx_param = &uart2_dma_cfg_tx,
595#endif
596};
597
Lee Jones18403422012-02-06 11:22:21 -0800598static void __init mop500_uart_init(struct device *parent)
Rabin Vincentfbf1ead2010-09-29 19:46:32 +0530599{
Lee Jones18403422012-02-06 11:22:21 -0800600 db8500_add_uart0(parent, &uart0_plat);
601 db8500_add_uart1(parent, &uart1_plat);
602 db8500_add_uart2(parent, &uart2_plat);
Rabin Vincentfbf1ead2010-09-29 19:46:32 +0530603}
604
Robert Marklund350abe02011-06-20 15:55:46 +0200605static struct platform_device *snowball_platform_devs[] __initdata = {
606 &snowball_led_dev,
607 &snowball_key_dev,
608 &snowball_sbnet_dev,
609 &ab8500_device,
610};
611
Linus Walleij4b4f7572011-02-15 15:01:35 +0100612static void __init mop500_init_machine(void)
Srinidhi Kasagaraa44ef42009-11-28 08:17:18 +0100613{
Lee Jones18403422012-02-06 11:22:21 -0800614 struct device *parent = NULL;
Linus Walleijcf568c52011-03-30 14:31:42 +0200615 int i2c0_devs;
Lee Jonesb024a0c2012-02-06 11:22:25 -0800616 int i;
Linus Walleijcf568c52011-03-30 14:31:42 +0200617
Lee Jones110c2c22011-08-26 16:54:07 +0100618 mop500_gpio_keys[0].gpio = GPIO_PROX_SENSOR;
Linus Walleij4b4f7572011-02-15 15:01:35 +0100619
Lee Jones18403422012-02-06 11:22:21 -0800620 parent = u8500_init_devices();
Rabin Vincentea05a572010-06-03 07:58:42 +0100621
Rabin Vincentfe052032011-02-11 17:07:21 -0700622 mop500_pins_init();
Rabin Vincentea05a572010-06-03 07:58:42 +0100623
Lee Jones7e0ce272012-03-15 16:46:17 +0000624 /* FIXME: parent of ab8500 should be prcmu */
Lee Jonesb024a0c2012-02-06 11:22:25 -0800625 for (i = 0; i < ARRAY_SIZE(mop500_platform_devs); i++)
626 mop500_platform_devs[i]->dev.parent = parent;
627
Lee Jones110c2c22011-08-26 16:54:07 +0100628 platform_add_devices(mop500_platform_devs,
629 ARRAY_SIZE(mop500_platform_devs));
Srinidhi Kasagard48a41c2010-02-03 13:02:48 +0100630
Lee Jones18403422012-02-06 11:22:21 -0800631 mop500_i2c_init(parent);
632 mop500_sdi_init(parent);
633 mop500_spi_init(parent);
634 mop500_uart_init(parent);
Hanumath Prasad008f8a22010-08-19 12:06:32 +0100635
Linus Walleijcf568c52011-03-30 14:31:42 +0200636 i2c0_devs = ARRAY_SIZE(mop500_i2c0_devices);
Lee Jones110c2c22011-08-26 16:54:07 +0100637
638 i2c_register_board_info(0, mop500_i2c0_devices, i2c0_devs);
639 i2c_register_board_info(2, mop500_i2c2_devices,
640 ARRAY_SIZE(mop500_i2c2_devices));
641
642 /* This board has full regulator constraints */
643 regulator_has_full_constraints();
644}
645
646static void __init snowball_init_machine(void)
647{
Lee Jones18403422012-02-06 11:22:21 -0800648 struct device *parent = NULL;
Lee Jones110c2c22011-08-26 16:54:07 +0100649 int i2c0_devs;
Lee Jonesb024a0c2012-02-06 11:22:25 -0800650 int i;
Lee Jones110c2c22011-08-26 16:54:07 +0100651
Lee Jones18403422012-02-06 11:22:21 -0800652 parent = u8500_init_devices();
Lee Jones110c2c22011-08-26 16:54:07 +0100653
654 snowball_pins_init();
655
Lee Jonesb024a0c2012-02-06 11:22:25 -0800656 for (i = 0; i < ARRAY_SIZE(snowball_platform_devs); i++)
657 snowball_platform_devs[i]->dev.parent = parent;
658
Lee Jones110c2c22011-08-26 16:54:07 +0100659 platform_add_devices(snowball_platform_devs,
660 ARRAY_SIZE(snowball_platform_devs));
661
Lee Jones18403422012-02-06 11:22:21 -0800662 mop500_i2c_init(parent);
663 snowball_sdi_init(parent);
664 mop500_spi_init(parent);
665 mop500_uart_init(parent);
Lee Jones110c2c22011-08-26 16:54:07 +0100666
667 i2c0_devs = ARRAY_SIZE(mop500_i2c0_devices);
668 i2c_register_board_info(0, mop500_i2c0_devices, i2c0_devs);
669 i2c_register_board_info(2, mop500_i2c2_devices,
670 ARRAY_SIZE(mop500_i2c2_devices));
671
672 /* This board has full regulator constraints */
673 regulator_has_full_constraints();
674}
675
676static void __init hrefv60_init_machine(void)
677{
Lee Jones18403422012-02-06 11:22:21 -0800678 struct device *parent = NULL;
Lee Jones110c2c22011-08-26 16:54:07 +0100679 int i2c0_devs;
Lee Jonesb024a0c2012-02-06 11:22:25 -0800680 int i;
Lee Jones110c2c22011-08-26 16:54:07 +0100681
682 /*
683 * The HREFv60 board removed a GPIO expander and routed
684 * all these GPIO pins to the internal GPIO controller
685 * instead.
686 */
687 mop500_gpio_keys[0].gpio = HREFV60_PROX_SENSE_GPIO;
688
Lee Jones18403422012-02-06 11:22:21 -0800689 parent = u8500_init_devices();
Lee Jones110c2c22011-08-26 16:54:07 +0100690
691 hrefv60_pins_init();
692
Lee Jonesb024a0c2012-02-06 11:22:25 -0800693 for (i = 0; i < ARRAY_SIZE(mop500_platform_devs); i++)
694 mop500_platform_devs[i]->dev.parent = parent;
695
Lee Jones110c2c22011-08-26 16:54:07 +0100696 platform_add_devices(mop500_platform_devs,
697 ARRAY_SIZE(mop500_platform_devs));
698
Lee Jones18403422012-02-06 11:22:21 -0800699 mop500_i2c_init(parent);
700 hrefv60_sdi_init(parent);
701 mop500_spi_init(parent);
702 mop500_uart_init(parent);
Lee Jones110c2c22011-08-26 16:54:07 +0100703
704 i2c0_devs = ARRAY_SIZE(mop500_i2c0_devices);
705
706 i2c0_devs -= NUM_PRE_V60_I2C0_DEVICES;
Linus Walleijcf568c52011-03-30 14:31:42 +0200707
708 i2c_register_board_info(0, mop500_i2c0_devices, i2c0_devs);
Philippe Langlaisdd7b2a02011-01-12 11:26:20 +0100709 i2c_register_board_info(2, mop500_i2c2_devices,
710 ARRAY_SIZE(mop500_i2c2_devices));
Linus Walleijdb245202011-04-04 10:44:51 +0200711
712 /* This board has full regulator constraints */
713 regulator_has_full_constraints();
Srinidhi Kasagaraa44ef42009-11-28 08:17:18 +0100714}
715
716MACHINE_START(U8500, "ST-Ericsson MOP500 platform")
717 /* Maintainer: Srinidhi Kasagar <srinidhi.kasagar@stericsson.com> */
Nicolas Pitrebc77b1a2011-07-05 22:38:18 -0400718 .atag_offset = 0x100,
Srinidhi Kasagaraa44ef42009-11-28 08:17:18 +0100719 .map_io = u8500_map_io,
Rabin Vincent178980f2010-05-03 07:39:02 +0100720 .init_irq = ux500_init_irq,
Srinidhi Kasagaraa44ef42009-11-28 08:17:18 +0100721 /* we re-use nomadik timer here */
Rabin Vincent41ac3292010-05-03 08:28:05 +0100722 .timer = &ux500_timer,
Marc Zyngierbbf5f382011-09-06 10:23:45 +0100723 .handle_irq = gic_handle_irq,
Linus Walleij4b4f7572011-02-15 15:01:35 +0100724 .init_machine = mop500_init_machine,
725MACHINE_END
726
727MACHINE_START(HREFV60, "ST-Ericsson U8500 Platform HREFv60+")
Nicolas Pitrebc77b1a2011-07-05 22:38:18 -0400728 .atag_offset = 0x100,
Linus Walleij4b4f7572011-02-15 15:01:35 +0100729 .map_io = u8500_map_io,
730 .init_irq = ux500_init_irq,
731 .timer = &ux500_timer,
Marc Zyngierbbf5f382011-09-06 10:23:45 +0100732 .handle_irq = gic_handle_irq,
Lee Jones110c2c22011-08-26 16:54:07 +0100733 .init_machine = hrefv60_init_machine,
Srinidhi Kasagaraa44ef42009-11-28 08:17:18 +0100734MACHINE_END
Robert Marklund350abe02011-06-20 15:55:46 +0200735
736MACHINE_START(SNOWBALL, "Calao Systems Snowball platform")
Nicolas Pitrebc77b1a2011-07-05 22:38:18 -0400737 .atag_offset = 0x100,
Robert Marklund350abe02011-06-20 15:55:46 +0200738 .map_io = u8500_map_io,
739 .init_irq = ux500_init_irq,
740 /* we re-use nomadik timer here */
741 .timer = &ux500_timer,
Marc Zyngierbbf5f382011-09-06 10:23:45 +0100742 .handle_irq = gic_handle_irq,
Lee Jones110c2c22011-08-26 16:54:07 +0100743 .init_machine = snowball_init_machine,
Robert Marklund350abe02011-06-20 15:55:46 +0200744MACHINE_END
Arnd Bergmann2d334292012-03-07 15:04:07 +0000745
746#ifdef CONFIG_MACH_UX500_DT
Lee Jones7e0ce272012-03-15 16:46:17 +0000747
748struct of_dev_auxdata u8500_auxdata_lookup[] __initdata = {
Lee Jones4905af02012-03-07 17:35:04 +0000749 OF_DEV_AUXDATA("arm,pl011", 0x80120000, "uart0", &uart0_plat),
750 OF_DEV_AUXDATA("arm,pl011", 0x80121000, "uart1", &uart1_plat),
751 OF_DEV_AUXDATA("arm,pl011", 0x80007000, "uart2", &uart2_plat),
Lee Jones15daf692012-03-15 16:47:11 +0000752 OF_DEV_AUXDATA("arm,pl022", 0x80002000, "ssp0", &ssp0_plat),
Lee Jones7e0ce272012-03-15 16:46:17 +0000753 {},
754};
755
756static const struct of_device_id u8500_soc_node[] = {
757 /* only create devices below soc node */
758 { .compatible = "stericsson,db8500", },
759 { },
760};
761
Arnd Bergmann2d334292012-03-07 15:04:07 +0000762static void __init u8500_init_machine(void)
763{
Arnd Bergmann7734fed2012-03-02 22:25:02 +0000764 struct device *parent = NULL;
765 int i2c0_devs;
766 int i;
767
768 parent = u8500_init_devices();
769 i2c0_devs = ARRAY_SIZE(mop500_i2c0_devices);
770
771 for (i = 0; i < ARRAY_SIZE(mop500_platform_devs); i++)
772 mop500_platform_devs[i]->dev.parent = parent;
773 for (i = 0; i < ARRAY_SIZE(snowball_platform_devs); i++)
774 snowball_platform_devs[i]->dev.parent = parent;
775
Lee Jones7e0ce272012-03-15 16:46:17 +0000776 /* automatically probe child nodes of db8500 device */
777 of_platform_populate(NULL, u8500_soc_node, u8500_auxdata_lookup, parent);
Arnd Bergmann7734fed2012-03-02 22:25:02 +0000778
779 if (of_machine_is_compatible("st-ericsson,mop500")) {
780 mop500_gpio_keys[0].gpio = GPIO_PROX_SENSOR;
781 mop500_pins_init();
782
783 platform_add_devices(mop500_platform_devs,
784 ARRAY_SIZE(mop500_platform_devs));
785
786 mop500_sdi_init(parent);
787 } else if (of_machine_is_compatible("calaosystems,snowball-a9500")) {
788 snowball_pins_init();
789 platform_add_devices(snowball_platform_devs,
790 ARRAY_SIZE(snowball_platform_devs));
791
792 snowball_sdi_init(parent);
793 } else if (of_machine_is_compatible("st-ericsson,hrefv60+")) {
794 /*
795 * The HREFv60 board removed a GPIO expander and routed
796 * all these GPIO pins to the internal GPIO controller
797 * instead.
798 */
799 mop500_gpio_keys[0].gpio = HREFV60_PROX_SENSE_GPIO;
800 i2c0_devs -= NUM_PRE_V60_I2C0_DEVICES;
801 hrefv60_pins_init();
802 platform_add_devices(mop500_platform_devs,
803 ARRAY_SIZE(mop500_platform_devs));
804
805 hrefv60_sdi_init(parent);
806 }
807 mop500_i2c_init(parent);
Arnd Bergmann7734fed2012-03-02 22:25:02 +0000808
809 i2c_register_board_info(0, mop500_i2c0_devices, i2c0_devs);
810 i2c_register_board_info(2, mop500_i2c2_devices,
811 ARRAY_SIZE(mop500_i2c2_devices));
812
813 /* This board has full regulator constraints */
814 regulator_has_full_constraints();
Arnd Bergmann2d334292012-03-07 15:04:07 +0000815}
816
817static const char * u8500_dt_board_compat[] = {
818 "calaosystems,snowball-a9500",
819 "st-ericsson,hrefv60+",
820 "st-ericsson,u8500",
821 "st-ericsson,mop500",
822 NULL,
823};
824
825
826DT_MACHINE_START(U8500_DT, "ST-Ericsson U8500 platform (Device Tree Support)")
827 .map_io = u8500_map_io,
828 .init_irq = ux500_init_irq,
829 /* we re-use nomadik timer here */
830 .timer = &ux500_timer,
831 .handle_irq = gic_handle_irq,
832 .init_machine = u8500_init_machine,
833 .dt_compat = u8500_dt_board_compat,
834MACHINE_END
835#endif