mainstone.c 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568
  1. /*
  2. * linux/arch/arm/mach-pxa/mainstone.c
  3. *
  4. * Support for the Intel HCDDBBVA0 Development Platform.
  5. * (go figure how they came up with such name...)
  6. *
  7. * Author: Nicolas Pitre
  8. * Created: Nov 05, 2002
  9. * Copyright: MontaVista Software Inc.
  10. *
  11. * This program is free software; you can redistribute it and/or modify
  12. * it under the terms of the GNU General Public License version 2 as
  13. * published by the Free Software Foundation.
  14. */
  15. #include <linux/gpio.h>
  16. #include <linux/gpio/machine.h>
  17. #include <linux/init.h>
  18. #include <linux/platform_device.h>
  19. #include <linux/syscore_ops.h>
  20. #include <linux/interrupt.h>
  21. #include <linux/sched.h>
  22. #include <linux/bitops.h>
  23. #include <linux/fb.h>
  24. #include <linux/ioport.h>
  25. #include <linux/mtd/mtd.h>
  26. #include <linux/mtd/partitions.h>
  27. #include <linux/input.h>
  28. #include <linux/gpio_keys.h>
  29. #include <linux/pwm_backlight.h>
  30. #include <linux/smc91x.h>
  31. #include <linux/i2c/pxa-i2c.h>
  32. #include <asm/types.h>
  33. #include <asm/setup.h>
  34. #include <asm/memory.h>
  35. #include <asm/mach-types.h>
  36. #include <mach/hardware.h>
  37. #include <asm/irq.h>
  38. #include <asm/sizes.h>
  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. #include <mach/pxa27x.h>
  44. #include <mach/mainstone.h>
  45. #include <mach/audio.h>
  46. #include <mach/pxafb.h>
  47. #include <mach/mmc.h>
  48. #include <mach/irda.h>
  49. #include <mach/ohci.h>
  50. #include <plat/pxa27x_keypad.h>
  51. #include <mach/smemc.h>
  52. #include "generic.h"
  53. #include "devices.h"
  54. static unsigned long mainstone_pin_config[] = {
  55. /* Chip Select */
  56. GPIO15_nCS_1,
  57. /* LCD - 16bpp Active TFT */
  58. GPIOxx_LCD_TFT_16BPP,
  59. GPIO16_PWM0_OUT, /* Backlight */
  60. /* MMC */
  61. GPIO32_MMC_CLK,
  62. GPIO112_MMC_CMD,
  63. GPIO92_MMC_DAT_0,
  64. GPIO109_MMC_DAT_1,
  65. GPIO110_MMC_DAT_2,
  66. GPIO111_MMC_DAT_3,
  67. /* USB Host Port 1 */
  68. GPIO88_USBH1_PWR,
  69. GPIO89_USBH1_PEN,
  70. /* PC Card */
  71. GPIO48_nPOE,
  72. GPIO49_nPWE,
  73. GPIO50_nPIOR,
  74. GPIO51_nPIOW,
  75. GPIO85_nPCE_1,
  76. GPIO54_nPCE_2,
  77. GPIO79_PSKTSEL,
  78. GPIO55_nPREG,
  79. GPIO56_nPWAIT,
  80. GPIO57_nIOIS16,
  81. /* AC97 */
  82. GPIO28_AC97_BITCLK,
  83. GPIO29_AC97_SDATA_IN_0,
  84. GPIO30_AC97_SDATA_OUT,
  85. GPIO31_AC97_SYNC,
  86. GPIO45_AC97_SYSCLK,
  87. /* Keypad */
  88. GPIO93_KP_DKIN_0,
  89. GPIO94_KP_DKIN_1,
  90. GPIO95_KP_DKIN_2,
  91. GPIO100_KP_MKIN_0 | WAKEUP_ON_LEVEL_HIGH,
  92. GPIO101_KP_MKIN_1 | WAKEUP_ON_LEVEL_HIGH,
  93. GPIO102_KP_MKIN_2 | WAKEUP_ON_LEVEL_HIGH,
  94. GPIO97_KP_MKIN_3 | WAKEUP_ON_LEVEL_HIGH,
  95. GPIO98_KP_MKIN_4 | WAKEUP_ON_LEVEL_HIGH,
  96. GPIO99_KP_MKIN_5 | WAKEUP_ON_LEVEL_HIGH,
  97. GPIO103_KP_MKOUT_0,
  98. GPIO104_KP_MKOUT_1,
  99. GPIO105_KP_MKOUT_2,
  100. GPIO106_KP_MKOUT_3,
  101. GPIO107_KP_MKOUT_4,
  102. GPIO108_KP_MKOUT_5,
  103. GPIO96_KP_MKOUT_6,
  104. /* I2C */
  105. GPIO117_I2C_SCL,
  106. GPIO118_I2C_SDA,
  107. /* GPIO */
  108. GPIO1_GPIO | WAKEUP_ON_EDGE_BOTH,
  109. };
  110. static struct resource smc91x_resources[] = {
  111. [0] = {
  112. .start = (MST_ETH_PHYS + 0x300),
  113. .end = (MST_ETH_PHYS + 0xfffff),
  114. .flags = IORESOURCE_MEM,
  115. },
  116. [1] = {
  117. .start = MAINSTONE_IRQ(3),
  118. .end = MAINSTONE_IRQ(3),
  119. .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE,
  120. }
  121. };
  122. static struct smc91x_platdata mainstone_smc91x_info = {
  123. .flags = SMC91X_USE_8BIT | SMC91X_USE_16BIT | SMC91X_USE_32BIT |
  124. SMC91X_NOWAIT | SMC91X_USE_DMA,
  125. };
  126. static struct platform_device smc91x_device = {
  127. .name = "smc91x",
  128. .id = 0,
  129. .num_resources = ARRAY_SIZE(smc91x_resources),
  130. .resource = smc91x_resources,
  131. .dev = {
  132. .platform_data = &mainstone_smc91x_info,
  133. },
  134. };
  135. static int mst_audio_startup(struct snd_pcm_substream *substream, void *priv)
  136. {
  137. if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
  138. MST_MSCWR2 &= ~MST_MSCWR2_AC97_SPKROFF;
  139. return 0;
  140. }
  141. static void mst_audio_shutdown(struct snd_pcm_substream *substream, void *priv)
  142. {
  143. if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
  144. MST_MSCWR2 |= MST_MSCWR2_AC97_SPKROFF;
  145. }
  146. static long mst_audio_suspend_mask;
  147. static void mst_audio_suspend(void *priv)
  148. {
  149. mst_audio_suspend_mask = MST_MSCWR2;
  150. MST_MSCWR2 |= MST_MSCWR2_AC97_SPKROFF;
  151. }
  152. static void mst_audio_resume(void *priv)
  153. {
  154. MST_MSCWR2 &= mst_audio_suspend_mask | ~MST_MSCWR2_AC97_SPKROFF;
  155. }
  156. static pxa2xx_audio_ops_t mst_audio_ops = {
  157. .startup = mst_audio_startup,
  158. .shutdown = mst_audio_shutdown,
  159. .suspend = mst_audio_suspend,
  160. .resume = mst_audio_resume,
  161. };
  162. static struct resource flash_resources[] = {
  163. [0] = {
  164. .start = PXA_CS0_PHYS,
  165. .end = PXA_CS0_PHYS + SZ_64M - 1,
  166. .flags = IORESOURCE_MEM,
  167. },
  168. [1] = {
  169. .start = PXA_CS1_PHYS,
  170. .end = PXA_CS1_PHYS + SZ_64M - 1,
  171. .flags = IORESOURCE_MEM,
  172. },
  173. };
  174. static struct mtd_partition mainstoneflash0_partitions[] = {
  175. {
  176. .name = "Bootloader",
  177. .size = 0x00040000,
  178. .offset = 0,
  179. .mask_flags = MTD_WRITEABLE /* force read-only */
  180. },{
  181. .name = "Kernel",
  182. .size = 0x00400000,
  183. .offset = 0x00040000,
  184. },{
  185. .name = "Filesystem",
  186. .size = MTDPART_SIZ_FULL,
  187. .offset = 0x00440000
  188. }
  189. };
  190. static struct flash_platform_data mst_flash_data[2] = {
  191. {
  192. .map_name = "cfi_probe",
  193. .parts = mainstoneflash0_partitions,
  194. .nr_parts = ARRAY_SIZE(mainstoneflash0_partitions),
  195. }, {
  196. .map_name = "cfi_probe",
  197. .parts = NULL,
  198. .nr_parts = 0,
  199. }
  200. };
  201. static struct platform_device mst_flash_device[2] = {
  202. {
  203. .name = "pxa2xx-flash",
  204. .id = 0,
  205. .dev = {
  206. .platform_data = &mst_flash_data[0],
  207. },
  208. .resource = &flash_resources[0],
  209. .num_resources = 1,
  210. },
  211. {
  212. .name = "pxa2xx-flash",
  213. .id = 1,
  214. .dev = {
  215. .platform_data = &mst_flash_data[1],
  216. },
  217. .resource = &flash_resources[1],
  218. .num_resources = 1,
  219. },
  220. };
  221. #if defined(CONFIG_FB_PXA) || defined(CONFIG_FB_PXA_MODULE)
  222. static struct platform_pwm_backlight_data mainstone_backlight_data = {
  223. .pwm_id = 0,
  224. .max_brightness = 1023,
  225. .dft_brightness = 1023,
  226. .pwm_period_ns = 78770,
  227. };
  228. static struct platform_device mainstone_backlight_device = {
  229. .name = "pwm-backlight",
  230. .dev = {
  231. .parent = &pxa27x_device_pwm0.dev,
  232. .platform_data = &mainstone_backlight_data,
  233. },
  234. };
  235. static void __init mainstone_backlight_register(void)
  236. {
  237. int ret = platform_device_register(&mainstone_backlight_device);
  238. if (ret)
  239. printk(KERN_ERR "mainstone: failed to register backlight device: %d\n", ret);
  240. }
  241. #else
  242. #define mainstone_backlight_register() do { } while (0)
  243. #endif
  244. static struct pxafb_mode_info toshiba_ltm04c380k_mode = {
  245. .pixclock = 50000,
  246. .xres = 640,
  247. .yres = 480,
  248. .bpp = 16,
  249. .hsync_len = 1,
  250. .left_margin = 0x9f,
  251. .right_margin = 1,
  252. .vsync_len = 44,
  253. .upper_margin = 0,
  254. .lower_margin = 0,
  255. .sync = FB_SYNC_HOR_HIGH_ACT|FB_SYNC_VERT_HIGH_ACT,
  256. };
  257. static struct pxafb_mode_info toshiba_ltm035a776c_mode = {
  258. .pixclock = 110000,
  259. .xres = 240,
  260. .yres = 320,
  261. .bpp = 16,
  262. .hsync_len = 4,
  263. .left_margin = 8,
  264. .right_margin = 20,
  265. .vsync_len = 3,
  266. .upper_margin = 1,
  267. .lower_margin = 10,
  268. .sync = FB_SYNC_HOR_HIGH_ACT|FB_SYNC_VERT_HIGH_ACT,
  269. };
  270. static struct pxafb_mach_info mainstone_pxafb_info = {
  271. .num_modes = 1,
  272. .lcd_conn = LCD_COLOR_TFT_16BPP | LCD_PCLK_EDGE_FALL,
  273. };
  274. static int mainstone_mci_init(struct device *dev, irq_handler_t mstone_detect_int, void *data)
  275. {
  276. int err;
  277. /* make sure SD/Memory Stick multiplexer's signals
  278. * are routed to MMC controller
  279. */
  280. MST_MSCWR1 &= ~MST_MSCWR1_MS_SEL;
  281. err = request_irq(MAINSTONE_MMC_IRQ, mstone_detect_int, IRQF_DISABLED,
  282. "MMC card detect", data);
  283. if (err)
  284. printk(KERN_ERR "mainstone_mci_init: MMC/SD: can't request MMC card detect IRQ\n");
  285. return err;
  286. }
  287. static void mainstone_mci_setpower(struct device *dev, unsigned int vdd)
  288. {
  289. struct pxamci_platform_data* p_d = dev->platform_data;
  290. if (( 1 << vdd) & p_d->ocr_mask) {
  291. printk(KERN_DEBUG "%s: on\n", __func__);
  292. MST_MSCWR1 |= MST_MSCWR1_MMC_ON;
  293. MST_MSCWR1 &= ~MST_MSCWR1_MS_SEL;
  294. } else {
  295. printk(KERN_DEBUG "%s: off\n", __func__);
  296. MST_MSCWR1 &= ~MST_MSCWR1_MMC_ON;
  297. }
  298. }
  299. static void mainstone_mci_exit(struct device *dev, void *data)
  300. {
  301. free_irq(MAINSTONE_MMC_IRQ, data);
  302. }
  303. static struct pxamci_platform_data mainstone_mci_platform_data = {
  304. .ocr_mask = MMC_VDD_32_33|MMC_VDD_33_34,
  305. .init = mainstone_mci_init,
  306. .setpower = mainstone_mci_setpower,
  307. .exit = mainstone_mci_exit,
  308. .gpio_card_detect = -1,
  309. .gpio_card_ro = -1,
  310. .gpio_power = -1,
  311. };
  312. static void mainstone_irda_transceiver_mode(struct device *dev, int mode)
  313. {
  314. unsigned long flags;
  315. local_irq_save(flags);
  316. if (mode & IR_SIRMODE) {
  317. MST_MSCWR1 &= ~MST_MSCWR1_IRDA_FIR;
  318. } else if (mode & IR_FIRMODE) {
  319. MST_MSCWR1 |= MST_MSCWR1_IRDA_FIR;
  320. }
  321. pxa2xx_transceiver_mode(dev, mode);
  322. if (mode & IR_OFF) {
  323. MST_MSCWR1 = (MST_MSCWR1 & ~MST_MSCWR1_IRDA_MASK) | MST_MSCWR1_IRDA_OFF;
  324. } else {
  325. MST_MSCWR1 = (MST_MSCWR1 & ~MST_MSCWR1_IRDA_MASK) | MST_MSCWR1_IRDA_FULL;
  326. }
  327. local_irq_restore(flags);
  328. }
  329. static struct pxaficp_platform_data mainstone_ficp_platform_data = {
  330. .gpio_pwdown = -1,
  331. .transceiver_cap = IR_SIRMODE | IR_FIRMODE | IR_OFF,
  332. .transceiver_mode = mainstone_irda_transceiver_mode,
  333. };
  334. static struct gpio_keys_button gpio_keys_button[] = {
  335. [0] = {
  336. .desc = "wakeup",
  337. .code = KEY_SUSPEND,
  338. .type = EV_KEY,
  339. .gpio = 1,
  340. .wakeup = 1,
  341. },
  342. };
  343. static struct gpio_keys_platform_data mainstone_gpio_keys = {
  344. .buttons = gpio_keys_button,
  345. .nbuttons = 1,
  346. };
  347. static struct platform_device mst_gpio_keys_device = {
  348. .name = "gpio-keys",
  349. .id = -1,
  350. .dev = {
  351. .platform_data = &mainstone_gpio_keys,
  352. },
  353. };
  354. static struct resource mst_cplds_resources[] = {
  355. [0] = {
  356. .start = MST_FPGA_PHYS + 0xc0,
  357. .end = MST_FPGA_PHYS + 0xe0 - 1,
  358. .flags = IORESOURCE_MEM,
  359. },
  360. [1] = {
  361. .start = PXA_GPIO_TO_IRQ(0),
  362. .end = PXA_GPIO_TO_IRQ(0),
  363. .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWEDGE,
  364. },
  365. [2] = {
  366. .start = MAINSTONE_IRQ(0),
  367. .end = MAINSTONE_IRQ(15),
  368. .flags = IORESOURCE_IRQ,
  369. },
  370. };
  371. static struct platform_device mst_cplds_device = {
  372. .name = "pxa_cplds_irqs",
  373. .id = -1,
  374. .resource = &mst_cplds_resources[0],
  375. .num_resources = 3,
  376. };
  377. static struct platform_device *platform_devices[] __initdata = {
  378. &smc91x_device,
  379. &mst_flash_device[0],
  380. &mst_flash_device[1],
  381. &mst_gpio_keys_device,
  382. &mst_cplds_device,
  383. };
  384. static struct pxaohci_platform_data mainstone_ohci_platform_data = {
  385. .port_mode = PMM_PERPORT_MODE,
  386. .flags = ENABLE_PORT_ALL | POWER_CONTROL_LOW | POWER_SENSE_LOW,
  387. };
  388. #if defined(CONFIG_KEYBOARD_PXA27x) || defined(CONFIG_KEYBOARD_PXA27x_MODULE)
  389. static unsigned int mainstone_matrix_keys[] = {
  390. KEY(0, 0, KEY_A), KEY(1, 0, KEY_B), KEY(2, 0, KEY_C),
  391. KEY(3, 0, KEY_D), KEY(4, 0, KEY_E), KEY(5, 0, KEY_F),
  392. KEY(0, 1, KEY_G), KEY(1, 1, KEY_H), KEY(2, 1, KEY_I),
  393. KEY(3, 1, KEY_J), KEY(4, 1, KEY_K), KEY(5, 1, KEY_L),
  394. KEY(0, 2, KEY_M), KEY(1, 2, KEY_N), KEY(2, 2, KEY_O),
  395. KEY(3, 2, KEY_P), KEY(4, 2, KEY_Q), KEY(5, 2, KEY_R),
  396. KEY(0, 3, KEY_S), KEY(1, 3, KEY_T), KEY(2, 3, KEY_U),
  397. KEY(3, 3, KEY_V), KEY(4, 3, KEY_W), KEY(5, 3, KEY_X),
  398. KEY(2, 4, KEY_Y), KEY(3, 4, KEY_Z),
  399. KEY(0, 4, KEY_DOT), /* . */
  400. KEY(1, 4, KEY_CLOSE), /* @ */
  401. KEY(4, 4, KEY_SLASH),
  402. KEY(5, 4, KEY_BACKSLASH),
  403. KEY(0, 5, KEY_HOME),
  404. KEY(1, 5, KEY_LEFTSHIFT),
  405. KEY(2, 5, KEY_SPACE),
  406. KEY(3, 5, KEY_SPACE),
  407. KEY(4, 5, KEY_ENTER),
  408. KEY(5, 5, KEY_BACKSPACE),
  409. KEY(0, 6, KEY_UP),
  410. KEY(1, 6, KEY_DOWN),
  411. KEY(2, 6, KEY_LEFT),
  412. KEY(3, 6, KEY_RIGHT),
  413. KEY(4, 6, KEY_SELECT),
  414. };
  415. struct pxa27x_keypad_platform_data mainstone_keypad_info = {
  416. .matrix_key_rows = 6,
  417. .matrix_key_cols = 7,
  418. .matrix_key_map = mainstone_matrix_keys,
  419. .matrix_key_map_size = ARRAY_SIZE(mainstone_matrix_keys),
  420. .enable_rotary0 = 1,
  421. .rotary0_up_key = KEY_UP,
  422. .rotary0_down_key = KEY_DOWN,
  423. .debounce_interval = 30,
  424. };
  425. static void __init mainstone_init_keypad(void)
  426. {
  427. pxa_set_keypad_info(&mainstone_keypad_info);
  428. }
  429. #else
  430. static inline void mainstone_init_keypad(void) {}
  431. #endif
  432. static void __init mainstone_init(void)
  433. {
  434. int SW7 = 0; /* FIXME: get from SCR (Mst doc section 3.2.1.1) */
  435. pxa2xx_mfp_config(ARRAY_AND_SIZE(mainstone_pin_config));
  436. pxa_set_ffuart_info(NULL);
  437. pxa_set_btuart_info(NULL);
  438. pxa_set_stuart_info(NULL);
  439. mst_flash_data[0].width = (__raw_readl(BOOT_DEF) & 1) ? 2 : 4;
  440. mst_flash_data[1].width = 4;
  441. /* Compensate for SW7 which swaps the flash banks */
  442. mst_flash_data[SW7].name = "processor-flash";
  443. mst_flash_data[SW7 ^ 1].name = "mainboard-flash";
  444. printk(KERN_NOTICE "Mainstone configured to boot from %s\n",
  445. mst_flash_data[0].name);
  446. /* system bus arbiter setting
  447. * - Core_Park
  448. * - LCD_wt:DMA_wt:CORE_Wt = 2:3:4
  449. */
  450. ARB_CNTRL = ARB_CORE_PARK | 0x234;
  451. platform_add_devices(platform_devices, ARRAY_SIZE(platform_devices));
  452. /* reading Mainstone's "Virtual Configuration Register"
  453. might be handy to select LCD type here */
  454. if (0)
  455. mainstone_pxafb_info.modes = &toshiba_ltm04c380k_mode;
  456. else
  457. mainstone_pxafb_info.modes = &toshiba_ltm035a776c_mode;
  458. pxa_set_fb_info(NULL, &mainstone_pxafb_info);
  459. mainstone_backlight_register();
  460. pxa_set_mci_info(&mainstone_mci_platform_data);
  461. pxa_set_ficp_info(&mainstone_ficp_platform_data);
  462. pxa_set_ohci_info(&mainstone_ohci_platform_data);
  463. pxa_set_i2c_info(NULL);
  464. pxa_set_ac97_info(&mst_audio_ops);
  465. mainstone_init_keypad();
  466. }
  467. static struct map_desc mainstone_io_desc[] __initdata = {
  468. { /* CPLD */
  469. .virtual = MST_FPGA_VIRT,
  470. .pfn = __phys_to_pfn(MST_FPGA_PHYS),
  471. .length = 0x00100000,
  472. .type = MT_DEVICE
  473. }
  474. };
  475. static void __init mainstone_map_io(void)
  476. {
  477. pxa27x_map_io();
  478. iotable_init(mainstone_io_desc, ARRAY_SIZE(mainstone_io_desc));
  479. /* for use I SRAM as framebuffer. */
  480. PSLR |= 0xF04;
  481. PCFR = 0x66;
  482. }
  483. MACHINE_START(MAINSTONE, "Intel HCDDBBVA0 Development Platform (aka Mainstone)")
  484. /* Maintainer: MontaVista Software Inc. */
  485. .atag_offset = 0x100, /* BLOB boot parameter setting */
  486. .map_io = mainstone_map_io,
  487. .nr_irqs = MAINSTONE_NR_IRQS,
  488. .init_irq = pxa27x_init_irq,
  489. .handle_irq = pxa27x_handle_irq,
  490. .timer = &pxa_timer,
  491. .init_machine = mainstone_init,
  492. .restart = pxa_restart,
  493. MACHINE_END