assabet.c 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778
  1. // SPDX-License-Identifier: GPL-2.0-only
  2. /*
  3. * linux/arch/arm/mach-sa1100/assabet.c
  4. *
  5. * Author: Nicolas Pitre
  6. *
  7. * This file contains all Assabet-specific tweaks.
  8. */
  9. #include <linux/init.h>
  10. #include <linux/kernel.h>
  11. #include <linux/module.h>
  12. #include <linux/errno.h>
  13. #include <linux/gpio/gpio-reg.h>
  14. #include <linux/gpio/machine.h>
  15. #include <linux/gpio_keys.h>
  16. #include <linux/ioport.h>
  17. #include <linux/platform_data/sa11x0-serial.h>
  18. #include <linux/regulator/fixed.h>
  19. #include <linux/regulator/machine.h>
  20. #include <linux/serial_core.h>
  21. #include <linux/platform_device.h>
  22. #include <linux/mfd/ucb1x00.h>
  23. #include <linux/mtd/mtd.h>
  24. #include <linux/mtd/partitions.h>
  25. #include <linux/delay.h>
  26. #include <linux/mm.h>
  27. #include <linux/leds.h>
  28. #include <linux/slab.h>
  29. #include <video/sa1100fb.h>
  30. #include <mach/hardware.h>
  31. #include <asm/mach-types.h>
  32. #include <asm/setup.h>
  33. #include <asm/page.h>
  34. #include <asm/pgtable-hwdef.h>
  35. #include <asm/tlbflush.h>
  36. #include <asm/mach/arch.h>
  37. #include <asm/mach/flash.h>
  38. #include <linux/platform_data/irda-sa11x0.h>
  39. #include <asm/mach/map.h>
  40. #include <mach/assabet.h>
  41. #include <linux/platform_data/mfd-mcp-sa11x0.h>
  42. #include <mach/irqs.h>
  43. #include "generic.h"
  44. #define ASSABET_BCR_DB1110 \
  45. (ASSABET_BCR_SPK_OFF | \
  46. ASSABET_BCR_LED_GREEN | ASSABET_BCR_LED_RED | \
  47. ASSABET_BCR_RS232EN | ASSABET_BCR_LCD_12RGB | \
  48. ASSABET_BCR_IRDA_MD0)
  49. #define ASSABET_BCR_DB1111 \
  50. (ASSABET_BCR_SPK_OFF | \
  51. ASSABET_BCR_LED_GREEN | ASSABET_BCR_LED_RED | \
  52. ASSABET_BCR_RS232EN | ASSABET_BCR_LCD_12RGB | \
  53. ASSABET_BCR_CF_BUS_OFF | ASSABET_BCR_STEREO_LB | \
  54. ASSABET_BCR_IRDA_MD0 | ASSABET_BCR_CF_RST)
  55. unsigned long SCR_value = ASSABET_SCR_INIT;
  56. EXPORT_SYMBOL(SCR_value);
  57. static struct gpio_chip *assabet_bcr_gc;
  58. static const char *assabet_names[] = {
  59. "cf_pwr", "cf_gfx_reset", "nsoft_reset", "irda_fsel",
  60. "irda_md0", "irda_md1", "stereo_loopback", "ncf_bus_on",
  61. "audio_pwr_on", "light_pwr_on", "lcd16data", "lcd_pwr_on",
  62. "rs232_on", "nred_led", "ngreen_led", "vib_on",
  63. "com_dtr", "com_rts", "radio_wake_mod", "i2c_enab",
  64. "tvir_enab", "qmute", "radio_pwr_on", "spkr_off",
  65. "rs232_valid", "com_dcd", "com_cts", "com_dsr",
  66. "radio_cts", "radio_dsr", "radio_dcd", "radio_ri",
  67. };
  68. /* The old deprecated interface */
  69. void ASSABET_BCR_frob(unsigned int mask, unsigned int val)
  70. {
  71. unsigned long m = mask, v = val;
  72. assabet_bcr_gc->set_multiple(assabet_bcr_gc, &m, &v);
  73. }
  74. EXPORT_SYMBOL(ASSABET_BCR_frob);
  75. static void __init assabet_init_gpio(void __iomem *reg, u32 def_val)
  76. {
  77. struct gpio_chip *gc;
  78. writel_relaxed(def_val, reg);
  79. gc = gpio_reg_init(NULL, reg, -1, 32, "assabet", 0xff000000, def_val,
  80. assabet_names, NULL, NULL);
  81. if (IS_ERR(gc))
  82. return;
  83. assabet_bcr_gc = gc;
  84. }
  85. /*
  86. * The codec reset goes to three devices, so we need to release
  87. * the rest when any one of these requests it. However, that
  88. * causes the ADV7171 to consume around 100mA - more than half
  89. * the LCD-blanked power.
  90. *
  91. * With the ADV7171, LCD and backlight enabled, we go over
  92. * budget on the MAX846 Li-Ion charger, and if no Li-Ion battery
  93. * is connected, the Assabet crashes.
  94. */
  95. #define RST_UCB1X00 (1 << 0)
  96. #define RST_UDA1341 (1 << 1)
  97. #define RST_ADV7171 (1 << 2)
  98. #define SDA GPIO_GPIO(15)
  99. #define SCK GPIO_GPIO(18)
  100. #define MOD GPIO_GPIO(17)
  101. static void adv7171_start(void)
  102. {
  103. GPSR = SCK;
  104. udelay(1);
  105. GPSR = SDA;
  106. udelay(2);
  107. GPCR = SDA;
  108. }
  109. static void adv7171_stop(void)
  110. {
  111. GPSR = SCK;
  112. udelay(2);
  113. GPSR = SDA;
  114. udelay(1);
  115. }
  116. static void adv7171_send(unsigned byte)
  117. {
  118. unsigned i;
  119. for (i = 0; i < 8; i++, byte <<= 1) {
  120. GPCR = SCK;
  121. udelay(1);
  122. if (byte & 0x80)
  123. GPSR = SDA;
  124. else
  125. GPCR = SDA;
  126. udelay(1);
  127. GPSR = SCK;
  128. udelay(1);
  129. }
  130. GPCR = SCK;
  131. udelay(1);
  132. GPSR = SDA;
  133. udelay(1);
  134. GPDR &= ~SDA;
  135. GPSR = SCK;
  136. udelay(1);
  137. if (GPLR & SDA)
  138. printk(KERN_WARNING "No ACK from ADV7171\n");
  139. udelay(1);
  140. GPCR = SCK | SDA;
  141. udelay(1);
  142. GPDR |= SDA;
  143. udelay(1);
  144. }
  145. static void adv7171_write(unsigned reg, unsigned val)
  146. {
  147. unsigned gpdr = GPDR;
  148. unsigned gplr = GPLR;
  149. ASSABET_BCR_frob(ASSABET_BCR_AUDIO_ON, ASSABET_BCR_AUDIO_ON);
  150. udelay(100);
  151. GPCR = SDA | SCK | MOD; /* clear L3 mode to ensure UDA1341 doesn't respond */
  152. GPDR = (GPDR | SCK | MOD) & ~SDA;
  153. udelay(10);
  154. if (!(GPLR & SDA))
  155. printk(KERN_WARNING "Something dragging SDA down?\n");
  156. GPDR |= SDA;
  157. adv7171_start();
  158. adv7171_send(0x54);
  159. adv7171_send(reg);
  160. adv7171_send(val);
  161. adv7171_stop();
  162. /* Restore GPIO state for L3 bus */
  163. GPSR = gplr & (SDA | SCK | MOD);
  164. GPCR = (~gplr) & (SDA | SCK | MOD);
  165. GPDR = gpdr;
  166. }
  167. static void adv7171_sleep(void)
  168. {
  169. /* Put the ADV7171 into sleep mode */
  170. adv7171_write(0x04, 0x40);
  171. }
  172. static unsigned codec_nreset;
  173. static void assabet_codec_reset(unsigned mask, int set)
  174. {
  175. unsigned long flags;
  176. bool old;
  177. local_irq_save(flags);
  178. old = !codec_nreset;
  179. if (set)
  180. codec_nreset &= ~mask;
  181. else
  182. codec_nreset |= mask;
  183. if (old != !codec_nreset) {
  184. if (codec_nreset) {
  185. ASSABET_BCR_set(ASSABET_BCR_NCODEC_RST);
  186. adv7171_sleep();
  187. } else {
  188. ASSABET_BCR_clear(ASSABET_BCR_NCODEC_RST);
  189. }
  190. }
  191. local_irq_restore(flags);
  192. }
  193. static void assabet_ucb1x00_reset(enum ucb1x00_reset state)
  194. {
  195. int set = state == UCB_RST_REMOVE || state == UCB_RST_SUSPEND ||
  196. state == UCB_RST_PROBE_FAIL;
  197. assabet_codec_reset(RST_UCB1X00, set);
  198. }
  199. void assabet_uda1341_reset(int set)
  200. {
  201. assabet_codec_reset(RST_UDA1341, set);
  202. }
  203. EXPORT_SYMBOL(assabet_uda1341_reset);
  204. /*
  205. * Assabet flash support code.
  206. */
  207. #ifdef ASSABET_REV_4
  208. /*
  209. * Phase 4 Assabet has two 28F160B3 flash parts in bank 0:
  210. */
  211. static struct mtd_partition assabet_partitions[] = {
  212. {
  213. .name = "bootloader",
  214. .size = 0x00020000,
  215. .offset = 0,
  216. .mask_flags = MTD_WRITEABLE,
  217. }, {
  218. .name = "bootloader params",
  219. .size = 0x00020000,
  220. .offset = MTDPART_OFS_APPEND,
  221. .mask_flags = MTD_WRITEABLE,
  222. }, {
  223. .name = "jffs",
  224. .size = MTDPART_SIZ_FULL,
  225. .offset = MTDPART_OFS_APPEND,
  226. }
  227. };
  228. #else
  229. /*
  230. * Phase 5 Assabet has two 28F128J3A flash parts in bank 0:
  231. */
  232. static struct mtd_partition assabet_partitions[] = {
  233. {
  234. .name = "bootloader",
  235. .size = 0x00040000,
  236. .offset = 0,
  237. .mask_flags = MTD_WRITEABLE,
  238. }, {
  239. .name = "bootloader params",
  240. .size = 0x00040000,
  241. .offset = MTDPART_OFS_APPEND,
  242. .mask_flags = MTD_WRITEABLE,
  243. }, {
  244. .name = "jffs",
  245. .size = MTDPART_SIZ_FULL,
  246. .offset = MTDPART_OFS_APPEND,
  247. }
  248. };
  249. #endif
  250. static struct flash_platform_data assabet_flash_data = {
  251. .map_name = "cfi_probe",
  252. .parts = assabet_partitions,
  253. .nr_parts = ARRAY_SIZE(assabet_partitions),
  254. };
  255. static struct resource assabet_flash_resources[] = {
  256. DEFINE_RES_MEM(SA1100_CS0_PHYS, SZ_32M),
  257. DEFINE_RES_MEM(SA1100_CS1_PHYS, SZ_32M),
  258. };
  259. /*
  260. * Assabet IrDA support code.
  261. */
  262. static int assabet_irda_set_power(struct device *dev, unsigned int state)
  263. {
  264. static unsigned int bcr_state[4] = {
  265. ASSABET_BCR_IRDA_MD0,
  266. ASSABET_BCR_IRDA_MD1|ASSABET_BCR_IRDA_MD0,
  267. ASSABET_BCR_IRDA_MD1,
  268. 0
  269. };
  270. if (state < 4)
  271. ASSABET_BCR_frob(ASSABET_BCR_IRDA_MD1 | ASSABET_BCR_IRDA_MD0,
  272. bcr_state[state]);
  273. return 0;
  274. }
  275. static void assabet_irda_set_speed(struct device *dev, unsigned int speed)
  276. {
  277. if (speed < 4000000)
  278. ASSABET_BCR_clear(ASSABET_BCR_IRDA_FSEL);
  279. else
  280. ASSABET_BCR_set(ASSABET_BCR_IRDA_FSEL);
  281. }
  282. static struct irda_platform_data assabet_irda_data = {
  283. .set_power = assabet_irda_set_power,
  284. .set_speed = assabet_irda_set_speed,
  285. };
  286. static struct ucb1x00_plat_data assabet_ucb1x00_data = {
  287. .reset = assabet_ucb1x00_reset,
  288. .gpio_base = -1,
  289. .can_wakeup = 1,
  290. };
  291. static struct mcp_plat_data assabet_mcp_data = {
  292. .mccr0 = MCCR0_ADM,
  293. .sclk_rate = 11981000,
  294. .codec_pdata = &assabet_ucb1x00_data,
  295. };
  296. static void assabet_lcd_set_visual(u32 visual)
  297. {
  298. u_int is_true_color = visual == FB_VISUAL_TRUECOLOR;
  299. if (machine_is_assabet()) {
  300. #if 1 // phase 4 or newer Assabet's
  301. if (is_true_color)
  302. ASSABET_BCR_set(ASSABET_BCR_LCD_12RGB);
  303. else
  304. ASSABET_BCR_clear(ASSABET_BCR_LCD_12RGB);
  305. #else
  306. // older Assabet's
  307. if (is_true_color)
  308. ASSABET_BCR_clear(ASSABET_BCR_LCD_12RGB);
  309. else
  310. ASSABET_BCR_set(ASSABET_BCR_LCD_12RGB);
  311. #endif
  312. }
  313. }
  314. #ifndef ASSABET_PAL_VIDEO
  315. static void assabet_lcd_backlight_power(int on)
  316. {
  317. if (on)
  318. ASSABET_BCR_set(ASSABET_BCR_LIGHT_ON);
  319. else
  320. ASSABET_BCR_clear(ASSABET_BCR_LIGHT_ON);
  321. }
  322. /*
  323. * Turn on/off the backlight. When turning the backlight on, we wait
  324. * 500us after turning it on so we don't cause the supplies to droop
  325. * when we enable the LCD controller (and cause a hard reset.)
  326. */
  327. static void assabet_lcd_power(int on)
  328. {
  329. if (on) {
  330. ASSABET_BCR_set(ASSABET_BCR_LCD_ON);
  331. udelay(500);
  332. } else
  333. ASSABET_BCR_clear(ASSABET_BCR_LCD_ON);
  334. }
  335. /*
  336. * The assabet uses a sharp LQ039Q2DS54 LCD module. It is actually
  337. * takes an RGB666 signal, but we provide it with an RGB565 signal
  338. * instead (def_rgb_16).
  339. */
  340. static struct sa1100fb_mach_info lq039q2ds54_info = {
  341. .pixclock = 171521, .bpp = 16,
  342. .xres = 320, .yres = 240,
  343. .hsync_len = 5, .vsync_len = 1,
  344. .left_margin = 61, .upper_margin = 3,
  345. .right_margin = 9, .lower_margin = 0,
  346. .sync = FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
  347. .lccr0 = LCCR0_Color | LCCR0_Sngl | LCCR0_Act,
  348. .lccr3 = LCCR3_OutEnH | LCCR3_PixRsEdg | LCCR3_ACBsDiv(2),
  349. .backlight_power = assabet_lcd_backlight_power,
  350. .lcd_power = assabet_lcd_power,
  351. .set_visual = assabet_lcd_set_visual,
  352. };
  353. #else
  354. static void assabet_pal_backlight_power(int on)
  355. {
  356. ASSABET_BCR_clear(ASSABET_BCR_LIGHT_ON);
  357. }
  358. static void assabet_pal_power(int on)
  359. {
  360. ASSABET_BCR_clear(ASSABET_BCR_LCD_ON);
  361. }
  362. static struct sa1100fb_mach_info pal_info = {
  363. .pixclock = 67797, .bpp = 16,
  364. .xres = 640, .yres = 512,
  365. .hsync_len = 64, .vsync_len = 6,
  366. .left_margin = 125, .upper_margin = 70,
  367. .right_margin = 115, .lower_margin = 36,
  368. .lccr0 = LCCR0_Color | LCCR0_Sngl | LCCR0_Act,
  369. .lccr3 = LCCR3_OutEnH | LCCR3_PixRsEdg | LCCR3_ACBsDiv(512),
  370. .backlight_power = assabet_pal_backlight_power,
  371. .lcd_power = assabet_pal_power,
  372. .set_visual = assabet_lcd_set_visual,
  373. };
  374. #endif
  375. #ifdef CONFIG_ASSABET_NEPONSET
  376. static struct resource neponset_resources[] = {
  377. DEFINE_RES_MEM(0x10000000, 0x08000000),
  378. DEFINE_RES_MEM(0x18000000, 0x04000000),
  379. DEFINE_RES_MEM(0x40000000, SZ_8K),
  380. DEFINE_RES_IRQ(IRQ_GPIO25),
  381. };
  382. #endif
  383. static struct gpiod_lookup_table assabet_cf_gpio_table = {
  384. .dev_id = "sa11x0-pcmcia.1",
  385. .table = {
  386. GPIO_LOOKUP("gpio", 21, "ready", GPIO_ACTIVE_HIGH),
  387. GPIO_LOOKUP("gpio", 22, "detect", GPIO_ACTIVE_LOW),
  388. GPIO_LOOKUP("gpio", 24, "bvd2", GPIO_ACTIVE_HIGH),
  389. GPIO_LOOKUP("gpio", 25, "bvd1", GPIO_ACTIVE_HIGH),
  390. GPIO_LOOKUP("assabet", 1, "reset", GPIO_ACTIVE_HIGH),
  391. GPIO_LOOKUP("assabet", 7, "bus-enable", GPIO_ACTIVE_LOW),
  392. { },
  393. },
  394. };
  395. static struct regulator_consumer_supply assabet_cf_vcc_consumers[] = {
  396. REGULATOR_SUPPLY("vcc", "sa11x0-pcmcia.1"),
  397. };
  398. static struct fixed_voltage_config assabet_cf_vcc_pdata __initdata = {
  399. .supply_name = "cf-power",
  400. .microvolts = 3300000,
  401. };
  402. static struct gpiod_lookup_table assabet_cf_vcc_gpio_table = {
  403. .dev_id = "reg-fixed-voltage.0",
  404. .table = {
  405. GPIO_LOOKUP("assabet", 0, NULL, GPIO_ACTIVE_HIGH),
  406. { },
  407. },
  408. };
  409. static struct gpiod_lookup_table assabet_leds_gpio_table = {
  410. .dev_id = "leds-gpio",
  411. .table = {
  412. GPIO_LOOKUP("assabet", 13, NULL, GPIO_ACTIVE_LOW),
  413. GPIO_LOOKUP("assabet", 14, NULL, GPIO_ACTIVE_LOW),
  414. { },
  415. },
  416. };
  417. static struct gpio_led assabet_leds[] __initdata = {
  418. {
  419. .name = "assabet:red",
  420. .default_trigger = "cpu0",
  421. .default_state = LEDS_GPIO_DEFSTATE_KEEP,
  422. }, {
  423. .name = "assabet:green",
  424. .default_trigger = "heartbeat",
  425. .default_state = LEDS_GPIO_DEFSTATE_KEEP,
  426. },
  427. };
  428. static const struct gpio_led_platform_data assabet_leds_pdata __initconst = {
  429. .num_leds = ARRAY_SIZE(assabet_leds),
  430. .leds = assabet_leds,
  431. };
  432. static struct gpio_keys_button assabet_keys_buttons[] = {
  433. {
  434. .gpio = 0,
  435. .irq = IRQ_GPIO0,
  436. .desc = "gpio0",
  437. .wakeup = 1,
  438. .can_disable = 1,
  439. .debounce_interval = 5,
  440. }, {
  441. .gpio = 1,
  442. .irq = IRQ_GPIO1,
  443. .desc = "gpio1",
  444. .wakeup = 1,
  445. .can_disable = 1,
  446. .debounce_interval = 5,
  447. },
  448. };
  449. static const struct gpio_keys_platform_data assabet_keys_pdata = {
  450. .buttons = assabet_keys_buttons,
  451. .nbuttons = ARRAY_SIZE(assabet_keys_buttons),
  452. .rep = 0,
  453. };
  454. static struct gpiod_lookup_table assabet_uart1_gpio_table = {
  455. .dev_id = "sa11x0-uart.1",
  456. .table = {
  457. GPIO_LOOKUP("assabet", 16, "dtr", GPIO_ACTIVE_LOW),
  458. GPIO_LOOKUP("assabet", 17, "rts", GPIO_ACTIVE_LOW),
  459. GPIO_LOOKUP("assabet", 25, "dcd", GPIO_ACTIVE_LOW),
  460. GPIO_LOOKUP("assabet", 26, "cts", GPIO_ACTIVE_LOW),
  461. GPIO_LOOKUP("assabet", 27, "dsr", GPIO_ACTIVE_LOW),
  462. { },
  463. },
  464. };
  465. static struct gpiod_lookup_table assabet_uart3_gpio_table = {
  466. .dev_id = "sa11x0-uart.3",
  467. .table = {
  468. GPIO_LOOKUP("assabet", 28, "cts", GPIO_ACTIVE_LOW),
  469. GPIO_LOOKUP("assabet", 29, "dsr", GPIO_ACTIVE_LOW),
  470. GPIO_LOOKUP("assabet", 30, "dcd", GPIO_ACTIVE_LOW),
  471. GPIO_LOOKUP("assabet", 31, "rng", GPIO_ACTIVE_LOW),
  472. { },
  473. },
  474. };
  475. static void __init assabet_init(void)
  476. {
  477. /*
  478. * Ensure that the power supply is in "high power" mode.
  479. */
  480. GPSR = GPIO_GPIO16;
  481. GPDR |= GPIO_GPIO16;
  482. /*
  483. * Ensure that these pins are set as outputs and are driving
  484. * logic 0. This ensures that we won't inadvertently toggle
  485. * the WS latch in the CPLD, and we don't float causing
  486. * excessive power drain. --rmk
  487. */
  488. GPCR = GPIO_SSP_TXD | GPIO_SSP_SCLK | GPIO_SSP_SFRM;
  489. GPDR |= GPIO_SSP_TXD | GPIO_SSP_SCLK | GPIO_SSP_SFRM;
  490. /*
  491. * Also set GPIO27 as an output; this is used to clock UART3
  492. * via the FPGA and as otherwise has no pullups or pulldowns,
  493. * so stop it floating.
  494. */
  495. GPCR = GPIO_GPIO27;
  496. GPDR |= GPIO_GPIO27;
  497. /*
  498. * Set up registers for sleep mode.
  499. */
  500. PWER = PWER_GPIO0;
  501. PGSR = 0;
  502. PCFR = 0;
  503. PSDR = 0;
  504. PPDR |= PPC_TXD3 | PPC_TXD1;
  505. PPSR |= PPC_TXD3 | PPC_TXD1;
  506. sa11x0_ppc_configure_mcp();
  507. if (machine_has_neponset()) {
  508. #ifndef CONFIG_ASSABET_NEPONSET
  509. printk( "Warning: Neponset detected but full support "
  510. "hasn't been configured in the kernel\n" );
  511. #else
  512. platform_device_register_simple("neponset", 0,
  513. neponset_resources, ARRAY_SIZE(neponset_resources));
  514. #endif
  515. } else {
  516. gpiod_add_lookup_table(&assabet_uart1_gpio_table);
  517. gpiod_add_lookup_table(&assabet_uart3_gpio_table);
  518. gpiod_add_lookup_table(&assabet_cf_vcc_gpio_table);
  519. sa11x0_register_fixed_regulator(0, &assabet_cf_vcc_pdata,
  520. assabet_cf_vcc_consumers,
  521. ARRAY_SIZE(assabet_cf_vcc_consumers),
  522. true);
  523. }
  524. platform_device_register_resndata(NULL, "gpio-keys", 0,
  525. NULL, 0,
  526. &assabet_keys_pdata,
  527. sizeof(assabet_keys_pdata));
  528. gpiod_add_lookup_table(&assabet_leds_gpio_table);
  529. gpio_led_register_device(-1, &assabet_leds_pdata);
  530. #ifndef ASSABET_PAL_VIDEO
  531. sa11x0_register_lcd(&lq039q2ds54_info);
  532. #else
  533. sa11x0_register_lcd(&pal_video);
  534. #endif
  535. sa11x0_register_mtd(&assabet_flash_data, assabet_flash_resources,
  536. ARRAY_SIZE(assabet_flash_resources));
  537. sa11x0_register_irda(&assabet_irda_data);
  538. sa11x0_register_mcp(&assabet_mcp_data);
  539. if (!machine_has_neponset())
  540. sa11x0_register_pcmcia(1, &assabet_cf_gpio_table);
  541. }
  542. /*
  543. * On Assabet, we must probe for the Neponset board _before_
  544. * paging_init() has occurred to actually determine the amount
  545. * of RAM available. To do so, we map the appropriate IO section
  546. * in the page table here in order to access GPIO registers.
  547. */
  548. static void __init map_sa1100_gpio_regs( void )
  549. {
  550. unsigned long phys = __PREG(GPLR) & PMD_MASK;
  551. unsigned long virt = (unsigned long)io_p2v(phys);
  552. int prot = PMD_TYPE_SECT | PMD_SECT_AP_WRITE | PMD_DOMAIN(DOMAIN_IO);
  553. pmd_t *pmd;
  554. pmd = pmd_off_k(virt);
  555. *pmd = __pmd(phys | prot);
  556. flush_pmd_entry(pmd);
  557. }
  558. /*
  559. * Read System Configuration "Register"
  560. * (taken from "Intel StrongARM SA-1110 Microprocessor Development Board
  561. * User's Guide", section 4.4.1)
  562. *
  563. * This same scan is performed in arch/arm/boot/compressed/head-sa1100.S
  564. * to set up the serial port for decompression status messages. We
  565. * repeat it here because the kernel may not be loaded as a zImage, and
  566. * also because it's a hassle to communicate the SCR value to the kernel
  567. * from the decompressor.
  568. *
  569. * Note that IRQs are guaranteed to be disabled.
  570. */
  571. static void __init get_assabet_scr(void)
  572. {
  573. unsigned long scr, i;
  574. GPDR |= 0x3fc; /* Configure GPIO 9:2 as outputs */
  575. GPSR = 0x3fc; /* Write 0xFF to GPIO 9:2 */
  576. GPDR &= ~(0x3fc); /* Configure GPIO 9:2 as inputs */
  577. for(i = 100; i--; ) /* Read GPIO 9:2 */
  578. scr = GPLR;
  579. GPDR |= 0x3fc; /* restore correct pin direction */
  580. scr &= 0x3fc; /* save as system configuration byte. */
  581. SCR_value = scr;
  582. }
  583. static void __init
  584. fixup_assabet(struct tag *tags, char **cmdline)
  585. {
  586. /* This must be done before any call to machine_has_neponset() */
  587. map_sa1100_gpio_regs();
  588. get_assabet_scr();
  589. if (machine_has_neponset())
  590. printk("Neponset expansion board detected\n");
  591. }
  592. static void assabet_uart_pm(struct uart_port *port, u_int state, u_int oldstate)
  593. {
  594. if (port->mapbase == _Ser1UTCR0) {
  595. if (state)
  596. ASSABET_BCR_clear(ASSABET_BCR_RS232EN);
  597. else
  598. ASSABET_BCR_set(ASSABET_BCR_RS232EN);
  599. }
  600. }
  601. static struct sa1100_port_fns assabet_port_fns __initdata = {
  602. .pm = assabet_uart_pm,
  603. };
  604. static struct map_desc assabet_io_desc[] __initdata = {
  605. { /* Board Control Register */
  606. .virtual = 0xf1000000,
  607. .pfn = __phys_to_pfn(0x12000000),
  608. .length = 0x00100000,
  609. .type = MT_DEVICE
  610. }, { /* MQ200 */
  611. .virtual = 0xf2800000,
  612. .pfn = __phys_to_pfn(0x4b800000),
  613. .length = 0x00800000,
  614. .type = MT_DEVICE
  615. }
  616. };
  617. static void __init assabet_map_io(void)
  618. {
  619. sa1100_map_io();
  620. iotable_init(assabet_io_desc, ARRAY_SIZE(assabet_io_desc));
  621. /*
  622. * Set SUS bit in SDCR0 so serial port 1 functions.
  623. * Its called GPCLKR0 in my SA1110 manual.
  624. */
  625. Ser1SDCR0 |= SDCR0_SUS;
  626. MSC1 = (MSC1 & ~0xffff) |
  627. MSC_NonBrst | MSC_32BitStMem |
  628. MSC_RdAcc(2) | MSC_WrAcc(2) | MSC_Rec(0);
  629. if (!machine_has_neponset())
  630. sa1100_register_uart_fns(&assabet_port_fns);
  631. /*
  632. * When Neponset is attached, the first UART should be
  633. * UART3. That's what Angel is doing and many documents
  634. * are stating this.
  635. *
  636. * We do the Neponset mapping even if Neponset support
  637. * isn't compiled in so the user will still get something on
  638. * the expected physical serial port.
  639. *
  640. * We no longer do this; not all boot loaders support it,
  641. * and UART3 appears to be somewhat unreliable with blob.
  642. */
  643. sa1100_register_uart(0, 1);
  644. sa1100_register_uart(2, 3);
  645. }
  646. void __init assabet_init_irq(void)
  647. {
  648. u32 def_val;
  649. sa1100_init_irq();
  650. if (machine_has_neponset())
  651. def_val = ASSABET_BCR_DB1111;
  652. else
  653. def_val = ASSABET_BCR_DB1110;
  654. /*
  655. * Angel sets this, but other bootloaders may not.
  656. *
  657. * This must precede any driver calls to BCR_set() or BCR_clear().
  658. */
  659. assabet_init_gpio((void *)&ASSABET_BCR, def_val);
  660. }
  661. MACHINE_START(ASSABET, "Intel-Assabet")
  662. .atag_offset = 0x100,
  663. .fixup = fixup_assabet,
  664. .map_io = assabet_map_io,
  665. .nr_irqs = SA1100_NR_IRQS,
  666. .init_irq = assabet_init_irq,
  667. .init_time = sa1100_timer_init,
  668. .init_machine = assabet_init,
  669. .init_late = sa11x0_init_late,
  670. #ifdef CONFIG_SA1111
  671. .dma_zone_size = SZ_1M,
  672. #endif
  673. .restart = sa11x0_restart,
  674. MACHINE_END