stamp.c 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804
  1. /*
  2. * File: arch/blackfin/mach-bf537/boards/stamp.c
  3. * Based on: arch/blackfin/mach-bf533/boards/ezkit.c
  4. * Author: Aidan Williams <aidan@nicta.com.au>
  5. *
  6. * Created:
  7. * Description:
  8. *
  9. * Modified:
  10. * Copyright 2005 National ICT Australia (NICTA)
  11. * Copyright 2004-2006 Analog Devices Inc.
  12. *
  13. * Bugs: Enter bugs at http://blackfin.uclinux.org/
  14. *
  15. * This program is free software; you can redistribute it and/or modify
  16. * it under the terms of the GNU General Public License as published by
  17. * the Free Software Foundation; either version 2 of the License, or
  18. * (at your option) any later version.
  19. *
  20. * This program is distributed in the hope that it will be useful,
  21. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  22. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  23. * GNU General Public License for more details.
  24. *
  25. * You should have received a copy of the GNU General Public License
  26. * along with this program; if not, see the file COPYING, or write
  27. * to the Free Software Foundation, Inc.,
  28. * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  29. */
  30. #include <linux/device.h>
  31. #include <linux/platform_device.h>
  32. #include <linux/mtd/mtd.h>
  33. #include <linux/mtd/partitions.h>
  34. #include <linux/spi/spi.h>
  35. #include <linux/spi/flash.h>
  36. #if defined(CONFIG_USB_ISP1362_HCD) || defined(CONFIG_USB_ISP1362_HCD_MODULE)
  37. #include <linux/usb/isp1362.h>
  38. #endif
  39. #include <linux/pata_platform.h>
  40. #include <linux/irq.h>
  41. #include <linux/interrupt.h>
  42. #include <linux/usb/sl811.h>
  43. #include <asm/dma.h>
  44. #include <asm/bfin5xx_spi.h>
  45. #include <asm/reboot.h>
  46. #include <asm/portmux.h>
  47. #include <linux/spi/ad7877.h>
  48. /*
  49. * Name the Board for the /proc/cpuinfo
  50. */
  51. const char bfin_board_name[] = "ADDS-BF537-STAMP";
  52. /*
  53. * Driver needs to know address, irq and flag pin.
  54. */
  55. #define ISP1761_BASE 0x203C0000
  56. #define ISP1761_IRQ IRQ_PF7
  57. #if defined(CONFIG_USB_ISP1760_HCD) || defined(CONFIG_USB_ISP1760_HCD_MODULE)
  58. static struct resource bfin_isp1761_resources[] = {
  59. [0] = {
  60. .name = "isp1761-regs",
  61. .start = ISP1761_BASE + 0x00000000,
  62. .end = ISP1761_BASE + 0x000fffff,
  63. .flags = IORESOURCE_MEM,
  64. },
  65. [1] = {
  66. .start = ISP1761_IRQ,
  67. .end = ISP1761_IRQ,
  68. .flags = IORESOURCE_IRQ,
  69. },
  70. };
  71. static struct platform_device bfin_isp1761_device = {
  72. .name = "isp1761",
  73. .id = 0,
  74. .num_resources = ARRAY_SIZE(bfin_isp1761_resources),
  75. .resource = bfin_isp1761_resources,
  76. };
  77. static struct platform_device *bfin_isp1761_devices[] = {
  78. &bfin_isp1761_device,
  79. };
  80. int __init bfin_isp1761_init(void)
  81. {
  82. unsigned int num_devices = ARRAY_SIZE(bfin_isp1761_devices);
  83. printk(KERN_INFO "%s(): registering device resources\n", __FUNCTION__);
  84. set_irq_type(ISP1761_IRQ, IRQF_TRIGGER_FALLING);
  85. return platform_add_devices(bfin_isp1761_devices, num_devices);
  86. }
  87. void __exit bfin_isp1761_exit(void)
  88. {
  89. platform_device_unregister(&bfin_isp1761_device);
  90. }
  91. arch_initcall(bfin_isp1761_init);
  92. #endif
  93. #if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
  94. #include <linux/input.h>
  95. #include <linux/gpio_keys.h>
  96. static struct gpio_keys_button bfin_gpio_keys_table[] = {
  97. {BTN_0, GPIO_PF2, 1, "gpio-keys: BTN0"},
  98. {BTN_1, GPIO_PF3, 1, "gpio-keys: BTN1"},
  99. {BTN_2, GPIO_PF4, 1, "gpio-keys: BTN2"},
  100. {BTN_3, GPIO_PF5, 1, "gpio-keys: BTN3"},
  101. };
  102. static struct gpio_keys_platform_data bfin_gpio_keys_data = {
  103. .buttons = bfin_gpio_keys_table,
  104. .nbuttons = ARRAY_SIZE(bfin_gpio_keys_table),
  105. };
  106. static struct platform_device bfin_device_gpiokeys = {
  107. .name = "gpio-keys",
  108. .dev = {
  109. .platform_data = &bfin_gpio_keys_data,
  110. },
  111. };
  112. #endif
  113. #if defined(CONFIG_BFIN_CFPCMCIA) || defined(CONFIG_BFIN_CFPCMCIA_MODULE)
  114. static struct resource bfin_pcmcia_cf_resources[] = {
  115. {
  116. .start = 0x20310000, /* IO PORT */
  117. .end = 0x20312000,
  118. .flags = IORESOURCE_MEM,
  119. }, {
  120. .start = 0x20311000, /* Attribute Memory */
  121. .end = 0x20311FFF,
  122. .flags = IORESOURCE_MEM,
  123. }, {
  124. .start = IRQ_PF4,
  125. .end = IRQ_PF4,
  126. .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWLEVEL,
  127. }, {
  128. .start = 6, /* Card Detect PF6 */
  129. .end = 6,
  130. .flags = IORESOURCE_IRQ,
  131. },
  132. };
  133. static struct platform_device bfin_pcmcia_cf_device = {
  134. .name = "bfin_cf_pcmcia",
  135. .id = -1,
  136. .num_resources = ARRAY_SIZE(bfin_pcmcia_cf_resources),
  137. .resource = bfin_pcmcia_cf_resources,
  138. };
  139. #endif
  140. #if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE)
  141. static struct platform_device rtc_device = {
  142. .name = "rtc-bfin",
  143. .id = -1,
  144. };
  145. #endif
  146. #if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)
  147. static struct resource smc91x_resources[] = {
  148. {
  149. .name = "smc91x-regs",
  150. .start = 0x20300300,
  151. .end = 0x20300300 + 16,
  152. .flags = IORESOURCE_MEM,
  153. }, {
  154. .start = IRQ_PF7,
  155. .end = IRQ_PF7,
  156. .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
  157. },
  158. };
  159. static struct platform_device smc91x_device = {
  160. .name = "smc91x",
  161. .id = 0,
  162. .num_resources = ARRAY_SIZE(smc91x_resources),
  163. .resource = smc91x_resources,
  164. };
  165. #endif
  166. #if defined(CONFIG_DM9000) || defined(CONFIG_DM9000_MODULE)
  167. static struct resource dm9000_resources[] = {
  168. [0] = {
  169. .start = 0x203FB800,
  170. .end = 0x203FB800 + 8,
  171. .flags = IORESOURCE_MEM,
  172. },
  173. [1] = {
  174. .start = IRQ_PF9,
  175. .end = IRQ_PF9,
  176. .flags = (IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE),
  177. },
  178. };
  179. static struct platform_device dm9000_device = {
  180. .name = "dm9000",
  181. .id = -1,
  182. .num_resources = ARRAY_SIZE(dm9000_resources),
  183. .resource = dm9000_resources,
  184. };
  185. #endif
  186. #if defined(CONFIG_AX88180) || defined(CONFIG_AX88180_MODULE)
  187. static struct resource ax88180_resources[] = {
  188. [0] = {
  189. .start = 0x20300000,
  190. .end = 0x20300000 + 0x8000,
  191. .flags = IORESOURCE_MEM,
  192. },
  193. [1] = {
  194. .start = IRQ_PF7,
  195. .end = IRQ_PF7,
  196. .flags = (IORESOURCE_IRQ | IORESOURCE_IRQ_LOWLEVEL),
  197. },
  198. };
  199. static struct platform_device ax88180_device = {
  200. .name = "ax88180",
  201. .id = -1,
  202. .num_resources = ARRAY_SIZE(ax88180_resources),
  203. .resource = ax88180_resources,
  204. };
  205. #endif
  206. #if defined(CONFIG_USB_SL811_HCD) || defined(CONFIG_USB_SL811_HCD_MODULE)
  207. static struct resource sl811_hcd_resources[] = {
  208. {
  209. .start = 0x20340000,
  210. .end = 0x20340000,
  211. .flags = IORESOURCE_MEM,
  212. }, {
  213. .start = 0x20340004,
  214. .end = 0x20340004,
  215. .flags = IORESOURCE_MEM,
  216. }, {
  217. .start = CONFIG_USB_SL811_BFIN_IRQ,
  218. .end = CONFIG_USB_SL811_BFIN_IRQ,
  219. .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
  220. },
  221. };
  222. #if defined(CONFIG_USB_SL811_BFIN_USE_VBUS)
  223. void sl811_port_power(struct device *dev, int is_on)
  224. {
  225. gpio_request(CONFIG_USB_SL811_BFIN_GPIO_VBUS, "usb:SL811_VBUS");
  226. gpio_direction_output(CONFIG_USB_SL811_BFIN_GPIO_VBUS);
  227. if (is_on)
  228. gpio_set_value(CONFIG_USB_SL811_BFIN_GPIO_VBUS, 1);
  229. else
  230. gpio_set_value(CONFIG_USB_SL811_BFIN_GPIO_VBUS, 0);
  231. }
  232. #endif
  233. static struct sl811_platform_data sl811_priv = {
  234. .potpg = 10,
  235. .power = 250, /* == 500mA */
  236. #if defined(CONFIG_USB_SL811_BFIN_USE_VBUS)
  237. .port_power = &sl811_port_power,
  238. #endif
  239. };
  240. static struct platform_device sl811_hcd_device = {
  241. .name = "sl811-hcd",
  242. .id = 0,
  243. .dev = {
  244. .platform_data = &sl811_priv,
  245. },
  246. .num_resources = ARRAY_SIZE(sl811_hcd_resources),
  247. .resource = sl811_hcd_resources,
  248. };
  249. #endif
  250. #if defined(CONFIG_USB_ISP1362_HCD) || defined(CONFIG_USB_ISP1362_HCD_MODULE)
  251. static struct resource isp1362_hcd_resources[] = {
  252. {
  253. .start = 0x20360000,
  254. .end = 0x20360000,
  255. .flags = IORESOURCE_MEM,
  256. }, {
  257. .start = 0x20360004,
  258. .end = 0x20360004,
  259. .flags = IORESOURCE_MEM,
  260. }, {
  261. .start = CONFIG_USB_ISP1362_BFIN_GPIO_IRQ,
  262. .end = CONFIG_USB_ISP1362_BFIN_GPIO_IRQ,
  263. .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
  264. },
  265. };
  266. static struct isp1362_platform_data isp1362_priv = {
  267. .sel15Kres = 1,
  268. .clknotstop = 0,
  269. .oc_enable = 0,
  270. .int_act_high = 0,
  271. .int_edge_triggered = 0,
  272. .remote_wakeup_connected = 0,
  273. .no_power_switching = 1,
  274. .power_switching_mode = 0,
  275. };
  276. static struct platform_device isp1362_hcd_device = {
  277. .name = "isp1362-hcd",
  278. .id = 0,
  279. .dev = {
  280. .platform_data = &isp1362_priv,
  281. },
  282. .num_resources = ARRAY_SIZE(isp1362_hcd_resources),
  283. .resource = isp1362_hcd_resources,
  284. };
  285. #endif
  286. #if defined(CONFIG_BFIN_MAC) || defined(CONFIG_BFIN_MAC_MODULE)
  287. static struct platform_device bfin_mac_device = {
  288. .name = "bfin_mac",
  289. };
  290. #endif
  291. #if defined(CONFIG_USB_NET2272) || defined(CONFIG_USB_NET2272_MODULE)
  292. static struct resource net2272_bfin_resources[] = {
  293. {
  294. .start = 0x20300000,
  295. .end = 0x20300000 + 0x100,
  296. .flags = IORESOURCE_MEM,
  297. }, {
  298. .start = IRQ_PF7,
  299. .end = IRQ_PF7,
  300. .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
  301. },
  302. };
  303. static struct platform_device net2272_bfin_device = {
  304. .name = "net2272",
  305. .id = -1,
  306. .num_resources = ARRAY_SIZE(net2272_bfin_resources),
  307. .resource = net2272_bfin_resources,
  308. };
  309. #endif
  310. #if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
  311. /* all SPI peripherals info goes here */
  312. #if defined(CONFIG_MTD_M25P80) \
  313. || defined(CONFIG_MTD_M25P80_MODULE)
  314. static struct mtd_partition bfin_spi_flash_partitions[] = {
  315. {
  316. .name = "bootloader",
  317. .size = 0x00020000,
  318. .offset = 0,
  319. .mask_flags = MTD_CAP_ROM
  320. }, {
  321. .name = "kernel",
  322. .size = 0xe0000,
  323. .offset = 0x20000
  324. }, {
  325. .name = "file system",
  326. .size = 0x700000,
  327. .offset = 0x00100000,
  328. }
  329. };
  330. static struct flash_platform_data bfin_spi_flash_data = {
  331. .name = "m25p80",
  332. .parts = bfin_spi_flash_partitions,
  333. .nr_parts = ARRAY_SIZE(bfin_spi_flash_partitions),
  334. .type = "m25p64",
  335. };
  336. /* SPI flash chip (m25p64) */
  337. static struct bfin5xx_spi_chip spi_flash_chip_info = {
  338. .enable_dma = 0, /* use dma transfer with this chip*/
  339. .bits_per_word = 8,
  340. };
  341. #endif
  342. #if defined(CONFIG_SPI_ADC_BF533) \
  343. || defined(CONFIG_SPI_ADC_BF533_MODULE)
  344. /* SPI ADC chip */
  345. static struct bfin5xx_spi_chip spi_adc_chip_info = {
  346. .enable_dma = 1, /* use dma transfer with this chip*/
  347. .bits_per_word = 16,
  348. };
  349. #endif
  350. #if defined(CONFIG_SND_BLACKFIN_AD1836) \
  351. || defined(CONFIG_SND_BLACKFIN_AD1836_MODULE)
  352. static struct bfin5xx_spi_chip ad1836_spi_chip_info = {
  353. .enable_dma = 0,
  354. .bits_per_word = 16,
  355. };
  356. #endif
  357. #if defined(CONFIG_AD9960) || defined(CONFIG_AD9960_MODULE)
  358. static struct bfin5xx_spi_chip ad9960_spi_chip_info = {
  359. .enable_dma = 0,
  360. .bits_per_word = 16,
  361. };
  362. #endif
  363. #if defined(CONFIG_SPI_MMC) || defined(CONFIG_SPI_MMC_MODULE)
  364. static struct bfin5xx_spi_chip spi_mmc_chip_info = {
  365. .enable_dma = 1,
  366. .bits_per_word = 8,
  367. };
  368. #endif
  369. #if defined(CONFIG_PBX)
  370. static struct bfin5xx_spi_chip spi_si3xxx_chip_info = {
  371. .ctl_reg = 0x4, /* send zero */
  372. .enable_dma = 0,
  373. .bits_per_word = 8,
  374. .cs_change_per_word = 1,
  375. };
  376. #endif
  377. #if defined(CONFIG_AD5304) || defined(CONFIG_AD5304_MODULE)
  378. static struct bfin5xx_spi_chip ad5304_chip_info = {
  379. .enable_dma = 0,
  380. .bits_per_word = 16,
  381. };
  382. #endif
  383. #if defined(CONFIG_TOUCHSCREEN_AD7877) || defined(CONFIG_TOUCHSCREEN_AD7877_MODULE)
  384. static struct bfin5xx_spi_chip spi_ad7877_chip_info = {
  385. .enable_dma = 0,
  386. .bits_per_word = 16,
  387. };
  388. static const struct ad7877_platform_data bfin_ad7877_ts_info = {
  389. .model = 7877,
  390. .vref_delay_usecs = 50, /* internal, no capacitor */
  391. .x_plate_ohms = 419,
  392. .y_plate_ohms = 486,
  393. .pressure_max = 1000,
  394. .pressure_min = 0,
  395. .stopacq_polarity = 1,
  396. .first_conversion_delay = 3,
  397. .acquisition_time = 1,
  398. .averaging = 1,
  399. .pen_down_acc_interval = 1,
  400. };
  401. #endif
  402. static struct spi_board_info bfin_spi_board_info[] __initdata = {
  403. #if defined(CONFIG_MTD_M25P80) \
  404. || defined(CONFIG_MTD_M25P80_MODULE)
  405. {
  406. /* the modalias must be the same as spi device driver name */
  407. .modalias = "m25p80", /* Name of spi_driver for this device */
  408. .max_speed_hz = 25000000, /* max spi clock (SCK) speed in HZ */
  409. .bus_num = 0, /* Framework bus number */
  410. .chip_select = 1, /* Framework chip select. On STAMP537 it is SPISSEL1*/
  411. .platform_data = &bfin_spi_flash_data,
  412. .controller_data = &spi_flash_chip_info,
  413. .mode = SPI_MODE_3,
  414. },
  415. #endif
  416. #if defined(CONFIG_SPI_ADC_BF533) \
  417. || defined(CONFIG_SPI_ADC_BF533_MODULE)
  418. {
  419. .modalias = "bfin_spi_adc", /* Name of spi_driver for this device */
  420. .max_speed_hz = 6250000, /* max spi clock (SCK) speed in HZ */
  421. .bus_num = 0, /* Framework bus number */
  422. .chip_select = 1, /* Framework chip select. */
  423. .platform_data = NULL, /* No spi_driver specific config */
  424. .controller_data = &spi_adc_chip_info,
  425. },
  426. #endif
  427. #if defined(CONFIG_SND_BLACKFIN_AD1836) \
  428. || defined(CONFIG_SND_BLACKFIN_AD1836_MODULE)
  429. {
  430. .modalias = "ad1836-spi",
  431. .max_speed_hz = 3125000, /* max spi clock (SCK) speed in HZ */
  432. .bus_num = 0,
  433. .chip_select = CONFIG_SND_BLACKFIN_SPI_PFBIT,
  434. .controller_data = &ad1836_spi_chip_info,
  435. },
  436. #endif
  437. #if defined(CONFIG_AD9960) || defined(CONFIG_AD9960_MODULE)
  438. {
  439. .modalias = "ad9960-spi",
  440. .max_speed_hz = 10000000, /* max spi clock (SCK) speed in HZ */
  441. .bus_num = 0,
  442. .chip_select = 1,
  443. .controller_data = &ad9960_spi_chip_info,
  444. },
  445. #endif
  446. #if defined(CONFIG_SPI_MMC) || defined(CONFIG_SPI_MMC_MODULE)
  447. {
  448. .modalias = "spi_mmc_dummy",
  449. .max_speed_hz = 20000000, /* max spi clock (SCK) speed in HZ */
  450. .bus_num = 0,
  451. .chip_select = 0,
  452. .platform_data = NULL,
  453. .controller_data = &spi_mmc_chip_info,
  454. .mode = SPI_MODE_3,
  455. },
  456. {
  457. .modalias = "spi_mmc",
  458. .max_speed_hz = 20000000, /* max spi clock (SCK) speed in HZ */
  459. .bus_num = 0,
  460. .chip_select = CONFIG_SPI_MMC_CS_CHAN,
  461. .platform_data = NULL,
  462. .controller_data = &spi_mmc_chip_info,
  463. .mode = SPI_MODE_3,
  464. },
  465. #endif
  466. #if defined(CONFIG_PBX)
  467. {
  468. .modalias = "fxs-spi",
  469. .max_speed_hz = 12500000, /* max spi clock (SCK) speed in HZ */
  470. .bus_num = 0,
  471. .chip_select = 8 - CONFIG_J11_JUMPER,
  472. .controller_data = &spi_si3xxx_chip_info,
  473. .mode = SPI_MODE_3,
  474. },
  475. {
  476. .modalias = "fxo-spi",
  477. .max_speed_hz = 12500000, /* max spi clock (SCK) speed in HZ */
  478. .bus_num = 0,
  479. .chip_select = 8 - CONFIG_J19_JUMPER,
  480. .controller_data = &spi_si3xxx_chip_info,
  481. .mode = SPI_MODE_3,
  482. },
  483. #endif
  484. #if defined(CONFIG_AD5304) || defined(CONFIG_AD5304_MODULE)
  485. {
  486. .modalias = "ad5304_spi",
  487. .max_speed_hz = 1250000, /* max spi clock (SCK) speed in HZ */
  488. .bus_num = 0,
  489. .chip_select = 2,
  490. .platform_data = NULL,
  491. .controller_data = &ad5304_chip_info,
  492. .mode = SPI_MODE_2,
  493. },
  494. #endif
  495. #if defined(CONFIG_TOUCHSCREEN_AD7877) || defined(CONFIG_TOUCHSCREEN_AD7877_MODULE)
  496. {
  497. .modalias = "ad7877",
  498. .platform_data = &bfin_ad7877_ts_info,
  499. .irq = IRQ_PF6,
  500. .max_speed_hz = 12500000, /* max spi clock (SCK) speed in HZ */
  501. .bus_num = 0,
  502. .chip_select = 1,
  503. .controller_data = &spi_ad7877_chip_info,
  504. },
  505. #endif
  506. };
  507. /* SPI controller data */
  508. static struct bfin5xx_spi_master bfin_spi0_info = {
  509. .num_chipselect = 8,
  510. .enable_dma = 1, /* master has the ability to do dma transfer */
  511. .pin_req = {P_SPI0_SCK, P_SPI0_MISO, P_SPI0_MOSI, 0},
  512. };
  513. /* SPI (0) */
  514. static struct resource bfin_spi0_resource[] = {
  515. [0] = {
  516. .start = SPI0_REGBASE,
  517. .end = SPI0_REGBASE + 0xFF,
  518. .flags = IORESOURCE_MEM,
  519. },
  520. [1] = {
  521. .start = CH_SPI,
  522. .end = CH_SPI,
  523. .flags = IORESOURCE_IRQ,
  524. },
  525. };
  526. static struct platform_device bfin_spi0_device = {
  527. .name = "bfin-spi",
  528. .id = 0, /* Bus number */
  529. .num_resources = ARRAY_SIZE(bfin_spi0_resource),
  530. .resource = bfin_spi0_resource,
  531. .dev = {
  532. .platform_data = &bfin_spi0_info, /* Passed to driver */
  533. },
  534. };
  535. #endif /* spi master and devices */
  536. #if defined(CONFIG_FB_BF537_LQ035) || defined(CONFIG_FB_BF537_LQ035_MODULE)
  537. static struct platform_device bfin_fb_device = {
  538. .name = "bf537-lq035",
  539. };
  540. #endif
  541. #if defined(CONFIG_FB_BFIN_7393) || defined(CONFIG_FB_BFIN_7393_MODULE)
  542. static struct platform_device bfin_fb_adv7393_device = {
  543. .name = "bfin-adv7393",
  544. };
  545. #endif
  546. #if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
  547. static struct resource bfin_uart_resources[] = {
  548. #ifdef CONFIG_SERIAL_BFIN_UART0
  549. {
  550. .start = 0xFFC00400,
  551. .end = 0xFFC004FF,
  552. .flags = IORESOURCE_MEM,
  553. },
  554. #endif
  555. #ifdef CONFIG_SERIAL_BFIN_UART1
  556. {
  557. .start = 0xFFC02000,
  558. .end = 0xFFC020FF,
  559. .flags = IORESOURCE_MEM,
  560. },
  561. #endif
  562. };
  563. static struct platform_device bfin_uart_device = {
  564. .name = "bfin-uart",
  565. .id = 1,
  566. .num_resources = ARRAY_SIZE(bfin_uart_resources),
  567. .resource = bfin_uart_resources,
  568. };
  569. #endif
  570. #if defined(CONFIG_I2C_BLACKFIN_TWI) || defined(CONFIG_I2C_BLACKFIN_TWI_MODULE)
  571. static struct resource bfin_twi0_resource[] = {
  572. [0] = {
  573. .start = TWI0_REGBASE,
  574. .end = TWI0_REGBASE,
  575. .flags = IORESOURCE_MEM,
  576. },
  577. [1] = {
  578. .start = IRQ_TWI,
  579. .end = IRQ_TWI,
  580. .flags = IORESOURCE_IRQ,
  581. },
  582. };
  583. static struct platform_device i2c_bfin_twi_device = {
  584. .name = "i2c-bfin-twi",
  585. .id = 0,
  586. .num_resources = ARRAY_SIZE(bfin_twi0_resource),
  587. .resource = bfin_twi0_resource,
  588. };
  589. #endif
  590. #if defined(CONFIG_SERIAL_BFIN_SPORT) || defined(CONFIG_SERIAL_BFIN_SPORT_MODULE)
  591. static struct platform_device bfin_sport0_uart_device = {
  592. .name = "bfin-sport-uart",
  593. .id = 0,
  594. };
  595. static struct platform_device bfin_sport1_uart_device = {
  596. .name = "bfin-sport-uart",
  597. .id = 1,
  598. };
  599. #endif
  600. #if defined(CONFIG_PATA_PLATFORM) || defined(CONFIG_PATA_PLATFORM_MODULE)
  601. #define PATA_INT 55
  602. static struct pata_platform_info bfin_pata_platform_data = {
  603. .ioport_shift = 1,
  604. .irq_flags = IRQF_TRIGGER_HIGH | IRQF_DISABLED,
  605. };
  606. static struct resource bfin_pata_resources[] = {
  607. {
  608. .start = 0x20314020,
  609. .end = 0x2031403F,
  610. .flags = IORESOURCE_MEM,
  611. },
  612. {
  613. .start = 0x2031401C,
  614. .end = 0x2031401F,
  615. .flags = IORESOURCE_MEM,
  616. },
  617. {
  618. .start = PATA_INT,
  619. .end = PATA_INT,
  620. .flags = IORESOURCE_IRQ,
  621. },
  622. };
  623. static struct platform_device bfin_pata_device = {
  624. .name = "pata_platform",
  625. .id = -1,
  626. .num_resources = ARRAY_SIZE(bfin_pata_resources),
  627. .resource = bfin_pata_resources,
  628. .dev = {
  629. .platform_data = &bfin_pata_platform_data,
  630. }
  631. };
  632. #endif
  633. static struct platform_device *stamp_devices[] __initdata = {
  634. #if defined(CONFIG_BFIN_CFPCMCIA) || defined(CONFIG_BFIN_CFPCMCIA_MODULE)
  635. &bfin_pcmcia_cf_device,
  636. #endif
  637. #if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE)
  638. &rtc_device,
  639. #endif
  640. #if defined(CONFIG_USB_SL811_HCD) || defined(CONFIG_USB_SL811_HCD_MODULE)
  641. &sl811_hcd_device,
  642. #endif
  643. #if defined(CONFIG_USB_ISP1362_HCD) || defined(CONFIG_USB_ISP1362_HCD_MODULE)
  644. &isp1362_hcd_device,
  645. #endif
  646. #if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)
  647. &smc91x_device,
  648. #endif
  649. #if defined(CONFIG_DM9000) || defined(CONFIG_DM9000_MODULE)
  650. &dm9000_device,
  651. #endif
  652. #if defined(CONFIG_AX88180) || defined(CONFIG_AX88180_MODULE)
  653. &ax88180_device,
  654. #endif
  655. #if defined(CONFIG_BFIN_MAC) || defined(CONFIG_BFIN_MAC_MODULE)
  656. &bfin_mac_device,
  657. #endif
  658. #if defined(CONFIG_USB_NET2272) || defined(CONFIG_USB_NET2272_MODULE)
  659. &net2272_bfin_device,
  660. #endif
  661. #if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
  662. &bfin_spi0_device,
  663. #endif
  664. #if defined(CONFIG_FB_BF537_LQ035) || defined(CONFIG_FB_BF537_LQ035_MODULE)
  665. &bfin_fb_device,
  666. #endif
  667. #if defined(CONFIG_FB_BFIN_7393) || defined(CONFIG_FB_BFIN_7393_MODULE)
  668. &bfin_fb_adv7393_device,
  669. #endif
  670. #if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
  671. &bfin_uart_device,
  672. #endif
  673. #if defined(CONFIG_I2C_BLACKFIN_TWI) || defined(CONFIG_I2C_BLACKFIN_TWI_MODULE)
  674. &i2c_bfin_twi_device,
  675. #endif
  676. #if defined(CONFIG_SERIAL_BFIN_SPORT) || defined(CONFIG_SERIAL_BFIN_SPORT_MODULE)
  677. &bfin_sport0_uart_device,
  678. &bfin_sport1_uart_device,
  679. #endif
  680. #if defined(CONFIG_PATA_PLATFORM) || defined(CONFIG_PATA_PLATFORM_MODULE)
  681. &bfin_pata_device,
  682. #endif
  683. #if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
  684. &bfin_device_gpiokeys,
  685. #endif
  686. };
  687. static int __init stamp_init(void)
  688. {
  689. printk(KERN_INFO "%s(): registering device resources\n", __FUNCTION__);
  690. platform_add_devices(stamp_devices, ARRAY_SIZE(stamp_devices));
  691. #if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
  692. spi_register_board_info(bfin_spi_board_info,
  693. ARRAY_SIZE(bfin_spi_board_info));
  694. #endif
  695. #if defined(CONFIG_PATA_PLATFORM) || defined(CONFIG_PATA_PLATFORM_MODULE)
  696. irq_desc[PATA_INT].status |= IRQ_NOAUTOEN;
  697. #endif
  698. return 0;
  699. }
  700. arch_initcall(stamp_init);
  701. void native_machine_restart(char *cmd)
  702. {
  703. /* workaround reboot hang when booting from SPI */
  704. if ((bfin_read_SYSCR() & 0x7) == 0x3)
  705. bfin_gpio_reset_spi0_ssel1();
  706. }
  707. /*
  708. * Currently the MAC address is saved in Flash by U-Boot
  709. */
  710. #define FLASH_MAC 0x203f0000
  711. void bfin_get_ether_addr(char *addr)
  712. {
  713. *(u32 *)(&(addr[0])) = bfin_read32(FLASH_MAC);
  714. *(u16 *)(&(addr[4])) = bfin_read16(FLASH_MAC + 4);
  715. }
  716. EXPORT_SYMBOL(bfin_get_ether_addr);