stamp.c 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910
  1. /*
  2. * Copyright 2004-2009 Analog Devices Inc.
  3. * 2005 National ICT Australia (NICTA)
  4. * Aidan Williams <aidan@nicta.com.au>
  5. *
  6. * Licensed under the GPL-2 or later.
  7. */
  8. #include <linux/device.h>
  9. #include <linux/delay.h>
  10. #include <linux/platform_device.h>
  11. #include <linux/mtd/mtd.h>
  12. #include <linux/mtd/partitions.h>
  13. #include <linux/mtd/physmap.h>
  14. #include <linux/spi/spi.h>
  15. #include <linux/spi/flash.h>
  16. #include <linux/spi/mmc_spi.h>
  17. #if IS_ENABLED(CONFIG_USB_ISP1362_HCD)
  18. #include <linux/usb/isp1362.h>
  19. #endif
  20. #include <linux/gpio.h>
  21. #include <linux/irq.h>
  22. #include <linux/i2c.h>
  23. #include <asm/dma.h>
  24. #include <asm/bfin5xx_spi.h>
  25. #include <asm/reboot.h>
  26. #include <asm/portmux.h>
  27. #include <asm/dpmc.h>
  28. /*
  29. * Name the Board for the /proc/cpuinfo
  30. */
  31. const char bfin_board_name[] = "ADI BF533-STAMP";
  32. #if IS_ENABLED(CONFIG_RTC_DRV_BFIN)
  33. static struct platform_device rtc_device = {
  34. .name = "rtc-bfin",
  35. .id = -1,
  36. };
  37. #endif
  38. /*
  39. * Driver needs to know address, irq and flag pin.
  40. */
  41. #if IS_ENABLED(CONFIG_SMC91X)
  42. #include <linux/smc91x.h>
  43. static struct smc91x_platdata smc91x_info = {
  44. .flags = SMC91X_USE_16BIT | SMC91X_NOWAIT,
  45. .leda = RPC_LED_100_10,
  46. .ledb = RPC_LED_TX_RX,
  47. };
  48. static struct resource smc91x_resources[] = {
  49. {
  50. .name = "smc91x-regs",
  51. .start = 0x20300300,
  52. .end = 0x20300300 + 16,
  53. .flags = IORESOURCE_MEM,
  54. }, {
  55. .start = IRQ_PF7,
  56. .end = IRQ_PF7,
  57. .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
  58. },
  59. };
  60. static struct platform_device smc91x_device = {
  61. .name = "smc91x",
  62. .id = 0,
  63. .num_resources = ARRAY_SIZE(smc91x_resources),
  64. .resource = smc91x_resources,
  65. .dev = {
  66. .platform_data = &smc91x_info,
  67. },
  68. };
  69. #endif
  70. #if IS_ENABLED(CONFIG_USB_NET2272)
  71. static struct resource net2272_bfin_resources[] = {
  72. {
  73. .start = 0x20300000,
  74. .end = 0x20300000 + 0x100,
  75. .flags = IORESOURCE_MEM,
  76. }, {
  77. .start = 1,
  78. .flags = IORESOURCE_BUS,
  79. }, {
  80. .start = IRQ_PF10,
  81. .end = IRQ_PF10,
  82. .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
  83. },
  84. };
  85. static struct platform_device net2272_bfin_device = {
  86. .name = "net2272",
  87. .id = -1,
  88. .num_resources = ARRAY_SIZE(net2272_bfin_resources),
  89. .resource = net2272_bfin_resources,
  90. };
  91. #endif
  92. #if IS_ENABLED(CONFIG_MTD_BFIN_ASYNC)
  93. static struct mtd_partition stamp_partitions[] = {
  94. {
  95. .name = "bootloader(nor)",
  96. .size = 0x40000,
  97. .offset = 0,
  98. }, {
  99. .name = "linux kernel(nor)",
  100. .size = 0x180000,
  101. .offset = MTDPART_OFS_APPEND,
  102. }, {
  103. .name = "file system(nor)",
  104. .size = MTDPART_SIZ_FULL,
  105. .offset = MTDPART_OFS_APPEND,
  106. }
  107. };
  108. static struct physmap_flash_data stamp_flash_data = {
  109. .width = 2,
  110. .parts = stamp_partitions,
  111. .nr_parts = ARRAY_SIZE(stamp_partitions),
  112. };
  113. static struct resource stamp_flash_resource[] = {
  114. {
  115. .name = "cfi_probe",
  116. .start = 0x20000000,
  117. .end = 0x203fffff,
  118. .flags = IORESOURCE_MEM,
  119. }, {
  120. .start = 0x7BB07BB0, /* AMBCTL0 setting when accessing flash */
  121. .end = 0x7BB07BB0, /* AMBCTL1 setting when accessing flash */
  122. .flags = IORESOURCE_MEM,
  123. }, {
  124. .start = GPIO_PF0,
  125. .flags = IORESOURCE_IRQ,
  126. }
  127. };
  128. static struct platform_device stamp_flash_device = {
  129. .name = "bfin-async-flash",
  130. .id = 0,
  131. .dev = {
  132. .platform_data = &stamp_flash_data,
  133. },
  134. .num_resources = ARRAY_SIZE(stamp_flash_resource),
  135. .resource = stamp_flash_resource,
  136. };
  137. #endif
  138. #if IS_ENABLED(CONFIG_MTD_M25P80)
  139. static struct mtd_partition bfin_spi_flash_partitions[] = {
  140. {
  141. .name = "bootloader(spi)",
  142. .size = 0x00040000,
  143. .offset = 0,
  144. .mask_flags = MTD_CAP_ROM
  145. }, {
  146. .name = "linux kernel(spi)",
  147. .size = 0x180000,
  148. .offset = MTDPART_OFS_APPEND,
  149. }, {
  150. .name = "file system(spi)",
  151. .size = MTDPART_SIZ_FULL,
  152. .offset = MTDPART_OFS_APPEND,
  153. }
  154. };
  155. static struct flash_platform_data bfin_spi_flash_data = {
  156. .name = "m25p80",
  157. .parts = bfin_spi_flash_partitions,
  158. .nr_parts = ARRAY_SIZE(bfin_spi_flash_partitions),
  159. .type = "m25p64",
  160. };
  161. /* SPI flash chip (m25p64) */
  162. static struct bfin5xx_spi_chip spi_flash_chip_info = {
  163. .enable_dma = 0, /* use dma transfer with this chip*/
  164. };
  165. #endif
  166. #if IS_ENABLED(CONFIG_MMC_SPI)
  167. #define MMC_SPI_CARD_DETECT_INT IRQ_PF5
  168. static int bfin_mmc_spi_init(struct device *dev,
  169. irqreturn_t (*detect_int)(int, void *), void *data)
  170. {
  171. return request_irq(MMC_SPI_CARD_DETECT_INT, detect_int,
  172. IRQF_TRIGGER_FALLING | IRQF_TRIGGER_RISING,
  173. "mmc-spi-detect", data);
  174. }
  175. static void bfin_mmc_spi_exit(struct device *dev, void *data)
  176. {
  177. free_irq(MMC_SPI_CARD_DETECT_INT, data);
  178. }
  179. static struct mmc_spi_platform_data bfin_mmc_spi_pdata = {
  180. .init = bfin_mmc_spi_init,
  181. .exit = bfin_mmc_spi_exit,
  182. .detect_delay = 100, /* msecs */
  183. };
  184. static struct bfin5xx_spi_chip mmc_spi_chip_info = {
  185. .enable_dma = 0,
  186. .pio_interrupt = 0,
  187. };
  188. #endif
  189. static struct spi_board_info bfin_spi_board_info[] __initdata = {
  190. #if IS_ENABLED(CONFIG_MTD_M25P80)
  191. {
  192. /* the modalias must be the same as spi device driver name */
  193. .modalias = "m25p80", /* Name of spi_driver for this device */
  194. .max_speed_hz = 25000000, /* max spi clock (SCK) speed in HZ */
  195. .bus_num = 0, /* Framework bus number */
  196. .chip_select = 2, /* Framework chip select. On STAMP537 it is SPISSEL2*/
  197. .platform_data = &bfin_spi_flash_data,
  198. .controller_data = &spi_flash_chip_info,
  199. .mode = SPI_MODE_3,
  200. },
  201. #endif
  202. #if IS_ENABLED(CONFIG_SND_BF5XX_SOC_AD1836)
  203. {
  204. .modalias = "ad1836",
  205. .max_speed_hz = 3125000, /* max spi clock (SCK) speed in HZ */
  206. .bus_num = 0,
  207. .chip_select = 4,
  208. .platform_data = "ad1836", /* only includes chip name for the moment */
  209. .mode = SPI_MODE_3,
  210. },
  211. #endif
  212. #if IS_ENABLED(CONFIG_SPI_SPIDEV)
  213. {
  214. .modalias = "spidev",
  215. .max_speed_hz = 3125000, /* max spi clock (SCK) speed in HZ */
  216. .bus_num = 0,
  217. .chip_select = 1,
  218. },
  219. #endif
  220. #if IS_ENABLED(CONFIG_MMC_SPI)
  221. {
  222. .modalias = "mmc_spi",
  223. .max_speed_hz = 20000000, /* max spi clock (SCK) speed in HZ */
  224. .bus_num = 0,
  225. .chip_select = 4,
  226. .platform_data = &bfin_mmc_spi_pdata,
  227. .controller_data = &mmc_spi_chip_info,
  228. .mode = SPI_MODE_3,
  229. },
  230. #endif
  231. };
  232. #if IS_ENABLED(CONFIG_SPI_BFIN5XX)
  233. /* SPI (0) */
  234. static struct resource bfin_spi0_resource[] = {
  235. [0] = {
  236. .start = SPI0_REGBASE,
  237. .end = SPI0_REGBASE + 0xFF,
  238. .flags = IORESOURCE_MEM,
  239. },
  240. [1] = {
  241. .start = CH_SPI,
  242. .end = CH_SPI,
  243. .flags = IORESOURCE_DMA,
  244. },
  245. [2] = {
  246. .start = IRQ_SPI,
  247. .end = IRQ_SPI,
  248. .flags = IORESOURCE_IRQ,
  249. }
  250. };
  251. /* SPI controller data */
  252. static struct bfin5xx_spi_master bfin_spi0_info = {
  253. .num_chipselect = 8,
  254. .enable_dma = 1, /* master has the ability to do dma transfer */
  255. .pin_req = {P_SPI0_SCK, P_SPI0_MISO, P_SPI0_MOSI, 0},
  256. };
  257. static struct platform_device bfin_spi0_device = {
  258. .name = "bfin-spi",
  259. .id = 0, /* Bus number */
  260. .num_resources = ARRAY_SIZE(bfin_spi0_resource),
  261. .resource = bfin_spi0_resource,
  262. .dev = {
  263. .platform_data = &bfin_spi0_info, /* Passed to driver */
  264. },
  265. };
  266. #endif /* spi master and devices */
  267. #if IS_ENABLED(CONFIG_SERIAL_BFIN)
  268. #ifdef CONFIG_SERIAL_BFIN_UART0
  269. static struct resource bfin_uart0_resources[] = {
  270. {
  271. .start = BFIN_UART_THR,
  272. .end = BFIN_UART_GCTL+2,
  273. .flags = IORESOURCE_MEM,
  274. },
  275. {
  276. .start = IRQ_UART0_TX,
  277. .end = IRQ_UART0_TX,
  278. .flags = IORESOURCE_IRQ,
  279. },
  280. {
  281. .start = IRQ_UART0_RX,
  282. .end = IRQ_UART0_RX,
  283. .flags = IORESOURCE_IRQ,
  284. },
  285. {
  286. .start = IRQ_UART0_ERROR,
  287. .end = IRQ_UART0_ERROR,
  288. .flags = IORESOURCE_IRQ,
  289. },
  290. {
  291. .start = CH_UART0_TX,
  292. .end = CH_UART0_TX,
  293. .flags = IORESOURCE_DMA,
  294. },
  295. {
  296. .start = CH_UART0_RX,
  297. .end = CH_UART0_RX,
  298. .flags = IORESOURCE_DMA,
  299. },
  300. };
  301. static unsigned short bfin_uart0_peripherals[] = {
  302. P_UART0_TX, P_UART0_RX, 0
  303. };
  304. static struct platform_device bfin_uart0_device = {
  305. .name = "bfin-uart",
  306. .id = 0,
  307. .num_resources = ARRAY_SIZE(bfin_uart0_resources),
  308. .resource = bfin_uart0_resources,
  309. .dev = {
  310. .platform_data = &bfin_uart0_peripherals, /* Passed to driver */
  311. },
  312. };
  313. #endif
  314. #endif
  315. #if IS_ENABLED(CONFIG_BFIN_SIR)
  316. #ifdef CONFIG_BFIN_SIR0
  317. static struct resource bfin_sir0_resources[] = {
  318. {
  319. .start = 0xFFC00400,
  320. .end = 0xFFC004FF,
  321. .flags = IORESOURCE_MEM,
  322. },
  323. {
  324. .start = IRQ_UART0_RX,
  325. .end = IRQ_UART0_RX+1,
  326. .flags = IORESOURCE_IRQ,
  327. },
  328. {
  329. .start = CH_UART0_RX,
  330. .end = CH_UART0_RX+1,
  331. .flags = IORESOURCE_DMA,
  332. },
  333. };
  334. static struct platform_device bfin_sir0_device = {
  335. .name = "bfin_sir",
  336. .id = 0,
  337. .num_resources = ARRAY_SIZE(bfin_sir0_resources),
  338. .resource = bfin_sir0_resources,
  339. };
  340. #endif
  341. #endif
  342. #if IS_ENABLED(CONFIG_SERIAL_BFIN_SPORT)
  343. #ifdef CONFIG_SERIAL_BFIN_SPORT0_UART
  344. static struct resource bfin_sport0_uart_resources[] = {
  345. {
  346. .start = SPORT0_TCR1,
  347. .end = SPORT0_MRCS3+4,
  348. .flags = IORESOURCE_MEM,
  349. },
  350. {
  351. .start = IRQ_SPORT0_RX,
  352. .end = IRQ_SPORT0_RX+1,
  353. .flags = IORESOURCE_IRQ,
  354. },
  355. {
  356. .start = IRQ_SPORT0_ERROR,
  357. .end = IRQ_SPORT0_ERROR,
  358. .flags = IORESOURCE_IRQ,
  359. },
  360. };
  361. static unsigned short bfin_sport0_peripherals[] = {
  362. P_SPORT0_TFS, P_SPORT0_DTPRI, P_SPORT0_TSCLK, P_SPORT0_RFS,
  363. P_SPORT0_DRPRI, P_SPORT0_RSCLK, 0
  364. };
  365. static struct platform_device bfin_sport0_uart_device = {
  366. .name = "bfin-sport-uart",
  367. .id = 0,
  368. .num_resources = ARRAY_SIZE(bfin_sport0_uart_resources),
  369. .resource = bfin_sport0_uart_resources,
  370. .dev = {
  371. .platform_data = &bfin_sport0_peripherals, /* Passed to driver */
  372. },
  373. };
  374. #endif
  375. #ifdef CONFIG_SERIAL_BFIN_SPORT1_UART
  376. static struct resource bfin_sport1_uart_resources[] = {
  377. {
  378. .start = SPORT1_TCR1,
  379. .end = SPORT1_MRCS3+4,
  380. .flags = IORESOURCE_MEM,
  381. },
  382. {
  383. .start = IRQ_SPORT1_RX,
  384. .end = IRQ_SPORT1_RX+1,
  385. .flags = IORESOURCE_IRQ,
  386. },
  387. {
  388. .start = IRQ_SPORT1_ERROR,
  389. .end = IRQ_SPORT1_ERROR,
  390. .flags = IORESOURCE_IRQ,
  391. },
  392. };
  393. static unsigned short bfin_sport1_peripherals[] = {
  394. P_SPORT1_TFS, P_SPORT1_DTPRI, P_SPORT1_TSCLK, P_SPORT1_RFS,
  395. P_SPORT1_DRPRI, P_SPORT1_RSCLK, 0
  396. };
  397. static struct platform_device bfin_sport1_uart_device = {
  398. .name = "bfin-sport-uart",
  399. .id = 1,
  400. .num_resources = ARRAY_SIZE(bfin_sport1_uart_resources),
  401. .resource = bfin_sport1_uart_resources,
  402. .dev = {
  403. .platform_data = &bfin_sport1_peripherals, /* Passed to driver */
  404. },
  405. };
  406. #endif
  407. #endif
  408. #if IS_ENABLED(CONFIG_BFIN_SPORT)
  409. static struct resource bfin_sport0_resources[] = {
  410. {
  411. .start = SPORT0_TCR1,
  412. .end = SPORT0_MRCS3+4,
  413. .flags = IORESOURCE_MEM,
  414. },
  415. {
  416. .start = IRQ_SPORT0_TX,
  417. .end = IRQ_SPORT0_TX+1,
  418. .flags = IORESOURCE_IRQ,
  419. },
  420. {
  421. .start = IRQ_SPORT0_RX,
  422. .end = IRQ_SPORT0_RX+1,
  423. .flags = IORESOURCE_IRQ,
  424. },
  425. {
  426. .start = IRQ_SPORT0_ERROR,
  427. .end = IRQ_SPORT0_ERROR,
  428. .flags = IORESOURCE_IRQ,
  429. },
  430. {
  431. .start = CH_SPORT0_TX,
  432. .end = CH_SPORT0_TX,
  433. .flags = IORESOURCE_DMA,
  434. },
  435. {
  436. .start = CH_SPORT0_RX,
  437. .end = CH_SPORT0_RX,
  438. .flags = IORESOURCE_DMA,
  439. },
  440. };
  441. static struct platform_device bfin_sport0_device = {
  442. .name = "bfin_sport_raw",
  443. .id = 0,
  444. .num_resources = ARRAY_SIZE(bfin_sport0_resources),
  445. .resource = bfin_sport0_resources,
  446. .dev = {
  447. .platform_data = &bfin_sport0_peripherals,
  448. },
  449. };
  450. #endif
  451. #if IS_ENABLED(CONFIG_KEYBOARD_GPIO)
  452. #include <linux/input.h>
  453. #include <linux/gpio_keys.h>
  454. static struct gpio_keys_button bfin_gpio_keys_table[] = {
  455. {BTN_0, GPIO_PF5, 0, "gpio-keys: BTN0"},
  456. {BTN_1, GPIO_PF6, 0, "gpio-keys: BTN1"},
  457. {BTN_2, GPIO_PF8, 0, "gpio-keys: BTN2"},
  458. };
  459. static struct gpio_keys_platform_data bfin_gpio_keys_data = {
  460. .buttons = bfin_gpio_keys_table,
  461. .nbuttons = ARRAY_SIZE(bfin_gpio_keys_table),
  462. };
  463. static struct platform_device bfin_device_gpiokeys = {
  464. .name = "gpio-keys",
  465. .dev = {
  466. .platform_data = &bfin_gpio_keys_data,
  467. },
  468. };
  469. #endif
  470. #if IS_ENABLED(CONFIG_I2C_GPIO)
  471. #include <linux/i2c-gpio.h>
  472. static struct i2c_gpio_platform_data i2c_gpio_data = {
  473. .sda_pin = GPIO_PF2,
  474. .scl_pin = GPIO_PF3,
  475. .sda_is_open_drain = 0,
  476. .scl_is_open_drain = 0,
  477. .udelay = 10,
  478. };
  479. static struct platform_device i2c_gpio_device = {
  480. .name = "i2c-gpio",
  481. .id = 0,
  482. .dev = {
  483. .platform_data = &i2c_gpio_data,
  484. },
  485. };
  486. #endif
  487. static struct i2c_board_info __initdata bfin_i2c_board_info[] = {
  488. #if IS_ENABLED(CONFIG_JOYSTICK_AD7142)
  489. {
  490. I2C_BOARD_INFO("ad7142_joystick", 0x2C),
  491. .irq = 39,
  492. },
  493. #endif
  494. #if IS_ENABLED(CONFIG_BFIN_TWI_LCD)
  495. {
  496. I2C_BOARD_INFO("pcf8574_lcd", 0x22),
  497. },
  498. #endif
  499. #if IS_ENABLED(CONFIG_INPUT_PCF8574)
  500. {
  501. I2C_BOARD_INFO("pcf8574_keypad", 0x27),
  502. .irq = 39,
  503. },
  504. #endif
  505. #if IS_ENABLED(CONFIG_FB_BFIN_7393)
  506. {
  507. I2C_BOARD_INFO("bfin-adv7393", 0x2B),
  508. },
  509. #endif
  510. #if IS_ENABLED(CONFIG_BFIN_TWI_LCD)
  511. {
  512. I2C_BOARD_INFO("ad5252", 0x2f),
  513. },
  514. #endif
  515. };
  516. static const unsigned int cclk_vlev_datasheet[] =
  517. {
  518. VRPAIR(VLEV_085, 250000000),
  519. VRPAIR(VLEV_090, 376000000),
  520. VRPAIR(VLEV_095, 426000000),
  521. VRPAIR(VLEV_100, 426000000),
  522. VRPAIR(VLEV_105, 476000000),
  523. VRPAIR(VLEV_110, 476000000),
  524. VRPAIR(VLEV_115, 476000000),
  525. VRPAIR(VLEV_120, 600000000),
  526. VRPAIR(VLEV_125, 600000000),
  527. VRPAIR(VLEV_130, 600000000),
  528. };
  529. static struct bfin_dpmc_platform_data bfin_dmpc_vreg_data = {
  530. .tuple_tab = cclk_vlev_datasheet,
  531. .tabsize = ARRAY_SIZE(cclk_vlev_datasheet),
  532. .vr_settling_time = 25 /* us */,
  533. };
  534. static struct platform_device bfin_dpmc = {
  535. .name = "bfin dpmc",
  536. .dev = {
  537. .platform_data = &bfin_dmpc_vreg_data,
  538. },
  539. };
  540. #if IS_ENABLED(CONFIG_SND_BF5XX_I2S) || \
  541. IS_ENABLED(CONFIG_SND_BF5XX_AC97)
  542. #include <asm/bfin_sport.h>
  543. #define SPORT_REQ(x) \
  544. [x] = {P_SPORT##x##_TFS, P_SPORT##x##_DTPRI, P_SPORT##x##_TSCLK, \
  545. P_SPORT##x##_RFS, P_SPORT##x##_DRPRI, P_SPORT##x##_RSCLK, 0}
  546. static const u16 bfin_snd_pin[][7] = {
  547. SPORT_REQ(0),
  548. SPORT_REQ(1),
  549. };
  550. static struct bfin_snd_platform_data bfin_snd_data[] = {
  551. {
  552. .pin_req = &bfin_snd_pin[0][0],
  553. },
  554. {
  555. .pin_req = &bfin_snd_pin[1][0],
  556. },
  557. };
  558. #define BFIN_SND_RES(x) \
  559. [x] = { \
  560. { \
  561. .start = SPORT##x##_TCR1, \
  562. .end = SPORT##x##_TCR1, \
  563. .flags = IORESOURCE_MEM \
  564. }, \
  565. { \
  566. .start = CH_SPORT##x##_RX, \
  567. .end = CH_SPORT##x##_RX, \
  568. .flags = IORESOURCE_DMA, \
  569. }, \
  570. { \
  571. .start = CH_SPORT##x##_TX, \
  572. .end = CH_SPORT##x##_TX, \
  573. .flags = IORESOURCE_DMA, \
  574. }, \
  575. { \
  576. .start = IRQ_SPORT##x##_ERROR, \
  577. .end = IRQ_SPORT##x##_ERROR, \
  578. .flags = IORESOURCE_IRQ, \
  579. } \
  580. }
  581. static struct resource bfin_snd_resources[][4] = {
  582. BFIN_SND_RES(0),
  583. BFIN_SND_RES(1),
  584. };
  585. #endif
  586. #if IS_ENABLED(CONFIG_SND_BF5XX_I2S)
  587. static struct platform_device bfin_i2s_pcm = {
  588. .name = "bfin-i2s-pcm-audio",
  589. .id = -1,
  590. };
  591. #endif
  592. #if IS_ENABLED(CONFIG_SND_BF5XX_AC97)
  593. static struct platform_device bfin_ac97_pcm = {
  594. .name = "bfin-ac97-pcm-audio",
  595. .id = -1,
  596. };
  597. #endif
  598. #if IS_ENABLED(CONFIG_SND_BF5XX_SOC_AD1836)
  599. static const char * const ad1836_link[] = {
  600. "bfin-i2s.0",
  601. "spi0.4",
  602. };
  603. static struct platform_device bfin_ad1836_machine = {
  604. .name = "bfin-snd-ad1836",
  605. .id = -1,
  606. .dev = {
  607. .platform_data = (void *)ad1836_link,
  608. },
  609. };
  610. #endif
  611. #if IS_ENABLED(CONFIG_SND_BF5XX_SOC_AD73311)
  612. static const unsigned ad73311_gpio[] = {
  613. GPIO_PF4,
  614. };
  615. static struct platform_device bfin_ad73311_machine = {
  616. .name = "bfin-snd-ad73311",
  617. .id = 1,
  618. .dev = {
  619. .platform_data = (void *)ad73311_gpio,
  620. },
  621. };
  622. #endif
  623. #if IS_ENABLED(CONFIG_SND_SOC_AD73311)
  624. static struct platform_device bfin_ad73311_codec_device = {
  625. .name = "ad73311",
  626. .id = -1,
  627. };
  628. #endif
  629. #if IS_ENABLED(CONFIG_SND_SOC_AD74111)
  630. static struct platform_device bfin_ad74111_codec_device = {
  631. .name = "ad74111",
  632. .id = -1,
  633. };
  634. #endif
  635. #if IS_ENABLED(CONFIG_SND_BF5XX_SOC_I2S)
  636. static struct platform_device bfin_i2s = {
  637. .name = "bfin-i2s",
  638. .id = CONFIG_SND_BF5XX_SPORT_NUM,
  639. .num_resources =
  640. ARRAY_SIZE(bfin_snd_resources[CONFIG_SND_BF5XX_SPORT_NUM]),
  641. .resource = bfin_snd_resources[CONFIG_SND_BF5XX_SPORT_NUM],
  642. .dev = {
  643. .platform_data = &bfin_snd_data[CONFIG_SND_BF5XX_SPORT_NUM],
  644. },
  645. };
  646. #endif
  647. #if IS_ENABLED(CONFIG_SND_BF5XX_SOC_AC97)
  648. static struct platform_device bfin_ac97 = {
  649. .name = "bfin-ac97",
  650. .id = CONFIG_SND_BF5XX_SPORT_NUM,
  651. .num_resources =
  652. ARRAY_SIZE(bfin_snd_resources[CONFIG_SND_BF5XX_SPORT_NUM]),
  653. .resource = bfin_snd_resources[CONFIG_SND_BF5XX_SPORT_NUM],
  654. .dev = {
  655. .platform_data = &bfin_snd_data[CONFIG_SND_BF5XX_SPORT_NUM],
  656. },
  657. };
  658. #endif
  659. static struct platform_device *stamp_devices[] __initdata = {
  660. &bfin_dpmc,
  661. #if IS_ENABLED(CONFIG_RTC_DRV_BFIN)
  662. &rtc_device,
  663. #endif
  664. #if IS_ENABLED(CONFIG_SMC91X)
  665. &smc91x_device,
  666. #endif
  667. #if IS_ENABLED(CONFIG_USB_NET2272)
  668. &net2272_bfin_device,
  669. #endif
  670. #if IS_ENABLED(CONFIG_SPI_BFIN5XX)
  671. &bfin_spi0_device,
  672. #endif
  673. #if IS_ENABLED(CONFIG_SERIAL_BFIN)
  674. #ifdef CONFIG_SERIAL_BFIN_UART0
  675. &bfin_uart0_device,
  676. #endif
  677. #endif
  678. #if IS_ENABLED(CONFIG_BFIN_SIR)
  679. #ifdef CONFIG_BFIN_SIR0
  680. &bfin_sir0_device,
  681. #endif
  682. #endif
  683. #if IS_ENABLED(CONFIG_SERIAL_BFIN_SPORT)
  684. #ifdef CONFIG_SERIAL_BFIN_SPORT0_UART
  685. &bfin_sport0_uart_device,
  686. #endif
  687. #ifdef CONFIG_SERIAL_BFIN_SPORT1_UART
  688. &bfin_sport1_uart_device,
  689. #endif
  690. #endif
  691. #if IS_ENABLED(CONFIG_KEYBOARD_GPIO)
  692. &bfin_device_gpiokeys,
  693. #endif
  694. #if IS_ENABLED(CONFIG_I2C_GPIO)
  695. &i2c_gpio_device,
  696. #endif
  697. #if IS_ENABLED(CONFIG_MTD_BFIN_ASYNC)
  698. &stamp_flash_device,
  699. #endif
  700. #if IS_ENABLED(CONFIG_SND_BF5XX_I2S)
  701. &bfin_i2s_pcm,
  702. #endif
  703. #if IS_ENABLED(CONFIG_SND_BF5XX_AC97)
  704. &bfin_ac97_pcm,
  705. #endif
  706. #if IS_ENABLED(CONFIG_SND_BF5XX_SOC_AD1836)
  707. &bfin_ad1836_machine,
  708. #endif
  709. #if IS_ENABLED(CONFIG_SND_BF5XX_SOC_AD73311)
  710. &bfin_ad73311_machine,
  711. #endif
  712. #if IS_ENABLED(CONFIG_SND_SOC_AD73311)
  713. &bfin_ad73311_codec_device,
  714. #endif
  715. #if IS_ENABLED(CONFIG_SND_SOC_AD74111)
  716. &bfin_ad74111_codec_device,
  717. #endif
  718. #if IS_ENABLED(CONFIG_SND_BF5XX_SOC_I2S)
  719. &bfin_i2s,
  720. #endif
  721. #if IS_ENABLED(CONFIG_SND_BF5XX_SOC_AC97)
  722. &bfin_ac97,
  723. #endif
  724. };
  725. static int __init net2272_init(void)
  726. {
  727. #if IS_ENABLED(CONFIG_USB_NET2272)
  728. int ret;
  729. /* Set PF0 to 0, PF1 to 1 make /AMS3 work properly */
  730. ret = gpio_request(GPIO_PF0, "net2272");
  731. if (ret)
  732. return ret;
  733. ret = gpio_request(GPIO_PF1, "net2272");
  734. if (ret) {
  735. gpio_free(GPIO_PF0);
  736. return ret;
  737. }
  738. ret = gpio_request(GPIO_PF11, "net2272");
  739. if (ret) {
  740. gpio_free(GPIO_PF0);
  741. gpio_free(GPIO_PF1);
  742. return ret;
  743. }
  744. gpio_direction_output(GPIO_PF0, 0);
  745. gpio_direction_output(GPIO_PF1, 1);
  746. /* Reset the USB chip */
  747. gpio_direction_output(GPIO_PF11, 0);
  748. mdelay(2);
  749. gpio_set_value(GPIO_PF11, 1);
  750. #endif
  751. return 0;
  752. }
  753. static int __init stamp_init(void)
  754. {
  755. int ret;
  756. printk(KERN_INFO "%s(): registering device resources\n", __func__);
  757. i2c_register_board_info(0, bfin_i2c_board_info,
  758. ARRAY_SIZE(bfin_i2c_board_info));
  759. ret = platform_add_devices(stamp_devices, ARRAY_SIZE(stamp_devices));
  760. if (ret < 0)
  761. return ret;
  762. #if IS_ENABLED(CONFIG_SMC91X)
  763. /*
  764. * setup BF533_STAMP CPLD to route AMS3 to Ethernet MAC.
  765. * the bfin-async-map driver takes care of flipping between
  766. * flash and ethernet when necessary.
  767. */
  768. ret = gpio_request(GPIO_PF0, "enet_cpld");
  769. if (!ret) {
  770. gpio_direction_output(GPIO_PF0, 1);
  771. gpio_free(GPIO_PF0);
  772. }
  773. #endif
  774. if (net2272_init())
  775. pr_warning("unable to configure net2272; it probably won't work\n");
  776. spi_register_board_info(bfin_spi_board_info, ARRAY_SIZE(bfin_spi_board_info));
  777. return 0;
  778. }
  779. arch_initcall(stamp_init);
  780. static struct platform_device *stamp_early_devices[] __initdata = {
  781. #if defined(CONFIG_SERIAL_BFIN_CONSOLE) || defined(CONFIG_EARLY_PRINTK)
  782. #ifdef CONFIG_SERIAL_BFIN_UART0
  783. &bfin_uart0_device,
  784. #endif
  785. #endif
  786. #if defined(CONFIG_SERIAL_BFIN_SPORT_CONSOLE)
  787. #ifdef CONFIG_SERIAL_BFIN_SPORT0_UART
  788. &bfin_sport0_uart_device,
  789. #endif
  790. #ifdef CONFIG_SERIAL_BFIN_SPORT1_UART
  791. &bfin_sport1_uart_device,
  792. #endif
  793. #endif
  794. };
  795. void __init native_machine_early_platform_add_devices(void)
  796. {
  797. printk(KERN_INFO "register early platform devices\n");
  798. early_platform_add_devices(stamp_early_devices,
  799. ARRAY_SIZE(stamp_early_devices));
  800. }
  801. void native_machine_restart(char *cmd)
  802. {
  803. /* workaround pull up on cpld / flash pin not being strong enough */
  804. gpio_request(GPIO_PF0, "flash_cpld");
  805. gpio_direction_output(GPIO_PF0, 0);
  806. }