stamp.c 17 KB

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