assabet.c 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450
  1. /*
  2. * linux/arch/arm/mach-sa1100/assabet.c
  3. *
  4. * Author: Nicolas Pitre
  5. *
  6. * This file contains all Assabet-specific tweaks.
  7. *
  8. * This program is free software; you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License version 2 as
  10. * published by the Free Software Foundation.
  11. */
  12. #include <linux/config.h>
  13. #include <linux/init.h>
  14. #include <linux/kernel.h>
  15. #include <linux/module.h>
  16. #include <linux/errno.h>
  17. #include <linux/ioport.h>
  18. #include <linux/serial_core.h>
  19. #include <linux/mtd/mtd.h>
  20. #include <linux/mtd/partitions.h>
  21. #include <linux/delay.h>
  22. #include <linux/mm.h>
  23. #include <asm/hardware.h>
  24. #include <asm/mach-types.h>
  25. #include <asm/irq.h>
  26. #include <asm/setup.h>
  27. #include <asm/page.h>
  28. #include <asm/pgtable.h>
  29. #include <asm/tlbflush.h>
  30. #include <asm/mach/arch.h>
  31. #include <asm/mach/flash.h>
  32. #include <asm/mach/irda.h>
  33. #include <asm/mach/map.h>
  34. #include <asm/mach/serial_sa1100.h>
  35. #include <asm/arch/assabet.h>
  36. #include <asm/arch/mcp.h>
  37. #include "generic.h"
  38. #define ASSABET_BCR_DB1110 \
  39. (ASSABET_BCR_SPK_OFF | ASSABET_BCR_QMUTE | \
  40. ASSABET_BCR_LED_GREEN | ASSABET_BCR_LED_RED | \
  41. ASSABET_BCR_RS232EN | ASSABET_BCR_LCD_12RGB | \
  42. ASSABET_BCR_IRDA_MD0)
  43. #define ASSABET_BCR_DB1111 \
  44. (ASSABET_BCR_SPK_OFF | ASSABET_BCR_QMUTE | \
  45. ASSABET_BCR_LED_GREEN | ASSABET_BCR_LED_RED | \
  46. ASSABET_BCR_RS232EN | ASSABET_BCR_LCD_12RGB | \
  47. ASSABET_BCR_CF_BUS_OFF | ASSABET_BCR_STEREO_LB | \
  48. ASSABET_BCR_IRDA_MD0 | ASSABET_BCR_CF_RST)
  49. unsigned long SCR_value = ASSABET_SCR_INIT;
  50. EXPORT_SYMBOL(SCR_value);
  51. static unsigned long BCR_value = ASSABET_BCR_DB1110;
  52. void ASSABET_BCR_frob(unsigned int mask, unsigned int val)
  53. {
  54. unsigned long flags;
  55. local_irq_save(flags);
  56. BCR_value = (BCR_value & ~mask) | val;
  57. ASSABET_BCR = BCR_value;
  58. local_irq_restore(flags);
  59. }
  60. EXPORT_SYMBOL(ASSABET_BCR_frob);
  61. static void assabet_backlight_power(int on)
  62. {
  63. #ifndef ASSABET_PAL_VIDEO
  64. if (on)
  65. ASSABET_BCR_set(ASSABET_BCR_LIGHT_ON);
  66. else
  67. #endif
  68. ASSABET_BCR_clear(ASSABET_BCR_LIGHT_ON);
  69. }
  70. /*
  71. * Turn on/off the backlight. When turning the backlight on,
  72. * we wait 500us after turning it on so we don't cause the
  73. * supplies to droop when we enable the LCD controller (and
  74. * cause a hard reset.)
  75. */
  76. static void assabet_lcd_power(int on)
  77. {
  78. #ifndef ASSABET_PAL_VIDEO
  79. if (on) {
  80. ASSABET_BCR_set(ASSABET_BCR_LCD_ON);
  81. udelay(500);
  82. } else
  83. #endif
  84. ASSABET_BCR_clear(ASSABET_BCR_LCD_ON);
  85. }
  86. /*
  87. * Assabet flash support code.
  88. */
  89. #ifdef ASSABET_REV_4
  90. /*
  91. * Phase 4 Assabet has two 28F160B3 flash parts in bank 0:
  92. */
  93. static struct mtd_partition assabet_partitions[] = {
  94. {
  95. .name = "bootloader",
  96. .size = 0x00020000,
  97. .offset = 0,
  98. .mask_flags = MTD_WRITEABLE,
  99. }, {
  100. .name = "bootloader params",
  101. .size = 0x00020000,
  102. .offset = MTDPART_OFS_APPEND,
  103. .mask_flags = MTD_WRITEABLE,
  104. }, {
  105. .name = "jffs",
  106. .size = MTDPART_SIZ_FULL,
  107. .offset = MTDPART_OFS_APPEND,
  108. }
  109. };
  110. #else
  111. /*
  112. * Phase 5 Assabet has two 28F128J3A flash parts in bank 0:
  113. */
  114. static struct mtd_partition assabet_partitions[] = {
  115. {
  116. .name = "bootloader",
  117. .size = 0x00040000,
  118. .offset = 0,
  119. .mask_flags = MTD_WRITEABLE,
  120. }, {
  121. .name = "bootloader params",
  122. .size = 0x00040000,
  123. .offset = MTDPART_OFS_APPEND,
  124. .mask_flags = MTD_WRITEABLE,
  125. }, {
  126. .name = "jffs",
  127. .size = MTDPART_SIZ_FULL,
  128. .offset = MTDPART_OFS_APPEND,
  129. }
  130. };
  131. #endif
  132. static struct flash_platform_data assabet_flash_data = {
  133. .map_name = "cfi_probe",
  134. .parts = assabet_partitions,
  135. .nr_parts = ARRAY_SIZE(assabet_partitions),
  136. };
  137. static struct resource assabet_flash_resources[] = {
  138. {
  139. .start = SA1100_CS0_PHYS,
  140. .end = SA1100_CS0_PHYS + SZ_32M - 1,
  141. .flags = IORESOURCE_MEM,
  142. }, {
  143. .start = SA1100_CS1_PHYS,
  144. .end = SA1100_CS1_PHYS + SZ_32M - 1,
  145. .flags = IORESOURCE_MEM,
  146. }
  147. };
  148. /*
  149. * Assabet IrDA support code.
  150. */
  151. static int assabet_irda_set_power(struct device *dev, unsigned int state)
  152. {
  153. static unsigned int bcr_state[4] = {
  154. ASSABET_BCR_IRDA_MD0,
  155. ASSABET_BCR_IRDA_MD1|ASSABET_BCR_IRDA_MD0,
  156. ASSABET_BCR_IRDA_MD1,
  157. 0
  158. };
  159. if (state < 4) {
  160. state = bcr_state[state];
  161. ASSABET_BCR_clear(state ^ (ASSABET_BCR_IRDA_MD1|
  162. ASSABET_BCR_IRDA_MD0));
  163. ASSABET_BCR_set(state);
  164. }
  165. return 0;
  166. }
  167. static void assabet_irda_set_speed(struct device *dev, unsigned int speed)
  168. {
  169. if (speed < 4000000)
  170. ASSABET_BCR_clear(ASSABET_BCR_IRDA_FSEL);
  171. else
  172. ASSABET_BCR_set(ASSABET_BCR_IRDA_FSEL);
  173. }
  174. static struct irda_platform_data assabet_irda_data = {
  175. .set_power = assabet_irda_set_power,
  176. .set_speed = assabet_irda_set_speed,
  177. };
  178. static struct mcp_plat_data assabet_mcp_data = {
  179. .mccr0 = MCCR0_ADM,
  180. .sclk_rate = 11981000,
  181. };
  182. static void __init assabet_init(void)
  183. {
  184. /*
  185. * Ensure that the power supply is in "high power" mode.
  186. */
  187. GPDR |= GPIO_GPIO16;
  188. GPSR = GPIO_GPIO16;
  189. /*
  190. * Ensure that these pins are set as outputs and are driving
  191. * logic 0. This ensures that we won't inadvertently toggle
  192. * the WS latch in the CPLD, and we don't float causing
  193. * excessive power drain. --rmk
  194. */
  195. GPDR |= GPIO_SSP_TXD | GPIO_SSP_SCLK | GPIO_SSP_SFRM;
  196. GPCR = GPIO_SSP_TXD | GPIO_SSP_SCLK | GPIO_SSP_SFRM;
  197. /*
  198. * Set up registers for sleep mode.
  199. */
  200. PWER = PWER_GPIO0;
  201. PGSR = 0;
  202. PCFR = 0;
  203. PSDR = 0;
  204. PPDR |= PPC_TXD3 | PPC_TXD1;
  205. PPSR |= PPC_TXD3 | PPC_TXD1;
  206. sa1100fb_lcd_power = assabet_lcd_power;
  207. sa1100fb_backlight_power = assabet_backlight_power;
  208. if (machine_has_neponset()) {
  209. /*
  210. * Angel sets this, but other bootloaders may not.
  211. *
  212. * This must precede any driver calls to BCR_set()
  213. * or BCR_clear().
  214. */
  215. ASSABET_BCR = BCR_value = ASSABET_BCR_DB1111;
  216. #ifndef CONFIG_ASSABET_NEPONSET
  217. printk( "Warning: Neponset detected but full support "
  218. "hasn't been configured in the kernel\n" );
  219. #endif
  220. }
  221. sa11x0_set_flash_data(&assabet_flash_data, assabet_flash_resources,
  222. ARRAY_SIZE(assabet_flash_resources));
  223. sa11x0_set_irda_data(&assabet_irda_data);
  224. sa11x0_set_mcp_data(&assabet_mcp_data);
  225. }
  226. /*
  227. * On Assabet, we must probe for the Neponset board _before_
  228. * paging_init() has occurred to actually determine the amount
  229. * of RAM available. To do so, we map the appropriate IO section
  230. * in the page table here in order to access GPIO registers.
  231. */
  232. static void __init map_sa1100_gpio_regs( void )
  233. {
  234. unsigned long phys = __PREG(GPLR) & PMD_MASK;
  235. unsigned long virt = io_p2v(phys);
  236. int prot = PMD_TYPE_SECT | PMD_SECT_AP_WRITE | PMD_DOMAIN(DOMAIN_IO);
  237. pmd_t *pmd;
  238. pmd = pmd_offset(pgd_offset_k(virt), virt);
  239. *pmd = __pmd(phys | prot);
  240. flush_pmd_entry(pmd);
  241. }
  242. /*
  243. * Read System Configuration "Register"
  244. * (taken from "Intel StrongARM SA-1110 Microprocessor Development Board
  245. * User's Guide", section 4.4.1)
  246. *
  247. * This same scan is performed in arch/arm/boot/compressed/head-sa1100.S
  248. * to set up the serial port for decompression status messages. We
  249. * repeat it here because the kernel may not be loaded as a zImage, and
  250. * also because it's a hassle to communicate the SCR value to the kernel
  251. * from the decompressor.
  252. *
  253. * Note that IRQs are guaranteed to be disabled.
  254. */
  255. static void __init get_assabet_scr(void)
  256. {
  257. unsigned long scr, i;
  258. GPDR |= 0x3fc; /* Configure GPIO 9:2 as outputs */
  259. GPSR = 0x3fc; /* Write 0xFF to GPIO 9:2 */
  260. GPDR &= ~(0x3fc); /* Configure GPIO 9:2 as inputs */
  261. for(i = 100; i--; scr = GPLR); /* Read GPIO 9:2 */
  262. GPDR |= 0x3fc; /* restore correct pin direction */
  263. scr &= 0x3fc; /* save as system configuration byte. */
  264. SCR_value = scr;
  265. }
  266. static void __init
  267. fixup_assabet(struct machine_desc *desc, struct tag *tags,
  268. char **cmdline, struct meminfo *mi)
  269. {
  270. /* This must be done before any call to machine_has_neponset() */
  271. map_sa1100_gpio_regs();
  272. get_assabet_scr();
  273. if (machine_has_neponset())
  274. printk("Neponset expansion board detected\n");
  275. }
  276. static void assabet_uart_pm(struct uart_port *port, u_int state, u_int oldstate)
  277. {
  278. if (port->mapbase == _Ser1UTCR0) {
  279. if (state)
  280. ASSABET_BCR_clear(ASSABET_BCR_RS232EN |
  281. ASSABET_BCR_COM_RTS |
  282. ASSABET_BCR_COM_DTR);
  283. else
  284. ASSABET_BCR_set(ASSABET_BCR_RS232EN |
  285. ASSABET_BCR_COM_RTS |
  286. ASSABET_BCR_COM_DTR);
  287. }
  288. }
  289. /*
  290. * Assabet uses COM_RTS and COM_DTR for both UART1 (com port)
  291. * and UART3 (radio module). We only handle them for UART1 here.
  292. */
  293. static void assabet_set_mctrl(struct uart_port *port, u_int mctrl)
  294. {
  295. if (port->mapbase == _Ser1UTCR0) {
  296. u_int set = 0, clear = 0;
  297. if (mctrl & TIOCM_RTS)
  298. clear |= ASSABET_BCR_COM_RTS;
  299. else
  300. set |= ASSABET_BCR_COM_RTS;
  301. if (mctrl & TIOCM_DTR)
  302. clear |= ASSABET_BCR_COM_DTR;
  303. else
  304. set |= ASSABET_BCR_COM_DTR;
  305. ASSABET_BCR_clear(clear);
  306. ASSABET_BCR_set(set);
  307. }
  308. }
  309. static u_int assabet_get_mctrl(struct uart_port *port)
  310. {
  311. u_int ret = 0;
  312. u_int bsr = ASSABET_BSR;
  313. /* need 2 reads to read current value */
  314. bsr = ASSABET_BSR;
  315. if (port->mapbase == _Ser1UTCR0) {
  316. if (bsr & ASSABET_BSR_COM_DCD)
  317. ret |= TIOCM_CD;
  318. if (bsr & ASSABET_BSR_COM_CTS)
  319. ret |= TIOCM_CTS;
  320. if (bsr & ASSABET_BSR_COM_DSR)
  321. ret |= TIOCM_DSR;
  322. } else if (port->mapbase == _Ser3UTCR0) {
  323. if (bsr & ASSABET_BSR_RAD_DCD)
  324. ret |= TIOCM_CD;
  325. if (bsr & ASSABET_BSR_RAD_CTS)
  326. ret |= TIOCM_CTS;
  327. if (bsr & ASSABET_BSR_RAD_DSR)
  328. ret |= TIOCM_DSR;
  329. if (bsr & ASSABET_BSR_RAD_RI)
  330. ret |= TIOCM_RI;
  331. } else {
  332. ret = TIOCM_CD | TIOCM_CTS | TIOCM_DSR;
  333. }
  334. return ret;
  335. }
  336. static struct sa1100_port_fns assabet_port_fns __initdata = {
  337. .set_mctrl = assabet_set_mctrl,
  338. .get_mctrl = assabet_get_mctrl,
  339. .pm = assabet_uart_pm,
  340. };
  341. static struct map_desc assabet_io_desc[] __initdata = {
  342. /* virtual physical length type */
  343. { 0xf1000000, 0x12000000, 0x00100000, MT_DEVICE }, /* Board Control Register */
  344. { 0xf2800000, 0x4b800000, 0x00800000, MT_DEVICE } /* MQ200 */
  345. };
  346. static void __init assabet_map_io(void)
  347. {
  348. sa1100_map_io();
  349. iotable_init(assabet_io_desc, ARRAY_SIZE(assabet_io_desc));
  350. /*
  351. * Set SUS bit in SDCR0 so serial port 1 functions.
  352. * Its called GPCLKR0 in my SA1110 manual.
  353. */
  354. Ser1SDCR0 |= SDCR0_SUS;
  355. if (machine_has_neponset()) {
  356. #ifdef CONFIG_ASSABET_NEPONSET
  357. extern void neponset_map_io(void);
  358. /*
  359. * We map Neponset registers even if it isn't present since
  360. * many drivers will try to probe their stuff (and fail).
  361. * This is still more friendly than a kernel paging request
  362. * crash.
  363. */
  364. neponset_map_io();
  365. #endif
  366. } else {
  367. sa1100_register_uart_fns(&assabet_port_fns);
  368. }
  369. /*
  370. * When Neponset is attached, the first UART should be
  371. * UART3. That's what Angel is doing and many documents
  372. * are stating this.
  373. *
  374. * We do the Neponset mapping even if Neponset support
  375. * isn't compiled in so the user will still get something on
  376. * the expected physical serial port.
  377. *
  378. * We no longer do this; not all boot loaders support it,
  379. * and UART3 appears to be somewhat unreliable with blob.
  380. */
  381. sa1100_register_uart(0, 1);
  382. sa1100_register_uart(2, 3);
  383. }
  384. MACHINE_START(ASSABET, "Intel-Assabet")
  385. .phys_ram = 0xc0000000,
  386. .phys_io = 0x80000000,
  387. .io_pg_offst = ((0xf8000000) >> 18) & 0xfffc,
  388. .boot_params = 0xc0000100,
  389. .fixup = fixup_assabet,
  390. .map_io = assabet_map_io,
  391. .init_irq = sa1100_init_irq,
  392. .timer = &sa1100_timer,
  393. .init_machine = assabet_init,
  394. MACHINE_END