db1300.c 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778
  1. /*
  2. * DBAu1300 init and platform device setup.
  3. *
  4. * (c) 2009 Manuel Lauss <manuel.lauss@googlemail.com>
  5. */
  6. #include <linux/dma-mapping.h>
  7. #include <linux/gpio.h>
  8. #include <linux/gpio_keys.h>
  9. #include <linux/init.h>
  10. #include <linux/input.h> /* KEY_* codes */
  11. #include <linux/i2c.h>
  12. #include <linux/io.h>
  13. #include <linux/leds.h>
  14. #include <linux/ata_platform.h>
  15. #include <linux/mmc/host.h>
  16. #include <linux/module.h>
  17. #include <linux/mtd/mtd.h>
  18. #include <linux/mtd/nand.h>
  19. #include <linux/mtd/partitions.h>
  20. #include <linux/platform_device.h>
  21. #include <linux/smsc911x.h>
  22. #include <asm/mach-au1x00/au1000.h>
  23. #include <asm/mach-au1x00/au1100_mmc.h>
  24. #include <asm/mach-au1x00/au1200fb.h>
  25. #include <asm/mach-au1x00/au1xxx_dbdma.h>
  26. #include <asm/mach-au1x00/au1xxx_psc.h>
  27. #include <asm/mach-db1x00/db1300.h>
  28. #include <asm/mach-db1x00/bcsr.h>
  29. #include <asm/mach-au1x00/prom.h>
  30. #include "platform.h"
  31. static struct i2c_board_info db1300_i2c_devs[] __initdata = {
  32. { I2C_BOARD_INFO("wm8731", 0x1b), }, /* I2S audio codec */
  33. { I2C_BOARD_INFO("ne1619", 0x2d), }, /* adm1025-compat hwmon */
  34. };
  35. /* multifunction pins to assign to GPIO controller */
  36. static int db1300_gpio_pins[] __initdata = {
  37. AU1300_PIN_LCDPWM0, AU1300_PIN_PSC2SYNC1, AU1300_PIN_WAKE1,
  38. AU1300_PIN_WAKE2, AU1300_PIN_WAKE3, AU1300_PIN_FG3AUX,
  39. AU1300_PIN_EXTCLK1,
  40. -1, /* terminator */
  41. };
  42. /* multifunction pins to assign to device functions */
  43. static int db1300_dev_pins[] __initdata = {
  44. /* wake-from-str pins 0-3 */
  45. AU1300_PIN_WAKE0,
  46. /* external clock sources for PSC0 */
  47. AU1300_PIN_EXTCLK0,
  48. /* 8bit MMC interface on SD0: 6-9 */
  49. AU1300_PIN_SD0DAT4, AU1300_PIN_SD0DAT5, AU1300_PIN_SD0DAT6,
  50. AU1300_PIN_SD0DAT7,
  51. /* UART1 pins: 11-18 */
  52. AU1300_PIN_U1RI, AU1300_PIN_U1DCD, AU1300_PIN_U1DSR,
  53. AU1300_PIN_U1CTS, AU1300_PIN_U1RTS, AU1300_PIN_U1DTR,
  54. AU1300_PIN_U1RX, AU1300_PIN_U1TX,
  55. /* UART0 pins: 19-24 */
  56. AU1300_PIN_U0RI, AU1300_PIN_U0DCD, AU1300_PIN_U0DSR,
  57. AU1300_PIN_U0CTS, AU1300_PIN_U0RTS, AU1300_PIN_U0DTR,
  58. /* UART2: 25-26 */
  59. AU1300_PIN_U2RX, AU1300_PIN_U2TX,
  60. /* UART3: 27-28 */
  61. AU1300_PIN_U3RX, AU1300_PIN_U3TX,
  62. /* LCD controller PWMs, ext pixclock: 30-31 */
  63. AU1300_PIN_LCDPWM1, AU1300_PIN_LCDCLKIN,
  64. /* SD1 interface: 32-37 */
  65. AU1300_PIN_SD1DAT0, AU1300_PIN_SD1DAT1, AU1300_PIN_SD1DAT2,
  66. AU1300_PIN_SD1DAT3, AU1300_PIN_SD1CMD, AU1300_PIN_SD1CLK,
  67. /* SD2 interface: 38-43 */
  68. AU1300_PIN_SD2DAT0, AU1300_PIN_SD2DAT1, AU1300_PIN_SD2DAT2,
  69. AU1300_PIN_SD2DAT3, AU1300_PIN_SD2CMD, AU1300_PIN_SD2CLK,
  70. /* PSC0/1 clocks: 44-45 */
  71. AU1300_PIN_PSC0CLK, AU1300_PIN_PSC1CLK,
  72. /* PSCs: 46-49/50-53/54-57/58-61 */
  73. AU1300_PIN_PSC0SYNC0, AU1300_PIN_PSC0SYNC1, AU1300_PIN_PSC0D0,
  74. AU1300_PIN_PSC0D1,
  75. AU1300_PIN_PSC1SYNC0, AU1300_PIN_PSC1SYNC1, AU1300_PIN_PSC1D0,
  76. AU1300_PIN_PSC1D1,
  77. AU1300_PIN_PSC2SYNC0, AU1300_PIN_PSC2D0,
  78. AU1300_PIN_PSC2D1,
  79. AU1300_PIN_PSC3SYNC0, AU1300_PIN_PSC3SYNC1, AU1300_PIN_PSC3D0,
  80. AU1300_PIN_PSC3D1,
  81. /* PCMCIA interface: 62-70 */
  82. AU1300_PIN_PCE2, AU1300_PIN_PCE1, AU1300_PIN_PIOS16,
  83. AU1300_PIN_PIOR, AU1300_PIN_PWE, AU1300_PIN_PWAIT,
  84. AU1300_PIN_PREG, AU1300_PIN_POE, AU1300_PIN_PIOW,
  85. /* camera interface H/V sync inputs: 71-72 */
  86. AU1300_PIN_CIMLS, AU1300_PIN_CIMFS,
  87. /* PSC2/3 clocks: 73-74 */
  88. AU1300_PIN_PSC2CLK, AU1300_PIN_PSC3CLK,
  89. -1, /* terminator */
  90. };
  91. static void __init db1300_gpio_config(void)
  92. {
  93. int *i;
  94. i = &db1300_dev_pins[0];
  95. while (*i != -1)
  96. au1300_pinfunc_to_dev(*i++);
  97. i = &db1300_gpio_pins[0];
  98. while (*i != -1)
  99. au1300_gpio_direction_input(*i++);/* implies pin_to_gpio */
  100. au1300_set_dbdma_gpio(1, AU1300_PIN_FG3AUX);
  101. }
  102. /**********************************************************************/
  103. static void au1300_nand_cmd_ctrl(struct mtd_info *mtd, int cmd,
  104. unsigned int ctrl)
  105. {
  106. struct nand_chip *this = mtd->priv;
  107. unsigned long ioaddr = (unsigned long)this->IO_ADDR_W;
  108. ioaddr &= 0xffffff00;
  109. if (ctrl & NAND_CLE) {
  110. ioaddr += MEM_STNAND_CMD;
  111. } else if (ctrl & NAND_ALE) {
  112. ioaddr += MEM_STNAND_ADDR;
  113. } else {
  114. /* assume we want to r/w real data by default */
  115. ioaddr += MEM_STNAND_DATA;
  116. }
  117. this->IO_ADDR_R = this->IO_ADDR_W = (void __iomem *)ioaddr;
  118. if (cmd != NAND_CMD_NONE) {
  119. __raw_writeb(cmd, this->IO_ADDR_W);
  120. wmb();
  121. }
  122. }
  123. static int au1300_nand_device_ready(struct mtd_info *mtd)
  124. {
  125. return __raw_readl((void __iomem *)MEM_STSTAT) & 1;
  126. }
  127. static struct mtd_partition db1300_nand_parts[] = {
  128. {
  129. .name = "NAND FS 0",
  130. .offset = 0,
  131. .size = 8 * 1024 * 1024,
  132. },
  133. {
  134. .name = "NAND FS 1",
  135. .offset = MTDPART_OFS_APPEND,
  136. .size = MTDPART_SIZ_FULL
  137. },
  138. };
  139. struct platform_nand_data db1300_nand_platdata = {
  140. .chip = {
  141. .nr_chips = 1,
  142. .chip_offset = 0,
  143. .nr_partitions = ARRAY_SIZE(db1300_nand_parts),
  144. .partitions = db1300_nand_parts,
  145. .chip_delay = 20,
  146. },
  147. .ctrl = {
  148. .dev_ready = au1300_nand_device_ready,
  149. .cmd_ctrl = au1300_nand_cmd_ctrl,
  150. },
  151. };
  152. static struct resource db1300_nand_res[] = {
  153. [0] = {
  154. .start = DB1300_NAND_PHYS_ADDR,
  155. .end = DB1300_NAND_PHYS_ADDR + 0xff,
  156. .flags = IORESOURCE_MEM,
  157. },
  158. };
  159. static struct platform_device db1300_nand_dev = {
  160. .name = "gen_nand",
  161. .num_resources = ARRAY_SIZE(db1300_nand_res),
  162. .resource = db1300_nand_res,
  163. .id = -1,
  164. .dev = {
  165. .platform_data = &db1300_nand_platdata,
  166. }
  167. };
  168. /**********************************************************************/
  169. static struct resource db1300_eth_res[] = {
  170. [0] = {
  171. .start = DB1300_ETH_PHYS_ADDR,
  172. .end = DB1300_ETH_PHYS_END,
  173. .flags = IORESOURCE_MEM,
  174. },
  175. [1] = {
  176. .start = DB1300_ETH_INT,
  177. .end = DB1300_ETH_INT,
  178. .flags = IORESOURCE_IRQ,
  179. },
  180. };
  181. static struct smsc911x_platform_config db1300_eth_config = {
  182. .phy_interface = PHY_INTERFACE_MODE_MII,
  183. .irq_polarity = SMSC911X_IRQ_POLARITY_ACTIVE_LOW,
  184. .irq_type = SMSC911X_IRQ_TYPE_PUSH_PULL,
  185. .flags = SMSC911X_USE_32BIT,
  186. };
  187. static struct platform_device db1300_eth_dev = {
  188. .name = "smsc911x",
  189. .id = -1,
  190. .num_resources = ARRAY_SIZE(db1300_eth_res),
  191. .resource = db1300_eth_res,
  192. .dev = {
  193. .platform_data = &db1300_eth_config,
  194. },
  195. };
  196. /**********************************************************************/
  197. static struct resource au1300_psc1_res[] = {
  198. [0] = {
  199. .start = AU1300_PSC1_PHYS_ADDR,
  200. .end = AU1300_PSC1_PHYS_ADDR + 0x0fff,
  201. .flags = IORESOURCE_MEM,
  202. },
  203. [1] = {
  204. .start = AU1300_PSC1_INT,
  205. .end = AU1300_PSC1_INT,
  206. .flags = IORESOURCE_IRQ,
  207. },
  208. [2] = {
  209. .start = AU1300_DSCR_CMD0_PSC1_TX,
  210. .end = AU1300_DSCR_CMD0_PSC1_TX,
  211. .flags = IORESOURCE_DMA,
  212. },
  213. [3] = {
  214. .start = AU1300_DSCR_CMD0_PSC1_RX,
  215. .end = AU1300_DSCR_CMD0_PSC1_RX,
  216. .flags = IORESOURCE_DMA,
  217. },
  218. };
  219. static struct platform_device db1300_ac97_dev = {
  220. .name = "au1xpsc_ac97",
  221. .id = 1, /* PSC ID. match with AC97 codec ID! */
  222. .num_resources = ARRAY_SIZE(au1300_psc1_res),
  223. .resource = au1300_psc1_res,
  224. };
  225. /**********************************************************************/
  226. static struct resource au1300_psc2_res[] = {
  227. [0] = {
  228. .start = AU1300_PSC2_PHYS_ADDR,
  229. .end = AU1300_PSC2_PHYS_ADDR + 0x0fff,
  230. .flags = IORESOURCE_MEM,
  231. },
  232. [1] = {
  233. .start = AU1300_PSC2_INT,
  234. .end = AU1300_PSC2_INT,
  235. .flags = IORESOURCE_IRQ,
  236. },
  237. [2] = {
  238. .start = AU1300_DSCR_CMD0_PSC2_TX,
  239. .end = AU1300_DSCR_CMD0_PSC2_TX,
  240. .flags = IORESOURCE_DMA,
  241. },
  242. [3] = {
  243. .start = AU1300_DSCR_CMD0_PSC2_RX,
  244. .end = AU1300_DSCR_CMD0_PSC2_RX,
  245. .flags = IORESOURCE_DMA,
  246. },
  247. };
  248. static struct platform_device db1300_i2s_dev = {
  249. .name = "au1xpsc_i2s",
  250. .id = 2, /* PSC ID */
  251. .num_resources = ARRAY_SIZE(au1300_psc2_res),
  252. .resource = au1300_psc2_res,
  253. };
  254. /**********************************************************************/
  255. static struct resource au1300_psc3_res[] = {
  256. [0] = {
  257. .start = AU1300_PSC3_PHYS_ADDR,
  258. .end = AU1300_PSC3_PHYS_ADDR + 0x0fff,
  259. .flags = IORESOURCE_MEM,
  260. },
  261. [1] = {
  262. .start = AU1300_PSC3_INT,
  263. .end = AU1300_PSC3_INT,
  264. .flags = IORESOURCE_IRQ,
  265. },
  266. [2] = {
  267. .start = AU1300_DSCR_CMD0_PSC3_TX,
  268. .end = AU1300_DSCR_CMD0_PSC3_TX,
  269. .flags = IORESOURCE_DMA,
  270. },
  271. [3] = {
  272. .start = AU1300_DSCR_CMD0_PSC3_RX,
  273. .end = AU1300_DSCR_CMD0_PSC3_RX,
  274. .flags = IORESOURCE_DMA,
  275. },
  276. };
  277. static struct platform_device db1300_i2c_dev = {
  278. .name = "au1xpsc_smbus",
  279. .id = 0, /* bus number */
  280. .num_resources = ARRAY_SIZE(au1300_psc3_res),
  281. .resource = au1300_psc3_res,
  282. };
  283. /**********************************************************************/
  284. /* proper key assignments when facing the LCD panel. For key assignments
  285. * according to the schematics swap up with down and left with right.
  286. * I chose to use it to emulate the arrow keys of a keyboard.
  287. */
  288. static struct gpio_keys_button db1300_5waysw_arrowkeys[] = {
  289. {
  290. .code = KEY_DOWN,
  291. .gpio = AU1300_PIN_LCDPWM0,
  292. .type = EV_KEY,
  293. .debounce_interval = 1,
  294. .active_low = 1,
  295. .desc = "5waysw-down",
  296. },
  297. {
  298. .code = KEY_UP,
  299. .gpio = AU1300_PIN_PSC2SYNC1,
  300. .type = EV_KEY,
  301. .debounce_interval = 1,
  302. .active_low = 1,
  303. .desc = "5waysw-up",
  304. },
  305. {
  306. .code = KEY_RIGHT,
  307. .gpio = AU1300_PIN_WAKE3,
  308. .type = EV_KEY,
  309. .debounce_interval = 1,
  310. .active_low = 1,
  311. .desc = "5waysw-right",
  312. },
  313. {
  314. .code = KEY_LEFT,
  315. .gpio = AU1300_PIN_WAKE2,
  316. .type = EV_KEY,
  317. .debounce_interval = 1,
  318. .active_low = 1,
  319. .desc = "5waysw-left",
  320. },
  321. {
  322. .code = KEY_ENTER,
  323. .gpio = AU1300_PIN_WAKE1,
  324. .type = EV_KEY,
  325. .debounce_interval = 1,
  326. .active_low = 1,
  327. .desc = "5waysw-push",
  328. },
  329. };
  330. static struct gpio_keys_platform_data db1300_5waysw_data = {
  331. .buttons = db1300_5waysw_arrowkeys,
  332. .nbuttons = ARRAY_SIZE(db1300_5waysw_arrowkeys),
  333. .rep = 1,
  334. .name = "db1300-5wayswitch",
  335. };
  336. static struct platform_device db1300_5waysw_dev = {
  337. .name = "gpio-keys",
  338. .dev = {
  339. .platform_data = &db1300_5waysw_data,
  340. },
  341. };
  342. /**********************************************************************/
  343. static struct pata_platform_info db1300_ide_info = {
  344. .ioport_shift = DB1300_IDE_REG_SHIFT,
  345. };
  346. #define IDE_ALT_START (14 << DB1300_IDE_REG_SHIFT)
  347. static struct resource db1300_ide_res[] = {
  348. [0] = {
  349. .start = DB1300_IDE_PHYS_ADDR,
  350. .end = DB1300_IDE_PHYS_ADDR + IDE_ALT_START - 1,
  351. .flags = IORESOURCE_MEM,
  352. },
  353. [1] = {
  354. .start = DB1300_IDE_PHYS_ADDR + IDE_ALT_START,
  355. .end = DB1300_IDE_PHYS_ADDR + DB1300_IDE_PHYS_LEN - 1,
  356. .flags = IORESOURCE_MEM,
  357. },
  358. [2] = {
  359. .start = DB1300_IDE_INT,
  360. .end = DB1300_IDE_INT,
  361. .flags = IORESOURCE_IRQ,
  362. },
  363. };
  364. static struct platform_device db1300_ide_dev = {
  365. .dev = {
  366. .platform_data = &db1300_ide_info,
  367. },
  368. .name = "pata_platform",
  369. .resource = db1300_ide_res,
  370. .num_resources = ARRAY_SIZE(db1300_ide_res),
  371. };
  372. /**********************************************************************/
  373. static irqreturn_t db1300_mmc_cd(int irq, void *ptr)
  374. {
  375. void(*mmc_cd)(struct mmc_host *, unsigned long);
  376. /* disable the one currently screaming. No other way to shut it up */
  377. if (irq == DB1300_SD1_INSERT_INT) {
  378. disable_irq_nosync(DB1300_SD1_INSERT_INT);
  379. enable_irq(DB1300_SD1_EJECT_INT);
  380. } else {
  381. disable_irq_nosync(DB1300_SD1_EJECT_INT);
  382. enable_irq(DB1300_SD1_INSERT_INT);
  383. }
  384. /* link against CONFIG_MMC=m. We can only be called once MMC core has
  385. * initialized the controller, so symbol_get() should always succeed.
  386. */
  387. mmc_cd = symbol_get(mmc_detect_change);
  388. mmc_cd(ptr, msecs_to_jiffies(500));
  389. symbol_put(mmc_detect_change);
  390. return IRQ_HANDLED;
  391. }
  392. static int db1300_mmc_card_readonly(void *mmc_host)
  393. {
  394. /* it uses SD1 interface, but the DB1200's SD0 bit in the CPLD */
  395. return bcsr_read(BCSR_STATUS) & BCSR_STATUS_SD0WP;
  396. }
  397. static int db1300_mmc_card_inserted(void *mmc_host)
  398. {
  399. return bcsr_read(BCSR_SIGSTAT) & (1 << 12); /* insertion irq signal */
  400. }
  401. static int db1300_mmc_cd_setup(void *mmc_host, int en)
  402. {
  403. int ret;
  404. if (en) {
  405. ret = request_irq(DB1300_SD1_INSERT_INT, db1300_mmc_cd, 0,
  406. "sd_insert", mmc_host);
  407. if (ret)
  408. goto out;
  409. ret = request_irq(DB1300_SD1_EJECT_INT, db1300_mmc_cd, 0,
  410. "sd_eject", mmc_host);
  411. if (ret) {
  412. free_irq(DB1300_SD1_INSERT_INT, mmc_host);
  413. goto out;
  414. }
  415. if (db1300_mmc_card_inserted(mmc_host))
  416. enable_irq(DB1300_SD1_EJECT_INT);
  417. else
  418. enable_irq(DB1300_SD1_INSERT_INT);
  419. } else {
  420. free_irq(DB1300_SD1_INSERT_INT, mmc_host);
  421. free_irq(DB1300_SD1_EJECT_INT, mmc_host);
  422. }
  423. ret = 0;
  424. out:
  425. return ret;
  426. }
  427. static void db1300_mmcled_set(struct led_classdev *led,
  428. enum led_brightness brightness)
  429. {
  430. if (brightness != LED_OFF)
  431. bcsr_mod(BCSR_LEDS, BCSR_LEDS_LED0, 0);
  432. else
  433. bcsr_mod(BCSR_LEDS, 0, BCSR_LEDS_LED0);
  434. }
  435. static struct led_classdev db1300_mmc_led = {
  436. .brightness_set = db1300_mmcled_set,
  437. };
  438. struct au1xmmc_platform_data db1300_sd1_platdata = {
  439. .cd_setup = db1300_mmc_cd_setup,
  440. .card_inserted = db1300_mmc_card_inserted,
  441. .card_readonly = db1300_mmc_card_readonly,
  442. .led = &db1300_mmc_led,
  443. };
  444. static struct resource au1300_sd1_res[] = {
  445. [0] = {
  446. .start = AU1300_SD1_PHYS_ADDR,
  447. .end = AU1300_SD1_PHYS_ADDR,
  448. .flags = IORESOURCE_MEM,
  449. },
  450. [1] = {
  451. .start = AU1300_SD1_INT,
  452. .end = AU1300_SD1_INT,
  453. .flags = IORESOURCE_IRQ,
  454. },
  455. [2] = {
  456. .start = AU1300_DSCR_CMD0_SDMS_TX1,
  457. .end = AU1300_DSCR_CMD0_SDMS_TX1,
  458. .flags = IORESOURCE_DMA,
  459. },
  460. [3] = {
  461. .start = AU1300_DSCR_CMD0_SDMS_RX1,
  462. .end = AU1300_DSCR_CMD0_SDMS_RX1,
  463. .flags = IORESOURCE_DMA,
  464. },
  465. };
  466. static struct platform_device db1300_sd1_dev = {
  467. .dev = {
  468. .platform_data = &db1300_sd1_platdata,
  469. },
  470. .name = "au1xxx-mmc",
  471. .id = 1,
  472. .resource = au1300_sd1_res,
  473. .num_resources = ARRAY_SIZE(au1300_sd1_res),
  474. };
  475. /**********************************************************************/
  476. static int db1300_movinand_inserted(void *mmc_host)
  477. {
  478. return 0; /* disable for now, it doesn't work yet */
  479. }
  480. static int db1300_movinand_readonly(void *mmc_host)
  481. {
  482. return 0;
  483. }
  484. static void db1300_movinand_led_set(struct led_classdev *led,
  485. enum led_brightness brightness)
  486. {
  487. if (brightness != LED_OFF)
  488. bcsr_mod(BCSR_LEDS, BCSR_LEDS_LED1, 0);
  489. else
  490. bcsr_mod(BCSR_LEDS, 0, BCSR_LEDS_LED1);
  491. }
  492. static struct led_classdev db1300_movinand_led = {
  493. .brightness_set = db1300_movinand_led_set,
  494. };
  495. struct au1xmmc_platform_data db1300_sd0_platdata = {
  496. .card_inserted = db1300_movinand_inserted,
  497. .card_readonly = db1300_movinand_readonly,
  498. .led = &db1300_movinand_led,
  499. .mask_host_caps = MMC_CAP_NEEDS_POLL,
  500. };
  501. static struct resource au1300_sd0_res[] = {
  502. [0] = {
  503. .start = AU1100_SD0_PHYS_ADDR,
  504. .end = AU1100_SD0_PHYS_ADDR,
  505. .flags = IORESOURCE_MEM,
  506. },
  507. [1] = {
  508. .start = AU1300_SD0_INT,
  509. .end = AU1300_SD0_INT,
  510. .flags = IORESOURCE_IRQ,
  511. },
  512. [2] = {
  513. .start = AU1300_DSCR_CMD0_SDMS_TX0,
  514. .end = AU1300_DSCR_CMD0_SDMS_TX0,
  515. .flags = IORESOURCE_DMA,
  516. },
  517. [3] = {
  518. .start = AU1300_DSCR_CMD0_SDMS_RX0,
  519. .end = AU1300_DSCR_CMD0_SDMS_RX0,
  520. .flags = IORESOURCE_DMA,
  521. },
  522. };
  523. static struct platform_device db1300_sd0_dev = {
  524. .dev = {
  525. .platform_data = &db1300_sd0_platdata,
  526. },
  527. .name = "au1xxx-mmc",
  528. .id = 0,
  529. .resource = au1300_sd0_res,
  530. .num_resources = ARRAY_SIZE(au1300_sd0_res),
  531. };
  532. /**********************************************************************/
  533. static struct platform_device db1300_wm9715_dev = {
  534. .name = "wm9712-codec",
  535. .id = 1, /* ID of PSC for AC97 audio, see asoc glue! */
  536. };
  537. static struct platform_device db1300_ac97dma_dev = {
  538. .name = "au1xpsc-pcm",
  539. .id = 1, /* PSC ID */
  540. };
  541. static struct platform_device db1300_i2sdma_dev = {
  542. .name = "au1xpsc-pcm",
  543. .id = 2, /* PSC ID */
  544. };
  545. static struct platform_device db1300_sndac97_dev = {
  546. .name = "db1300-ac97",
  547. };
  548. static struct platform_device db1300_sndi2s_dev = {
  549. .name = "db1300-i2s",
  550. };
  551. /**********************************************************************/
  552. static int db1300fb_panel_index(void)
  553. {
  554. return 9; /* DB1300_800x480 */
  555. }
  556. static int db1300fb_panel_init(void)
  557. {
  558. /* Apply power (Vee/Vdd logic is inverted on Panel DB1300_800x480) */
  559. bcsr_mod(BCSR_BOARD, BCSR_BOARD_LCDVEE | BCSR_BOARD_LCDVDD,
  560. BCSR_BOARD_LCDBL);
  561. return 0;
  562. }
  563. static int db1300fb_panel_shutdown(void)
  564. {
  565. /* Remove power (Vee/Vdd logic is inverted on Panel DB1300_800x480) */
  566. bcsr_mod(BCSR_BOARD, BCSR_BOARD_LCDBL,
  567. BCSR_BOARD_LCDVEE | BCSR_BOARD_LCDVDD);
  568. return 0;
  569. }
  570. static struct au1200fb_platdata db1300fb_pd = {
  571. .panel_index = db1300fb_panel_index,
  572. .panel_init = db1300fb_panel_init,
  573. .panel_shutdown = db1300fb_panel_shutdown,
  574. };
  575. static struct resource au1300_lcd_res[] = {
  576. [0] = {
  577. .start = AU1200_LCD_PHYS_ADDR,
  578. .end = AU1200_LCD_PHYS_ADDR + 0x800 - 1,
  579. .flags = IORESOURCE_MEM,
  580. },
  581. [1] = {
  582. .start = AU1300_LCD_INT,
  583. .end = AU1300_LCD_INT,
  584. .flags = IORESOURCE_IRQ,
  585. }
  586. };
  587. static u64 au1300_lcd_dmamask = DMA_BIT_MASK(32);
  588. static struct platform_device db1300_lcd_dev = {
  589. .name = "au1200-lcd",
  590. .id = 0,
  591. .dev = {
  592. .dma_mask = &au1300_lcd_dmamask,
  593. .coherent_dma_mask = DMA_BIT_MASK(32),
  594. .platform_data = &db1300fb_pd,
  595. },
  596. .num_resources = ARRAY_SIZE(au1300_lcd_res),
  597. .resource = au1300_lcd_res,
  598. };
  599. /**********************************************************************/
  600. static struct platform_device *db1300_dev[] __initdata = {
  601. &db1300_eth_dev,
  602. &db1300_i2c_dev,
  603. &db1300_5waysw_dev,
  604. &db1300_nand_dev,
  605. &db1300_ide_dev,
  606. &db1300_sd0_dev,
  607. &db1300_sd1_dev,
  608. &db1300_lcd_dev,
  609. &db1300_ac97_dev,
  610. &db1300_i2s_dev,
  611. &db1300_wm9715_dev,
  612. &db1300_ac97dma_dev,
  613. &db1300_i2sdma_dev,
  614. &db1300_sndac97_dev,
  615. &db1300_sndi2s_dev,
  616. };
  617. int __init db1300_dev_setup(void)
  618. {
  619. int swapped, cpldirq;
  620. /* setup CPLD IRQ muxer */
  621. cpldirq = au1300_gpio_to_irq(AU1300_PIN_EXTCLK1);
  622. irq_set_irq_type(cpldirq, IRQ_TYPE_LEVEL_HIGH);
  623. bcsr_init_irq(DB1300_FIRST_INT, DB1300_LAST_INT, cpldirq);
  624. /* insert/eject IRQs: one always triggers so don't enable them
  625. * when doing request_irq() on them. DB1200 has this bug too.
  626. */
  627. irq_set_status_flags(DB1300_SD1_INSERT_INT, IRQ_NOAUTOEN);
  628. irq_set_status_flags(DB1300_SD1_EJECT_INT, IRQ_NOAUTOEN);
  629. irq_set_status_flags(DB1300_CF_INSERT_INT, IRQ_NOAUTOEN);
  630. irq_set_status_flags(DB1300_CF_EJECT_INT, IRQ_NOAUTOEN);
  631. /*
  632. * setup board
  633. */
  634. prom_get_ethernet_addr(&db1300_eth_config.mac[0]);
  635. i2c_register_board_info(0, db1300_i2c_devs,
  636. ARRAY_SIZE(db1300_i2c_devs));
  637. /* Audio PSC clock is supplied by codecs (PSC1, 2) */
  638. __raw_writel(PSC_SEL_CLK_SERCLK,
  639. (void __iomem *)KSEG1ADDR(AU1300_PSC1_PHYS_ADDR) + PSC_SEL_OFFSET);
  640. wmb();
  641. __raw_writel(PSC_SEL_CLK_SERCLK,
  642. (void __iomem *)KSEG1ADDR(AU1300_PSC2_PHYS_ADDR) + PSC_SEL_OFFSET);
  643. wmb();
  644. /* I2C uses internal 48MHz EXTCLK1 */
  645. __raw_writel(PSC_SEL_CLK_INTCLK,
  646. (void __iomem *)KSEG1ADDR(AU1300_PSC3_PHYS_ADDR) + PSC_SEL_OFFSET);
  647. wmb();
  648. /* enable power to USB ports */
  649. bcsr_mod(BCSR_RESETS, 0, BCSR_RESETS_USBHPWR | BCSR_RESETS_OTGPWR);
  650. /* although it is socket #0, it uses the CPLD bits which previous boards
  651. * have used for socket #1.
  652. */
  653. db1x_register_pcmcia_socket(
  654. AU1000_PCMCIA_ATTR_PHYS_ADDR,
  655. AU1000_PCMCIA_ATTR_PHYS_ADDR + 0x00400000 - 1,
  656. AU1000_PCMCIA_MEM_PHYS_ADDR,
  657. AU1000_PCMCIA_MEM_PHYS_ADDR + 0x00400000 - 1,
  658. AU1000_PCMCIA_IO_PHYS_ADDR,
  659. AU1000_PCMCIA_IO_PHYS_ADDR + 0x00010000 - 1,
  660. DB1300_CF_INT, DB1300_CF_INSERT_INT, 0, DB1300_CF_EJECT_INT, 1);
  661. swapped = bcsr_read(BCSR_STATUS) & BCSR_STATUS_DB1200_SWAPBOOT;
  662. db1x_register_norflash(64 << 20, 2, swapped);
  663. return platform_add_devices(db1300_dev, ARRAY_SIZE(db1300_dev));
  664. }
  665. int __init db1300_board_setup(void)
  666. {
  667. unsigned short whoami;
  668. db1300_gpio_config();
  669. bcsr_init(DB1300_BCSR_PHYS_ADDR,
  670. DB1300_BCSR_PHYS_ADDR + DB1300_BCSR_HEXLED_OFS);
  671. whoami = bcsr_read(BCSR_WHOAMI);
  672. printk(KERN_INFO "NetLogic DBAu1300 Development Platform.\n\t"
  673. "BoardID %d CPLD Rev %d DaughtercardID %d\n",
  674. BCSR_WHOAMI_BOARD(whoami), BCSR_WHOAMI_CPLD(whoami),
  675. BCSR_WHOAMI_DCID(whoami));
  676. /* enable UARTs, YAMON only enables #2 */
  677. alchemy_uart_enable(AU1300_UART0_PHYS_ADDR);
  678. alchemy_uart_enable(AU1300_UART1_PHYS_ADDR);
  679. alchemy_uart_enable(AU1300_UART3_PHYS_ADDR);
  680. return 0;
  681. }