blob: 4c9a48bef569b41c57948d43d3dd9d8de8e686b5 [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>
30#include <linux/i2c/at24.h>
31#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
46#include <mach/pxa27x.h>
Jonathan Cameron4036e1d2009-05-16 18:20:39 +000047#include <mach/mmc.h>
48#include <mach/udc.h>
Jonathan Cameron4036e1d2009-05-16 18:20:39 +000049#include <mach/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>
55#include <linux/sht15.h>
56
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[] = {
154 {
155 .dev = &sht15.dev,
156 .supply = "vcc",
157 },
158};
159
160enum stargate2_ldos{
161 vcc_vref,
162 vcc_cc2420,
163 /* a mote connector? */
164 vcc_mica,
165 /* the CSR bluecore chip */
166 vcc_bt,
167 /* The two voltages available to sensor boards */
168 vcc_sensor_1_8,
169 vcc_sensor_3,
170 /* directly connected to the pxa27x */
171 vcc_sram_ext,
172 vcc_pxa_pll,
173 vcc_pxa_usim, /* Reference voltage for certain gpios */
174 vcc_pxa_mem,
175 vcc_pxa_flash,
176 vcc_pxa_core, /*Dc-Dc buck not yet supported */
177 vcc_lcd,
178 vcc_bb,
179 vcc_bbio, /*not sure!*/
180 vcc_io, /* cc2420 802.15.4 radio and pxa vcc_io ?*/
181};
182
183/* The values of the various regulator constraints are obviously dependent
184 * on exactly what is wired to each ldo. Unfortunately this information is
185 * not generally available. More information has been requested from Xbow.
186 */
187static struct regulator_init_data stargate2_ldo_init_data[] = {
188 [vcc_bbio] = {
189 .constraints = { /* board default 1.8V */
190 .name = "vcc_bbio",
191 .min_uV = 1800000,
192 .max_uV = 1800000,
193 },
194 },
195 [vcc_bb] = {
196 .constraints = { /* board default 2.8V */
197 .name = "vcc_bb",
198 .min_uV = 2700000,
199 .max_uV = 3000000,
200 },
201 },
202 [vcc_pxa_flash] = {
203 .constraints = {/* default is 1.8V */
204 .name = "vcc_pxa_flash",
205 .min_uV = 1800000,
206 .max_uV = 1800000,
207 },
208 },
209 [vcc_cc2420] = { /* also vcc_io */
210 .constraints = {
211 /* board default is 2.8V */
212 .name = "vcc_cc2420",
213 .min_uV = 2700000,
214 .max_uV = 3300000,
215 },
216 },
217 [vcc_vref] = { /* Reference for what? */
218 .constraints = { /* default 1.8V */
219 .name = "vcc_vref",
220 .min_uV = 1800000,
221 .max_uV = 1800000,
222 },
223 },
224 [vcc_sram_ext] = {
225 .constraints = { /* default 2.8V */
226 .name = "vcc_sram_ext",
227 .min_uV = 2800000,
228 .max_uV = 2800000,
229 },
230 },
231 [vcc_mica] = {
232 .constraints = { /* default 2.8V */
233 .name = "vcc_mica",
234 .min_uV = 2800000,
235 .max_uV = 2800000,
236 },
237 },
238 [vcc_bt] = {
239 .constraints = { /* default 2.8V */
240 .name = "vcc_bt",
241 .min_uV = 2800000,
242 .max_uV = 2800000,
243 },
244 },
245 [vcc_lcd] = {
246 .constraints = { /* default 2.8V */
247 .name = "vcc_lcd",
248 .min_uV = 2700000,
249 .max_uV = 3300000,
250 },
251 },
252 [vcc_io] = { /* Same or higher than everything
253 * bar vccbat and vccusb */
254 .constraints = { /* default 2.8V */
255 .name = "vcc_io",
256 .min_uV = 2692000,
257 .max_uV = 3300000,
258 },
259 },
260 [vcc_sensor_1_8] = {
261 .constraints = { /* default 1.8V */
262 .name = "vcc_sensor_1_8",
263 .min_uV = 1800000,
264 .max_uV = 1800000,
265 },
266 },
267 [vcc_sensor_3] = { /* curiously default 2.8V */
268 .constraints = {
269 .name = "vcc_sensor_3",
270 .min_uV = 2800000,
271 .max_uV = 3000000,
272 },
273 .num_consumer_supplies = ARRAY_SIZE(stargate2_sensor_3_con),
274 .consumer_supplies = stargate2_sensor_3_con,
275 },
276 [vcc_pxa_pll] = { /* 1.17V - 1.43V, default 1.3V*/
277 .constraints = {
278 .name = "vcc_pxa_pll",
279 .min_uV = 1170000,
280 .max_uV = 1430000,
281 },
282 },
283 [vcc_pxa_usim] = {
284 .constraints = { /* default 1.8V */
285 .name = "vcc_pxa_usim",
286 .min_uV = 1710000,
287 .max_uV = 2160000,
288 },
289 },
290 [vcc_pxa_mem] = {
291 .constraints = { /* default 1.8V */
292 .name = "vcc_pxa_mem",
293 .min_uV = 1800000,
294 .max_uV = 1800000,
295 },
296 },
297};
298
Jonathan Camerondcd925f92010-06-06 14:55:02 +0100299static struct mtd_partition stargate2flash_partitions[] = {
300 {
301 .name = "Bootloader",
302 .size = 0x00040000,
303 .offset = 0,
304 .mask_flags = 0,
305 }, {
306 .name = "Kernel",
307 .size = 0x00200000,
308 .offset = 0x00040000,
309 .mask_flags = 0
310 }, {
311 .name = "Filesystem",
312 .size = 0x01DC0000,
313 .offset = 0x00240000,
314 .mask_flags = 0
315 },
316};
317
318static struct resource flash_resources = {
319 .start = PXA_CS0_PHYS,
320 .end = PXA_CS0_PHYS + SZ_32M - 1,
321 .flags = IORESOURCE_MEM,
322};
323
324static struct flash_platform_data stargate2_flash_data = {
325 .map_name = "cfi_probe",
326 .parts = stargate2flash_partitions,
327 .nr_parts = ARRAY_SIZE(stargate2flash_partitions),
328 .name = "PXA27xOnChipROM",
329 .width = 2,
330};
331
332static struct platform_device stargate2_flash_device = {
333 .name = "pxa2xx-flash",
334 .id = 0,
335 .dev = {
336 .platform_data = &stargate2_flash_data,
337 },
338 .resource = &flash_resources,
339 .num_resources = 1,
340};
341
342static struct pxa2xx_spi_master pxa_ssp_master_0_info = {
343 .num_chipselect = 1,
344};
345
346static struct pxa2xx_spi_master pxa_ssp_master_1_info = {
347 .num_chipselect = 1,
348};
349
350static struct pxa2xx_spi_master pxa_ssp_master_2_info = {
351 .num_chipselect = 1,
352};
353
354/* An upcoming kernel change will scrap SFRM usage so these
355 * drivers have been moved to use gpio's via cs_control */
356static struct pxa2xx_spi_chip staccel_chip_info = {
357 .tx_threshold = 8,
358 .rx_threshold = 8,
359 .dma_burst_size = 8,
360 .timeout = 235,
361 .gpio_cs = 24,
362};
363
364static struct pxa2xx_spi_chip cc2420_info = {
365 .tx_threshold = 8,
366 .rx_threshold = 8,
367 .dma_burst_size = 8,
368 .timeout = 235,
369 .gpio_cs = 39,
370};
371
372static struct spi_board_info spi_board_info[] __initdata = {
373 {
374 .modalias = "lis3l02dq",
375 .max_speed_hz = 8000000,/* 8MHz max spi frequency at 3V */
376 .bus_num = 1,
377 .chip_select = 0,
378 .controller_data = &staccel_chip_info,
379 .irq = IRQ_GPIO(96),
380 }, {
381 .modalias = "cc2420",
382 .max_speed_hz = 6500000,
383 .bus_num = 3,
384 .chip_select = 0,
385 .controller_data = &cc2420_info,
386 },
387};
388
389static void sg2_udc_command(int cmd)
390{
391 switch (cmd) {
392 case PXA2XX_UDC_CMD_CONNECT:
393 UP2OCR |= UP2OCR_HXOE | UP2OCR_DPPUE | UP2OCR_DPPUBE;
394 break;
395 case PXA2XX_UDC_CMD_DISCONNECT:
396 UP2OCR &= ~(UP2OCR_HXOE | UP2OCR_DPPUE | UP2OCR_DPPUBE);
397 break;
398 }
399}
400
401static struct i2c_pxa_platform_data i2c_pwr_pdata = {
402 .fast_mode = 1,
403};
404
405static struct i2c_pxa_platform_data i2c_pdata = {
406 .fast_mode = 1,
407};
408
409static void __init imote2_stargate2_init(void)
410{
411
412 pxa2xx_mfp_config(ARRAY_AND_SIZE(sg2_im2_unified_pin_config));
413
414 pxa_set_ffuart_info(NULL);
415 pxa_set_btuart_info(NULL);
416 pxa_set_stuart_info(NULL);
417
418 pxa2xx_set_spi_info(1, &pxa_ssp_master_0_info);
419 pxa2xx_set_spi_info(2, &pxa_ssp_master_1_info);
420 pxa2xx_set_spi_info(3, &pxa_ssp_master_2_info);
421 spi_register_board_info(spi_board_info, ARRAY_SIZE(spi_board_info));
422
423
424 pxa27x_set_i2c_power_info(&i2c_pwr_pdata);
425 pxa_set_i2c_info(&i2c_pdata);
426}
427
428#ifdef CONFIG_MACH_INTELMOTE2
429/* As the the imote2 doesn't currently have a conventional SD slot
430 * there is no option to hotplug cards, making all this rather simple
431 */
432static int imote2_mci_get_ro(struct device *dev)
433{
434 return 0;
435}
436
437/* Rather simple case as hotplugging not possible */
438static struct pxamci_platform_data imote2_mci_platform_data = {
439 .ocr_mask = MMC_VDD_32_33 | MMC_VDD_33_34, /* default anyway */
440 .get_ro = imote2_mci_get_ro,
441 .gpio_card_detect = -1,
442 .gpio_card_ro = -1,
443 .gpio_power = -1,
444};
445
446static struct gpio_led imote2_led_pins[] = {
447 {
448 .name = "imote2:red",
449 .gpio = 103,
450 .active_low = 1,
451 }, {
452 .name = "imote2:green",
453 .gpio = 104,
454 .active_low = 1,
455 }, {
456 .name = "imote2:blue",
457 .gpio = 105,
458 .active_low = 1,
459 },
460};
461
462static struct gpio_led_platform_data imote2_led_data = {
463 .num_leds = ARRAY_SIZE(imote2_led_pins),
464 .leds = imote2_led_pins,
465};
466
467static struct platform_device imote2_leds = {
468 .name = "leds-gpio",
469 .id = -1,
470 .dev = {
471 .platform_data = &imote2_led_data,
472 },
473};
474
475static struct da903x_subdev_info imote2_da9030_subdevs[] = {
476 {
477 .name = "da903x-regulator",
478 .id = DA9030_ID_LDO2,
479 .platform_data = &stargate2_ldo_init_data[vcc_bbio],
480 }, {
481 .name = "da903x-regulator",
482 .id = DA9030_ID_LDO3,
483 .platform_data = &stargate2_ldo_init_data[vcc_bb],
484 }, {
485 .name = "da903x-regulator",
486 .id = DA9030_ID_LDO4,
487 .platform_data = &stargate2_ldo_init_data[vcc_pxa_flash],
488 }, {
489 .name = "da903x-regulator",
490 .id = DA9030_ID_LDO5,
491 .platform_data = &stargate2_ldo_init_data[vcc_cc2420],
492 }, {
493 .name = "da903x-regulator",
494 .id = DA9030_ID_LDO6,
495 .platform_data = &stargate2_ldo_init_data[vcc_vref],
496 }, {
497 .name = "da903x-regulator",
498 .id = DA9030_ID_LDO7,
499 .platform_data = &stargate2_ldo_init_data[vcc_sram_ext],
500 }, {
501 .name = "da903x-regulator",
502 .id = DA9030_ID_LDO8,
503 .platform_data = &stargate2_ldo_init_data[vcc_mica],
504 }, {
505 .name = "da903x-regulator",
506 .id = DA9030_ID_LDO9,
507 .platform_data = &stargate2_ldo_init_data[vcc_bt],
508 }, {
509 .name = "da903x-regulator",
510 .id = DA9030_ID_LDO10,
511 .platform_data = &stargate2_ldo_init_data[vcc_sensor_1_8],
512 }, {
513 .name = "da903x-regulator",
514 .id = DA9030_ID_LDO11,
515 .platform_data = &stargate2_ldo_init_data[vcc_sensor_3],
516 }, {
517 .name = "da903x-regulator",
518 .id = DA9030_ID_LDO12,
519 .platform_data = &stargate2_ldo_init_data[vcc_lcd],
520 }, {
521 .name = "da903x-regulator",
522 .id = DA9030_ID_LDO15,
523 .platform_data = &stargate2_ldo_init_data[vcc_pxa_pll],
524 }, {
525 .name = "da903x-regulator",
526 .id = DA9030_ID_LDO17,
527 .platform_data = &stargate2_ldo_init_data[vcc_pxa_usim],
528 }, {
529 .name = "da903x-regulator", /*pxa vcc i/o and cc2420 vcc i/o */
530 .id = DA9030_ID_LDO18,
531 .platform_data = &stargate2_ldo_init_data[vcc_io],
532 }, {
533 .name = "da903x-regulator",
534 .id = DA9030_ID_LDO19,
535 .platform_data = &stargate2_ldo_init_data[vcc_pxa_mem],
536 },
537};
538
539static struct da903x_platform_data imote2_da9030_pdata = {
540 .num_subdevs = ARRAY_SIZE(imote2_da9030_subdevs),
541 .subdevs = imote2_da9030_subdevs,
542};
543
544static struct i2c_board_info __initdata imote2_pwr_i2c_board_info[] = {
545 {
546 .type = "da9030",
547 .addr = 0x49,
548 .platform_data = &imote2_da9030_pdata,
549 .irq = gpio_to_irq(1),
550 },
551};
552
553static struct i2c_board_info __initdata imote2_i2c_board_info[] = {
554 { /* UCAM sensor board */
555 .type = "max1239",
556 .addr = 0x35,
557 }, { /* ITS400 Sensor board only */
558 .type = "max1363",
559 .addr = 0x34,
560 /* Through a nand gate - Also beware, on V2 sensor board the
561 * pull up resistors are missing.
562 */
563 .irq = IRQ_GPIO(99),
564 }, { /* ITS400 Sensor board only */
565 .type = "tsl2561",
566 .addr = 0x49,
567 /* Through a nand gate - Also beware, on V2 sensor board the
568 * pull up resistors are missing.
569 */
570 .irq = IRQ_GPIO(99),
571 }, { /* ITS400 Sensor board only */
572 .type = "tmp175",
573 .addr = 0x4A,
574 .irq = IRQ_GPIO(96),
575 }, { /* IMB400 Multimedia board */
576 .type = "wm8940",
577 .addr = 0x1A,
578 },
579};
580
581static unsigned long imote2_pin_config[] __initdata = {
582
583 /* Button */
584 GPIO91_GPIO,
585
586 /* LEDS */
587 GPIO103_GPIO, /* red led */
588 GPIO104_GPIO, /* green led */
589 GPIO105_GPIO, /* blue led */
590};
591
592static struct pxa2xx_udc_mach_info imote2_udc_info __initdata = {
593 .udc_command = sg2_udc_command,
594};
595
596static struct platform_device *imote2_devices[] = {
597 &stargate2_flash_device,
598 &imote2_leds,
599 &sht15,
600};
601
602static void __init imote2_init(void)
603{
604 pxa2xx_mfp_config(ARRAY_AND_SIZE(imote2_pin_config));
605
606 imote2_stargate2_init();
607
608 platform_add_devices(imote2_devices, ARRAY_SIZE(imote2_devices));
609
610 i2c_register_board_info(0, imote2_i2c_board_info,
611 ARRAY_SIZE(imote2_i2c_board_info));
612 i2c_register_board_info(1, imote2_pwr_i2c_board_info,
613 ARRAY_SIZE(imote2_pwr_i2c_board_info));
614
615 pxa_set_mci_info(&imote2_mci_platform_data);
616 pxa_set_udc_info(&imote2_udc_info);
617}
618#endif
619
620#ifdef CONFIG_MACH_STARGATE2
621
622static unsigned long stargate2_pin_config[] __initdata = {
623
624 GPIO15_nCS_1, /* SRAM */
625 /* SMC91x */
626 GPIO80_nCS_4,
627 GPIO40_GPIO, /*cable detect?*/
628
629 /* Button */
630 GPIO91_GPIO | WAKEUP_ON_LEVEL_HIGH,
631
632 /* Compact Flash */
633 GPIO79_PSKTSEL,
634 GPIO48_nPOE,
635 GPIO49_nPWE,
636 GPIO50_nPIOR,
637 GPIO51_nPIOW,
638 GPIO85_nPCE_1,
639 GPIO54_nPCE_2,
640 GPIO55_nPREG,
641 GPIO56_nPWAIT,
642 GPIO57_nIOIS16,
643 GPIO120_GPIO, /* Buff ctrl */
644 GPIO108_GPIO, /* Power ctrl */
645 GPIO82_GPIO, /* Reset */
646 GPIO53_GPIO, /* SG2_S0_GPIO_DETECT */
647
648 /* MMC not shared with imote2 */
649 GPIO90_GPIO, /* nSD detect */
650 GPIO89_GPIO, /* SD_POWER_ENABLE */
651
652 /* Bluetooth */
653 GPIO81_GPIO, /* reset */
654};
655
656static struct resource smc91x_resources[] = {
657 [0] = {
658 .name = "smc91x-regs",
659 .start = (PXA_CS4_PHYS + 0x300),
660 .end = (PXA_CS4_PHYS + 0xfffff),
661 .flags = IORESOURCE_MEM,
662 },
663 [1] = {
664 .start = IRQ_GPIO(40),
665 .end = IRQ_GPIO(40),
666 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE,
667 }
668};
669
670static struct smc91x_platdata stargate2_smc91x_info = {
671 .flags = SMC91X_USE_8BIT | SMC91X_USE_16BIT | SMC91X_USE_32BIT
672 | SMC91X_NOWAIT | SMC91X_USE_DMA,
673};
674
675static struct platform_device smc91x_device = {
676 .name = "smc91x",
677 .id = -1,
678 .num_resources = ARRAY_SIZE(smc91x_resources),
679 .resource = smc91x_resources,
680 .dev = {
681 .platform_data = &stargate2_smc91x_info,
682 },
683};
684
685
686/*
687 * The card detect interrupt isn't debounced so we delay it by 250ms
688 * to give the card a chance to fully insert / eject.
689 */
690static int stargate2_mci_init(struct device *dev,
691 irq_handler_t stargate2_detect_int,
692 void *data)
693{
694 int err;
695
696 err = gpio_request(SG2_SD_POWER_ENABLE, "SG2_sd_power_enable");
697 if (err) {
698 printk(KERN_ERR "Can't get the gpio for SD power control");
699 goto return_err;
700 }
701 gpio_direction_output(SG2_SD_POWER_ENABLE, 0);
702
703 err = gpio_request(SG2_GPIO_nSD_DETECT, "SG2_sd_detect");
704 if (err) {
705 printk(KERN_ERR "Can't get the sd detect gpio");
706 goto free_power_en;
707 }
708 gpio_direction_input(SG2_GPIO_nSD_DETECT);
709
710 err = request_irq(IRQ_GPIO(SG2_GPIO_nSD_DETECT),
711 stargate2_detect_int,
712 IRQ_TYPE_EDGE_BOTH,
713 "MMC card detect",
714 data);
715 if (err) {
716 printk(KERN_ERR "can't request MMC card detect IRQ\n");
717 goto free_nsd_detect;
718 }
719 return 0;
720
721 free_nsd_detect:
722 gpio_free(SG2_GPIO_nSD_DETECT);
723 free_power_en:
724 gpio_free(SG2_SD_POWER_ENABLE);
725 return_err:
726 return err;
727}
728
729/**
730 * stargate2_mci_setpower() - set state of mmc power supply
731 *
732 * Very simple control. Either it is on or off and is controlled by
733 * a gpio pin */
734static void stargate2_mci_setpower(struct device *dev, unsigned int vdd)
735{
736 gpio_set_value(SG2_SD_POWER_ENABLE, !!vdd);
737}
738
739static void stargate2_mci_exit(struct device *dev, void *data)
740{
741 free_irq(IRQ_GPIO(SG2_GPIO_nSD_DETECT), data);
742 gpio_free(SG2_SD_POWER_ENABLE);
743 gpio_free(SG2_GPIO_nSD_DETECT);
744}
745
746static struct pxamci_platform_data stargate2_mci_platform_data = {
747 .detect_delay_ms = 250,
748 .ocr_mask = MMC_VDD_32_33 | MMC_VDD_33_34,
749 .init = stargate2_mci_init,
750 .setpower = stargate2_mci_setpower,
751 .exit = stargate2_mci_exit,
752};
753
754
755/*
756 * SRAM - The Stargate 2 has 32MB of SRAM.
757 *
758 * Here it is made available as an MTD. This will then
759 * typically have a cifs filesystem created on it to provide
760 * fast temporary storage.
761 */
762static struct resource sram_resources = {
763 .start = PXA_CS1_PHYS,
764 .end = PXA_CS1_PHYS + SZ_32M-1,
765 .flags = IORESOURCE_MEM,
766};
767
768static struct platdata_mtd_ram stargate2_sram_pdata = {
769 .mapname = "Stargate2 SRAM",
770 .bankwidth = 2,
771};
772
773static struct platform_device stargate2_sram = {
774 .name = "mtd-ram",
775 .id = 0,
776 .resource = &sram_resources,
777 .num_resources = 1,
778 .dev = {
779 .platform_data = &stargate2_sram_pdata,
780 },
781};
782
783static struct pcf857x_platform_data platform_data_pcf857x = {
784 .gpio_base = 128,
785 .n_latch = 0,
786 .setup = NULL,
787 .teardown = NULL,
788 .context = NULL,
789};
790
791static struct at24_platform_data pca9500_eeprom_pdata = {
792 .byte_len = 256,
793 .page_size = 4,
794};
795
796/**
797 * stargate2_reset_bluetooth() reset the bluecore to ensure consistent state
798 **/
799static int stargate2_reset_bluetooth(void)
800{
801 int err;
802 err = gpio_request(SG2_BT_RESET, "SG2_BT_RESET");
803 if (err) {
804 printk(KERN_ERR "Could not get gpio for bluetooth reset\n");
805 return err;
806 }
807 gpio_direction_output(SG2_BT_RESET, 1);
808 mdelay(5);
809 /* now reset it - 5 msec minimum */
810 gpio_set_value(SG2_BT_RESET, 0);
811 mdelay(10);
812 gpio_set_value(SG2_BT_RESET, 1);
813 gpio_free(SG2_BT_RESET);
814 return 0;
815}
816
817static struct led_info stargate2_leds[] = {
818 {
819 .name = "sg2:red",
820 .flags = DA9030_LED_RATE_ON,
821 }, {
822 .name = "sg2:blue",
823 .flags = DA9030_LED_RATE_ON,
824 }, {
825 .name = "sg2:green",
826 .flags = DA9030_LED_RATE_ON,
827 },
828};
829
Jonathan Cameron4036e1d2009-05-16 18:20:39 +0000830static struct da903x_subdev_info stargate2_da9030_subdevs[] = {
831 {
832 .name = "da903x-led",
833 .id = DA9030_ID_LED_2,
834 .platform_data = &stargate2_leds[0],
835 }, {
836 .name = "da903x-led",
837 .id = DA9030_ID_LED_3,
838 .platform_data = &stargate2_leds[2],
839 }, {
840 .name = "da903x-led",
841 .id = DA9030_ID_LED_4,
842 .platform_data = &stargate2_leds[1],
843 }, {
844 .name = "da903x-regulator",
845 .id = DA9030_ID_LDO2,
846 .platform_data = &stargate2_ldo_init_data[vcc_bbio],
847 }, {
848 .name = "da903x-regulator",
849 .id = DA9030_ID_LDO3,
850 .platform_data = &stargate2_ldo_init_data[vcc_bb],
851 }, {
852 .name = "da903x-regulator",
853 .id = DA9030_ID_LDO4,
854 .platform_data = &stargate2_ldo_init_data[vcc_pxa_flash],
855 }, {
856 .name = "da903x-regulator",
857 .id = DA9030_ID_LDO5,
858 .platform_data = &stargate2_ldo_init_data[vcc_cc2420],
859 }, {
860 .name = "da903x-regulator",
861 .id = DA9030_ID_LDO6,
862 .platform_data = &stargate2_ldo_init_data[vcc_vref],
863 }, {
864 .name = "da903x-regulator",
865 .id = DA9030_ID_LDO7,
866 .platform_data = &stargate2_ldo_init_data[vcc_sram_ext],
867 }, {
868 .name = "da903x-regulator",
869 .id = DA9030_ID_LDO8,
870 .platform_data = &stargate2_ldo_init_data[vcc_mica],
871 }, {
872 .name = "da903x-regulator",
873 .id = DA9030_ID_LDO9,
874 .platform_data = &stargate2_ldo_init_data[vcc_bt],
875 }, {
876 .name = "da903x-regulator",
877 .id = DA9030_ID_LDO10,
878 .platform_data = &stargate2_ldo_init_data[vcc_sensor_1_8],
879 }, {
880 .name = "da903x-regulator",
881 .id = DA9030_ID_LDO11,
882 .platform_data = &stargate2_ldo_init_data[vcc_sensor_3],
883 }, {
884 .name = "da903x-regulator",
885 .id = DA9030_ID_LDO12,
886 .platform_data = &stargate2_ldo_init_data[vcc_lcd],
887 }, {
888 .name = "da903x-regulator",
889 .id = DA9030_ID_LDO15,
890 .platform_data = &stargate2_ldo_init_data[vcc_pxa_pll],
891 }, {
892 .name = "da903x-regulator",
893 .id = DA9030_ID_LDO17,
894 .platform_data = &stargate2_ldo_init_data[vcc_pxa_usim],
895 }, {
896 .name = "da903x-regulator", /*pxa vcc i/o and cc2420 vcc i/o */
897 .id = DA9030_ID_LDO18,
898 .platform_data = &stargate2_ldo_init_data[vcc_io],
899 }, {
900 .name = "da903x-regulator",
901 .id = DA9030_ID_LDO19,
902 .platform_data = &stargate2_ldo_init_data[vcc_pxa_mem],
903 },
904};
905
906static struct da903x_platform_data stargate2_da9030_pdata = {
907 .num_subdevs = ARRAY_SIZE(stargate2_da9030_subdevs),
908 .subdevs = stargate2_da9030_subdevs,
909};
910
Jonathan Camerondcd925f92010-06-06 14:55:02 +0100911static struct i2c_board_info __initdata stargate2_pwr_i2c_board_info[] = {
Jonathan Cameron4036e1d2009-05-16 18:20:39 +0000912 {
Jonathan Camerondcd925f92010-06-06 14:55:02 +0100913 .type = "da9030",
914 .addr = 0x49,
915 .platform_data = &stargate2_da9030_pdata,
916 .irq = gpio_to_irq(1),
Jonathan Cameron4036e1d2009-05-16 18:20:39 +0000917 },
918};
919
Jonathan Cameron4036e1d2009-05-16 18:20:39 +0000920static struct i2c_board_info __initdata stargate2_i2c_board_info[] = {
921 /* Techically this a pca9500 - but it's compatible with the 8574
922 * for gpio expansion and the 24c02 for eeprom access.
923 */
924 {
925 .type = "pcf8574",
926 .addr = 0x27,
927 .platform_data = &platform_data_pcf857x,
928 }, {
929 .type = "24c02",
930 .addr = 0x57,
931 .platform_data = &pca9500_eeprom_pdata,
932 }, {
933 .type = "max1238",
934 .addr = 0x35,
935 }, { /* ITS400 Sensor board only */
936 .type = "max1363",
937 .addr = 0x34,
938 /* Through a nand gate - Also beware, on V2 sensor board the
939 * pull up resistors are missing.
940 */
941 .irq = IRQ_GPIO(99),
942 }, { /* ITS400 Sensor board only */
943 .type = "tsl2561",
944 .addr = 0x49,
945 /* Through a nand gate - Also beware, on V2 sensor board the
946 * pull up resistors are missing.
947 */
948 .irq = IRQ_GPIO(99),
949 }, { /* ITS400 Sensor board only */
950 .type = "tmp175",
951 .addr = 0x4A,
952 .irq = IRQ_GPIO(96),
953 },
954};
955
Jonathan Cameron4036e1d2009-05-16 18:20:39 +0000956/* Board doesn't support cable detection - so always lie and say
957 * something is there.
958 */
959static int sg2_udc_detect(void)
960{
961 return 1;
962}
963
964static struct pxa2xx_udc_mach_info stargate2_udc_info __initdata = {
965 .udc_is_connected = sg2_udc_detect,
966 .udc_command = sg2_udc_command,
967};
968
969static struct platform_device *stargate2_devices[] = {
970 &stargate2_flash_device,
971 &stargate2_sram,
972 &smc91x_device,
973 &sht15,
974};
975
Jonathan Cameron4036e1d2009-05-16 18:20:39 +0000976static void __init stargate2_init(void)
977{
978 /* This is probably a board specific hack as this must be set
979 prior to connecting the MFP stuff up. */
Marek Vasutad68bb92010-11-03 16:29:35 +0100980 __raw_writel(__raw_readl(MECR) & ~MECR_NOS, MECR);
Jonathan Cameron4036e1d2009-05-16 18:20:39 +0000981
982 pxa2xx_mfp_config(ARRAY_AND_SIZE(stargate2_pin_config));
983
Jonathan Camerondcd925f92010-06-06 14:55:02 +0100984 imote2_stargate2_init();
Russell Kingcc155c62009-11-09 13:34:08 +0800985
Jonathan Cameron4036e1d2009-05-16 18:20:39 +0000986 platform_add_devices(ARRAY_AND_SIZE(stargate2_devices));
987
Jonathan Cameron4036e1d2009-05-16 18:20:39 +0000988 i2c_register_board_info(0, ARRAY_AND_SIZE(stargate2_i2c_board_info));
Jonathan Camerondcd925f92010-06-06 14:55:02 +0100989 i2c_register_board_info(1, stargate2_pwr_i2c_board_info,
990 ARRAY_SIZE(stargate2_pwr_i2c_board_info));
Jonathan Cameron4036e1d2009-05-16 18:20:39 +0000991
992 pxa_set_mci_info(&stargate2_mci_platform_data);
993
994 pxa_set_udc_info(&stargate2_udc_info);
995
996 stargate2_reset_bluetooth();
997}
Jonathan Camerondcd925f92010-06-06 14:55:02 +0100998#endif
Jonathan Cameron4036e1d2009-05-16 18:20:39 +0000999
Jonathan Camerondcd925f92010-06-06 14:55:02 +01001000#ifdef CONFIG_MACH_INTELMOTE2
1001MACHINE_START(INTELMOTE2, "IMOTE 2")
Marek Vasut851982c2010-10-11 02:20:19 +02001002 .map_io = pxa27x_map_io,
Jonathan Camerondcd925f92010-06-06 14:55:02 +01001003 .init_irq = pxa27x_init_irq,
Eric Miao8a97ae22011-05-18 21:30:04 +08001004 .handle_irq = pxa27x_handle_irq,
Jonathan Camerondcd925f92010-06-06 14:55:02 +01001005 .timer = &pxa_timer,
1006 .init_machine = imote2_init,
Nicolas Pitre7375aba2011-07-05 22:38:15 -04001007 .atag_offset = 0x100,
Jonathan Camerondcd925f92010-06-06 14:55:02 +01001008MACHINE_END
1009#endif
1010
1011#ifdef CONFIG_MACH_STARGATE2
Jonathan Cameron4036e1d2009-05-16 18:20:39 +00001012MACHINE_START(STARGATE2, "Stargate 2")
Marek Vasut851982c2010-10-11 02:20:19 +02001013 .map_io = pxa27x_map_io,
Haojian Zhuang6ac6b812010-08-20 15:23:59 +08001014 .nr_irqs = STARGATE_NR_IRQS,
Jonathan Cameron4036e1d2009-05-16 18:20:39 +00001015 .init_irq = pxa27x_init_irq,
Eric Miao8a97ae22011-05-18 21:30:04 +08001016 .handle_irq = pxa27x_handle_irq,
Jonathan Cameron4036e1d2009-05-16 18:20:39 +00001017 .timer = &pxa_timer,
1018 .init_machine = stargate2_init,
Nicolas Pitre7375aba2011-07-05 22:38:15 -04001019 .atag_offset = 0x100,
Jonathan Cameron4036e1d2009-05-16 18:20:39 +00001020MACHINE_END
Jonathan Camerondcd925f92010-06-06 14:55:02 +01001021#endif