stamp.c 26 KB

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