board-nokia770.c 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247
  1. /*
  2. * linux/arch/arm/mach-omap1/board-nokia770.c
  3. *
  4. * Modified from board-generic.c
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License version 2 as
  8. * published by the Free Software Foundation.
  9. */
  10. #include <linux/gpio.h>
  11. #include <linux/kernel.h>
  12. #include <linux/init.h>
  13. #include <linux/mutex.h>
  14. #include <linux/platform_device.h>
  15. #include <linux/input.h>
  16. #include <linux/clk.h>
  17. #include <linux/omapfb.h>
  18. #include <linux/spi/spi.h>
  19. #include <linux/spi/ads7846.h>
  20. #include <linux/workqueue.h>
  21. #include <linux/delay.h>
  22. #include <linux/platform_data/keypad-omap.h>
  23. #include <linux/platform_data/lcd-mipid.h>
  24. #include <asm/mach-types.h>
  25. #include <asm/mach/arch.h>
  26. #include <asm/mach/map.h>
  27. #include <mach/mux.h>
  28. #include <mach/hardware.h>
  29. #include <mach/usb.h>
  30. #include "common.h"
  31. #include "clock.h"
  32. #include "mmc.h"
  33. #define ADS7846_PENDOWN_GPIO 15
  34. static const unsigned int nokia770_keymap[] = {
  35. KEY(1, 0, GROUP_0 | KEY_UP),
  36. KEY(2, 0, GROUP_1 | KEY_F5),
  37. KEY(0, 1, GROUP_0 | KEY_LEFT),
  38. KEY(1, 1, GROUP_0 | KEY_ENTER),
  39. KEY(2, 1, GROUP_0 | KEY_RIGHT),
  40. KEY(0, 2, GROUP_1 | KEY_ESC),
  41. KEY(1, 2, GROUP_0 | KEY_DOWN),
  42. KEY(2, 2, GROUP_1 | KEY_F4),
  43. KEY(0, 3, GROUP_2 | KEY_F7),
  44. KEY(1, 3, GROUP_2 | KEY_F8),
  45. KEY(2, 3, GROUP_2 | KEY_F6),
  46. };
  47. static struct resource nokia770_kp_resources[] = {
  48. [0] = {
  49. .start = INT_KEYBOARD,
  50. .end = INT_KEYBOARD,
  51. .flags = IORESOURCE_IRQ,
  52. },
  53. };
  54. static const struct matrix_keymap_data nokia770_keymap_data = {
  55. .keymap = nokia770_keymap,
  56. .keymap_size = ARRAY_SIZE(nokia770_keymap),
  57. };
  58. static struct omap_kp_platform_data nokia770_kp_data = {
  59. .rows = 8,
  60. .cols = 8,
  61. .keymap_data = &nokia770_keymap_data,
  62. .delay = 4,
  63. };
  64. static struct platform_device nokia770_kp_device = {
  65. .name = "omap-keypad",
  66. .id = -1,
  67. .dev = {
  68. .platform_data = &nokia770_kp_data,
  69. },
  70. .num_resources = ARRAY_SIZE(nokia770_kp_resources),
  71. .resource = nokia770_kp_resources,
  72. };
  73. static struct platform_device *nokia770_devices[] __initdata = {
  74. &nokia770_kp_device,
  75. };
  76. static void mipid_shutdown(struct mipid_platform_data *pdata)
  77. {
  78. if (pdata->nreset_gpio != -1) {
  79. printk(KERN_INFO "shutdown LCD\n");
  80. gpio_set_value(pdata->nreset_gpio, 0);
  81. msleep(120);
  82. }
  83. }
  84. static struct mipid_platform_data nokia770_mipid_platform_data = {
  85. .shutdown = mipid_shutdown,
  86. };
  87. static struct omap_lcd_config nokia770_lcd_config __initdata = {
  88. .ctrl_name = "hwa742",
  89. };
  90. static void __init mipid_dev_init(void)
  91. {
  92. nokia770_mipid_platform_data.nreset_gpio = 13;
  93. nokia770_mipid_platform_data.data_lines = 16;
  94. omapfb_set_lcd_config(&nokia770_lcd_config);
  95. }
  96. static struct ads7846_platform_data nokia770_ads7846_platform_data __initdata = {
  97. .x_max = 0x0fff,
  98. .y_max = 0x0fff,
  99. .x_plate_ohms = 180,
  100. .pressure_max = 255,
  101. .debounce_max = 10,
  102. .debounce_tol = 3,
  103. .debounce_rep = 1,
  104. .gpio_pendown = ADS7846_PENDOWN_GPIO,
  105. };
  106. static struct spi_board_info nokia770_spi_board_info[] __initdata = {
  107. [0] = {
  108. .modalias = "lcd_mipid",
  109. .bus_num = 2,
  110. .chip_select = 3,
  111. .max_speed_hz = 12000000,
  112. .platform_data = &nokia770_mipid_platform_data,
  113. },
  114. [1] = {
  115. .modalias = "ads7846",
  116. .bus_num = 2,
  117. .chip_select = 0,
  118. .max_speed_hz = 2500000,
  119. .platform_data = &nokia770_ads7846_platform_data,
  120. },
  121. };
  122. static void __init hwa742_dev_init(void)
  123. {
  124. clk_add_alias("hwa_sys_ck", NULL, "bclk", NULL);
  125. }
  126. /* assume no Mini-AB port */
  127. static struct omap_usb_config nokia770_usb_config __initdata = {
  128. .otg = 1,
  129. .register_host = 1,
  130. .register_dev = 1,
  131. .hmc_mode = 16,
  132. .pins[0] = 6,
  133. };
  134. #if defined(CONFIG_MMC_OMAP) || defined(CONFIG_MMC_OMAP_MODULE)
  135. #define NOKIA770_GPIO_MMC_POWER 41
  136. #define NOKIA770_GPIO_MMC_SWITCH 23
  137. static int nokia770_mmc_set_power(struct device *dev, int slot, int power_on,
  138. int vdd)
  139. {
  140. gpio_set_value(NOKIA770_GPIO_MMC_POWER, power_on);
  141. return 0;
  142. }
  143. static int nokia770_mmc_get_cover_state(struct device *dev, int slot)
  144. {
  145. return gpio_get_value(NOKIA770_GPIO_MMC_SWITCH);
  146. }
  147. static struct omap_mmc_platform_data nokia770_mmc2_data = {
  148. .nr_slots = 1,
  149. .max_freq = 12000000,
  150. .slots[0] = {
  151. .set_power = nokia770_mmc_set_power,
  152. .get_cover_state = nokia770_mmc_get_cover_state,
  153. .ocr_mask = MMC_VDD_32_33|MMC_VDD_33_34,
  154. .name = "mmcblk",
  155. },
  156. };
  157. static struct omap_mmc_platform_data *nokia770_mmc_data[OMAP16XX_NR_MMC];
  158. static void __init nokia770_mmc_init(void)
  159. {
  160. int ret;
  161. ret = gpio_request(NOKIA770_GPIO_MMC_POWER, "MMC power");
  162. if (ret < 0)
  163. return;
  164. gpio_direction_output(NOKIA770_GPIO_MMC_POWER, 0);
  165. ret = gpio_request(NOKIA770_GPIO_MMC_SWITCH, "MMC cover");
  166. if (ret < 0) {
  167. gpio_free(NOKIA770_GPIO_MMC_POWER);
  168. return;
  169. }
  170. gpio_direction_input(NOKIA770_GPIO_MMC_SWITCH);
  171. /* Only the second MMC controller is used */
  172. nokia770_mmc_data[1] = &nokia770_mmc2_data;
  173. omap1_init_mmc(nokia770_mmc_data, OMAP16XX_NR_MMC);
  174. }
  175. #else
  176. static inline void nokia770_mmc_init(void)
  177. {
  178. }
  179. #endif
  180. static void __init omap_nokia770_init(void)
  181. {
  182. /* On Nokia 770, the SleepX signal is masked with an
  183. * MPUIO line by default. It has to be unmasked for it
  184. * to become functional */
  185. /* SleepX mask direction */
  186. omap_writew((omap_readw(0xfffb5008) & ~2), 0xfffb5008);
  187. /* Unmask SleepX signal */
  188. omap_writew((omap_readw(0xfffb5004) & ~2), 0xfffb5004);
  189. platform_add_devices(nokia770_devices, ARRAY_SIZE(nokia770_devices));
  190. nokia770_spi_board_info[1].irq = gpio_to_irq(15);
  191. spi_register_board_info(nokia770_spi_board_info,
  192. ARRAY_SIZE(nokia770_spi_board_info));
  193. omap_serial_init();
  194. omap_register_i2c_bus(1, 100, NULL, 0);
  195. hwa742_dev_init();
  196. mipid_dev_init();
  197. omap1_usb_init(&nokia770_usb_config);
  198. nokia770_mmc_init();
  199. }
  200. MACHINE_START(NOKIA770, "Nokia 770")
  201. .atag_offset = 0x100,
  202. .map_io = omap16xx_map_io,
  203. .init_early = omap1_init_early,
  204. .init_irq = omap1_init_irq,
  205. .init_machine = omap_nokia770_init,
  206. .init_late = omap1_init_late,
  207. .timer = &omap1_timer,
  208. .restart = omap1_restart,
  209. MACHINE_END