board-p720t.c 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376
  1. /*
  2. * linux/arch/arm/mach-clps711x/p720t.c
  3. *
  4. * Copyright (C) 2000-2001 Deep Blue Solutions Ltd
  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 as published by
  8. * the Free Software Foundation; either version 2 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program; if not, write to the Free Software
  18. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  19. */
  20. #include <linux/kernel.h>
  21. #include <linux/init.h>
  22. #include <linux/types.h>
  23. #include <linux/string.h>
  24. #include <linux/mm.h>
  25. #include <linux/io.h>
  26. #include <linux/gpio.h>
  27. #include <linux/slab.h>
  28. #include <linux/leds.h>
  29. #include <linux/sizes.h>
  30. #include <linux/backlight.h>
  31. #include <linux/basic_mmio_gpio.h>
  32. #include <linux/platform_device.h>
  33. #include <linux/mtd/partitions.h>
  34. #include <linux/mtd/nand-gpio.h>
  35. #include <mach/hardware.h>
  36. #include <asm/pgtable.h>
  37. #include <asm/page.h>
  38. #include <asm/setup.h>
  39. #include <asm/mach-types.h>
  40. #include <asm/mach/arch.h>
  41. #include <asm/mach/map.h>
  42. #include <video/platform_lcd.h>
  43. #include "common.h"
  44. #include "devices.h"
  45. #define P720T_USERLED CLPS711X_GPIO(3, 0)
  46. #define P720T_NAND_CLE CLPS711X_GPIO(4, 0)
  47. #define P720T_NAND_ALE CLPS711X_GPIO(4, 1)
  48. #define P720T_NAND_NCE CLPS711X_GPIO(4, 2)
  49. #define P720T_NAND_BASE (CLPS711X_SDRAM1_BASE)
  50. #define P720T_MMGPIO_BASE (CLPS711X_NR_GPIO)
  51. #define SYSPLD_PHYS_BASE IOMEM(CS1_PHYS_BASE)
  52. #define PLD_INT (SYSPLD_PHYS_BASE + 0x000000)
  53. #define PLD_INT_MMGPIO_BASE (P720T_MMGPIO_BASE + 0)
  54. #define PLD_INT_PENIRQ (PLD_INT_MMGPIO_BASE + 5)
  55. #define PLD_INT_UCB_IRQ (PLD_INT_MMGPIO_BASE + 1)
  56. #define PLD_INT_KBD_ATN (PLD_INT_MMGPIO_BASE + 0) /* EINT1 */
  57. #define PLD_PWR (SYSPLD_PHYS_BASE + 0x000004)
  58. #define PLD_PWR_MMGPIO_BASE (P720T_MMGPIO_BASE + 8)
  59. #define PLD_PWR_EXT (PLD_PWR_MMGPIO_BASE + 5)
  60. #define PLD_PWR_MODE (PLD_PWR_MMGPIO_BASE + 4) /* 1 = PWM, 0 = PFM */
  61. #define PLD_S4_ON (PLD_PWR_MMGPIO_BASE + 3) /* LCD bias voltage enable */
  62. #define PLD_S3_ON (PLD_PWR_MMGPIO_BASE + 2) /* LCD backlight enable */
  63. #define PLD_S2_ON (PLD_PWR_MMGPIO_BASE + 1) /* LCD 3V3 supply enable */
  64. #define PLD_S1_ON (PLD_PWR_MMGPIO_BASE + 0) /* LCD 3V supply enable */
  65. #define PLD_KBD (SYSPLD_PHYS_BASE + 0x000008)
  66. #define PLD_KBD_MMGPIO_BASE (P720T_MMGPIO_BASE + 16)
  67. #define PLD_KBD_WAKE (PLD_KBD_MMGPIO_BASE + 1)
  68. #define PLD_KBD_EN (PLD_KBD_MMGPIO_BASE + 0)
  69. #define PLD_SPI (SYSPLD_PHYS_BASE + 0x00000c)
  70. #define PLD_SPI_MMGPIO_BASE (P720T_MMGPIO_BASE + 24)
  71. #define PLD_SPI_EN (PLD_SPI_MMGPIO_BASE + 0)
  72. #define PLD_IO (SYSPLD_PHYS_BASE + 0x000010)
  73. #define PLD_IO_MMGPIO_BASE (P720T_MMGPIO_BASE + 32)
  74. #define PLD_IO_BOOTSEL (PLD_IO_MMGPIO_BASE + 6) /* Boot sel switch */
  75. #define PLD_IO_USER (PLD_IO_MMGPIO_BASE + 5) /* User defined switch */
  76. #define PLD_IO_LED3 (PLD_IO_MMGPIO_BASE + 4)
  77. #define PLD_IO_LED2 (PLD_IO_MMGPIO_BASE + 3)
  78. #define PLD_IO_LED1 (PLD_IO_MMGPIO_BASE + 2)
  79. #define PLD_IO_LED0 (PLD_IO_MMGPIO_BASE + 1)
  80. #define PLD_IO_LEDEN (PLD_IO_MMGPIO_BASE + 0)
  81. #define PLD_IRDA (SYSPLD_PHYS_BASE + 0x000014)
  82. #define PLD_IRDA_MMGPIO_BASE (P720T_MMGPIO_BASE + 40)
  83. #define PLD_IRDA_EN (PLD_IRDA_MMGPIO_BASE + 0)
  84. #define PLD_COM2 (SYSPLD_PHYS_BASE + 0x000018)
  85. #define PLD_COM2_MMGPIO_BASE (P720T_MMGPIO_BASE + 48)
  86. #define PLD_COM2_EN (PLD_COM2_MMGPIO_BASE + 0)
  87. #define PLD_COM1 (SYSPLD_PHYS_BASE + 0x00001c)
  88. #define PLD_COM1_MMGPIO_BASE (P720T_MMGPIO_BASE + 56)
  89. #define PLD_COM1_EN (PLD_COM1_MMGPIO_BASE + 0)
  90. #define PLD_AUD (SYSPLD_PHYS_BASE + 0x000020)
  91. #define PLD_AUD_MMGPIO_BASE (P720T_MMGPIO_BASE + 64)
  92. #define PLD_AUD_DIV1 (PLD_AUD_MMGPIO_BASE + 6)
  93. #define PLD_AUD_DIV0 (PLD_AUD_MMGPIO_BASE + 5)
  94. #define PLD_AUD_CLK_SEL1 (PLD_AUD_MMGPIO_BASE + 4)
  95. #define PLD_AUD_CLK_SEL0 (PLD_AUD_MMGPIO_BASE + 3)
  96. #define PLD_AUD_MIC_PWR (PLD_AUD_MMGPIO_BASE + 2)
  97. #define PLD_AUD_MIC_GAIN (PLD_AUD_MMGPIO_BASE + 1)
  98. #define PLD_AUD_CODEC_EN (PLD_AUD_MMGPIO_BASE + 0)
  99. #define PLD_CF (SYSPLD_PHYS_BASE + 0x000024)
  100. #define PLD_CF_MMGPIO_BASE (P720T_MMGPIO_BASE + 72)
  101. #define PLD_CF2_SLEEP (PLD_CF_MMGPIO_BASE + 5)
  102. #define PLD_CF1_SLEEP (PLD_CF_MMGPIO_BASE + 4)
  103. #define PLD_CF2_nPDREQ (PLD_CF_MMGPIO_BASE + 3)
  104. #define PLD_CF1_nPDREQ (PLD_CF_MMGPIO_BASE + 2)
  105. #define PLD_CF2_nIRQ (PLD_CF_MMGPIO_BASE + 1)
  106. #define PLD_CF1_nIRQ (PLD_CF_MMGPIO_BASE + 0)
  107. #define PLD_SDC (SYSPLD_PHYS_BASE + 0x000028)
  108. #define PLD_SDC_MMGPIO_BASE (P720T_MMGPIO_BASE + 80)
  109. #define PLD_SDC_INT_EN (PLD_SDC_MMGPIO_BASE + 2)
  110. #define PLD_SDC_WP (PLD_SDC_MMGPIO_BASE + 1)
  111. #define PLD_SDC_CD (PLD_SDC_MMGPIO_BASE + 0)
  112. #define PLD_CODEC (SYSPLD_PHYS_BASE + 0x400000)
  113. #define PLD_CODEC_MMGPIO_BASE (P720T_MMGPIO_BASE + 88)
  114. #define PLD_CODEC_IRQ3 (PLD_CODEC_MMGPIO_BASE + 4)
  115. #define PLD_CODEC_IRQ2 (PLD_CODEC_MMGPIO_BASE + 3)
  116. #define PLD_CODEC_IRQ1 (PLD_CODEC_MMGPIO_BASE + 2)
  117. #define PLD_CODEC_EN (PLD_CODEC_MMGPIO_BASE + 0)
  118. #define PLD_BRITE (SYSPLD_PHYS_BASE + 0x400004)
  119. #define PLD_BRITE_MMGPIO_BASE (P720T_MMGPIO_BASE + 96)
  120. #define PLD_BRITE_UP (PLD_BRITE_MMGPIO_BASE + 1)
  121. #define PLD_BRITE_DN (PLD_BRITE_MMGPIO_BASE + 0)
  122. #define PLD_LCDEN (SYSPLD_PHYS_BASE + 0x400008)
  123. #define PLD_LCDEN_MMGPIO_BASE (P720T_MMGPIO_BASE + 104)
  124. #define PLD_LCDEN_EN (PLD_LCDEN_MMGPIO_BASE + 0)
  125. #define PLD_TCH (SYSPLD_PHYS_BASE + 0x400010)
  126. #define PLD_TCH_MMGPIO_BASE (P720T_MMGPIO_BASE + 112)
  127. #define PLD_TCH_PENIRQ (PLD_TCH_MMGPIO_BASE + 1)
  128. #define PLD_TCH_EN (PLD_TCH_MMGPIO_BASE + 0)
  129. #define PLD_GPIO (SYSPLD_PHYS_BASE + 0x400014)
  130. #define PLD_GPIO_MMGPIO_BASE (P720T_MMGPIO_BASE + 120)
  131. #define PLD_GPIO2 (PLD_GPIO_MMGPIO_BASE + 2)
  132. #define PLD_GPIO1 (PLD_GPIO_MMGPIO_BASE + 1)
  133. #define PLD_GPIO0 (PLD_GPIO_MMGPIO_BASE + 0)
  134. static struct gpio p720t_gpios[] __initconst = {
  135. { PLD_S1_ON, GPIOF_OUT_INIT_LOW, "PLD_S1_ON" },
  136. { PLD_S2_ON, GPIOF_OUT_INIT_LOW, "PLD_S2_ON" },
  137. { PLD_S3_ON, GPIOF_OUT_INIT_LOW, "PLD_S3_ON" },
  138. { PLD_S4_ON, GPIOF_OUT_INIT_LOW, "PLD_S4_ON" },
  139. { PLD_KBD_EN, GPIOF_OUT_INIT_LOW, "PLD_KBD_EN" },
  140. { PLD_SPI_EN, GPIOF_OUT_INIT_LOW, "PLD_SPI_EN" },
  141. { PLD_IO_USER, GPIOF_OUT_INIT_LOW, "PLD_IO_USER" },
  142. { PLD_IO_LED0, GPIOF_OUT_INIT_LOW, "PLD_IO_LED0" },
  143. { PLD_IO_LED1, GPIOF_OUT_INIT_LOW, "PLD_IO_LED1" },
  144. { PLD_IO_LED2, GPIOF_OUT_INIT_LOW, "PLD_IO_LED2" },
  145. { PLD_IO_LED3, GPIOF_OUT_INIT_LOW, "PLD_IO_LED3" },
  146. { PLD_IO_LEDEN, GPIOF_OUT_INIT_LOW, "PLD_IO_LEDEN" },
  147. { PLD_IRDA_EN, GPIOF_OUT_INIT_LOW, "PLD_IRDA_EN" },
  148. { PLD_COM1_EN, GPIOF_OUT_INIT_HIGH, "PLD_COM1_EN" },
  149. { PLD_COM2_EN, GPIOF_OUT_INIT_HIGH, "PLD_COM2_EN" },
  150. { PLD_CODEC_EN, GPIOF_OUT_INIT_LOW, "PLD_CODEC_EN" },
  151. { PLD_LCDEN_EN, GPIOF_OUT_INIT_LOW, "PLD_LCDEN_EN" },
  152. { PLD_TCH_EN, GPIOF_OUT_INIT_LOW, "PLD_TCH_EN" },
  153. { P720T_USERLED,GPIOF_OUT_INIT_LOW, "USER_LED" },
  154. };
  155. static struct resource p720t_mmgpio_resource[] __initdata = {
  156. DEFINE_RES_MEM_NAMED(0, 4, "dat"),
  157. };
  158. static struct bgpio_pdata p720t_mmgpio_pdata = {
  159. .ngpio = 8,
  160. };
  161. static struct platform_device p720t_mmgpio __initdata = {
  162. .name = "basic-mmio-gpio",
  163. .id = -1,
  164. .resource = p720t_mmgpio_resource,
  165. .num_resources = ARRAY_SIZE(p720t_mmgpio_resource),
  166. .dev = {
  167. .platform_data = &p720t_mmgpio_pdata,
  168. },
  169. };
  170. static void __init p720t_mmgpio_init(void __iomem *addrbase, int gpiobase)
  171. {
  172. p720t_mmgpio_resource[0].start = (unsigned long)addrbase;
  173. p720t_mmgpio_pdata.base = gpiobase;
  174. platform_device_register(&p720t_mmgpio);
  175. }
  176. static struct {
  177. void __iomem *addrbase;
  178. int gpiobase;
  179. } mmgpios[] __initconst = {
  180. { PLD_INT, PLD_INT_MMGPIO_BASE },
  181. { PLD_PWR, PLD_PWR_MMGPIO_BASE },
  182. { PLD_KBD, PLD_KBD_MMGPIO_BASE },
  183. { PLD_SPI, PLD_SPI_MMGPIO_BASE },
  184. { PLD_IO, PLD_IO_MMGPIO_BASE },
  185. { PLD_IRDA, PLD_IRDA_MMGPIO_BASE },
  186. { PLD_COM2, PLD_COM2_MMGPIO_BASE },
  187. { PLD_COM1, PLD_COM1_MMGPIO_BASE },
  188. { PLD_AUD, PLD_AUD_MMGPIO_BASE },
  189. { PLD_CF, PLD_CF_MMGPIO_BASE },
  190. { PLD_SDC, PLD_SDC_MMGPIO_BASE },
  191. { PLD_CODEC, PLD_CODEC_MMGPIO_BASE },
  192. { PLD_BRITE, PLD_BRITE_MMGPIO_BASE },
  193. { PLD_LCDEN, PLD_LCDEN_MMGPIO_BASE },
  194. { PLD_TCH, PLD_TCH_MMGPIO_BASE },
  195. { PLD_GPIO, PLD_GPIO_MMGPIO_BASE },
  196. };
  197. static struct resource p720t_nand_resource[] __initdata = {
  198. DEFINE_RES_MEM(P720T_NAND_BASE, SZ_4),
  199. };
  200. static struct mtd_partition p720t_nand_parts[] __initdata = {
  201. {
  202. .name = "Flash partition 1",
  203. .offset = 0,
  204. .size = SZ_2M,
  205. },
  206. {
  207. .name = "Flash partition 2",
  208. .offset = MTDPART_OFS_APPEND,
  209. .size = MTDPART_SIZ_FULL,
  210. },
  211. };
  212. static struct gpio_nand_platdata p720t_nand_pdata __initdata = {
  213. .gpio_rdy = -1,
  214. .gpio_nce = P720T_NAND_NCE,
  215. .gpio_ale = P720T_NAND_ALE,
  216. .gpio_cle = P720T_NAND_CLE,
  217. .gpio_nwp = -1,
  218. .chip_delay = 15,
  219. .parts = p720t_nand_parts,
  220. .num_parts = ARRAY_SIZE(p720t_nand_parts),
  221. };
  222. static struct platform_device p720t_nand_pdev __initdata = {
  223. .name = "gpio-nand",
  224. .id = -1,
  225. .resource = p720t_nand_resource,
  226. .num_resources = ARRAY_SIZE(p720t_nand_resource),
  227. .dev = {
  228. .platform_data = &p720t_nand_pdata,
  229. },
  230. };
  231. static void p720t_lcd_power_set(struct plat_lcd_data *pd, unsigned int power)
  232. {
  233. if (power) {
  234. gpio_set_value(PLD_LCDEN_EN, 1);
  235. gpio_set_value(PLD_S1_ON, 1);
  236. gpio_set_value(PLD_S2_ON, 1);
  237. gpio_set_value(PLD_S4_ON, 1);
  238. } else {
  239. gpio_set_value(PLD_S1_ON, 0);
  240. gpio_set_value(PLD_S2_ON, 0);
  241. gpio_set_value(PLD_S4_ON, 0);
  242. gpio_set_value(PLD_LCDEN_EN, 0);
  243. }
  244. }
  245. static struct plat_lcd_data p720t_lcd_power_pdata = {
  246. .set_power = p720t_lcd_power_set,
  247. };
  248. static void p720t_lcd_backlight_set_intensity(int intensity)
  249. {
  250. gpio_set_value(PLD_S3_ON, intensity);
  251. }
  252. static struct generic_bl_info p720t_lcd_backlight_pdata = {
  253. .name = "lcd-backlight.0",
  254. .default_intensity = 0x01,
  255. .max_intensity = 0x01,
  256. .set_bl_intensity = p720t_lcd_backlight_set_intensity,
  257. };
  258. static void __init
  259. fixup_p720t(struct tag *tag, char **cmdline, struct meminfo *mi)
  260. {
  261. /*
  262. * Our bootloader doesn't setup any tags (yet).
  263. */
  264. if (tag->hdr.tag != ATAG_CORE) {
  265. tag->hdr.tag = ATAG_CORE;
  266. tag->hdr.size = tag_size(tag_core);
  267. tag->u.core.flags = 0;
  268. tag->u.core.pagesize = PAGE_SIZE;
  269. tag->u.core.rootdev = 0x0100;
  270. tag = tag_next(tag);
  271. tag->hdr.tag = ATAG_MEM;
  272. tag->hdr.size = tag_size(tag_mem32);
  273. tag->u.mem.size = 4096;
  274. tag->u.mem.start = PHYS_OFFSET;
  275. tag = tag_next(tag);
  276. tag->hdr.tag = ATAG_NONE;
  277. tag->hdr.size = 0;
  278. }
  279. }
  280. static struct gpio_led p720t_gpio_leds[] = {
  281. {
  282. .name = "User LED",
  283. .default_trigger = "heartbeat",
  284. .gpio = P720T_USERLED,
  285. },
  286. };
  287. static struct gpio_led_platform_data p720t_gpio_led_pdata __initdata = {
  288. .leds = p720t_gpio_leds,
  289. .num_leds = ARRAY_SIZE(p720t_gpio_leds),
  290. };
  291. static void __init p720t_init(void)
  292. {
  293. int i;
  294. clps711x_devices_init();
  295. for (i = 0; i < ARRAY_SIZE(mmgpios); i++)
  296. p720t_mmgpio_init(mmgpios[i].addrbase, mmgpios[i].gpiobase);
  297. platform_device_register(&p720t_nand_pdev);
  298. }
  299. static void __init p720t_init_late(void)
  300. {
  301. WARN_ON(gpio_request_array(p720t_gpios, ARRAY_SIZE(p720t_gpios)));
  302. platform_device_register_data(&platform_bus, "platform-lcd", 0,
  303. &p720t_lcd_power_pdata,
  304. sizeof(p720t_lcd_power_pdata));
  305. platform_device_register_data(&platform_bus, "generic-bl", 0,
  306. &p720t_lcd_backlight_pdata,
  307. sizeof(p720t_lcd_backlight_pdata));
  308. platform_device_register_simple("video-clps711x", 0, NULL, 0);
  309. platform_device_register_data(&platform_bus, "leds-gpio", 0,
  310. &p720t_gpio_led_pdata,
  311. sizeof(p720t_gpio_led_pdata));
  312. }
  313. MACHINE_START(P720T, "ARM-Prospector720T")
  314. /* Maintainer: ARM Ltd/Deep Blue Solutions Ltd */
  315. .atag_offset = 0x100,
  316. .nr_irqs = CLPS711X_NR_IRQS,
  317. .fixup = fixup_p720t,
  318. .map_io = clps711x_map_io,
  319. .init_early = clps711x_init_early,
  320. .init_irq = clps711x_init_irq,
  321. .init_time = clps711x_timer_init,
  322. .init_machine = p720t_init,
  323. .init_late = p720t_init_late,
  324. .handle_irq = clps711x_handle_irq,
  325. .restart = clps711x_restart,
  326. MACHINE_END