summaryrefslogtreecommitdiff
path: root/arch/arm/mach-ux500/board-snowball.c
blob: c7d785fb1d663ff4bf6fee1bd6e2b8d180ffae50 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
/*
 * Copyright (C) 2011-2012 ST-Ericsson
 *
 * Author: Mathieu Poirier <mathieu.poirier@linaro.org>, based on the
 * work of Srinidhi KASAGAR <srinidhi.kasagar@stericsson.com> in
 * board-mop500.c
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2, as
 * published by the Free Software Foundation.
 *
 */
#include <linux/types.h>
#include <linux/kernel.h>
#include <linux/init.h>
#include <linux/platform_device.h>
#include <linux/amba/bus.h>
#include <linux/amba/pl022.h>
#include <linux/interrupt.h>
#include <linux/spi/spi.h>
#include <linux/i2c.h>
#include <linux/hsi.h>
#include <linux/i2s/i2s.h>
#include <linux/gpio.h>
#include <linux/input.h>
#include <linux/input/matrix_keypad.h>
#include <linux/mfd/stmpe.h>
#include <linux/mfd/tc35892.h>
#include <linux/i2c/lp5521.h>
#include <linux/power_supply.h>
#include <linux/mfd/abx500.h>
#include <linux/mfd/ab8500.h>
#include <linux/input/bu21013.h>
#include <linux/spi/stm_msp.h>
#include <linux/leds_pwm.h>
#include <linux/pwm_backlight.h>
#include <linux/mfd/ab8500/ab8500-bm.h>
#include <linux/mfd/ab8500/denc.h>
#include <linux/ste_timed_vibra.h>
#include <linux/mfd/ab8500/ab8500-gpio.h>
#include <linux/mfd/cg2900.h>

#include <net/bluetooth/bluetooth.h>
#include <net/bluetooth/hci.h>

#include <asm/mach/arch.h>
#include <asm/mach/irq.h>
#include <asm/mach/map.h>
#include <asm/mach-types.h>

#include <plat/pincfg.h>
#include <plat/ske.h>
#include <plat/i2c.h>

#include <mach/devices.h>
#include <mach/sensors1p.h>
#include <mach/ste_audio_io.h>
#include <mach/setup.h>
#include <mach/tc35893-keypad.h>
#include <mach/ste_audio_io_vibrator.h>
#include <video/av8100.h>
#include <mach/devices.h>
#include <mach/irqs.h>
#include <mach/ste-dma40-db8500.h>

#include "devices-cg2900.h"
#include "devices-db8500.h"
#include "board-mop500-regulators.h"
#include "regulator-u8500.h"
#include "pins-db8500.h"
#include "board-snowball.h"

static struct av8100_platform_data av8100_plat_data = {
	.irq = GPIO_TO_IRQ(192),
	.reset = 196,
	.regulator_pwr_id = "hdmi_1v8",
};

static struct i2c_board_info __initdata mop500_i2c0_devices[] = {
       {
               I2C_BOARD_INFO("av8100", 0x70),
               .platform_data = &av8100_plat_data,
       },
};
static struct i2c_board_info __initdata mop500_i2c1_devices[] = {};
static struct i2c_board_info __initdata mop500_i2c2_devices[] = {};
static struct i2c_board_info __initdata mop500_i2c3_devices[] = {};

/*
 * MSP-SPI
 */

#define NUM_MSP_CLIENTS 10

static struct stm_msp_controller mop500_msp2_spi_data = {
       .id             = MSP_2_CONTROLLER,
       .num_chipselect = NUM_MSP_CLIENTS,
       .base_addr      = U8500_MSP2_BASE,
       .device_name    = "msp2",
};

/*
 * SSP
 */

#define NUM_SSP_CLIENTS 10

#ifdef CONFIG_STE_DMA40
struct stedma40_chan_cfg ssp0_dma_cfg_rx = {
       .dir = STEDMA40_PERIPH_TO_MEM,
       .src_dev_type = DB8500_DMA_DEV8_SSP0_RX,
       .dst_dev_type = STEDMA40_DEV_DST_MEMORY,
       .src_info.data_width = STEDMA40_WORD_WIDTH,
       .dst_info.data_width = STEDMA40_WORD_WIDTH,
};

static struct stedma40_chan_cfg ssp0_dma_cfg_tx = {
       .dir = STEDMA40_MEM_TO_PERIPH,
       .src_dev_type = STEDMA40_DEV_SRC_MEMORY,
       .dst_dev_type = DB8500_DMA_DEV8_SSP0_TX,
       .src_info.data_width = STEDMA40_WORD_WIDTH,
       .dst_info.data_width = STEDMA40_WORD_WIDTH,
};
#endif

