mainstone.c 16 KB

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