1
2
3
4
5
6
7
8
9
10
11
12
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
28#include <linux/i2c/pcf857x.h>
29#include <linux/i2c/at24.h>
30#include <linux/smc91x.h>
31#include <linux/gpio.h>
32
33#include <asm/types.h>
34#include <asm/setup.h>
35#include <asm/memory.h>
36#include <asm/mach-types.h>
37#include <asm/irq.h>
38
39#include <asm/mach/arch.h>
40#include <asm/mach/map.h>
41#include <asm/mach/irq.h>
42#include <asm/mach/flash.h>
43
44#include <mach/pxa27x.h>
45#include <plat/i2c.h>
46#include <mach/mmc.h>
47#include <mach/udc.h>
48#include <mach/pxa2xx_spi.h>
49#include <mach/pxa27x-udc.h>
50
51#include <linux/spi/spi.h>
52#include <linux/mfd/da903x.h>
53#include <linux/sht15.h>
54
55#include "devices.h"
56#include "generic.h"
57
58
59#define SG2_BT_RESET 81
60
61
62#define SG2_GPIO_nSD_DETECT 90
63#define SG2_SD_POWER_ENABLE 89
64
65static unsigned long stargate2_pin_config[] __initdata = {
66
67 GPIO15_nCS_1,
68
69 GPIO80_nCS_4,
70 GPIO40_GPIO,
71
72 GPIO102_GPIO,
73
74
75 GPIO91_GPIO | WAKEUP_ON_LEVEL_HIGH,
76
77
78 GPIO1_GPIO,
79
80
81 GPIO79_PSKTSEL,
82 GPIO48_nPOE,
83 GPIO49_nPWE,
84 GPIO50_nPIOR,
85 GPIO51_nPIOW,
86 GPIO85_nPCE_1,
87 GPIO54_nPCE_2,
88 GPIO55_nPREG,
89 GPIO56_nPWAIT,
90 GPIO57_nIOIS16,
91 GPIO120_GPIO,
92 GPIO108_GPIO,
93 GPIO82_GPIO,
94 GPIO53_GPIO,
95
96
97 GPIO32_MMC_CLK,
98 GPIO112_MMC_CMD,
99 GPIO92_MMC_DAT_0,
100 GPIO109_MMC_DAT_1,
101 GPIO110_MMC_DAT_2,
102 GPIO111_MMC_DAT_3,
103 GPIO90_GPIO,
104 GPIO89_GPIO,
105
106
107 GPIO81_GPIO,
108
109
110 GPIO22_GPIO,
111 GPIO114_GPIO,
112 GPIO116_GPIO,
113 GPIO0_GPIO,
114 GPIO16_GPIO,
115 GPIO39_GPIO,
116
117
118 GPIO117_I2C_SCL,
119 GPIO118_I2C_SDA,
120
121
122 GPIO39_GPIO,
123 GPIO34_SSP3_SCLK,
124 GPIO35_SSP3_TXD,
125 GPIO41_SSP3_RXD,
126
127
128 GPIO11_SSP2_RXD,
129 GPIO38_SSP2_TXD,
130 GPIO36_SSP2_SCLK,
131 GPIO37_GPIO,
132
133
134 GPIO26_SSP1_RXD,
135 GPIO25_SSP1_TXD,
136 GPIO23_SSP1_SCLK,
137 GPIO24_GPIO,
138
139
140 GPIO42_BTUART_RXD,
141 GPIO43_BTUART_TXD,
142 GPIO44_BTUART_CTS,
143 GPIO45_BTUART_RTS,
144
145
146 GPIO46_STUART_RXD,
147 GPIO47_STUART_TXD,
148
149
150 GPIO96_GPIO,
151 GPIO99_GPIO,
152
153
154 GPIO94_GPIO,
155 GPIO10_GPIO,
156
157
158 GPIO100_GPIO,
159 GPIO98_GPIO,
160};
161
162
163
164
165static int stargate2_reset_bluetooth(void)
166{
167 int err;
168 err = gpio_request(SG2_BT_RESET, "SG2_BT_RESET");
169 if (err) {
170 printk(KERN_ERR "Could not get gpio for bluetooth reset \n");
171 return err;
172 }
173 gpio_direction_output(SG2_BT_RESET, 1);
174 mdelay(5);
175
176 gpio_set_value(SG2_BT_RESET, 0);
177 mdelay(10);
178 gpio_set_value(SG2_BT_RESET, 1);
179 gpio_free(SG2_BT_RESET);
180 return 0;
181}
182
183static struct led_info stargate2_leds[] = {
184 {
185 .name = "sg2:red",
186 .flags = DA9030_LED_RATE_ON,
187 }, {
188 .name = "sg2:blue",
189 .flags = DA9030_LED_RATE_ON,
190 }, {
191 .name = "sg2:green",
192 .flags = DA9030_LED_RATE_ON,
193 },
194};
195
196static struct sht15_platform_data platform_data_sht15 = {
197 .gpio_data = 100,
198 .gpio_sck = 98,
199};
200
201static struct platform_device sht15 = {
202 .name = "sht15",
203 .id = -1,
204 .dev = {
205 .platform_data = &platform_data_sht15,
206 },
207};
208
209static struct regulator_consumer_supply stargate2_sensor_3_con[] = {
210 {
211 .dev = &sht15.dev,
212 .supply = "vcc",
213 },
214};
215
216enum stargate2_ldos{
217 vcc_vref,
218 vcc_cc2420,
219
220 vcc_mica,
221
222 vcc_bt,
223
224 vcc_sensor_1_8,
225 vcc_sensor_3,
226
227 vcc_sram_ext,
228 vcc_pxa_pll,
229 vcc_pxa_usim,
230 vcc_pxa_mem,
231 vcc_pxa_flash,
232 vcc_pxa_core,
233 vcc_lcd,
234 vcc_bb,
235 vcc_bbio,
236 vcc_io,
237};
238
239
240
241
242
243static struct regulator_init_data stargate2_ldo_init_data[] = {
244 [vcc_bbio] = {
245 .constraints = {
246 .name = "vcc_bbio",
247 .min_uV = 1800000,
248 .max_uV = 1800000,
249 },
250 },
251 [vcc_bb] = {
252 .constraints = {
253 .name = "vcc_bb",
254 .min_uV = 2700000,
255 .max_uV = 3000000,
256 },
257 },
258 [vcc_pxa_flash] = {
259 .constraints = {
260 .name = "vcc_pxa_flash",
261 .min_uV = 1800000,
262 .max_uV = 1800000,
263 },
264 },
265 [vcc_cc2420] = {
266 .constraints = {
267
268 .name = "vcc_cc2420",
269 .min_uV = 2700000,
270 .max_uV = 3300000,
271 },
272 },
273 [vcc_vref] = {
274 .constraints = {
275 .name = "vcc_vref",
276 .min_uV = 1800000,
277 .max_uV = 1800000,
278 },
279 },
280 [vcc_sram_ext] = {
281 .constraints = {
282 .name = "vcc_sram_ext",
283 .min_uV = 2800000,
284 .max_uV = 2800000,
285 },
286 },
287 [vcc_mica] = {
288 .constraints = {
289 .name = "vcc_mica",
290 .min_uV = 2800000,
291 .max_uV = 2800000,
292 },
293 },
294 [vcc_bt] = {
295 .constraints = {
296 .name = "vcc_bt",
297 .min_uV = 2800000,
298 .max_uV = 2800000,
299 },
300 },
301 [vcc_lcd] = {
302 .constraints = {
303 .name = "vcc_lcd",
304 .min_uV = 2700000,
305 .max_uV = 3300000,
306 },
307 },
308 [vcc_io] = {
309
310 .constraints = {
311 .name = "vcc_io",
312 .min_uV = 2692000,
313 .max_uV = 3300000,
314 },
315 },
316 [vcc_sensor_1_8] = {
317 .constraints = {
318 .name = "vcc_sensor_1_8",
319 .min_uV = 1800000,
320 .max_uV = 1800000,
321 },
322 },
323 [vcc_sensor_3] = {
324 .constraints = {
325 .name = "vcc_sensor_3",
326 .min_uV = 2800000,
327 .max_uV = 3000000,
328 },
329 .num_consumer_supplies = ARRAY_SIZE(stargate2_sensor_3_con),
330 .consumer_supplies = stargate2_sensor_3_con,
331 },
332 [vcc_pxa_pll] = {
333 .constraints = {
334 .name = "vcc_pxa_pll",
335 .min_uV = 1170000,
336 .max_uV = 1430000,
337 },
338 },
339 [vcc_pxa_usim] = {
340 .constraints = {
341 .name = "vcc_pxa_usim",
342 .min_uV = 1710000,
343 .max_uV = 2160000,
344 },
345 },
346 [vcc_pxa_mem] = {
347 .constraints = {
348 .name = "vcc_pxa_mem",
349 .min_uV = 1800000,
350 .max_uV = 1800000,
351 },
352 },
353};
354
355static struct da903x_subdev_info stargate2_da9030_subdevs[] = {
356 {
357 .name = "da903x-led",
358 .id = DA9030_ID_LED_2,
359 .platform_data = &stargate2_leds[0],
360 }, {
361 .name = "da903x-led",
362 .id = DA9030_ID_LED_3,
363 .platform_data = &stargate2_leds[2],
364 }, {
365 .name = "da903x-led",
366 .id = DA9030_ID_LED_4,
367 .platform_data = &stargate2_leds[1],
368 }, {
369 .name = "da903x-regulator",
370 .id = DA9030_ID_LDO2,
371 .platform_data = &stargate2_ldo_init_data[vcc_bbio],
372 }, {
373 .name = "da903x-regulator",
374 .id = DA9030_ID_LDO3,
375 .platform_data = &stargate2_ldo_init_data[vcc_bb],
376 }, {
377 .name = "da903x-regulator",
378 .id = DA9030_ID_LDO4,
379 .platform_data = &stargate2_ldo_init_data[vcc_pxa_flash],
380 }, {
381 .name = "da903x-regulator",
382 .id = DA9030_ID_LDO5,
383 .platform_data = &stargate2_ldo_init_data[vcc_cc2420],
384 }, {
385 .name = "da903x-regulator",
386 .id = DA9030_ID_LDO6,
387 .platform_data = &stargate2_ldo_init_data[vcc_vref],
388 }, {
389 .name = "da903x-regulator",
390 .id = DA9030_ID_LDO7,
391 .platform_data = &stargate2_ldo_init_data[vcc_sram_ext],
392 }, {
393 .name = "da903x-regulator",
394 .id = DA9030_ID_LDO8,
395 .platform_data = &stargate2_ldo_init_data[vcc_mica],
396 }, {
397 .name = "da903x-regulator",
398 .id = DA9030_ID_LDO9,
399 .platform_data = &stargate2_ldo_init_data[vcc_bt],
400 }, {
401 .name = "da903x-regulator",
402 .id = DA9030_ID_LDO10,
403 .platform_data = &stargate2_ldo_init_data[vcc_sensor_1_8],
404 }, {
405 .name = "da903x-regulator",
406 .id = DA9030_ID_LDO11,
407 .platform_data = &stargate2_ldo_init_data[vcc_sensor_3],
408 }, {
409 .name = "da903x-regulator",
410 .id = DA9030_ID_LDO12,
411 .platform_data = &stargate2_ldo_init_data[vcc_lcd],
412 }, {
413 .name = "da903x-regulator",
414 .id = DA9030_ID_LDO15,
415 .platform_data = &stargate2_ldo_init_data[vcc_pxa_pll],
416 }, {
417 .name = "da903x-regulator",
418 .id = DA9030_ID_LDO17,
419 .platform_data = &stargate2_ldo_init_data[vcc_pxa_usim],
420 }, {
421 .name = "da903x-regulator",
422 .id = DA9030_ID_LDO18,
423 .platform_data = &stargate2_ldo_init_data[vcc_io],
424 }, {
425 .name = "da903x-regulator",
426 .id = DA9030_ID_LDO19,
427 .platform_data = &stargate2_ldo_init_data[vcc_pxa_mem],
428 },
429};
430
431static struct da903x_platform_data stargate2_da9030_pdata = {
432 .num_subdevs = ARRAY_SIZE(stargate2_da9030_subdevs),
433 .subdevs = stargate2_da9030_subdevs,
434};
435
436static struct resource smc91x_resources[] = {
437 [0] = {
438 .name = "smc91x-regs",
439 .start = (PXA_CS4_PHYS + 0x300),
440 .end = (PXA_CS4_PHYS + 0xfffff),
441 .flags = IORESOURCE_MEM,
442 },
443 [1] = {
444 .start = IRQ_GPIO(40),
445 .end = IRQ_GPIO(40),
446 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE,
447 }
448};
449
450static struct smc91x_platdata stargate2_smc91x_info = {
451 .flags = SMC91X_USE_8BIT | SMC91X_USE_16BIT | SMC91X_USE_32BIT
452 | SMC91X_NOWAIT | SMC91X_USE_DMA,
453};
454
455static struct platform_device smc91x_device = {
456 .name = "smc91x",
457 .id = -1,
458 .num_resources = ARRAY_SIZE(smc91x_resources),
459 .resource = smc91x_resources,
460 .dev = {
461 .platform_data = &stargate2_smc91x_info,
462 },
463};
464
465
466
467static struct pxamci_platform_data stargate2_mci_platform_data;
468
469
470
471
472
473static int stargate2_mci_init(struct device *dev,
474 irq_handler_t stargate2_detect_int,
475 void *data)
476{
477 int err;
478
479 err = gpio_request(SG2_SD_POWER_ENABLE, "SG2_sd_power_enable");
480 if (err) {
481 printk(KERN_ERR "Can't get the gpio for SD power control");
482 goto return_err;
483 }
484 gpio_direction_output(SG2_SD_POWER_ENABLE, 0);
485
486 err = gpio_request(SG2_GPIO_nSD_DETECT, "SG2_sd_detect");
487 if (err) {
488 printk(KERN_ERR "Can't get the sd detect gpio");
489 goto free_power_en;
490 }
491 gpio_direction_input(SG2_GPIO_nSD_DETECT);
492
493 stargate2_mci_platform_data.detect_delay = msecs_to_jiffies(250);
494
495 err = request_irq(IRQ_GPIO(SG2_GPIO_nSD_DETECT),
496 stargate2_detect_int,
497 IRQ_TYPE_EDGE_BOTH,
498 "MMC card detect",
499 data);
500 if (err) {
501 printk(KERN_ERR "can't request MMC card detect IRQ\n");
502 goto free_nsd_detect;
503 }
504 return 0;
505
506 free_nsd_detect:
507 gpio_free(SG2_GPIO_nSD_DETECT);
508 free_power_en:
509 gpio_free(SG2_SD_POWER_ENABLE);
510 return_err:
511 return err;
512}
513
514
515
516
517
518
519static void stargate2_mci_setpower(struct device *dev, unsigned int vdd)
520{
521 gpio_set_value(SG2_SD_POWER_ENABLE, !!vdd);
522}
523
524static void stargate2_mci_exit(struct device *dev, void *data)
525{
526 free_irq(IRQ_GPIO(SG2_GPIO_nSD_DETECT), data);
527 gpio_free(SG2_SD_POWER_ENABLE);
528 gpio_free(SG2_GPIO_nSD_DETECT);
529}
530
531static struct pxamci_platform_data stargate2_mci_platform_data = {
532 .ocr_mask = MMC_VDD_32_33 | MMC_VDD_33_34,
533 .init = stargate2_mci_init,
534 .setpower = stargate2_mci_setpower,
535 .exit = stargate2_mci_exit,
536};
537
538static struct mtd_partition stargate2flash_partitions[] = {
539 {
540 .name = "Bootloader",
541 .size = 0x00040000,
542 .offset = 0,
543 .mask_flags = 0,
544 }, {
545 .name = "Kernel",
546 .size = 0x00200000,
547 .offset = 0x00040000,
548 .mask_flags = 0
549 }, {
550 .name = "Filesystem",
551 .size = 0x01DC0000,
552 .offset = 0x00240000,
553 .mask_flags = 0
554 },
555};
556
557static struct resource flash_resources = {
558 .start = PXA_CS0_PHYS,
559 .end = PXA_CS0_PHYS + SZ_32M - 1,
560 .flags = IORESOURCE_MEM,
561};
562
563static struct flash_platform_data stargate2_flash_data = {
564 .map_name = "cfi_probe",
565 .parts = stargate2flash_partitions,
566 .nr_parts = ARRAY_SIZE(stargate2flash_partitions),
567 .name = "PXA27xOnChipROM",
568 .width = 2,
569};
570
571static struct platform_device stargate2_flash_device = {
572 .name = "pxa2xx-flash",
573 .id = 0,
574 .dev = {
575 .platform_data = &stargate2_flash_data,
576 },
577 .resource = &flash_resources,
578 .num_resources = 1,
579};
580
581
582
583
584
585
586
587
588static struct resource sram_resources = {
589 .start = PXA_CS1_PHYS,
590 .end = PXA_CS1_PHYS + SZ_32M-1,
591 .flags = IORESOURCE_MEM,
592};
593
594static struct platdata_mtd_ram stargate2_sram_pdata = {
595 .mapname = "Stargate2 SRAM",
596 .bankwidth = 2,
597};
598
599static struct platform_device stargate2_sram = {
600 .name = "mtd-ram",
601 .id = 0,
602 .resource = &sram_resources,
603 .num_resources = 1,
604 .dev = {
605 .platform_data = &stargate2_sram_pdata,
606 },
607};
608
609static struct pcf857x_platform_data platform_data_pcf857x = {
610 .gpio_base = 128,
611 .n_latch = 0,
612 .setup = NULL,
613 .teardown = NULL,
614 .context = NULL,
615};
616
617static struct at24_platform_data pca9500_eeprom_pdata = {
618 .byte_len = 256,
619 .page_size = 4,
620};
621
622
623static struct i2c_board_info __initdata stargate2_i2c_board_info[] = {
624
625
626
627 {
628 .type = "pcf8574",
629 .addr = 0x27,
630 .platform_data = &platform_data_pcf857x,
631 }, {
632 .type = "24c02",
633 .addr = 0x57,
634 .platform_data = &pca9500_eeprom_pdata,
635 }, {
636 .type = "max1238",
637 .addr = 0x35,
638 }, {
639 .type = "max1363",
640 .addr = 0x34,
641
642
643
644 .irq = IRQ_GPIO(99),
645 }, {
646 .type = "tsl2561",
647 .addr = 0x49,
648
649
650
651 .irq = IRQ_GPIO(99),
652 }, {
653 .type = "tmp175",
654 .addr = 0x4A,
655 .irq = IRQ_GPIO(96),
656 },
657};
658
659static struct i2c_board_info __initdata stargate2_pwr_i2c_board_info[] = {
660 {
661 .type = "da9030",
662 .addr = 0x49,
663 .platform_data = &stargate2_da9030_pdata,
664 .irq = gpio_to_irq(1),
665 },
666};
667
668static struct pxa2xx_spi_master pxa_ssp_master_0_info = {
669 .num_chipselect = 1,
670};
671
672static struct pxa2xx_spi_master pxa_ssp_master_1_info = {
673 .num_chipselect = 1,
674};
675
676static struct pxa2xx_spi_master pxa_ssp_master_2_info = {
677 .num_chipselect = 1,
678};
679
680
681
682static struct pxa2xx_spi_chip staccel_chip_info = {
683 .tx_threshold = 8,
684 .rx_threshold = 8,
685 .dma_burst_size = 8,
686 .timeout = 235,
687 .gpio_cs = 24,
688};
689
690static struct pxa2xx_spi_chip cc2420_info = {
691 .tx_threshold = 8,
692 .rx_threshold = 8,
693 .dma_burst_size = 8,
694 .timeout = 235,
695 .gpio_cs = 39,
696};
697
698static struct spi_board_info spi_board_info[] __initdata = {
699 {
700 .modalias = "lis3l02dq",
701 .max_speed_hz = 8000000,
702 .bus_num = 1,
703 .chip_select = 0,
704 .controller_data = &staccel_chip_info,
705 .irq = IRQ_GPIO(96),
706 }, {
707 .modalias = "cc2420",
708 .max_speed_hz = 6500000,
709 .bus_num = 3,
710 .chip_select = 0,
711 .controller_data = &cc2420_info,
712 },
713};
714
715static void sg2_udc_command(int cmd)
716{
717 switch (cmd) {
718 case PXA2XX_UDC_CMD_CONNECT:
719 UP2OCR |= UP2OCR_HXOE | UP2OCR_DPPUE | UP2OCR_DPPUBE;
720 break;
721 case PXA2XX_UDC_CMD_DISCONNECT:
722 UP2OCR &= ~(UP2OCR_HXOE | UP2OCR_DPPUE | UP2OCR_DPPUBE);
723 break;
724 }
725}
726
727
728
729
730static int sg2_udc_detect(void)
731{
732 return 1;
733}
734
735static struct pxa2xx_udc_mach_info stargate2_udc_info __initdata = {
736 .udc_is_connected = sg2_udc_detect,
737 .udc_command = sg2_udc_command,
738};
739
740static struct platform_device *stargate2_devices[] = {
741 &stargate2_flash_device,
742 &stargate2_sram,
743 &smc91x_device,
744 &sht15,
745};
746
747static struct i2c_pxa_platform_data i2c_pwr_pdata = {
748 .fast_mode = 1,
749};
750
751static struct i2c_pxa_platform_data i2c_pdata = {
752 .fast_mode = 1,
753};
754
755static void __init stargate2_init(void)
756{
757
758
759 MECR &= ~MECR_NOS;
760
761 pxa2xx_mfp_config(ARRAY_AND_SIZE(stargate2_pin_config));
762
763
764 gpio_direction_output(37, 0);
765 gpio_direction_output(24, 0);
766 gpio_direction_output(39, 0);
767
768 platform_add_devices(ARRAY_AND_SIZE(stargate2_devices));
769
770 pxa2xx_set_spi_info(1, &pxa_ssp_master_0_info);
771 pxa2xx_set_spi_info(2, &pxa_ssp_master_1_info);
772 pxa2xx_set_spi_info(3, &pxa_ssp_master_2_info);
773 spi_register_board_info(spi_board_info, ARRAY_SIZE(spi_board_info));
774
775 i2c_register_board_info(0, ARRAY_AND_SIZE(stargate2_i2c_board_info));
776 i2c_register_board_info(1,
777 ARRAY_AND_SIZE(stargate2_pwr_i2c_board_info));
778 pxa27x_set_i2c_power_info(&i2c_pwr_pdata);
779 pxa_set_i2c_info(&i2c_pdata);
780
781 pxa_set_mci_info(&stargate2_mci_platform_data);
782
783 pxa_set_udc_info(&stargate2_udc_info);
784
785 stargate2_reset_bluetooth();
786}
787
788MACHINE_START(STARGATE2, "Stargate 2")
789 .phys_io = 0x40000000,
790 .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc,
791 .map_io = pxa_map_io,
792 .init_irq = pxa27x_init_irq,
793 .timer = &pxa_timer,
794 .init_machine = stargate2_init,
795 .boot_params = 0xA0000100,
796MACHINE_END
797