static struct pl022_ssp_controller mop500_ssp0_data = {
       .bus_id         = SSP_0_CONTROLLER,
       .num_chipselect = NUM_SSP_CLIENTS,
#ifdef CONFIG_STE_DMA40
       .enable_dma     = 1,
       .dma_filter     = stedma40_filter,
       .dma_rx_param   = &ssp0_dma_cfg_rx,
       .dma_tx_param   = &ssp0_dma_cfg_tx,
#endif

};

#define U8500_I2C_CONTROLLER(id, _slsu, _tft, _rft, clk, t_out, _sm) \
static struct nmk_i2c_controller mop500_i2c##id##_data = { \
       /*                              \
        * slave data setup time, which is      \
        * 250 ns,100ns,10ns which is 14,6,2    \
        * respectively for a 48 Mhz    \
        * i2c clock                    \
        */                             \
       .slsu           = _slsu,        \
       /* Tx FIFO threshold */         \
       .tft            = _tft,         \
       /* Rx FIFO threshold */         \
       .rft            = _rft,         \
       /* std. mode operation */       \
       .clk_freq       = clk,          \
       /* Slave response timeout(ms) */\
       .timeout        = t_out,        \
       .sm             = _sm,          \
}

/*
 * The board uses 4 i2c controllers, initialize all of
 * them with slave data setup time of 250 ns,
 * Tx & Rx FIFO threshold values as 1 and standard
 * mode of operation
 */
U8500_I2C_CONTROLLER(0, 0xe, 1, 1, 400000, 500, I2C_FREQ_MODE_FAST);
U8500_I2C_CONTROLLER(1, 0xe, 1, 1, 400000, 500, I2C_FREQ_MODE_FAST);
U8500_I2C_CONTROLLER(2, 0xe, 1, 1, 400000, 500, I2C_FREQ_MODE_FAST);
U8500_I2C_CONTROLLER(3, 0xe, 1, 1, 400000, 500, I2C_FREQ_MODE_FAST);

static struct hsi_board_info __initdata stm_hsi_devices[] = {
       {.type = "HSI_LOOPBACK", .flags = 0, .controller_id = 0,
        .chan_num = 0, .mode = 1},
       {.type = "HSI_LOOPBACK", .flags = 0, .controller_id = 1,
        .chan_num = 0, .mode = 1},
       {.type = "HSI_LOOPBACK", .flags = 0, .controller_id = 0,
        .chan_num = 1, .mode = 1},
       {.type = "HSI_LOOPBACK", .flags = 0, .controller_id = 1,
        .chan_num = 1, .mode = 1},
       {.type = "HSI_LOOPBACK", .flags = 0, .controller_id = 0,
        .chan_num = 2, .mode = 1},
       {.type = "HSI_LOOPBACK", .flags = 0, .controller_id = 1,
        .chan_num = 2, .mode = 1},
       {.type = "HSI_LOOPBACK", .flags = 0, .controller_id = 0,
        .chan_num = 3, .mode = 1},
       {.type = "HSI_LOOPBACK", .flags = 0, .controller_id = 1,
        .chan_num = 3, .mode = 1},
};

#ifdef CONFIG_AB8500_GPIO
static struct ab8500_gpio_platform_data ab8500_gpio_pdata = {
       .gpio_base              = AB8500_PIN_GPIO1,
       /* config_reg is the initial configuration of ab8500 pins.
        * The pins can be configured as GPIO or alt functions based
        * on value present in GpioSel1 to GpioSel6 and AlternatFunction
        * register. This is the array of 7 configuration settings.
        * One has to compile time decide these settings. Below is the
        * explaination of these setting
        * GpioSel1 = 0x00 => Pins GPIO1 to GPIO8 are not used as GPIO
        * GpioSel2 = 0x1E => Pins GPIO10 to GPIO13 are configured as GPIO
        * GpioSel3 = 0x80 => Pin GPIO24 is configured as GPIO
        * GpioSel4 = 0x01 => Pin GPIo25 is configured as GPIO
        * GpioSel5 = 0x7A => Pins GPIO34, GPIO36 to GPIO39 are conf as GPIO
        * GpioSel6 = 0x00 => Pins GPIo41 & GPIo42 are not configured as GPIO
        * AlternaFunction = 0x00 => If Pins GPIO10 to 13 are not configured
        * as GPIO then this register selectes the alternate fucntions
        */
       .config_reg             = {0x00, 0x1E, 0x80, 0x01,
                                       0x7A, 0x00, 0x00},
};
#endif

