blob: 702f4f14b708ccb4ca80da7e7ef3da9595b2a784 [file] [log] [blame]
Jonathan Cameron4036e1d2009-05-16 18:20:39 +00001/*
2 * linux/arch/arm/mach-pxa/stargate2.c
3 *
4 * Author: Ed C. Epp
5 * Created: Nov 05, 2002
6 * Copyright: Intel Corp.
7 *
8 * Modified 2009: Jonathan Cameron <jic23@cam.ac.uk>
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License version 2 as
12 * published by the Free Software Foundation.
13 */
14
15#include <linux/init.h>
16#include <linux/device.h>
17#include <linux/interrupt.h>
18#include <linux/sched.h>
19#include <linux/bitops.h>
20#include <linux/fb.h>
21#include <linux/delay.h>
22#include <linux/platform_device.h>
23#include <linux/regulator/machine.h>
24#include <linux/mtd/mtd.h>
25#include <linux/mtd/plat-ram.h>
26#include <linux/mtd/partitions.h>
27
Sebastian Andrzej Siewiorb4593962011-02-23 12:38:16 +010028#include <linux/i2c/pxa-i2c.h>
Jonathan Cameron4036e1d2009-05-16 18:20:39 +000029#include <linux/i2c/pcf857x.h>
Vivien Didelot25f73ed2013-09-27 15:06:28 -040030#include <linux/platform_data/at24.h>
Jonathan Cameron4036e1d2009-05-16 18:20:39 +000031#include <linux/smc91x.h>
32#include <linux/gpio.h>
Jonathan Camerondcd925f92010-06-06 14:55:02 +010033#include <linux/leds.h>
Jonathan Cameron4036e1d2009-05-16 18:20:39 +000034
35#include <asm/types.h>
36#include <asm/setup.h>
37#include <asm/memory.h>
38#include <asm/mach-types.h>
39#include <asm/irq.h>
40
41#include <asm/mach/arch.h>
42#include <asm/mach/map.h>
43#include <asm/mach/irq.h>
44#include <asm/mach/flash.h>
45
Arnd Bergmann4c25c5d2015-01-30 10:45:33 +010046#include "pxa27x.h"
Arnd Bergmann293b2da2012-08-24 15:16:48 +020047#include <linux/platform_data/mmc-pxamci.h>
Arnd Bergmann4c25c5d2015-01-30 10:45:33 +010048#include "udc.h"
49#include "pxa27x-udc.h"
Marek Vasutad68bb92010-11-03 16:29:35 +010050#include <mach/smemc.h>
Jonathan Cameron4036e1d2009-05-16 18:20:39 +000051
52#include <linux/spi/spi.h>
Sebastian Andrzej Siewior8348c252010-11-22 17:12:15 -080053#include <linux/spi/pxa2xx_spi.h>
Jonathan Cameron4036e1d2009-05-16 18:20:39 +000054#include <linux/mfd/da903x.h>
Vivien Didelotf9b693e2012-09-12 12:23:44 -040055#include <linux/platform_data/sht15.h>
Jonathan Cameron4036e1d2009-05-16 18:20:39 +000056
57#include "devices.h"
58#include "generic.h"
59
Haojian Zhuang6ac6b812010-08-20 15:23:59 +080060#define STARGATE_NR_IRQS (IRQ_BOARD_START + 8)
61
Jonathan Cameron4036e1d2009-05-16 18:20:39 +000062/* Bluetooth */
63#define SG2_BT_RESET 81
64
65/* SD */
66#define SG2_GPIO_nSD_DETECT 90
67#define SG2_SD_POWER_ENABLE 89
68
Jonathan Camerondcd925f92010-06-06 14:55:02 +010069static unsigned long sg2_im2_unified_pin_config[] __initdata = {
Jonathan Cameron4036e1d2009-05-16 18:20:39 +000070 /* Device Identification for wakeup*/
71 GPIO102_GPIO,
Jonathan Cameron4036e1d2009-05-16 18:20:39 +000072 /* DA9030 */
73 GPIO1_GPIO,
74
Jonathan Cameron4036e1d2009-05-16 18:20:39 +000075 /* MMC */
76 GPIO32_MMC_CLK,
77 GPIO112_MMC_CMD,
78 GPIO92_MMC_DAT_0,
79 GPIO109_MMC_DAT_1,
80 GPIO110_MMC_DAT_2,
81 GPIO111_MMC_DAT_3,
Jonathan Cameron4036e1d2009-05-16 18:20:39 +000082
Jonathan Camerondcd925f92010-06-06 14:55:02 +010083 /* 802.15.4 radio - driver out of mainline */
84 GPIO22_GPIO, /* CC_RSTN */
85 GPIO114_GPIO, /* CC_FIFO */
86 GPIO116_GPIO, /* CC_CCA */
87 GPIO0_GPIO, /* CC_FIFOP */
88 GPIO16_GPIO, /* CCSFD */
89 GPIO115_GPIO, /* Power enable */
Jonathan Cameron4036e1d2009-05-16 18:20:39 +000090
91 /* I2C */
92 GPIO117_I2C_SCL,
93 GPIO118_I2C_SDA,
94
95 /* SSP 3 - 802.15.4 radio */
Jonathan Camerondcd925f92010-06-06 14:55:02 +010096 GPIO39_GPIO, /* Chip Select */
Jonathan Cameron4036e1d2009-05-16 18:20:39 +000097 GPIO34_SSP3_SCLK,
98 GPIO35_SSP3_TXD,
99 GPIO41_SSP3_RXD,
100
Jonathan Camerondcd925f92010-06-06 14:55:02 +0100101 /* SSP 2 to daughter boards */
Jonathan Cameron4036e1d2009-05-16 18:20:39 +0000102 GPIO11_SSP2_RXD,
103 GPIO38_SSP2_TXD,
104 GPIO36_SSP2_SCLK,
105 GPIO37_GPIO, /* chip select */
106
Jonathan Camerondcd925f92010-06-06 14:55:02 +0100107 /* SSP 1 - to daughter boards */
108 GPIO24_GPIO, /* Chip Select */
Jonathan Cameron4036e1d2009-05-16 18:20:39 +0000109 GPIO23_SSP1_SCLK,
Jonathan Camerondcd925f92010-06-06 14:55:02 +0100110 GPIO25_SSP1_TXD,
111 GPIO26_SSP1_RXD,
Jonathan Cameron4036e1d2009-05-16 18:20:39 +0000112
Jonathan Camerondcd925f92010-06-06 14:55:02 +0100113 /* BTUART Basic Connector*/
Jonathan Cameron4036e1d2009-05-16 18:20:39 +0000114 GPIO42_BTUART_RXD,
115 GPIO43_BTUART_TXD,
116 GPIO44_BTUART_CTS,
117 GPIO45_BTUART_RTS,
118
Jonathan Camerondcd925f92010-06-06 14:55:02 +0100119 /* STUART - IM2 via debug board not sure on SG2*/
Jonathan Cameron4036e1d2009-05-16 18:20:39 +0000120 GPIO46_STUART_RXD,
121 GPIO47_STUART_TXD,
122
123 /* Basic sensor board */
124 GPIO96_GPIO, /* accelerometer interrupt */
125 GPIO99_GPIO, /* ADC interrupt */
126
Jonathan Camerondcd925f92010-06-06 14:55:02 +0100127 /* SHT15 */
128 GPIO100_GPIO,
129 GPIO98_GPIO,
130
131 /* Basic sensor board */
132 GPIO96_GPIO, /* accelerometer interrupt */
133 GPIO99_GPIO, /* ADC interrupt */
134
Jonathan Cameron4036e1d2009-05-16 18:20:39 +0000135 /* Connector pins specified as gpios */
136 GPIO94_GPIO, /* large basic connector pin 14 */
137 GPIO10_GPIO, /* large basic connector pin 23 */
Jonathan Cameron4036e1d2009-05-16 18:20:39 +0000138};
139
140static struct sht15_platform_data platform_data_sht15 = {
141 .gpio_data = 100,
142 .gpio_sck = 98,
143};
144
145static struct platform_device sht15 = {
146 .name = "sht15",
147 .id = -1,
148 .dev = {
149 .platform_data = &platform_data_sht15,
150 },
151};
152
153static struct regulator_consumer_supply stargate2_sensor_3_con[] = {
Axel Lin0bf189a2012-05-08 16:25:10 +0800154 REGULATOR_SUPPLY("vcc", "sht15"),
Jonathan Cameron4036e1d2009-05-16 18:20:39 +0000155};
156
157enum stargate2_ldos{
158 vcc_vref,
159 vcc_cc2420,
160 /* a mote connector? */
161 vcc_mica,
162 /* the CSR bluecore chip */
163 vcc_bt,
164 /* The two voltages available to sensor boards */
165 vcc_sensor_1_8,
166 vcc_sensor_3,
167 /* directly connected to the pxa27x */
168 vcc_sram_ext,
169 vcc_pxa_pll,
170 vcc_pxa_usim, /* Reference voltage for certain gpios */
171 vcc_pxa_mem,
172 vcc_pxa_flash,
173 vcc_pxa_core, /*Dc-Dc buck not yet supported */
174 vcc_lcd,
175 vcc_bb,
176 vcc_bbio, /*not sure!*/
177 vcc_io, /* cc2420 802.15.4 radio and pxa vcc_io ?*/
178};
179
180/* The values of the various regulator constraints are obviously dependent
181 * on exactly what is wired to each ldo. Unfortunately this information is
182 * not generally available. More information has been requested from Xbow.
183 */
184static struct regulator_init_data stargate2_ldo_init_data[] = {
185 [vcc_bbio] = {
186 .constraints = { /* board default 1.8V */
187 .name = "vcc_bbio",
188 .min_uV = 1800000,
189 .max_uV = 1800000,
190 },
191 },
192 [vcc_bb] = {
193 .constraints = { /* board default 2.8V */
194 .name = "vcc_bb",
195 .min_uV = 2700000,
196 .max_uV = 3000000,
197 },
198 },
199 [vcc_pxa_flash] = {
200 .constraints = {/* default is 1.8V */
201 .name = "vcc_pxa_flash",
202 .min_uV = 1800000,
203 .max_uV = 1800000,
204 },
205 },
206 [vcc_cc2420] = { /* also vcc_io */
207 .constraints = {
208 /* board default is 2.8V */
209 .name = "vcc_cc2420",
210 .min_uV = 2700000,
211 .max_uV = 3300000,
212 },
213 },
214 [vcc_vref] = { /* Reference for what? */
215 .constraints = { /* default 1.8V */
216 .name = "vcc_vref",
217 .min_uV = 1800000,
218 .max_uV = 1800000,
219 },
220 },
221 [vcc_sram_ext] = {
222 .constraints = { /* default 2.8V */
223 .name = "vcc_sram_ext",
224 .min_uV = 2800000,
225 .max_uV = 2800000,
226 },
227 },
228 [vcc_mica] = {
229 .constraints = { /* default 2.8V */
230 .name = "vcc_mica",
231 .min_uV = 2800000,
232 .max_uV = 2800000,
233 },
234 },
235 [vcc_bt] = {
236 .constraints = { /* default 2.8V */
237 .name = "vcc_bt",
238 .min_uV = 2800000,
239 .max_uV = 2800000,
240 },
241 },
242 [vcc_lcd] = {
243 .constraints = { /* default 2.8V */
244 .name = "vcc_lcd",
245 .min_uV = 2700000,
246 .max_uV = 3300000,
247 },
248 },
249 [vcc_io] = { /* Same or higher than everything
250 * bar vccbat and vccusb */
251 .constraints = { /* default 2.8V */
252 .name = "vcc_io",
253 .min_uV = 2692000,
254 .max_uV = 3300000,
255 },
256 },
257 [vcc_sensor_1_8] = {
258 .constraints = { /* default 1.8V */
259 .name = "vcc_sensor_1_8",
260 .min_uV = 1800000,
261 .max_uV = 1800000,
262 },
263 },
264 [vcc_sensor_3] = { /* curiously default 2.8V */
265 .constraints = {
266 .name = "vcc_sensor_3",
267 .min_uV = 2800000,
268 .max_uV = 3000000,
269 },
270 .num_consumer_supplies = ARRAY_SIZE(stargate2_sensor_3_con),
271 .consumer_supplies = stargate2_sensor_3_con,
272 },
273 [vcc_pxa_pll] = { /* 1.17V - 1.43V, default 1.3V*/
274 .constraints = {
275 .name = "vcc_pxa_pll",
276 .min_uV = 1170000,
277 .max_uV = 1430000,
278 },
279 },
280 [vcc_pxa_usim] = {
281 .constraints = { /* default 1.8V */
282 .name = "vcc_pxa_usim",
283 .min_uV = 1710000,
284 .max_uV = 2160000,
285 },
286 },
287 [vcc_pxa_mem] = {
288 .constraints = { /* default 1.8V */
289 .name = "vcc_pxa_mem",
290 .min_uV = 1800000,
291 .max_uV = 1800000,
292 },
293 },
294};
295
Jonathan Camerondcd925f92010-06-06 14:55:02 +0100296static struct mtd_partition stargate2flash_partitions[] = {
297 {
298 .name = "Bootloader",
299 .size = 0x00040000,
300 .offset = 0,
301 .mask_flags = 0,
302 }, {
303 .name = "Kernel",
304 .size = 0x00200000,
305 .offset = 0x00040000,
306 .mask_flags = 0
307 }, {
308 .name = "Filesystem",
309 .size = 0x01DC0000,
310 .offset = 0x00240000,
311 .mask_flags = 0
312 },
313};
314
315static struct resource flash_resources = {
316 .start = PXA_CS0_PHYS,
317 .end = PXA_CS0_PHYS + SZ_32M - 1,
318 .flags = IORESOURCE_MEM,
319};
320
321static struct flash_platform_data stargate2_flash_data = {
322 .map_name = "cfi_probe",
323 .parts = stargate2flash_partitions,
324 .nr_parts = ARRAY_SIZE(stargate2flash_partitions),
325 .name = "PXA27xOnChipROM",
326 .width = 2,
327};
328
329static struct platform_device stargate2_flash_device = {
330 .name = "pxa2xx-flash",
331 .id = 0,
332 .dev = {
333 .platform_data = &stargate2_flash_data,
334 },
335 .resource = &flash_resources,
336 .num_resources = 1,
337};
338
339static struct pxa2xx_spi_master pxa_ssp_master_0_info = {
340 .num_chipselect = 1,
341};
342
343static struct pxa2xx_spi_master pxa_ssp_master_1_info = {
344 .num_chipselect = 1,
345};
346
347static struct pxa2xx_spi_master pxa_ssp_master_2_info = {
348 .num_chipselect = 1,
349};
350
351/* An upcoming kernel change will scrap SFRM usage so these
352 * drivers have been moved to use gpio's via cs_control */
353static struct pxa2xx_spi_chip staccel_chip_info = {
354 .tx_threshold = 8,
355 .rx_threshold = 8,
356 .dma_burst_size = 8,
357 .timeout = 235,
358 .gpio_cs = 24,
359};
360
361static struct pxa2xx_spi_chip cc2420_info = {
362 .tx_threshold = 8,
363 .rx_threshold = 8,
364 .dma_burst_size = 8,
365 .timeout = 235,
366 .gpio_cs = 39,
367};
368
369static struct spi_board_info spi_board_info[] __initdata = {
370 {
371 .modalias = "lis3l02dq",
372 .max_speed_hz = 8000000,/* 8MHz max spi frequency at 3V */
373 .bus_num = 1,
374 .chip_select = 0,
375 .controller_data = &staccel_chip_info,
Haojian Zhuang6384fda2011-10-10 14:21:08 +0800376 .irq = PXA_GPIO_TO_IRQ(96),
Jonathan Camerondcd925f92010-06-06 14:55:02 +0100377 }, {
378 .modalias = "cc2420",
379 .max_speed_hz = 6500000,
380 .bus_num = 3,
381 .chip_select = 0,
382 .controller_data = &cc2420_info,
383 },
384};
385
386static void sg2_udc_command(int cmd)
387{
388 switch (cmd) {
389 case PXA2XX_UDC_CMD_CONNECT:
390 UP2OCR |= UP2OCR_HXOE | UP2OCR_DPPUE | UP2OCR_DPPUBE;
391 break;
392 case PXA2XX_UDC_CMD_DISCONNECT:
393 UP2OCR &= ~(UP2OCR_HXOE | UP2OCR_DPPUE | UP2OCR_DPPUBE);
394 break;
395 }
396}
397
398static struct i2c_pxa_platform_data i2c_pwr_pdata = {
399 .fast_mode = 1,
400};
401
402static struct i2c_pxa_platform_data i2c_pdata = {
403 .fast_mode = 1,
404};
405
406static void __init imote2_stargate2_init(void)
407{
408
409 pxa2xx_mfp_config(ARRAY_AND_SIZE(sg2_im2_unified_pin_config));
410
411 pxa_set_ffuart_info(NULL);
412 pxa_set_btuart_info(NULL);
413 pxa_set_stuart_info(NULL);
414
415 pxa2xx_set_spi_info(1, &pxa_ssp_master_0_info);
416 pxa2xx_set_spi_info(2, &pxa_ssp_master_1_info);
417 pxa2xx_set_spi_info(3, &pxa_ssp_master_2_info);
418 spi_register_board_info(spi_board_info, ARRAY_SIZE(spi_board_info));
419
420
421 pxa27x_set_i2c_power_info(&i2c_pwr_pdata);
422 pxa_set_i2c_info(&i2c_pdata);
423}
424
425#ifdef CONFIG_MACH_INTELMOTE2
426/* As the the imote2 doesn't currently have a conventional SD slot
427 * there is no option to hotplug cards, making all this rather simple
428 */
429static int imote2_mci_get_ro(struct device *dev)
430{
431 return 0;
432}
433
434/* Rather simple case as hotplugging not possible */
435static struct pxamci_platform_data imote2_mci_platform_data = {
436 .ocr_mask = MMC_VDD_32_33 | MMC_VDD_33_34, /* default anyway */
437 .get_ro = imote2_mci_get_ro,
438 .gpio_card_detect = -1,
439 .gpio_card_ro = -1,
440 .gpio_power = -1,
441};
442
443static struct gpio_led imote2_led_pins[] = {
444 {
445 .name = "imote2:red",
446 .gpio = 103,
447 .active_low = 1,
448 }, {
449 .name = "imote2:green",
450 .gpio = 104,
451 .active_low = 1,
452 }, {
453 .name = "imote2:blue",
454 .gpio = 105,
455 .active_low = 1,
456 },
457};
458
459static struct gpio_led_platform_data imote2_led_data = {
460 .num_leds = ARRAY_SIZE(imote2_led_pins),
461 .leds = imote2_led_pins,
462};
463
464static struct platform_device imote2_leds = {
465 .name = "leds-gpio",
466 .id = -1,
467 .dev = {
468 .platform_data = &imote2_led_data,
469 },
470};
471
472static struct da903x_subdev_info imote2_da9030_subdevs[] = {
473 {
474 .name = "da903x-regulator",
475 .id = DA9030_ID_LDO2,
476 .platform_data = &stargate2_ldo_init_data[vcc_bbio],
477 }, {
478 .name = "da903x-regulator",
479 .id = DA9030_ID_LDO3,
480 .platform_data = &stargate2_ldo_init_data[vcc_bb],
481 }, {
482 .name = "da903x-regulator",
483 .id = DA9030_ID_LDO4,
484 .platform_data = &stargate2_ldo_init_data[vcc_pxa_flash],
485 }, {
486 .name = "da903x-regulator",
487 .id = DA9030_ID_LDO5,
488 .platform_data = &stargate2_ldo_init_data[vcc_cc2420],
489 }, {
490 .name = "da903x-regulator",
491 .id = DA9030_ID_LDO6,
492 .platform_data = &stargate2_ldo_init_data[vcc_vref],
493 }, {
494 .name = "da903x-regulator",
495 .id = DA9030_ID_LDO7,
496 .platform_data = &stargate2_ldo_init_data[vcc_sram_ext],
497 }, {
498 .name = "da903x-regulator",
499 .id = DA9030_ID_LDO8,
500 .platform_data = &stargate2_ldo_init_data[vcc_mica],
501 }, {
502 .name = "da903x-regulator",
503 .id = DA9030_ID_LDO9,
504 .platform_data = &stargate2_ldo_init_data[vcc_bt],
505 }, {
506 .name = "da903x-regulator",
507 .id = DA9030_ID_LDO10,
508 .platform_data = &stargate2_ldo_init_data[vcc_sensor_1_8],
509 }, {
510 .name = "da903x-regulator",
511 .id = DA9030_ID_LDO11,
512 .platform_data = &stargate2_ldo_init_data[vcc_sensor_3],
513 }, {
514 .name = "da903x-regulator",
515 .id = DA9030_ID_LDO12,
516 .platform_data = &stargate2_ldo_init_data[vcc_lcd],
517 }, {
518 .name = "da903x-regulator",
519 .id = DA9030_ID_LDO15,
520 .platform_data = &stargate2_ldo_init_data[vcc_pxa_pll],
521 }, {
522 .name = "da903x-regulator",
523 .id = DA9030_ID_LDO17,
524 .platform_data = &stargate2_ldo_init_data[vcc_pxa_usim],
525 }, {
526 .name = "da903x-regulator", /*pxa vcc i/o and cc2420 vcc i/o */
527 .id = DA9030_ID_LDO18,
528 .platform_data = &stargate2_ldo_init_data[vcc_io],
529 }, {
530 .name = "da903x-regulator",
531 .id = DA9030_ID_LDO19,
532 .platform_data = &stargate2_ldo_init_data[vcc_pxa_mem],
533 },
534};
535
536static struct da903x_platform_data imote2_da9030_pdata = {
537 .num_subdevs = ARRAY_SIZE(imote2_da9030_subdevs),
538 .subdevs = imote2_da9030_subdevs,
539};
540
541static struct i2c_board_info __initdata imote2_pwr_i2c_board_info[] = {
542 {
543 .type = "da9030",
544 .addr = 0x49,
545 .platform_data = &imote2_da9030_pdata,
Haojian Zhuang4929f5a2011-10-10 16:03:51 +0800546 .irq = PXA_GPIO_TO_IRQ(1),
Jonathan Camerondcd925f92010-06-06 14:55:02 +0100547 },
548};
549
550static struct i2c_board_info __initdata imote2_i2c_board_info[] = {
551 { /* UCAM sensor board */
552 .type = "max1239",
553 .addr = 0x35,
554 }, { /* ITS400 Sensor board only */
555 .type = "max1363",
556 .addr = 0x34,
557 /* Through a nand gate - Also beware, on V2 sensor board the
558 * pull up resistors are missing.
559 */
Haojian Zhuang6384fda2011-10-10 14:21:08 +0800560 .irq = PXA_GPIO_TO_IRQ(99),
Jonathan Camerondcd925f92010-06-06 14:55:02 +0100561 }, { /* ITS400 Sensor board only */
562 .type = "tsl2561",
563 .addr = 0x49,
564 /* Through a nand gate - Also beware, on V2 sensor board the
565 * pull up resistors are missing.
566 */
Haojian Zhuang6384fda2011-10-10 14:21:08 +0800567 .irq = PXA_GPIO_TO_IRQ(99),
Jonathan Camerondcd925f92010-06-06 14:55:02 +0100568 }, { /* ITS400 Sensor board only */
569 .type = "tmp175",
570 .addr = 0x4A,
Haojian Zhuang6384fda2011-10-10 14:21:08 +0800571 .irq = PXA_GPIO_TO_IRQ(96),
Jonathan Camerondcd925f92010-06-06 14:55:02 +0100572 }, { /* IMB400 Multimedia board */
573 .type = "wm8940",
574 .addr = 0x1A,
575 },
576};
577
578static unsigned long imote2_pin_config[] __initdata = {
579
580 /* Button */
581 GPIO91_GPIO,
582
583 /* LEDS */
584 GPIO103_GPIO, /* red led */
585 GPIO104_GPIO, /* green led */
586 GPIO105_GPIO, /* blue led */
587};
588
589static struct pxa2xx_udc_mach_info imote2_udc_info __initdata = {
590 .udc_command = sg2_udc_command,
591};
592
Axel Linac1e8982011-12-15 10:55:24 +0800593static struct platform_device imote2_audio_device = {
594 .name = "imote2-audio",
595 .id = -1,
596};
597
Jonathan Camerondcd925f92010-06-06 14:55:02 +0100598static struct platform_device *imote2_devices[] = {
599 &stargate2_flash_device,
600 &imote2_leds,
601 &sht15,
Axel Linac1e8982011-12-15 10:55:24 +0800602 &imote2_audio_device,
Jonathan Camerondcd925f92010-06-06 14:55:02 +0100603};
604
605static void __init imote2_init(void)
606{
607 pxa2xx_mfp_config(ARRAY_AND_SIZE(imote2_pin_config));
608
609 imote2_stargate2_init();
610
611 platform_add_devices(imote2_devices, ARRAY_SIZE(imote2_devices));
612
613 i2c_register_board_info(0, imote2_i2c_board_info,
614 ARRAY_SIZE(imote2_i2c_board_info));
615 i2c_register_board_info(1, imote2_pwr_i2c_board_info,
616 ARRAY_SIZE(imote2_pwr_i2c_board_info));
617
618 pxa_set_mci_info(&imote2_mci_platform_data);
619 pxa_set_udc_info(&imote2_udc_info);
620}
621#endif
622
623#ifdef CONFIG_MACH_STARGATE2
624
625static unsigned long stargate2_pin_config[] __initdata = {
626
627 GPIO15_nCS_1, /* SRAM */
628 /* SMC91x */
629 GPIO80_nCS_4,
630 GPIO40_GPIO, /*cable detect?*/
631
632 /* Button */
633 GPIO91_GPIO | WAKEUP_ON_LEVEL_HIGH,
634
635 /* Compact Flash */
636 GPIO79_PSKTSEL,
637 GPIO48_nPOE,
638 GPIO49_nPWE,
639 GPIO50_nPIOR,
640 GPIO51_nPIOW,
641 GPIO85_nPCE_1,
642 GPIO54_nPCE_2,
643 GPIO55_nPREG,
644 GPIO56_nPWAIT,
645 GPIO57_nIOIS16,
646 GPIO120_GPIO, /* Buff ctrl */
647 GPIO108_GPIO, /* Power ctrl */
648 GPIO82_GPIO, /* Reset */
649 GPIO53_GPIO, /* SG2_S0_GPIO_DETECT */
650
651 /* MMC not shared with imote2 */
652 GPIO90_GPIO, /* nSD detect */
653 GPIO89_GPIO, /* SD_POWER_ENABLE */
654
655 /* Bluetooth */
656 GPIO81_GPIO, /* reset */
657};
658
659static struct resource smc91x_resources[] = {
660 [0] = {
661 .name = "smc91x-regs",
662 .start = (PXA_CS4_PHYS + 0x300),
663 .end = (PXA_CS4_PHYS + 0xfffff),
664 .flags = IORESOURCE_MEM,
665 },
666 [1] = {
Haojian Zhuang6384fda2011-10-10 14:21:08 +0800667 .start = PXA_GPIO_TO_IRQ(40),
668 .end = PXA_GPIO_TO_IRQ(40),
Jonathan Camerondcd925f92010-06-06 14:55:02 +0100669 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE,
670 }
671};
672
673static struct smc91x_platdata stargate2_smc91x_info = {
674 .flags = SMC91X_USE_8BIT | SMC91X_USE_16BIT | SMC91X_USE_32BIT
675 | SMC91X_NOWAIT | SMC91X_USE_DMA,
676};
677
678static struct platform_device smc91x_device = {
679 .name = "smc91x",
680 .id = -1,
681 .num_resources = ARRAY_SIZE(smc91x_resources),
682 .resource = smc91x_resources,
683 .dev = {
684 .platform_data = &stargate2_smc91x_info,
685 },
686};
687
688
689/*
690 * The card detect interrupt isn't debounced so we delay it by 250ms
691 * to give the card a chance to fully insert / eject.
692 */
693static int stargate2_mci_init(struct device *dev,
694 irq_handler_t stargate2_detect_int,
695 void *data)
696{
697 int err;
698
699 err = gpio_request(SG2_SD_POWER_ENABLE, "SG2_sd_power_enable");
700 if (err) {
701 printk(KERN_ERR "Can't get the gpio for SD power control");
702 goto return_err;
703 }
704 gpio_direction_output(SG2_SD_POWER_ENABLE, 0);
705
706 err = gpio_request(SG2_GPIO_nSD_DETECT, "SG2_sd_detect");
707 if (err) {
708 printk(KERN_ERR "Can't get the sd detect gpio");
709 goto free_power_en;
710 }
711 gpio_direction_input(SG2_GPIO_nSD_DETECT);
712
Haojian Zhuang6384fda2011-10-10 14:21:08 +0800713 err = request_irq(PXA_GPIO_TO_IRQ(SG2_GPIO_nSD_DETECT),
Jonathan Camerondcd925f92010-06-06 14:55:02 +0100714 stargate2_detect_int,
715 IRQ_TYPE_EDGE_BOTH,
716 "MMC card detect",
717 data);
718 if (err) {
719 printk(KERN_ERR "can't request MMC card detect IRQ\n");
720 goto free_nsd_detect;
721 }
722 return 0;
723
724 free_nsd_detect:
725 gpio_free(SG2_GPIO_nSD_DETECT);
726 free_power_en:
727 gpio_free(SG2_SD_POWER_ENABLE);
728 return_err:
729 return err;
730}
731
732/**
733 * stargate2_mci_setpower() - set state of mmc power supply
734 *
735 * Very simple control. Either it is on or off and is controlled by
736 * a gpio pin */
Arnd Bergmanna829abf2013-07-05 17:51:20 +0200737static int stargate2_mci_setpower(struct device *dev, unsigned int vdd)
Jonathan Camerondcd925f92010-06-06 14:55:02 +0100738{
739 gpio_set_value(SG2_SD_POWER_ENABLE, !!vdd);
Arnd Bergmanna829abf2013-07-05 17:51:20 +0200740 return 0;
Jonathan Camerondcd925f92010-06-06 14:55:02 +0100741}
742
743static void stargate2_mci_exit(struct device *dev, void *data)
744{
Haojian Zhuang6384fda2011-10-10 14:21:08 +0800745 free_irq(PXA_GPIO_TO_IRQ(SG2_GPIO_nSD_DETECT), data);
Jonathan Camerondcd925f92010-06-06 14:55:02 +0100746 gpio_free(SG2_SD_POWER_ENABLE);
747 gpio_free(SG2_GPIO_nSD_DETECT);
748}
749
750static struct pxamci_platform_data stargate2_mci_platform_data = {
751 .detect_delay_ms = 250,
752 .ocr_mask = MMC_VDD_32_33 | MMC_VDD_33_34,
753 .init = stargate2_mci_init,
754 .setpower = stargate2_mci_setpower,
755 .exit = stargate2_mci_exit,
756};
757
758
759/*
760 * SRAM - The Stargate 2 has 32MB of SRAM.
761 *
762 * Here it is made available as an MTD. This will then
763 * typically have a cifs filesystem created on it to provide
764 * fast temporary storage.
765 */
766static struct resource sram_resources = {
767 .start = PXA_CS1_PHYS,
768 .end = PXA_CS1_PHYS + SZ_32M-1,
769 .flags = IORESOURCE_MEM,
770};
771
772static struct platdata_mtd_ram stargate2_sram_pdata = {
773 .mapname = "Stargate2 SRAM",
774 .bankwidth = 2,
775};
776
777static struct platform_device stargate2_sram = {
778 .name = "mtd-ram",
779 .id = 0,
780 .resource = &sram_resources,
781 .num_resources = 1,
782 .dev = {
783 .platform_data = &stargate2_sram_pdata,
784 },
785};
786
787static struct pcf857x_platform_data platform_data_pcf857x = {
788 .gpio_base = 128,
789 .n_latch = 0,
790 .setup = NULL,
791 .teardown = NULL,
792 .context = NULL,
793};
794
795static struct at24_platform_data pca9500_eeprom_pdata = {
796 .byte_len = 256,
797 .page_size = 4,
798};
799
800/**
801 * stargate2_reset_bluetooth() reset the bluecore to ensure consistent state
802 **/
803static int stargate2_reset_bluetooth(void)
804{
805 int err;
806 err = gpio_request(SG2_BT_RESET, "SG2_BT_RESET");
807 if (err) {
808 printk(KERN_ERR "Could not get gpio for bluetooth reset\n");
809 return err;
810 }
811 gpio_direction_output(SG2_BT_RESET, 1);
812 mdelay(5);
813 /* now reset it - 5 msec minimum */
814 gpio_set_value(SG2_BT_RESET, 0);
815 mdelay(10);
816 gpio_set_value(SG2_BT_RESET, 1);
817 gpio_free(SG2_BT_RESET);
818 return 0;
819}
820
821static struct led_info stargate2_leds[] = {
822 {
823 .name = "sg2:red",
824 .flags = DA9030_LED_RATE_ON,
825 }, {
826 .name = "sg2:blue",
827 .flags = DA9030_LED_RATE_ON,
828 }, {
829 .name = "sg2:green",
830 .flags = DA9030_LED_RATE_ON,
831 },
832};
833
Jonathan Cameron4036e1d2009-05-16 18:20:39 +0000834static struct da903x_subdev_info stargate2_da9030_subdevs[] = {
835 {
836 .name = "da903x-led",
837 .id = DA9030_ID_LED_2,
838 .platform_data = &stargate2_leds[0],
839 }, {
840 .name = "da903x-led",
841 .id = DA9030_ID_LED_3,
842 .platform_data = &stargate2_leds[2],
843 }, {
844 .name = "da903x-led",
845 .id = DA9030_ID_LED_4,
846 .platform_data = &stargate2_leds[1],
847 }, {
848 .name = "da903x-regulator",
849 .id = DA9030_ID_LDO2,
850 .platform_data = &stargate2_ldo_init_data[vcc_bbio],
851 }, {
852 .name = "da903x-regulator",
853 .id = DA9030_ID_LDO3,
854 .platform_data = &stargate2_ldo_init_data[vcc_bb],
855 }, {
856 .name = "da903x-regulator",
857 .id = DA9030_ID_LDO4,
858 .platform_data = &stargate2_ldo_init_data[vcc_pxa_flash],
859 }, {
860 .name = "da903x-regulator",
861 .id = DA9030_ID_LDO5,
862 .platform_data = &stargate2_ldo_init_data[vcc_cc2420],
863 }, {
864 .name = "da903x-regulator",
865 .id = DA9030_ID_LDO6,
866 .platform_data = &stargate2_ldo_init_data[vcc_vref],
867 }, {
868 .name = "da903x-regulator",
869 .id = DA9030_ID_LDO7,
870 .platform_data = &stargate2_ldo_init_data[vcc_sram_ext],
871 }, {
872 .name = "da903x-regulator",
873 .id = DA9030_ID_LDO8,
874 .platform_data = &stargate2_ldo_init_data[vcc_mica],
875 }, {
876 .name = "da903x-regulator",
877 .id = DA9030_ID_LDO9,
878 .platform_data = &stargate2_ldo_init_data[vcc_bt],
879 }, {
880 .name = "da903x-regulator",
881 .id = DA9030_ID_LDO10,
882 .platform_data = &stargate2_ldo_init_data[vcc_sensor_1_8],
883 }, {
884 .name = "da903x-regulator",
885 .id = DA9030_ID_LDO11,
886 .platform_data = &stargate2_ldo_init_data[vcc_sensor_3],
887 }, {
888 .name = "da903x-regulator",
889 .id = DA9030_ID_LDO12,
890 .platform_data = &stargate2_ldo_init_data[vcc_lcd],
891 }, {
892 .name = "da903x-regulator",
893 .id = DA9030_ID_LDO15,
894 .platform_data = &stargate2_ldo_init_data[vcc_pxa_pll],
895 }, {
896 .name = "da903x-regulator",
897 .id = DA9030_ID_LDO17,
898 .platform_data = &stargate2_ldo_init_data[vcc_pxa_usim],
899 }, {
900 .name = "da903x-regulator", /*pxa vcc i/o and cc2420 vcc i/o */
901 .id = DA9030_ID_LDO18,
902 .platform_data = &stargate2_ldo_init_data[vcc_io],
903 }, {
904 .name = "da903x-regulator",
905 .id = DA9030_ID_LDO19,
906 .platform_data = &stargate2_ldo_init_data[vcc_pxa_mem],
907 },
908};
909
910static struct da903x_platform_data stargate2_da9030_pdata = {
911 .num_subdevs = ARRAY_SIZE(stargate2_da9030_subdevs),
912 .subdevs = stargate2_da9030_subdevs,
913};
914
Jonathan Camerondcd925f92010-06-06 14:55:02 +0100915static struct i2c_board_info __initdata stargate2_pwr_i2c_board_info[] = {
Jonathan Cameron4036e1d2009-05-16 18:20:39 +0000916 {
Jonathan Camerondcd925f92010-06-06 14:55:02 +0100917 .type = "da9030",
918 .addr = 0x49,
919 .platform_data = &stargate2_da9030_pdata,
Haojian Zhuang4929f5a2011-10-10 16:03:51 +0800920 .irq = PXA_GPIO_TO_IRQ(1),
Jonathan Cameron4036e1d2009-05-16 18:20:39 +0000921 },
922};
923
Jonathan Cameron4036e1d2009-05-16 18:20:39 +0000924static struct i2c_board_info __initdata stargate2_i2c_board_info[] = {
925 /* Techically this a pca9500 - but it's compatible with the 8574
926 * for gpio expansion and the 24c02 for eeprom access.
927 */
928 {
929 .type = "pcf8574",
930 .addr = 0x27,
931 .platform_data = &platform_data_pcf857x,
932 }, {
933 .type = "24c02",
934 .addr = 0x57,
935 .platform_data = &pca9500_eeprom_pdata,
936 }, {
937 .type = "max1238",
938 .addr = 0x35,
939 }, { /* ITS400 Sensor board only */
940 .type = "max1363",
941 .addr = 0x34,
942 /* Through a nand gate - Also beware, on V2 sensor board the
943 * pull up resistors are missing.
944 */
Haojian Zhuang6384fda2011-10-10 14:21:08 +0800945 .irq = PXA_GPIO_TO_IRQ(99),
Jonathan Cameron4036e1d2009-05-16 18:20:39 +0000946 }, { /* ITS400 Sensor board only */
947 .type = "tsl2561",
948 .addr = 0x49,
949 /* Through a nand gate - Also beware, on V2 sensor board the
950 * pull up resistors are missing.
951 */
Haojian Zhuang6384fda2011-10-10 14:21:08 +0800952 .irq = PXA_GPIO_TO_IRQ(99),
Jonathan Cameron4036e1d2009-05-16 18:20:39 +0000953 }, { /* ITS400 Sensor board only */
954 .type = "tmp175",
955 .addr = 0x4A,
Haojian Zhuang6384fda2011-10-10 14:21:08 +0800956 .irq = PXA_GPIO_TO_IRQ(96),
Jonathan Cameron4036e1d2009-05-16 18:20:39 +0000957 },
958};
959
Jonathan Cameron4036e1d2009-05-16 18:20:39 +0000960/* Board doesn't support cable detection - so always lie and say
961 * something is there.
962 */
963static int sg2_udc_detect(void)
964{
965 return 1;
966}
967
968static struct pxa2xx_udc_mach_info stargate2_udc_info __initdata = {
969 .udc_is_connected = sg2_udc_detect,
970 .udc_command = sg2_udc_command,
971};
972
973static struct platform_device *stargate2_devices[] = {
974 &stargate2_flash_device,
975 &stargate2_sram,
976 &smc91x_device,
977 &sht15,
978};
979
Jonathan Cameron4036e1d2009-05-16 18:20:39 +0000980static void __init stargate2_init(void)
981{
982 /* This is probably a board specific hack as this must be set
983 prior to connecting the MFP stuff up. */
Marek Vasutad68bb92010-11-03 16:29:35 +0100984 __raw_writel(__raw_readl(MECR) & ~MECR_NOS, MECR);
Jonathan Cameron4036e1d2009-05-16 18:20:39 +0000985
986 pxa2xx_mfp_config(ARRAY_AND_SIZE(stargate2_pin_config));
987
Jonathan Camerondcd925f92010-06-06 14:55:02 +0100988 imote2_stargate2_init();
Russell Kingcc155c62009-11-09 13:34:08 +0800989
Jonathan Cameron4036e1d2009-05-16 18:20:39 +0000990 platform_add_devices(ARRAY_AND_SIZE(stargate2_devices));
991
Jonathan Cameron4036e1d2009-05-16 18:20:39 +0000992 i2c_register_board_info(0, ARRAY_AND_SIZE(stargate2_i2c_board_info));
Jonathan Camerondcd925f92010-06-06 14:55:02 +0100993 i2c_register_board_info(1, stargate2_pwr_i2c_board_info,
994 ARRAY_SIZE(stargate2_pwr_i2c_board_info));
Jonathan Cameron4036e1d2009-05-16 18:20:39 +0000995
996 pxa_set_mci_info(&stargate2_mci_platform_data);
997
998 pxa_set_udc_info(&stargate2_udc_info);
999
1000 stargate2_reset_bluetooth();
1001}
Jonathan Camerondcd925f92010-06-06 14:55:02 +01001002#endif
Jonathan Cameron4036e1d2009-05-16 18:20:39 +00001003
Jonathan Camerondcd925f92010-06-06 14:55:02 +01001004#ifdef CONFIG_MACH_INTELMOTE2
1005MACHINE_START(INTELMOTE2, "IMOTE 2")
Marek Vasut851982c2010-10-11 02:20:19 +02001006 .map_io = pxa27x_map_io,
Rob Herring4e611092012-01-03 16:53:48 -06001007 .nr_irqs = PXA_NR_IRQS,
Jonathan Camerondcd925f92010-06-06 14:55:02 +01001008 .init_irq = pxa27x_init_irq,
Eric Miao8a97ae22011-05-18 21:30:04 +08001009 .handle_irq = pxa27x_handle_irq,
Stephen Warren6bb27d72012-11-08 12:40:59 -07001010 .init_time = pxa_timer_init,
Jonathan Camerondcd925f92010-06-06 14:55:02 +01001011 .init_machine = imote2_init,
Nicolas Pitre7375aba2011-07-05 22:38:15 -04001012 .atag_offset = 0x100,
Russell King271a74f2011-11-04 14:15:53 +00001013 .restart = pxa_restart,
Jonathan Camerondcd925f92010-06-06 14:55:02 +01001014MACHINE_END
1015#endif
1016
1017#ifdef CONFIG_MACH_STARGATE2
Jonathan Cameron4036e1d2009-05-16 18:20:39 +00001018MACHINE_START(STARGATE2, "Stargate 2")
Marek Vasut851982c2010-10-11 02:20:19 +02001019 .map_io = pxa27x_map_io,
Haojian Zhuang6ac6b812010-08-20 15:23:59 +08001020 .nr_irqs = STARGATE_NR_IRQS,
Jonathan Cameron4036e1d2009-05-16 18:20:39 +00001021 .init_irq = pxa27x_init_irq,
Eric Miao8a97ae22011-05-18 21:30:04 +08001022 .handle_irq = pxa27x_handle_irq,
Stephen Warren6bb27d72012-11-08 12:40:59 -07001023 .init_time = pxa_timer_init,
Jonathan Cameron4036e1d2009-05-16 18:20:39 +00001024 .init_machine = stargate2_init,
Nicolas Pitre7375aba2011-07-05 22:38:15 -04001025 .atag_offset = 0x100,
Russell King271a74f2011-11-04 14:15:53 +00001026 .restart = pxa_restart,
Jonathan Cameron4036e1d2009-05-16 18:20:39 +00001027MACHINE_END
Jonathan Camerondcd925f92010-06-06 14:55:02 +01001028#endif