stamp.c 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944
  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/mtd/physmap.h>
  35. #include <linux/spi/spi.h>
  36. #include <linux/spi/flash.h>
  37. #if defined(CONFIG_USB_ISP1362_HCD) || defined(CONFIG_USB_ISP1362_HCD_MODULE)
  38. #include <linux/usb/isp1362.h>
  39. #endif
  40. #include <linux/ata_platform.h>
  41. #include <linux/irq.h>
  42. #include <linux/interrupt.h>
  43. #include <linux/i2c.h>
  44. #include <linux/usb/sl811.h>
  45. #include <asm/dma.h>
  46. #include <asm/bfin5xx_spi.h>
  47. #include <asm/reboot.h>
  48. #include <asm/portmux.h>
  49. #include <linux/spi/ad7877.h>
  50. /*
  51. * Name the Board for the /proc/cpuinfo
  52. */
  53. const char bfin_board_name[] = "ADDS-BF537-STAMP";
  54. /*
  55. * Driver needs to know address, irq and flag pin.
  56. */
  57. #define ISP1761_BASE 0x203C0000
  58. #define ISP1761_IRQ IRQ_PF7
  59. #if defined(CONFIG_USB_ISP1760_HCD) || defined(CONFIG_USB_ISP1760_HCD_MODULE)
  60. static struct resource bfin_isp1761_resources[] = {
  61. [0] = {
  62. .name = "isp1761-regs",
  63. .start = ISP1761_BASE + 0x00000000,
  64. .end = ISP1761_BASE + 0x000fffff,
  65. .flags = IORESOURCE_MEM,
  66. },
  67. [1] = {
  68. .start = ISP1761_IRQ,
  69. .end = ISP1761_IRQ,
  70. .flags = IORESOURCE_IRQ,
  71. },
  72. };
  73. static struct platform_device bfin_isp1761_device = {
  74. .name = "isp1761",
  75. .id = 0,
  76. .num_resources = ARRAY_SIZE(bfin_isp1761_resources),
  77. .resource = bfin_isp1761_resources,
  78. };
  79. static struct platform_device *bfin_isp1761_devices[] = {
  80. &bfin_isp1761_device,
  81. };
  82. int __init bfin_isp1761_init(void)
  83. {
  84. unsigned int num_devices = ARRAY_SIZE(bfin_isp1761_devices);
  85. printk(KERN_INFO "%s(): registering device resources\n", __func__);
  86. set_irq_type(ISP1761_IRQ, IRQF_TRIGGER_FALLING);
  87. return platform_add_devices(bfin_isp1761_devices, num_devices);
  88. }
  89. void __exit bfin_isp1761_exit(void)
  90. {
  91. platform_device_unregister(&bfin_isp1761_device);
  92. }
  93. arch_initcall(bfin_isp1761_init);
  94. #endif
  95. #if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
  96. #include <linux/input.h>
  97. #include <linux/gpio_keys.h>
  98. static struct gpio_keys_button bfin_gpio_keys_table[] = {
  99. {BTN_0, GPIO_PF2, 1, "gpio-keys: BTN0"},
  100. {BTN_1, GPIO_PF3, 1, "gpio-keys: BTN1"},
  101. {BTN_2, GPIO_PF4, 1, "gpio-keys: BTN2"},
  102. {BTN_3, GPIO_PF5, 1, "gpio-keys: BTN3"},
  103. };
  104. static struct gpio_keys_platform_data bfin_gpio_keys_data = {
  105. .buttons = bfin_gpio_keys_table,
  106. .nbuttons = ARRAY_SIZE(bfin_gpio_keys_table),
  107. };
  108. static struct platform_device bfin_device_gpiokeys = {
  109. .name = "gpio-keys",
  110. .dev = {
  111. .platform_data = &bfin_gpio_keys_data,
  112. },
  113. };
  114. #endif
  115. static struct resource bfin_gpios_resources = {
  116. .start = 0,
  117. .end = MAX_BLACKFIN_GPIOS - 1,
  118. .flags = IORESOURCE_IRQ,
  119. };
  120. static struct platform_device bfin_gpios_device = {
  121. .name = "simple-gpio",
  122. .id = -1,
  123. .num_resources = 1,
  124. .resource = &bfin_gpios_resources,
  125. };
  126. #if defined(CONFIG_BFIN_CFPCMCIA) || defined(CONFIG_BFIN_CFPCMCIA_MODULE)
  127. static struct resource bfin_pcmcia_cf_resources[] = {
  128. {
  129. .start = 0x20310000, /* IO PORT */
  130. .end = 0x20312000,
  131. .flags = IORESOURCE_MEM,
  132. }, {
  133. .start = 0x20311000, /* Attribute Memory */
  134. .end = 0x20311FFF,
  135. .flags = IORESOURCE_MEM,
  136. }, {
  137. .start = IRQ_PF4,
  138. .end = IRQ_PF4,
  139. .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWLEVEL,
  140. }, {
  141. .start = 6, /* Card Detect PF6 */
  142. .end = 6,
  143. .flags = IORESOURCE_IRQ,
  144. },
  145. };
  146. static struct platform_device bfin_pcmcia_cf_device = {
  147. .name = "bfin_cf_pcmcia",
  148. .id = -1,
  149. .num_resources = ARRAY_SIZE(bfin_pcmcia_cf_resources),
  150. .resource = bfin_pcmcia_cf_resources,
  151. };
  152. #endif
  153. #if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE)
  154. static struct platform_device rtc_device = {
  155. .name = "rtc-bfin",
  156. .id = -1,
  157. };
  158. #endif
  159. #if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)
  160. static struct resource smc91x_resources[] = {
  161. {
  162. .name = "smc91x-regs",
  163. .start = 0x20300300,
  164. .end = 0x20300300 + 16,
  165. .flags = IORESOURCE_MEM,
  166. }, {
  167. .start = IRQ_PF7,
  168. .end = IRQ_PF7,
  169. .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
  170. },
  171. };
  172. static struct platform_device smc91x_device = {
  173. .name = "smc91x",
  174. .id = 0,
  175. .num_resources = ARRAY_SIZE(smc91x_resources),
  176. .resource = smc91x_resources,
  177. };
  178. #endif
  179. #if defined(CONFIG_DM9000) || defined(CONFIG_DM9000_MODULE)
  180. static struct resource dm9000_resources[] = {
  181. [0] = {
  182. .start = 0x203FB800,
  183. .end = 0x203FB800 + 8,
  184. .flags = IORESOURCE_MEM,
  185. },
  186. [1] = {
  187. .start = IRQ_PF9,
  188. .end = IRQ_PF9,
  189. .flags = (IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE),
  190. },
  191. };
  192. static struct platform_device dm9000_device = {
  193. .name = "dm9000",
  194. .id = -1,
  195. .num_resources = ARRAY_SIZE(dm9000_resources),
  196. .resource = dm9000_resources,
  197. };
  198. #endif
  199. #if defined(CONFIG_AX88180) || defined(CONFIG_AX88180_MODULE)
  200. static struct resource ax88180_resources[] = {
  201. [0] = {
  202. .start = 0x20300000,
  203. .end = 0x20300000 + 0x8000,
  204. .flags = IORESOURCE_MEM,
  205. },
  206. [1] = {
  207. .start = IRQ_PF7,
  208. .end = IRQ_PF7,
  209. .flags = (IORESOURCE_IRQ | IORESOURCE_IRQ_LOWLEVEL),
  210. },
  211. };
  212. static struct platform_device ax88180_device = {
  213. .name = "ax88180",
  214. .id = -1,
  215. .num_resources = ARRAY_SIZE(ax88180_resources),
  216. .resource = ax88180_resources,
  217. };
  218. #endif
  219. #if defined(CONFIG_USB_SL811_HCD) || defined(CONFIG_USB_SL811_HCD_MODULE)
  220. static struct resource sl811_hcd_resources[] = {
  221. {
  222. .start = 0x20340000,
  223. .end = 0x20340000,
  224. .flags = IORESOURCE_MEM,
  225. }, {
  226. .start = 0x20340004,
  227. .end = 0x20340004,
  228. .flags = IORESOURCE_MEM,
  229. }, {
  230. .start = CONFIG_USB_SL811_BFIN_IRQ,
  231. .end = CONFIG_USB_SL811_BFIN_IRQ,
  232. .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
  233. },
  234. };
  235. #if defined(CONFIG_USB_SL811_BFIN_USE_VBUS)
  236. void sl811_port_power(struct device *dev, int is_on)
  237. {
  238. gpio_request(CONFIG_USB_SL811_BFIN_GPIO_VBUS, "usb:SL811_VBUS");
  239. gpio_direction_output(CONFIG_USB_SL811_BFIN_GPIO_VBUS, is_on);
  240. }
  241. #endif
  242. static struct sl811_platform_data sl811_priv = {
  243. .potpg = 10,
  244. .power = 250, /* == 500mA */
  245. #if defined(CONFIG_USB_SL811_BFIN_USE_VBUS)
  246. .port_power = &sl811_port_power,
  247. #endif
  248. };
  249. static struct platform_device sl811_hcd_device = {
  250. .name = "sl811-hcd",
  251. .id = 0,
  252. .dev = {
  253. .platform_data = &sl811_priv,
  254. },
  255. .num_resources = ARRAY_SIZE(sl811_hcd_resources),
  256. .resource = sl811_hcd_resources,
  257. };
  258. #endif
  259. #if defined(CONFIG_USB_ISP1362_HCD) || defined(CONFIG_USB_ISP1362_HCD_MODULE)
  260. static struct resource isp1362_hcd_resources[] = {
  261. {
  262. .start = 0x20360000,
  263. .end = 0x20360000,
  264. .flags = IORESOURCE_MEM,
  265. }, {
  266. .start = 0x20360004,
  267. .end = 0x20360004,
  268. .flags = IORESOURCE_MEM,
  269. }, {
  270. .start = CONFIG_USB_ISP1362_BFIN_GPIO_IRQ,
  271. .end = CONFIG_USB_ISP1362_BFIN_GPIO_IRQ,
  272. .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
  273. },
  274. };
  275. static struct isp1362_platform_data isp1362_priv = {
  276. .sel15Kres = 1,
  277. .clknotstop = 0,
  278. .oc_enable = 0,
  279. .int_act_high = 0,
  280. .int_edge_triggered = 0,
  281. .remote_wakeup_connected = 0,
  282. .no_power_switching = 1,
  283. .power_switching_mode = 0,
  284. };
  285. static struct platform_device isp1362_hcd_device = {
  286. .name = "isp1362-hcd",
  287. .id = 0,
  288. .dev = {
  289. .platform_data = &isp1362_priv,
  290. },
  291. .num_resources = ARRAY_SIZE(isp1362_hcd_resources),
  292. .resource = isp1362_hcd_resources,
  293. };
  294. #endif
  295. #if defined(CONFIG_BFIN_MAC) || defined(CONFIG_BFIN_MAC_MODULE)
  296. static struct platform_device bfin_mac_device = {
  297. .name = "bfin_mac",
  298. };
  299. #endif
  300. #if defined(CONFIG_USB_NET2272) || defined(CONFIG_USB_NET2272_MODULE)
  301. static struct resource net2272_bfin_resources[] = {
  302. {
  303. .start = 0x20300000,
  304. .end = 0x20300000 + 0x100,
  305. .flags = IORESOURCE_MEM,
  306. }, {
  307. .start = IRQ_PF7,
  308. .end = IRQ_PF7,
  309. .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
  310. },
  311. };
  312. static struct platform_device net2272_bfin_device = {
  313. .name = "net2272",
  314. .id = -1,
  315. .num_resources = ARRAY_SIZE(net2272_bfin_resources),
  316. .resource = net2272_bfin_resources,
  317. };
  318. #endif
  319. #if defined(CONFIG_MTD_PHYSMAP) || defined(CONFIG_MTD_PHYSMAP_MODULE)
  320. static struct mtd_partition stamp_partitions[] = {
  321. {
  322. .name = "Bootloader",
  323. .size = 0x40000,
  324. .offset = 0,
  325. }, {
  326. .name = "Kernel",
  327. .size = 0xE0000,
  328. .offset = MTDPART_OFS_APPEND,
  329. }, {
  330. .name = "RootFS",
  331. .size = 0x400000 - 0x40000 - 0xE0000 - 0x10000,
  332. .offset = MTDPART_OFS_APPEND,
  333. }, {
  334. .name = "MAC Address",
  335. .size = MTDPART_SIZ_FULL,
  336. .offset = 0x3F0000,
  337. .mask_flags = MTD_WRITEABLE,
  338. }
  339. };
  340. static struct physmap_flash_data stamp_flash_data = {
  341. .width = 2,
  342. .parts = stamp_partitions,
  343. .nr_parts = ARRAY_SIZE(stamp_partitions),
  344. };
  345. static struct resource stamp_flash_resource = {
  346. .start = 0x20000000,
  347. .end = 0x203fffff,
  348. .flags = IORESOURCE_MEM,
  349. };
  350. static struct platform_device stamp_flash_device = {
  351. .name = "physmap-flash",
  352. .id = 0,
  353. .dev = {
  354. .platform_data = &stamp_flash_data,
  355. },
  356. .num_resources = 1,
  357. .resource = &stamp_flash_resource,
  358. };
  359. #endif
  360. #if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
  361. /* all SPI peripherals info goes here */
  362. #if defined(CONFIG_MTD_M25P80) \
  363. || defined(CONFIG_MTD_M25P80_MODULE)
  364. static struct mtd_partition bfin_spi_flash_partitions[] = {
  365. {
  366. .name = "bootloader",
  367. .size = 0x00040000,
  368. .offset = 0,
  369. .mask_flags = MTD_CAP_ROM
  370. }, {
  371. .name = "kernel",
  372. .size = 0xe0000,
  373. .offset = MTDPART_OFS_APPEND,
  374. }, {
  375. .name = "file system",
  376. .size = MTDPART_SIZ_FULL,
  377. .offset = MTDPART_OFS_APPEND,
  378. }
  379. };
  380. static struct flash_platform_data bfin_spi_flash_data = {
  381. .name = "m25p80",
  382. .parts = bfin_spi_flash_partitions,
  383. .nr_parts = ARRAY_SIZE(bfin_spi_flash_partitions),
  384. .type = "m25p64",
  385. };
  386. /* SPI flash chip (m25p64) */
  387. static struct bfin5xx_spi_chip spi_flash_chip_info = {
  388. .enable_dma = 0, /* use dma transfer with this chip*/
  389. .bits_per_word = 8,
  390. };
  391. #endif
  392. #if defined(CONFIG_SPI_ADC_BF533) \
  393. || defined(CONFIG_SPI_ADC_BF533_MODULE)
  394. /* SPI ADC chip */
  395. static struct bfin5xx_spi_chip spi_adc_chip_info = {
  396. .enable_dma = 1, /* use dma transfer with this chip*/
  397. .bits_per_word = 16,
  398. };
  399. #endif
  400. #if defined(CONFIG_SND_BLACKFIN_AD1836) \
  401. || defined(CONFIG_SND_BLACKFIN_AD1836_MODULE)
  402. static struct bfin5xx_spi_chip ad1836_spi_chip_info = {
  403. .enable_dma = 0,
  404. .bits_per_word = 16,
  405. };
  406. #endif
  407. #if defined(CONFIG_AD9960) || defined(CONFIG_AD9960_MODULE)
  408. static struct bfin5xx_spi_chip ad9960_spi_chip_info = {
  409. .enable_dma = 0,
  410. .bits_per_word = 16,
  411. };
  412. #endif
  413. #if defined(CONFIG_SPI_MMC) || defined(CONFIG_SPI_MMC_MODULE)
  414. static struct bfin5xx_spi_chip spi_mmc_chip_info = {
  415. .enable_dma = 1,
  416. .bits_per_word = 8,
  417. };
  418. #endif
  419. #if defined(CONFIG_PBX)
  420. static struct bfin5xx_spi_chip spi_si3xxx_chip_info = {
  421. .ctl_reg = 0x4, /* send zero */
  422. .enable_dma = 0,
  423. .bits_per_word = 8,
  424. .cs_change_per_word = 1,
  425. };
  426. #endif
  427. #if defined(CONFIG_TOUCHSCREEN_AD7877) || defined(CONFIG_TOUCHSCREEN_AD7877_MODULE)
  428. static struct bfin5xx_spi_chip spi_ad7877_chip_info = {
  429. .enable_dma = 0,
  430. .bits_per_word = 16,
  431. };
  432. static const struct ad7877_platform_data bfin_ad7877_ts_info = {
  433. .model = 7877,
  434. .vref_delay_usecs = 50, /* internal, no capacitor */
  435. .x_plate_ohms = 419,
  436. .y_plate_ohms = 486,
  437. .pressure_max = 1000,
  438. .pressure_min = 0,
  439. .stopacq_polarity = 1,
  440. .first_conversion_delay = 3,
  441. .acquisition_time = 1,
  442. .averaging = 1,
  443. .pen_down_acc_interval = 1,
  444. };
  445. #endif
  446. #if defined(CONFIG_SPI_SPIDEV) || defined(CONFIG_SPI_SPIDEV_MODULE)
  447. static struct bfin5xx_spi_chip spidev_chip_info = {
  448. .enable_dma = 0,
  449. .bits_per_word = 8,
  450. };
  451. #endif
  452. #if defined(CONFIG_MTD_DATAFLASH) \
  453. || defined(CONFIG_MTD_DATAFLASH_MODULE)
  454. /* DataFlash chip */
  455. static struct bfin5xx_spi_chip data_flash_chip_info = {
  456. .enable_dma = 0, /* use dma transfer with this chip*/
  457. .bits_per_word = 8,
  458. };
  459. #endif
  460. static struct spi_board_info bfin_spi_board_info[] __initdata = {
  461. #if defined(CONFIG_MTD_M25P80) \
  462. || defined(CONFIG_MTD_M25P80_MODULE)
  463. {
  464. /* the modalias must be the same as spi device driver name */
  465. .modalias = "m25p80", /* Name of spi_driver for this device */
  466. .max_speed_hz = 25000000, /* max spi clock (SCK) speed in HZ */
  467. .bus_num = 0, /* Framework bus number */
  468. .chip_select = 1, /* Framework chip select. On STAMP537 it is SPISSEL1*/
  469. .platform_data = &bfin_spi_flash_data,
  470. .controller_data = &spi_flash_chip_info,
  471. .mode = SPI_MODE_3,
  472. },
  473. #endif
  474. #if defined(CONFIG_MTD_DATAFLASH) \
  475. || defined(CONFIG_MTD_DATAFLASH_MODULE)
  476. { /* DataFlash chip */
  477. .modalias = "mtd_dataflash",
  478. .max_speed_hz = 25000000, /* max spi clock (SCK) speed in HZ */
  479. .bus_num = 0, /* Framework bus number */
  480. .chip_select = 1, /* Framework chip select. On STAMP537 it is SPISSEL1*/
  481. .controller_data = &data_flash_chip_info,
  482. .mode = SPI_MODE_3,
  483. },
  484. #endif
  485. #if defined(CONFIG_SPI_ADC_BF533) \
  486. || defined(CONFIG_SPI_ADC_BF533_MODULE)
  487. {
  488. .modalias = "bfin_spi_adc", /* Name of spi_driver for this device */
  489. .max_speed_hz = 6250000, /* max spi clock (SCK) speed in HZ */
  490. .bus_num = 0, /* Framework bus number */
  491. .chip_select = 1, /* Framework chip select. */
  492. .platform_data = NULL, /* No spi_driver specific config */
  493. .controller_data = &spi_adc_chip_info,
  494. },
  495. #endif
  496. #if defined(CONFIG_SND_BLACKFIN_AD1836) \
  497. || defined(CONFIG_SND_BLACKFIN_AD1836_MODULE)
  498. {
  499. .modalias = "ad1836-spi",
  500. .max_speed_hz = 3125000, /* max spi clock (SCK) speed in HZ */
  501. .bus_num = 0,
  502. .chip_select = CONFIG_SND_BLACKFIN_SPI_PFBIT,
  503. .controller_data = &ad1836_spi_chip_info,
  504. },
  505. #endif
  506. #if defined(CONFIG_AD9960) || defined(CONFIG_AD9960_MODULE)
  507. {
  508. .modalias = "ad9960-spi",
  509. .max_speed_hz = 10000000, /* max spi clock (SCK) speed in HZ */
  510. .bus_num = 0,
  511. .chip_select = 1,
  512. .controller_data = &ad9960_spi_chip_info,
  513. },
  514. #endif
  515. #if defined(CONFIG_SPI_MMC) || defined(CONFIG_SPI_MMC_MODULE)
  516. {
  517. .modalias = "spi_mmc_dummy",
  518. .max_speed_hz = 20000000, /* max spi clock (SCK) speed in HZ */
  519. .bus_num = 0,
  520. .chip_select = 0,
  521. .platform_data = NULL,
  522. .controller_data = &spi_mmc_chip_info,
  523. .mode = SPI_MODE_3,
  524. },
  525. {
  526. .modalias = "spi_mmc",
  527. .max_speed_hz = 20000000, /* max spi clock (SCK) speed in HZ */
  528. .bus_num = 0,
  529. .chip_select = CONFIG_SPI_MMC_CS_CHAN,
  530. .platform_data = NULL,
  531. .controller_data = &spi_mmc_chip_info,
  532. .mode = SPI_MODE_3,
  533. },
  534. #endif
  535. #if defined(CONFIG_PBX)
  536. {
  537. .modalias = "fxs-spi",
  538. .max_speed_hz = 12500000, /* max spi clock (SCK) speed in HZ */
  539. .bus_num = 0,
  540. .chip_select = 8 - CONFIG_J11_JUMPER,
  541. .controller_data = &spi_si3xxx_chip_info,
  542. .mode = SPI_MODE_3,
  543. },
  544. {
  545. .modalias = "fxo-spi",
  546. .max_speed_hz = 12500000, /* max spi clock (SCK) speed in HZ */
  547. .bus_num = 0,
  548. .chip_select = 8 - CONFIG_J19_JUMPER,
  549. .controller_data = &spi_si3xxx_chip_info,
  550. .mode = SPI_MODE_3,
  551. },
  552. #endif
  553. #if defined(CONFIG_TOUCHSCREEN_AD7877) || defined(CONFIG_TOUCHSCREEN_AD7877_MODULE)
  554. {
  555. .modalias = "ad7877",
  556. .platform_data = &bfin_ad7877_ts_info,
  557. .irq = IRQ_PF6,
  558. .max_speed_hz = 12500000, /* max spi clock (SCK) speed in HZ */
  559. .bus_num = 0,
  560. .chip_select = 1,
  561. .controller_data = &spi_ad7877_chip_info,
  562. },
  563. #endif
  564. #if defined(CONFIG_SPI_SPIDEV) || defined(CONFIG_SPI_SPIDEV_MODULE)
  565. {
  566. .modalias = "spidev",
  567. .max_speed_hz = 3125000, /* max spi clock (SCK) speed in HZ */
  568. .bus_num = 0,
  569. .chip_select = 1,
  570. .controller_data = &spidev_chip_info,
  571. },
  572. #endif
  573. };
  574. /* SPI controller data */
  575. static struct bfin5xx_spi_master bfin_spi0_info = {
  576. .num_chipselect = 8,
  577. .enable_dma = 1, /* master has the ability to do dma transfer */
  578. .pin_req = {P_SPI0_SCK, P_SPI0_MISO, P_SPI0_MOSI, 0},
  579. };
  580. /* SPI (0) */
  581. static struct resource bfin_spi0_resource[] = {
  582. [0] = {
  583. .start = SPI0_REGBASE,
  584. .end = SPI0_REGBASE + 0xFF,
  585. .flags = IORESOURCE_MEM,
  586. },
  587. [1] = {
  588. .start = CH_SPI,
  589. .end = CH_SPI,
  590. .flags = IORESOURCE_IRQ,
  591. },
  592. };
  593. static struct platform_device bfin_spi0_device = {
  594. .name = "bfin-spi",
  595. .id = 0, /* Bus number */
  596. .num_resources = ARRAY_SIZE(bfin_spi0_resource),
  597. .resource = bfin_spi0_resource,
  598. .dev = {
  599. .platform_data = &bfin_spi0_info, /* Passed to driver */
  600. },
  601. };
  602. #endif /* spi master and devices */
  603. #if defined(CONFIG_FB_BF537_LQ035) || defined(CONFIG_FB_BF537_LQ035_MODULE)
  604. static struct platform_device bfin_fb_device = {
  605. .name = "bf537-lq035",
  606. };
  607. #endif
  608. #if defined(CONFIG_FB_BFIN_7393) || defined(CONFIG_FB_BFIN_7393_MODULE)
  609. static struct platform_device bfin_fb_adv7393_device = {
  610. .name = "bfin-adv7393",
  611. };
  612. #endif
  613. #if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
  614. static struct resource bfin_uart_resources[] = {
  615. #ifdef CONFIG_SERIAL_BFIN_UART0
  616. {
  617. .start = 0xFFC00400,
  618. .end = 0xFFC004FF,
  619. .flags = IORESOURCE_MEM,
  620. },
  621. #endif
  622. #ifdef CONFIG_SERIAL_BFIN_UART1
  623. {
  624. .start = 0xFFC02000,
  625. .end = 0xFFC020FF,
  626. .flags = IORESOURCE_MEM,
  627. },
  628. #endif
  629. };
  630. static struct platform_device bfin_uart_device = {
  631. .name = "bfin-uart",
  632. .id = 1,
  633. .num_resources = ARRAY_SIZE(bfin_uart_resources),
  634. .resource = bfin_uart_resources,
  635. };
  636. #endif
  637. #if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE)
  638. static struct resource bfin_sir_resources[] = {
  639. #ifdef CONFIG_BFIN_SIR0
  640. {
  641. .start = 0xFFC00400,
  642. .end = 0xFFC004FF,
  643. .flags = IORESOURCE_MEM,
  644. },
  645. #endif
  646. #ifdef CONFIG_BFIN_SIR1
  647. {
  648. .start = 0xFFC02000,
  649. .end = 0xFFC020FF,
  650. .flags = IORESOURCE_MEM,
  651. },
  652. #endif
  653. };
  654. static struct platform_device bfin_sir_device = {
  655. .name = "bfin_sir",
  656. .id = 0,
  657. .num_resources = ARRAY_SIZE(bfin_sir_resources),
  658. .resource = bfin_sir_resources,
  659. };
  660. #endif
  661. #if defined(CONFIG_I2C_BLACKFIN_TWI) || defined(CONFIG_I2C_BLACKFIN_TWI_MODULE)
  662. static struct resource bfin_twi0_resource[] = {
  663. [0] = {
  664. .start = TWI0_REGBASE,
  665. .end = TWI0_REGBASE,
  666. .flags = IORESOURCE_MEM,
  667. },
  668. [1] = {
  669. .start = IRQ_TWI,
  670. .end = IRQ_TWI,
  671. .flags = IORESOURCE_IRQ,
  672. },
  673. };
  674. static struct platform_device i2c_bfin_twi_device = {
  675. .name = "i2c-bfin-twi",
  676. .id = 0,
  677. .num_resources = ARRAY_SIZE(bfin_twi0_resource),
  678. .resource = bfin_twi0_resource,
  679. };
  680. #endif
  681. #ifdef CONFIG_I2C_BOARDINFO
  682. static struct i2c_board_info __initdata bfin_i2c_board_info[] = {
  683. #if defined(CONFIG_JOYSTICK_AD7142) || defined(CONFIG_JOYSTICK_AD7142_MODULE)
  684. {
  685. I2C_BOARD_INFO("ad7142_joystick", 0x2C),
  686. .type = "ad7142_joystick",
  687. .irq = 55,
  688. },
  689. #endif
  690. #if defined(CONFIG_TWI_LCD) || defined(CONFIG_TWI_LCD_MODULE)
  691. {
  692. I2C_BOARD_INFO("pcf8574_lcd", 0x22),
  693. .type = "pcf8574_lcd",
  694. },
  695. #endif
  696. #if defined(CONFIG_TWI_KEYPAD) || defined(CONFIG_TWI_KEYPAD_MODULE)
  697. {
  698. I2C_BOARD_INFO("pcf8574_keypad", 0x27),
  699. .type = "pcf8574_keypad",
  700. .irq = 72,
  701. },
  702. #endif
  703. };
  704. #endif
  705. #if defined(CONFIG_SERIAL_BFIN_SPORT) || defined(CONFIG_SERIAL_BFIN_SPORT_MODULE)
  706. static struct platform_device bfin_sport0_uart_device = {
  707. .name = "bfin-sport-uart",
  708. .id = 0,
  709. };
  710. static struct platform_device bfin_sport1_uart_device = {
  711. .name = "bfin-sport-uart",
  712. .id = 1,
  713. };
  714. #endif
  715. #if defined(CONFIG_PATA_PLATFORM) || defined(CONFIG_PATA_PLATFORM_MODULE)
  716. #define PATA_INT 55
  717. static struct pata_platform_info bfin_pata_platform_data = {
  718. .ioport_shift = 1,
  719. .irq_flags = IRQF_TRIGGER_HIGH | IRQF_DISABLED,
  720. };
  721. static struct resource bfin_pata_resources[] = {
  722. {
  723. .start = 0x20314020,
  724. .end = 0x2031403F,
  725. .flags = IORESOURCE_MEM,
  726. },
  727. {
  728. .start = 0x2031401C,
  729. .end = 0x2031401F,
  730. .flags = IORESOURCE_MEM,
  731. },
  732. {
  733. .start = PATA_INT,
  734. .end = PATA_INT,
  735. .flags = IORESOURCE_IRQ,
  736. },
  737. };
  738. static struct platform_device bfin_pata_device = {
  739. .name = "pata_platform",
  740. .id = -1,
  741. .num_resources = ARRAY_SIZE(bfin_pata_resources),
  742. .resource = bfin_pata_resources,
  743. .dev = {
  744. .platform_data = &bfin_pata_platform_data,
  745. }
  746. };
  747. #endif
  748. static struct platform_device *stamp_devices[] __initdata = {
  749. #if defined(CONFIG_BFIN_CFPCMCIA) || defined(CONFIG_BFIN_CFPCMCIA_MODULE)
  750. &bfin_pcmcia_cf_device,
  751. #endif
  752. #if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE)
  753. &rtc_device,
  754. #endif
  755. #if defined(CONFIG_USB_SL811_HCD) || defined(CONFIG_USB_SL811_HCD_MODULE)
  756. &sl811_hcd_device,
  757. #endif
  758. #if defined(CONFIG_USB_ISP1362_HCD) || defined(CONFIG_USB_ISP1362_HCD_MODULE)
  759. &isp1362_hcd_device,
  760. #endif
  761. #if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)
  762. &smc91x_device,
  763. #endif
  764. #if defined(CONFIG_DM9000) || defined(CONFIG_DM9000_MODULE)
  765. &dm9000_device,
  766. #endif
  767. #if defined(CONFIG_AX88180) || defined(CONFIG_AX88180_MODULE)
  768. &ax88180_device,
  769. #endif
  770. #if defined(CONFIG_BFIN_MAC) || defined(CONFIG_BFIN_MAC_MODULE)
  771. &bfin_mac_device,
  772. #endif
  773. #if defined(CONFIG_USB_NET2272) || defined(CONFIG_USB_NET2272_MODULE)
  774. &net2272_bfin_device,
  775. #endif
  776. #if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
  777. &bfin_spi0_device,
  778. #endif
  779. #if defined(CONFIG_FB_BF537_LQ035) || defined(CONFIG_FB_BF537_LQ035_MODULE)
  780. &bfin_fb_device,
  781. #endif
  782. #if defined(CONFIG_FB_BFIN_7393) || defined(CONFIG_FB_BFIN_7393_MODULE)
  783. &bfin_fb_adv7393_device,
  784. #endif
  785. #if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
  786. &bfin_uart_device,
  787. #endif
  788. #if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE)
  789. &bfin_sir_device,
  790. #endif
  791. #if defined(CONFIG_I2C_BLACKFIN_TWI) || defined(CONFIG_I2C_BLACKFIN_TWI_MODULE)
  792. &i2c_bfin_twi_device,
  793. #endif
  794. #if defined(CONFIG_SERIAL_BFIN_SPORT) || defined(CONFIG_SERIAL_BFIN_SPORT_MODULE)
  795. &bfin_sport0_uart_device,
  796. &bfin_sport1_uart_device,
  797. #endif
  798. #if defined(CONFIG_PATA_PLATFORM) || defined(CONFIG_PATA_PLATFORM_MODULE)
  799. &bfin_pata_device,
  800. #endif
  801. #if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
  802. &bfin_device_gpiokeys,
  803. #endif
  804. &bfin_gpios_device,
  805. #if defined(CONFIG_MTD_PHYSMAP) || defined(CONFIG_MTD_PHYSMAP_MODULE)
  806. &stamp_flash_device,
  807. #endif
  808. };
  809. static int __init stamp_init(void)
  810. {
  811. printk(KERN_INFO "%s(): registering device resources\n", __func__);
  812. #ifdef CONFIG_I2C_BOARDINFO
  813. i2c_register_board_info(0, bfin_i2c_board_info,
  814. ARRAY_SIZE(bfin_i2c_board_info));
  815. #endif
  816. platform_add_devices(stamp_devices, ARRAY_SIZE(stamp_devices));
  817. #if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
  818. spi_register_board_info(bfin_spi_board_info,
  819. ARRAY_SIZE(bfin_spi_board_info));
  820. #endif
  821. #if defined(CONFIG_PATA_PLATFORM) || defined(CONFIG_PATA_PLATFORM_MODULE)
  822. irq_desc[PATA_INT].status |= IRQ_NOAUTOEN;
  823. #endif
  824. return 0;
  825. }
  826. arch_initcall(stamp_init);
  827. void native_machine_restart(char *cmd)
  828. {
  829. /* workaround reboot hang when booting from SPI */
  830. if ((bfin_read_SYSCR() & 0x7) == 0x3)
  831. bfin_gpio_reset_spi0_ssel1();
  832. }
  833. /*
  834. * Currently the MAC address is saved in Flash by U-Boot
  835. */
  836. #define FLASH_MAC 0x203f0000
  837. void bfin_get_ether_addr(char *addr)
  838. {
  839. *(u32 *)(&(addr[0])) = bfin_read32(FLASH_MAC);
  840. *(u16 *)(&(addr[4])) = bfin_read16(FLASH_MAC + 4);
  841. }
  842. EXPORT_SYMBOL(bfin_get_ether_addr);