static struct regulator_init_data *u8500_regulators[U8500_NUM_REGULATORS] = {
       [U8500_REGULATOR_VAPE]                  = &u8500_vape_regulator,
       [U8500_REGULATOR_VARM]                  = &u8500_varm_regulator,
       [U8500_REGULATOR_VMODEM]                = &u8500_vmodem_regulator,
       [U8500_REGULATOR_VPLL]                  = &u8500_vpll_regulator,
       [U8500_REGULATOR_VSMPS1]                = &u8500_vsmps1_regulator,
       [U8500_REGULATOR_VSMPS2]                = &u8500_vsmps2_regulator,
       [U8500_REGULATOR_VSMPS3]                = &u8500_vsmps3_regulator,
       [U8500_REGULATOR_VRF1]                  = &u8500_vrf1_regulator,
       [U8500_REGULATOR_SWITCH_SVAMMDSP]       = &u8500_svammdsp_regulator,
       [U8500_REGULATOR_SWITCH_SVAMMDSPRET]    = &u8500_svammdspret_regulator,
       [U8500_REGULATOR_SWITCH_SVAPIPE]        = &u8500_svapipe_regulator,
       [U8500_REGULATOR_SWITCH_SIAMMDSP]       = &u8500_siammdsp_regulator,
       [U8500_REGULATOR_SWITCH_SIAMMDSPRET]    = &u8500_siammdspret_regulator,
       [U8500_REGULATOR_SWITCH_SIAPIPE]        = &u8500_siapipe_regulator,
       [U8500_REGULATOR_SWITCH_SGA]            = &u8500_sga_regulator,
       [U8500_REGULATOR_SWITCH_B2R2_MCDE]      = &u8500_b2r2_mcde_regulator,
       [U8500_REGULATOR_SWITCH_ESRAM12]        = &u8500_esram12_regulator,
       [U8500_REGULATOR_SWITCH_ESRAM12RET]     = &u8500_esram12ret_regulator,
       [U8500_REGULATOR_SWITCH_ESRAM34]        = &u8500_esram34_regulator,
       [U8500_REGULATOR_SWITCH_ESRAM34RET]     = &u8500_esram34ret_regulator,
};

static struct platform_device u8500_regulator_dev = {
       .name = "u8500-regulators",
       .id   = 0,
       .dev  = {
               .platform_data = u8500_regulators,
       },
};

static struct ab8500_audio_platform_data ab8500_audio_plat_data = {
       .ste_gpio_altf_init = msp13_i2s_init,
       .ste_gpio_altf_exit = msp13_i2s_exit,
};

/*
 * NOTE! The regulator configuration below must be in exactly the same order as
 * the regulator description in the driver, see drivers/regulator/ab8500.c
 */
static struct ab8500_platform_data ab8500_platdata = {
       .irq_base = MOP500_AB8500_IRQ_BASE,
       .regulator      = ab8500_regulators,
       .num_regulator  = ARRAY_SIZE(ab8500_regulators),
       .audio = &ab8500_audio_plat_data,
#ifdef CONFIG_AB8500_GPIO
       .gpio = &ab8500_gpio_pdata,
#endif
};

static struct resource ab8500_resources[] = {
       [0] = {
               .start = IRQ_DB8500_AB8500,
               .end = IRQ_DB8500_AB8500,
               .flags = IORESOURCE_IRQ
       }
};

static struct platform_device ux500_ab8500_device = {
       .name = "ab8500-i2c",
       .id = 0,
       .dev = {
               .platform_data = &ab8500_platdata,
       },
       .num_resources = 1,
       .resource = ab8500_resources,
};

#ifdef CONFIG_MFD_CG2900
#define CG2900_BT_ENABLE_GPIO          170
#define CG2900_GBF_ENA_RESET_GPIO      171
#define CG2900_BT_CTS_GPIO             0

