assabet.c 11 KB

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