mainstone.c 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738
  1. // SPDX-License-Identifier: GPL-2.0-only
  2. /*
  3. * linux/arch/arm/mach-pxa/mainstone.c
  4. *
  5. * Support for the Intel HCDDBBVA0 Development Platform.
  6. * (go figure how they came up with such name...)
  7. *
  8. * Author: Nicolas Pitre
  9. * Created: Nov 05, 2002
  10. * Copyright: MontaVista Software Inc.
  11. */
  12. #include <linux/gpio.h>
  13. #include <linux/gpio/gpio-reg.h>
  14. #include <linux/gpio/machine.h>
  15. #include <linux/init.h>
  16. #include <linux/platform_device.h>
  17. #include <linux/syscore_ops.h>
  18. #include <linux/interrupt.h>
  19. #include <linux/sched.h>
  20. #include <linux/bitops.h>
  21. #include <linux/fb.h>
  22. #include <linux/ioport.h>
  23. #include <linux/mtd/mtd.h>
  24. #include <linux/mtd/partitions.h>
  25. #include <linux/input.h>
  26. #include <linux/gpio_keys.h>
  27. #include <linux/pwm.h>
  28. #include <linux/pwm_backlight.h>
  29. #include <linux/smc91x.h>
  30. #include <linux/platform_data/i2c-pxa.h>
  31. #include <linux/slab.h>
  32. #include <linux/leds.h>
  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. #include <linux/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 "pxa27x.h"
  44. #include "mainstone.h"
  45. #include <linux/platform_data/asoc-pxa.h>
  46. #include <linux/platform_data/video-pxafb.h>
  47. #include <linux/platform_data/mmc-pxamci.h>
  48. #include <linux/platform_data/irda-pxaficp.h>
  49. #include <linux/platform_data/usb-ohci-pxa27x.h>
  50. #include <linux/platform_data/keypad-pxa27x.h>
  51. #include "addr-map.h"
  52. #include "smemc.h"
  53. #include "generic.h"
  54. #include "devices.h"
  55. static unsigned long mainstone_pin_config[] = {
  56. /* Chip Select */
  57. GPIO15_nCS_1,
  58. /* LCD - 16bpp Active TFT */
  59. GPIOxx_LCD_TFT_16BPP,
  60. GPIO16_PWM0_OUT, /* Backlight */
  61. /* MMC */
  62. GPIO32_MMC_CLK,
  63. GPIO112_MMC_CMD,
  64. GPIO92_MMC_DAT_0,
  65. GPIO109_MMC_DAT_1,
  66. GPIO110_MMC_DAT_2,
  67. GPIO111_MMC_DAT_3,
  68. /* USB Host Port 1 */
  69. GPIO88_USBH1_PWR,
  70. GPIO89_USBH1_PEN,
  71. /* PC Card */
  72. GPIO48_nPOE,
  73. GPIO49_nPWE,
  74. GPIO50_nPIOR,
  75. GPIO51_nPIOW,
  76. GPIO85_nPCE_1,
  77. GPIO54_nPCE_2,
  78. GPIO79_PSKTSEL,
  79. GPIO55_nPREG,
  80. GPIO56_nPWAIT,
  81. GPIO57_nIOIS16,
  82. /* AC97 */
  83. GPIO28_AC97_BITCLK,
  84. GPIO29_AC97_SDATA_IN_0,
  85. GPIO30_AC97_SDATA_OUT,
  86. GPIO31_AC97_SYNC,
  87. GPIO45_AC97_SYSCLK,
  88. /* Keypad */
  89. GPIO93_KP_DKIN_0,
  90. GPIO94_KP_DKIN_1,
  91. GPIO95_KP_DKIN_2,
  92. GPIO100_KP_MKIN_0 | WAKEUP_ON_LEVEL_HIGH,
  93. GPIO101_KP_MKIN_1 | WAKEUP_ON_LEVEL_HIGH,
  94. GPIO102_KP_MKIN_2 | WAKEUP_ON_LEVEL_HIGH,
  95. GPIO97_KP_MKIN_3 | WAKEUP_ON_LEVEL_HIGH,
  96. GPIO98_KP_MKIN_4 | WAKEUP_ON_LEVEL_HIGH,
  97. GPIO99_KP_MKIN_5 | WAKEUP_ON_LEVEL_HIGH,
  98. GPIO103_KP_MKOUT_0,
  99. GPIO104_KP_MKOUT_1,
  100. GPIO105_KP_MKOUT_2,
  101. GPIO106_KP_MKOUT_3,
  102. GPIO107_KP_MKOUT_4,
  103. GPIO108_KP_MKOUT_5,
  104. GPIO96_KP_MKOUT_6,
  105. /* I2C */
  106. GPIO117_I2C_SCL,
  107. GPIO118_I2C_SDA,
  108. /* GPIO */
  109. GPIO1_GPIO | WAKEUP_ON_EDGE_BOTH,
  110. };
  111. static struct resource smc91x_resources[] = {
  112. [0] = {
  113. .start = (MST_ETH_PHYS + 0x300),
  114. .end = (MST_ETH_PHYS + 0xfffff),
  115. .flags = IORESOURCE_MEM,
  116. },
  117. [1] = {
  118. .start = MAINSTONE_IRQ(3),
  119. .end = MAINSTONE_IRQ(3),
  120. .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE,
  121. }
  122. };
  123. static struct smc91x_platdata mainstone_smc91x_info = {
  124. .flags = SMC91X_USE_8BIT | SMC91X_USE_16BIT | SMC91X_USE_32BIT |
  125. SMC91X_NOWAIT | SMC91X_USE_DMA,
  126. .pxa_u16_align4 = true,
  127. };
  128. static struct platform_device smc91x_device = {
  129. .name = "smc91x",
  130. .id = 0,
  131. .num_resources = ARRAY_SIZE(smc91x_resources),
  132. .resource = smc91x_resources,
  133. .dev = {
  134. .platform_data = &mainstone_smc91x_info,
  135. },
  136. };
  137. static int mst_audio_startup(struct snd_pcm_substream *substream, void *priv)
  138. {
  139. if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
  140. MST_MSCWR2 &= ~MST_MSCWR2_AC97_SPKROFF;
  141. return 0;
  142. }
  143. static void mst_audio_shutdown(struct snd_pcm_substream *substream, void *priv)
  144. {
  145. if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
  146. MST_MSCWR2 |= MST_MSCWR2_AC97_SPKROFF;
  147. }
  148. static long mst_audio_suspend_mask;
  149. static void mst_audio_suspend(void *priv)
  150. {
  151. mst_audio_suspend_mask = MST_MSCWR2;
  152. MST_MSCWR2 |= MST_MSCWR2_AC97_SPKROFF;
  153. }
  154. static void mst_audio_resume(void *priv)
  155. {
  156. MST_MSCWR2 &= mst_audio_suspend_mask | ~MST_MSCWR2_AC97_SPKROFF;
  157. }
  158. static pxa2xx_audio_ops_t mst_audio_ops = {
  159. .startup = mst_audio_startup,
  160. .shutdown = mst_audio_shutdown,
  161. .suspend = mst_audio_suspend,
  162. .resume = mst_audio_resume,
  163. };
  164. static struct resource flash_resources[] = {
  165. [0] = {
  166. .start = PXA_CS0_PHYS,
  167. .end = PXA_CS0_PHYS + SZ_64M - 1,
  168. .flags = IORESOURCE_MEM,
  169. },
  170. [1] = {
  171. .start = PXA_CS1_PHYS,
  172. .end = PXA_CS1_PHYS + SZ_64M - 1,
  173. .flags = IORESOURCE_MEM,
  174. },
  175. };
  176. static struct mtd_partition mainstoneflash0_partitions[] = {
  177. {
  178. .name = "Bootloader",
  179. .size = 0x00040000,
  180. .offset = 0,
  181. .mask_flags = MTD_WRITEABLE /* force read-only */
  182. },{
  183. .name = "Kernel",
  184. .size = 0x00400000,
  185. .offset = 0x00040000,
  186. },{
  187. .name = "Filesystem",
  188. .size = MTDPART_SIZ_FULL,
  189. .offset = 0x00440000
  190. }
  191. };
  192. static struct flash_platform_data mst_flash_data[2] = {
  193. {
  194. .map_name = "cfi_probe",
  195. .parts = mainstoneflash0_partitions,
  196. .nr_parts = ARRAY_SIZE(mainstoneflash0_partitions),
  197. }, {
  198. .map_name = "cfi_probe",
  199. .parts = NULL,
  200. .nr_parts = 0,
  201. }
  202. };
  203. static struct platform_device mst_flash_device[2] = {
  204. {
  205. .name = "pxa2xx-flash",
  206. .id = 0,
  207. .dev = {
  208. .platform_data = &mst_flash_data[0],
  209. },
  210. .resource = &flash_resources[0],
  211. .num_resources = 1,
  212. },
  213. {
  214. .name = "pxa2xx-flash",
  215. .id = 1,
  216. .dev = {
  217. .platform_data = &mst_flash_data[1],
  218. },
  219. .resource = &flash_resources[1],
  220. .num_resources = 1,
  221. },
  222. };
  223. #if defined(CONFIG_FB_PXA) || defined(CONFIG_FB_PXA_MODULE)
  224. static struct pwm_lookup mainstone_pwm_lookup[] = {
  225. PWM_LOOKUP("pxa27x-pwm.0", 0, "pwm-backlight.0", NULL, 78770,
  226. PWM_POLARITY_NORMAL),
  227. };
  228. static struct platform_pwm_backlight_data mainstone_backlight_data = {
  229. .max_brightness = 1023,
  230. .dft_brightness = 1023,
  231. };
  232. static struct platform_device mainstone_backlight_device = {
  233. .name = "pwm-backlight",
  234. .dev = {
  235. .parent = &pxa27x_device_pwm0.dev,
  236. .platform_data = &mainstone_backlight_data,
  237. },
  238. };
  239. static void __init mainstone_backlight_register(void)
  240. {
  241. int ret;
  242. pwm_add_table(mainstone_pwm_lookup, ARRAY_SIZE(mainstone_pwm_lookup));
  243. ret = platform_device_register(&mainstone_backlight_device);
  244. if (ret) {
  245. printk(KERN_ERR "mainstone: failed to register backlight device: %d\n", ret);
  246. pwm_remove_table(mainstone_pwm_lookup,
  247. ARRAY_SIZE(mainstone_pwm_lookup));
  248. }
  249. }
  250. #else
  251. #define mainstone_backlight_register() do { } while (0)
  252. #endif
  253. static struct pxafb_mode_info toshiba_ltm04c380k_mode = {
  254. .pixclock = 50000,
  255. .xres = 640,
  256. .yres = 480,
  257. .bpp = 16,
  258. .hsync_len = 1,
  259. .left_margin = 0x9f,
  260. .right_margin = 1,
  261. .vsync_len = 44,
  262. .upper_margin = 0,
  263. .lower_margin = 0,
  264. .sync = FB_SYNC_HOR_HIGH_ACT|FB_SYNC_VERT_HIGH_ACT,
  265. };
  266. static struct pxafb_mode_info toshiba_ltm035a776c_mode = {
  267. .pixclock = 110000,
  268. .xres = 240,
  269. .yres = 320,
  270. .bpp = 16,
  271. .hsync_len = 4,
  272. .left_margin = 8,
  273. .right_margin = 20,
  274. .vsync_len = 3,
  275. .upper_margin = 1,
  276. .lower_margin = 10,
  277. .sync = FB_SYNC_HOR_HIGH_ACT|FB_SYNC_VERT_HIGH_ACT,
  278. };
  279. static struct pxafb_mach_info mainstone_pxafb_info = {
  280. .num_modes = 1,
  281. .lcd_conn = LCD_COLOR_TFT_16BPP | LCD_PCLK_EDGE_FALL,
  282. };
  283. static int mainstone_mci_init(struct device *dev, irq_handler_t mstone_detect_int, void *data)
  284. {
  285. int err;
  286. /* make sure SD/Memory Stick multiplexer's signals
  287. * are routed to MMC controller
  288. */
  289. MST_MSCWR1 &= ~MST_MSCWR1_MS_SEL;
  290. err = request_irq(MAINSTONE_MMC_IRQ, mstone_detect_int, 0,
  291. "MMC card detect", data);
  292. if (err)
  293. printk(KERN_ERR "mainstone_mci_init: MMC/SD: can't request MMC card detect IRQ\n");
  294. return err;
  295. }
  296. static int mainstone_mci_setpower(struct device *dev, unsigned int vdd)
  297. {
  298. struct pxamci_platform_data* p_d = dev->platform_data;
  299. if (( 1 << vdd) & p_d->ocr_mask) {
  300. printk(KERN_DEBUG "%s: on\n", __func__);
  301. MST_MSCWR1 |= MST_MSCWR1_MMC_ON;
  302. MST_MSCWR1 &= ~MST_MSCWR1_MS_SEL;
  303. } else {
  304. printk(KERN_DEBUG "%s: off\n", __func__);
  305. MST_MSCWR1 &= ~MST_MSCWR1_MMC_ON;
  306. }
  307. return 0;
  308. }
  309. static void mainstone_mci_exit(struct device *dev, void *data)
  310. {
  311. free_irq(MAINSTONE_MMC_IRQ, data);
  312. }
  313. static struct pxamci_platform_data mainstone_mci_platform_data = {
  314. .ocr_mask = MMC_VDD_32_33|MMC_VDD_33_34,
  315. .init = mainstone_mci_init,
  316. .setpower = mainstone_mci_setpower,
  317. .exit = mainstone_mci_exit,
  318. };
  319. static void mainstone_irda_transceiver_mode(struct device *dev, int mode)
  320. {
  321. unsigned long flags;
  322. local_irq_save(flags);
  323. if (mode & IR_SIRMODE) {
  324. MST_MSCWR1 &= ~MST_MSCWR1_IRDA_FIR;
  325. } else if (mode & IR_FIRMODE) {
  326. MST_MSCWR1 |= MST_MSCWR1_IRDA_FIR;
  327. }
  328. pxa2xx_transceiver_mode(dev, mode);
  329. if (mode & IR_OFF) {
  330. MST_MSCWR1 = (MST_MSCWR1 & ~MST_MSCWR1_IRDA_MASK) | MST_MSCWR1_IRDA_OFF;
  331. } else {
  332. MST_MSCWR1 = (MST_MSCWR1 & ~MST_MSCWR1_IRDA_MASK) | MST_MSCWR1_IRDA_FULL;
  333. }
  334. local_irq_restore(flags);
  335. }
  336. static struct pxaficp_platform_data mainstone_ficp_platform_data = {
  337. .gpio_pwdown = -1,
  338. .transceiver_cap = IR_SIRMODE | IR_FIRMODE | IR_OFF,
  339. .transceiver_mode = mainstone_irda_transceiver_mode,
  340. };
  341. static struct gpio_keys_button gpio_keys_button[] = {
  342. [0] = {
  343. .desc = "wakeup",
  344. .code = KEY_SUSPEND,
  345. .type = EV_KEY,
  346. .gpio = 1,
  347. .wakeup = 1,
  348. },
  349. };
  350. static struct gpio_keys_platform_data mainstone_gpio_keys = {
  351. .buttons = gpio_keys_button,
  352. .nbuttons = 1,
  353. };
  354. static struct platform_device mst_gpio_keys_device = {
  355. .name = "gpio-keys",
  356. .id = -1,
  357. .dev = {
  358. .platform_data = &mainstone_gpio_keys,
  359. },
  360. };
  361. static struct resource mst_cplds_resources[] = {
  362. [0] = {
  363. .start = MST_FPGA_PHYS + 0xc0,
  364. .end = MST_FPGA_PHYS + 0xe0 - 1,
  365. .flags = IORESOURCE_MEM,
  366. },
  367. [1] = {
  368. .start = PXA_GPIO_TO_IRQ(0),
  369. .end = PXA_GPIO_TO_IRQ(0),
  370. .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWEDGE,
  371. },
  372. [2] = {
  373. .start = MAINSTONE_IRQ(0),
  374. .end = MAINSTONE_IRQ(15),
  375. .flags = IORESOURCE_IRQ,
  376. },
  377. };
  378. static struct platform_device mst_cplds_device = {
  379. .name = "pxa_cplds_irqs",
  380. .id = -1,
  381. .resource = &mst_cplds_resources[0],
  382. .num_resources = 3,
  383. };
  384. static struct platform_device *platform_devices[] __initdata = {
  385. &smc91x_device,
  386. &mst_flash_device[0],
  387. &mst_flash_device[1],
  388. &mst_gpio_keys_device,
  389. &mst_cplds_device,
  390. };
  391. static struct pxaohci_platform_data mainstone_ohci_platform_data = {
  392. .port_mode = PMM_PERPORT_MODE,
  393. .flags = ENABLE_PORT_ALL | POWER_CONTROL_LOW | POWER_SENSE_LOW,
  394. };
  395. #if defined(CONFIG_KEYBOARD_PXA27x) || defined(CONFIG_KEYBOARD_PXA27x_MODULE)
  396. static const unsigned int mainstone_matrix_keys[] = {
  397. KEY(0, 0, KEY_A), KEY(1, 0, KEY_B), KEY(2, 0, KEY_C),
  398. KEY(3, 0, KEY_D), KEY(4, 0, KEY_E), KEY(5, 0, KEY_F),
  399. KEY(0, 1, KEY_G), KEY(1, 1, KEY_H), KEY(2, 1, KEY_I),
  400. KEY(3, 1, KEY_J), KEY(4, 1, KEY_K), KEY(5, 1, KEY_L),
  401. KEY(0, 2, KEY_M), KEY(1, 2, KEY_N), KEY(2, 2, KEY_O),
  402. KEY(3, 2, KEY_P), KEY(4, 2, KEY_Q), KEY(5, 2, KEY_R),
  403. KEY(0, 3, KEY_S), KEY(1, 3, KEY_T), KEY(2, 3, KEY_U),
  404. KEY(3, 3, KEY_V), KEY(4, 3, KEY_W), KEY(5, 3, KEY_X),
  405. KEY(2, 4, KEY_Y), KEY(3, 4, KEY_Z),
  406. KEY(0, 4, KEY_DOT), /* . */
  407. KEY(1, 4, KEY_CLOSE), /* @ */
  408. KEY(4, 4, KEY_SLASH),
  409. KEY(5, 4, KEY_BACKSLASH),
  410. KEY(0, 5, KEY_HOME),
  411. KEY(1, 5, KEY_LEFTSHIFT),
  412. KEY(2, 5, KEY_SPACE),
  413. KEY(3, 5, KEY_SPACE),
  414. KEY(4, 5, KEY_ENTER),
  415. KEY(5, 5, KEY_BACKSPACE),
  416. KEY(0, 6, KEY_UP),
  417. KEY(1, 6, KEY_DOWN),
  418. KEY(2, 6, KEY_LEFT),
  419. KEY(3, 6, KEY_RIGHT),
  420. KEY(4, 6, KEY_SELECT),
  421. };
  422. static struct matrix_keymap_data mainstone_matrix_keymap_data = {
  423. .keymap = mainstone_matrix_keys,
  424. .keymap_size = ARRAY_SIZE(mainstone_matrix_keys),
  425. };
  426. struct pxa27x_keypad_platform_data mainstone_keypad_info = {
  427. .matrix_key_rows = 6,
  428. .matrix_key_cols = 7,
  429. .matrix_keymap_data = &mainstone_matrix_keymap_data,
  430. .enable_rotary0 = 1,
  431. .rotary0_up_key = KEY_UP,
  432. .rotary0_down_key = KEY_DOWN,
  433. .debounce_interval = 30,
  434. };
  435. static void __init mainstone_init_keypad(void)
  436. {
  437. pxa_set_keypad_info(&mainstone_keypad_info);
  438. }
  439. #else
  440. static inline void mainstone_init_keypad(void) {}
  441. #endif
  442. static int mst_pcmcia0_irqs[11] = {
  443. [0 ... 4] = -1,
  444. [5] = MAINSTONE_S0_CD_IRQ,
  445. [6 ... 7] = -1,
  446. [8] = MAINSTONE_S0_STSCHG_IRQ,
  447. [9] = -1,
  448. [10] = MAINSTONE_S0_IRQ,
  449. };
  450. static int mst_pcmcia1_irqs[11] = {
  451. [0 ... 4] = -1,
  452. [5] = MAINSTONE_S1_CD_IRQ,
  453. [6 ... 7] = -1,
  454. [8] = MAINSTONE_S1_STSCHG_IRQ,
  455. [9] = -1,
  456. [10] = MAINSTONE_S1_IRQ,
  457. };
  458. static struct gpiod_lookup_table mainstone_pcmcia_gpio_table = {
  459. .dev_id = "pxa2xx-pcmcia",
  460. .table = {
  461. GPIO_LOOKUP("mst-pcmcia0", 0, "a0vpp", GPIO_ACTIVE_HIGH),
  462. GPIO_LOOKUP("mst-pcmcia0", 1, "a1vpp", GPIO_ACTIVE_HIGH),
  463. GPIO_LOOKUP("mst-pcmcia0", 2, "a0vcc", GPIO_ACTIVE_HIGH),
  464. GPIO_LOOKUP("mst-pcmcia0", 3, "a1vcc", GPIO_ACTIVE_HIGH),
  465. GPIO_LOOKUP("mst-pcmcia0", 4, "areset", GPIO_ACTIVE_HIGH),
  466. GPIO_LOOKUP("mst-pcmcia0", 5, "adetect", GPIO_ACTIVE_LOW),
  467. GPIO_LOOKUP("mst-pcmcia0", 6, "avs1", GPIO_ACTIVE_LOW),
  468. GPIO_LOOKUP("mst-pcmcia0", 7, "avs2", GPIO_ACTIVE_LOW),
  469. GPIO_LOOKUP("mst-pcmcia0", 8, "abvd1", GPIO_ACTIVE_HIGH),
  470. GPIO_LOOKUP("mst-pcmcia0", 9, "abvd2", GPIO_ACTIVE_HIGH),
  471. GPIO_LOOKUP("mst-pcmcia0", 10, "aready", GPIO_ACTIVE_HIGH),
  472. GPIO_LOOKUP("mst-pcmcia1", 0, "b0vpp", GPIO_ACTIVE_HIGH),
  473. GPIO_LOOKUP("mst-pcmcia1", 1, "b1vpp", GPIO_ACTIVE_HIGH),
  474. GPIO_LOOKUP("mst-pcmcia1", 2, "b0vcc", GPIO_ACTIVE_HIGH),
  475. GPIO_LOOKUP("mst-pcmcia1", 3, "b1vcc", GPIO_ACTIVE_HIGH),
  476. GPIO_LOOKUP("mst-pcmcia1", 4, "breset", GPIO_ACTIVE_HIGH),
  477. GPIO_LOOKUP("mst-pcmcia1", 5, "bdetect", GPIO_ACTIVE_LOW),
  478. GPIO_LOOKUP("mst-pcmcia1", 6, "bvs1", GPIO_ACTIVE_LOW),
  479. GPIO_LOOKUP("mst-pcmcia1", 7, "bvs2", GPIO_ACTIVE_LOW),
  480. GPIO_LOOKUP("mst-pcmcia1", 8, "bbvd1", GPIO_ACTIVE_HIGH),
  481. GPIO_LOOKUP("mst-pcmcia1", 9, "bbvd2", GPIO_ACTIVE_HIGH),
  482. GPIO_LOOKUP("mst-pcmcia1", 10, "bready", GPIO_ACTIVE_HIGH),
  483. { },
  484. },
  485. };
  486. static struct gpiod_lookup_table mainstone_wm97xx_gpio_table = {
  487. .dev_id = "wm97xx-touch",
  488. .table = {
  489. GPIO_LOOKUP("gpio-pxa", 4, "touch", GPIO_ACTIVE_HIGH),
  490. { },
  491. },
  492. };
  493. static void __init mainstone_init(void)
  494. {
  495. int SW7 = 0; /* FIXME: get from SCR (Mst doc section 3.2.1.1) */
  496. pxa2xx_mfp_config(ARRAY_AND_SIZE(mainstone_pin_config));
  497. /* Register board control register(s) as GPIOs */
  498. gpio_reg_init(NULL, (void __iomem *)&MST_PCMCIA0, -1, 11,
  499. "mst-pcmcia0", MST_PCMCIA_INPUTS, 0, NULL,
  500. NULL, mst_pcmcia0_irqs);
  501. gpio_reg_init(NULL, (void __iomem *)&MST_PCMCIA1, -1, 11,
  502. "mst-pcmcia1", MST_PCMCIA_INPUTS, 0, NULL,
  503. NULL, mst_pcmcia1_irqs);
  504. gpiod_add_lookup_table(&mainstone_pcmcia_gpio_table);
  505. gpiod_add_lookup_table(&mainstone_wm97xx_gpio_table);
  506. pxa_set_ffuart_info(NULL);
  507. pxa_set_btuart_info(NULL);
  508. pxa_set_stuart_info(NULL);
  509. mst_flash_data[0].width = (__raw_readl(BOOT_DEF) & 1) ? 2 : 4;
  510. mst_flash_data[1].width = 4;
  511. /* Compensate for SW7 which swaps the flash banks */
  512. mst_flash_data[SW7].name = "processor-flash";
  513. mst_flash_data[SW7 ^ 1].name = "mainboard-flash";
  514. printk(KERN_NOTICE "Mainstone configured to boot from %s\n",
  515. mst_flash_data[0].name);
  516. /* system bus arbiter setting
  517. * - Core_Park
  518. * - LCD_wt:DMA_wt:CORE_Wt = 2:3:4
  519. */
  520. ARB_CNTRL = ARB_CORE_PARK | 0x234;
  521. platform_add_devices(platform_devices, ARRAY_SIZE(platform_devices));
  522. /* reading Mainstone's "Virtual Configuration Register"
  523. might be handy to select LCD type here */
  524. if (0)
  525. mainstone_pxafb_info.modes = &toshiba_ltm04c380k_mode;
  526. else
  527. mainstone_pxafb_info.modes = &toshiba_ltm035a776c_mode;
  528. pxa_set_fb_info(NULL, &mainstone_pxafb_info);
  529. mainstone_backlight_register();
  530. pxa_set_mci_info(&mainstone_mci_platform_data);
  531. pxa_set_ficp_info(&mainstone_ficp_platform_data);
  532. pxa_set_ohci_info(&mainstone_ohci_platform_data);
  533. pxa_set_i2c_info(NULL);
  534. pxa_set_ac97_info(&mst_audio_ops);
  535. mainstone_init_keypad();
  536. }
  537. static struct map_desc mainstone_io_desc[] __initdata = {
  538. { /* CPLD */
  539. .virtual = MST_FPGA_VIRT,
  540. .pfn = __phys_to_pfn(MST_FPGA_PHYS),
  541. .length = 0x00100000,
  542. .type = MT_DEVICE
  543. }
  544. };
  545. static void __init mainstone_map_io(void)
  546. {
  547. pxa27x_map_io();
  548. iotable_init(mainstone_io_desc, ARRAY_SIZE(mainstone_io_desc));
  549. /* for use I SRAM as framebuffer. */
  550. PSLR |= 0xF04;
  551. PCFR = 0x66;
  552. }
  553. /*
  554. * Driver for the 8 discrete LEDs available for general use:
  555. * Note: bits [15-8] are used to enable/blank the 8 7 segment hex displays
  556. * so be sure to not monkey with them here.
  557. */
  558. #if defined(CONFIG_NEW_LEDS) && defined(CONFIG_LEDS_CLASS)
  559. struct mainstone_led {
  560. struct led_classdev cdev;
  561. u8 mask;
  562. };
  563. /*
  564. * The triggers lines up below will only be used if the
  565. * LED triggers are compiled in.
  566. */
  567. static const struct {
  568. const char *name;
  569. const char *trigger;
  570. } mainstone_leds[] = {
  571. { "mainstone:D28", "default-on", },
  572. { "mainstone:D27", "cpu0", },
  573. { "mainstone:D26", "heartbeat" },
  574. { "mainstone:D25", },
  575. { "mainstone:D24", },
  576. { "mainstone:D23", },
  577. { "mainstone:D22", },
  578. { "mainstone:D21", },
  579. };
  580. static void mainstone_led_set(struct led_classdev *cdev,
  581. enum led_brightness b)
  582. {
  583. struct mainstone_led *led = container_of(cdev,
  584. struct mainstone_led, cdev);
  585. u32 reg = MST_LEDCTRL;
  586. if (b != LED_OFF)
  587. reg |= led->mask;
  588. else
  589. reg &= ~led->mask;
  590. MST_LEDCTRL = reg;
  591. }
  592. static enum led_brightness mainstone_led_get(struct led_classdev *cdev)
  593. {
  594. struct mainstone_led *led = container_of(cdev,
  595. struct mainstone_led, cdev);
  596. u32 reg = MST_LEDCTRL;
  597. return (reg & led->mask) ? LED_FULL : LED_OFF;
  598. }
  599. static int __init mainstone_leds_init(void)
  600. {
  601. int i;
  602. if (!machine_is_mainstone())
  603. return -ENODEV;
  604. /* All ON */
  605. MST_LEDCTRL |= 0xff;
  606. for (i = 0; i < ARRAY_SIZE(mainstone_leds); i++) {
  607. struct mainstone_led *led;
  608. led = kzalloc(sizeof(*led), GFP_KERNEL);
  609. if (!led)
  610. break;
  611. led->cdev.name = mainstone_leds[i].name;
  612. led->cdev.brightness_set = mainstone_led_set;
  613. led->cdev.brightness_get = mainstone_led_get;
  614. led->cdev.default_trigger = mainstone_leds[i].trigger;
  615. led->mask = BIT(i);
  616. if (led_classdev_register(NULL, &led->cdev) < 0) {
  617. kfree(led);
  618. break;
  619. }
  620. }
  621. return 0;
  622. }
  623. /*
  624. * Since we may have triggers on any subsystem, defer registration
  625. * until after subsystem_init.
  626. */
  627. fs_initcall(mainstone_leds_init);
  628. #endif
  629. MACHINE_START(MAINSTONE, "Intel HCDDBBVA0 Development Platform (aka Mainstone)")
  630. /* Maintainer: MontaVista Software Inc. */
  631. .atag_offset = 0x100, /* BLOB boot parameter setting */
  632. .map_io = mainstone_map_io,
  633. .nr_irqs = MAINSTONE_NR_IRQS,
  634. .init_irq = pxa27x_init_irq,
  635. .handle_irq = pxa27x_handle_irq,
  636. .init_time = pxa_timer_init,
  637. .init_machine = mainstone_init,
  638. .restart = pxa_restart,
  639. MACHINE_END