enum cg2900_gpio_pull_sleep cg2900_sleep_gpio[21] = {
       CG2900_NO_PULL,         /* GPIO 0:  PTA_CONFX */
       CG2900_PULL_DN,         /* GPIO 1:  PTA_STATUS */
       CG2900_NO_PULL,         /* GPIO 2:  UART_CTSN */
       CG2900_PULL_UP,         /* GPIO 3:  UART_RTSN */
       CG2900_PULL_UP,         /* GPIO 4:  UART_TXD */
       CG2900_NO_PULL,         /* GPIO 5:  UART_RXD */
       CG2900_PULL_DN,         /* GPIO 6:  IOM_DOUT */
       CG2900_NO_PULL,         /* GPIO 7:  IOM_FSC */
       CG2900_NO_PULL,         /* GPIO 8:  IOM_CLK */
       CG2900_NO_PULL,         /* GPIO 9:  IOM_DIN */
       CG2900_PULL_DN,         /* GPIO 10: PWR_REQ */
       CG2900_PULL_DN,         /* GPIO 11: HOST_WAKEUP */
       CG2900_PULL_DN,         /* GPIO 12: IIS_DOUT */
       CG2900_NO_PULL,         /* GPIO 13: IIS_WS */
       CG2900_NO_PULL,         /* GPIO 14: IIS_CLK */
       CG2900_NO_PULL,         /* GPIO 15: IIS_DIN */
       CG2900_PULL_DN,         /* GPIO 16: PTA_FREQ */
       CG2900_PULL_DN,         /* GPIO 17: PTA_RF_ACTIVE */
       CG2900_NO_PULL,         /* GPIO 18: NotConnected (J6428) */
       CG2900_NO_PULL,         /* GPIO 19: EXT_DUTY_CYCLE */
       CG2900_NO_PULL,         /* GPIO 20: EXT_FRM_SYNCH */
};

static struct platform_device ux500_cg2900_device = {
       .name = "cg2900",
};

#ifdef CONFIG_MFD_CG2900_CHIP
static struct platform_device ux500_cg2900_chip_device = {
       .name = "cg2900-chip",
       .dev = {
               .parent = &ux500_cg2900_device.dev,
       },
};
#endif /* CONFIG_MFD_CG2900_CHIP */

#ifdef CONFIG_MFD_STLC2690_CHIP
static struct platform_device ux500_stlc2690_chip_device = {
       .name = "stlc2690-chip",
       .dev = {
               .parent = &ux500_cg2900_device.dev,
       },
};
#endif /* CONFIG_MFD_STLC2690_CHIP */

#ifdef CONFIG_MFD_CG2900_TEST
static struct cg2900_platform_data cg2900_test_platform_data = {
       .bus = HCI_VIRTUAL,
       .gpio_sleep = cg2900_sleep_gpio,
};

static struct platform_device ux500_cg2900_test_device = {
       .name = "cg2900-test",
       .dev = {
               .parent = &ux500_cg2900_device.dev,
               .platform_data = &cg2900_test_platform_data,
       },
};
#endif /* CONFIG_MFD_CG2900_TEST */

#ifdef CONFIG_MFD_CG2900_UART
static struct resource cg2900_uart_resources[] = {
       {
               .start = CG2900_GBF_ENA_RESET_GPIO,
               .end = CG2900_GBF_ENA_RESET_GPIO,
               .flags = IORESOURCE_IO,
               .name = "gbf_ena_reset",
       },
       {
               .start = CG2900_BT_ENABLE_GPIO,
               .end = CG2900_BT_ENABLE_GPIO,
               .flags = IORESOURCE_IO,
               .name = "bt_enable",
       },
       {
               .start = GPIO_TO_IRQ(CG2900_BT_CTS_GPIO),
               .end = GPIO_TO_IRQ(CG2900_BT_CTS_GPIO),
               .flags = IORESOURCE_IRQ,
               .name = "cts_irq",
       },
};

static pin_cfg_t cg2900_uart_enabled[] = {
       GPIO0_U0_CTSn   | PIN_INPUT_PULLUP,
       GPIO1_U0_RTSn   | PIN_OUTPUT_HIGH,
       GPIO2_U0_RXD    | PIN_INPUT_PULLUP,
       GPIO3_U0_TXD    | PIN_OUTPUT_HIGH
};

static pin_cfg_t cg2900_uart_disabled[] = {
       GPIO0_GPIO   | PIN_INPUT_PULLUP,        /* CTS pull up. */
       GPIO1_GPIO   | PIN_OUTPUT_HIGH,         /* RTS high-flow off. */
       GPIO2_GPIO   | PIN_INPUT_PULLUP,        /* RX pull down. */
       GPIO3_GPIO   | PIN_OUTPUT_LOW           /* TX low - break on. */
};

static struct cg2900_platform_data cg2900_uart_platform_data = {
       .bus = HCI_UART,
       .gpio_sleep = cg2900_sleep_gpio,
       .uart = {
               .n_uart_gpios = 4,
               .uart_enabled = cg2900_uart_enabled,
               .uart_disabled = cg2900_uart_disabled,
       },
};

static struct platform_device ux500_cg2900_uart_device = {
       .name = "cg2900-uart",
       .dev = {
               .platform_data = &cg2900_uart_platform_data,
               .parent = &ux500_cg2900_device.dev,
       },
       .num_resources = ARRAY_SIZE(cg2900_uart_resources),
       .resource = cg2900_uart_resources,
};
#endif /* CONFIG_MFD_CG2900_UART */
#endif /* CONFIG_MFD_CG2900 */

static struct platform_device *u8500_platform_devices[] __initdata = {
       /*TODO - add platform devices here */
};

static struct platform_device *platform_devs[] __initdata = {
       &u8500_hsit_device,
       &u8500_hsir_device,
       &u8500_shrm_device,
       &ux500_musb_device,
       &ux500_hwmem_device,
       &ux500_mcde_device,
       &ux500_b2r2_device,
};

static void __init mop500_i2c_init(void)
{
       db8500_add_i2c0(&mop500_i2c0_data);
       db8500_add_i2c1(&mop500_i2c1_data);
       db8500_add_i2c2(&mop500_i2c2_data);
       db8500_add_i2c3(&mop500_i2c3_data);

       i2c_register_board_info(0, ARRAY_AND_SIZE(mop500_i2c0_devices));
       i2c_register_board_info(1, ARRAY_AND_SIZE(mop500_i2c1_devices));
       i2c_register_board_info(2, ARRAY_AND_SIZE(mop500_i2c2_devices));
       i2c_register_board_info(3, ARRAY_AND_SIZE(mop500_i2c3_devices));
}

static void __init mop500_spi_init(void)
{
       db8500_add_ssp0(&mop500_ssp0_data);
       db8500_add_msp2_spi(&mop500_msp2_spi_data);
}

static void __init mop500_uart_init(void)
{
       db8500_add_uart0();
       db8500_add_uart1();
       db8500_add_uart2();
}

static void __init mop500_init_machine(void)
{
#ifdef CONFIG_REGULATOR
       platform_device_register(&u8500_regulator_dev);
#endif

       u8500_init_devices();

        platform_add_devices(platform_devs,
                        ARRAY_SIZE(platform_devs));

       snowball_pins_init();

       platform_device_register(&ux500_ab8500_device);

#ifdef CONFIG_MFD_CG2900
#ifdef CONFIG_MFD_CG2900_TEST
       dcg2900_init_platdata(&cg2900_test_platform_data);
#endif /* CONFIG_MFD_CG2900_TEST */
#ifdef CONFIG_MFD_CG2900_UART
       dcg2900_init_platdata(&cg2900_uart_platform_data);
#endif /* CONFIG_MFD_CG2900_UART */

       platform_device_register(&ux500_cg2900_device);
#ifdef CONFIG_MFD_CG2900_UART
       platform_device_register(&ux500_cg2900_uart_device);
#endif /* CONFIG_MFD_CG2900_UART */
#ifdef CONFIG_MFD_CG2900_TEST
       platform_device_register(&ux500_cg2900_test_device);
#endif /* CONFIG_MFD_CG2900_TEST */
#ifdef CONFIG_MFD_CG2900_CHIP
       platform_device_register(&ux500_cg2900_chip_device);
#endif /* CONFIG_MFD_CG2900_CHIP */
#ifdef CONFIG_MFD_STLC2690_CHIP
       platform_device_register(&ux500_stlc2690_chip_device);
#endif /* CONFIG_MFD_STLC2690_CHIP */
#endif /* CONFIG_MFD_CG2900 */

       mop500_i2c_init();
       mop500_msp_init();
       mop500_spi_init();
       mop500_uart_init();

       hsi_register_board_info(stm_hsi_devices, ARRAY_SIZE(stm_hsi_devices));

       platform_add_devices(u8500_platform_devices,
                            ARRAY_SIZE(u8500_platform_devices));
}

MACHINE_START(SNOWBALL, "ST-Ericsson Snowball board")
       .phys_io        = U8500_UART2_BASE,
       .io_pg_offst    = (IO_ADDRESS(U8500_UART2_BASE) >> 18) & 0xfffc,
       .boot_params    = 0x00000100,
       .map_io         = u8500_map_io,
       .init_irq       = ux500_init_irq,
       .timer          = &u8500_timer,
       .init_machine   = mop500_init_machine,
MACHINE_END