tcpConnectionMonitoring.c 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578
  1. /*
  2. * Copyright 2004-2009 Analog Devices Inc.
  3. * 2005 National ICT Australia (NICTA)
  4. * Aidan Williams <aidan@nicta.com.au>
  5. *
  6. * Licensed under the GPL-2 or later.
  7. */
  8. #include <linux/device.h>
  9. #include <linux/export.h>
  10. #include <linux/kernel.h>
  11. #include <linux/platform_device.h>
  12. #include <linux/io.h>
  13. #include <linux/mtd/mtd.h>
  14. #include <linux/mtd/nand.h>
  15. #include <linux/mtd/partitions.h>
  16. #include <linux/mtd/plat-ram.h>
  17. #include <linux/mtd/physmap.h>
  18. #include <linux/spi/spi.h>
  19. #include <linux/spi/flash.h>
  20. #if defined(CONFIG_USB_ISP1362_HCD) || defined(CONFIG_USB_ISP1362_HCD_MODULE)
  21. #include <linux/usb/isp1362.h>
  22. #endif
  23. #include <linux/i2c.h>
  24. #include <linux/i2c/adp5588.h>
  25. #include <linux/etherdevice.h>
  26. #include <linux/ata_platform.h>
  27. #include <linux/irq.h>
  28. #include <linux/interrupt.h>
  29. #include <linux/usb/sl811.h>
  30. #include <linux/spi/mmc_spi.h>
  31. #include <linux/leds.h>
  32. #include <linux/input.h>
  33. #include <asm/dma.h>
  34. #include <asm/bfin5xx_spi.h>
  35. #include <asm/reboot.h>
  36. #include <asm/portmux.h>
  37. #include <asm/dpmc.h>
  38. #include <asm/bfin_sport.h>
  39. #ifdef CONFIG_REGULATOR_FIXED_VOLTAGE
  40. #include <linux/regulator/fixed.h>
  41. #endif
  42. #include <linux/regulator/machine.h>
  43. #include <linux/regulator/consumer.h>
  44. #include <linux/regulator/userspace-consumer.h>
  45. /*
  46. * Name the Board for the /proc/cpuinfo
  47. */
  48. const char bfin_board_name[] = "ADI BF537-STAMP";
  49. /*
  50. * Driver needs to know address, irq and flag pin.
  51. */
  52. #if defined(CONFIG_USB_ISP1760_HCD) || defined(CONFIG_USB_ISP1760_HCD_MODULE)
  53. #include <linux/usb/isp1760.h>
  54. static struct resource bfin_isp1760_resources[] = {
  55. [0] = {
  56. .start = 0x203C0000,
  57. .end = 0x203C0000 + 0x000fffff,
  58. .flags = IORESOURCE_MEM,
  59. },
  60. [1] = {
  61. .start = IRQ_PF7,
  62. .end = IRQ_PF7,
  63. .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWLEVEL,
  64. },
  65. };
  66. static struct isp1760_platform_data isp1760_priv = {
  67. .is_isp1761 = 0,
  68. .bus_width_16 = 1,
  69. .port1_otg = 0,
  70. .analog_oc = 0,
  71. .dack_polarity_high = 0,
  72. .dreq_polarity_high = 0,
  73. };
  74. static struct platform_device bfin_isp1760_device = {
  75. .name = "isp1760",
  76. .id = 0,
  77. .dev = {
  78. .platform_data = &isp1760_priv,
  79. },
  80. .num_resources = ARRAY_SIZE(bfin_isp1760_resources),
  81. .resource = bfin_isp1760_resources,
  82. };
  83. #endif
  84. #if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
  85. #include <linux/gpio_keys.h>
  86. static struct gpio_keys_button bfin_gpio_keys_table[] = {
  87. {BTN_0, GPIO_PF2, 1, "gpio-keys: BTN0"},
  88. {BTN_1, GPIO_PF3, 1, "gpio-keys: BTN1"},
  89. {BTN_2, GPIO_PF4, 1, "gpio-keys: BTN2"},
  90. {BTN_3, GPIO_PF5, 1, "gpio-keys: BTN3"},
  91. };
  92. static struct gpio_keys_platform_data bfin_gpio_keys_data = {
  93. .buttons = bfin_gpio_keys_table,
  94. .nbuttons = ARRAY_SIZE(bfin_gpio_keys_table),
  95. };
  96. static struct platform_device bfin_device_gpiokeys = {
  97. .name = "gpio-keys",
  98. .dev = {
  99. .platform_data = &bfin_gpio_keys_data,
  100. },
  101. };
  102. #endif
  103. #if defined(CONFIG_BFIN_CFPCMCIA) || defined(CONFIG_BFIN_CFPCMCIA_MODULE)
  104. static struct resource bfin_pcmcia_cf_resources[] = {
  105. {
  106. .start = 0x20310000, /* IO PORT */
  107. .end = 0x20312000,
  108. .flags = IORESOURCE_MEM,
  109. }, {
  110. .start = 0x20311000, /* Attribute Memory */
  111. .end = 0x20311FFF,
  112. .flags = IORESOURCE_MEM,
  113. }, {
  114. .start = IRQ_PF4,
  115. .end = IRQ_PF4,
  116. .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWLEVEL,
  117. }, {
  118. .start = 6, /* Card Detect PF6 */
  119. .end = 6,
  120. .flags = IORESOURCE_IRQ,
  121. },
  122. };
  123. static struct platform_device bfin_pcmcia_cf_device = {
  124. .name = "bfin_cf_pcmcia",
  125. .id = -1,
  126. .num_resources = ARRAY_SIZE(bfin_pcmcia_cf_resources),
  127. .resource = bfin_pcmcia_cf_resources,
  128. };
  129. #endif
  130. #if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE)
  131. static struct platform_device rtc_device = {
  132. .name = "rtc-bfin",
  133. .id = -1,
  134. };
  135. #endif
  136. #if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)
  137. #include <linux/smc91x.h>
  138. static struct smc91x_platdata smc91x_info = {
  139. .flags = SMC91X_USE_16BIT | SMC91X_NOWAIT,
  140. .leda = RPC_LED_100_10,
  141. .ledb = RPC_LED_TX_RX,
  142. };
  143. static struct resource smc91x_resources[] = {
  144. {
  145. .name = "smc91x-regs",
  146. .start = 0x20300300,
  147. .end = 0x20300300 + 16,
  148. .flags = IORESOURCE_MEM,
  149. }, {
  150. .start = IRQ_PF7,
  151. .end = IRQ_PF7,
  152. .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
  153. },
  154. };
  155. static struct platform_device smc91x_device = {
  156. .name = "smc91x",
  157. .id = 0,
  158. .num_resources = ARRAY_SIZE(smc91x_resources),
  159. .resource = smc91x_resources,
  160. .dev = {
  161. .platform_data = &smc91x_info,
  162. },
  163. };
  164. #endif
  165. #if defined(CONFIG_DM9000) || defined(CONFIG_DM9000_MODULE)
  166. static struct resource dm9000_resources[] = {
  167. [0] = {
  168. .start = 0x203FB800,
  169. .end = 0x203FB800 + 1,
  170. .flags = IORESOURCE_MEM,
  171. },
  172. [1] = {
  173. .start = 0x203FB804,
  174. .end = 0x203FB804 + 1,
  175. .flags = IORESOURCE_MEM,
  176. },
  177. [2] = {
  178. .start = IRQ_PF9,
  179. .end = IRQ_PF9,
  180. .flags = (IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE),
  181. },
  182. };
  183. static struct platform_device dm9000_device = {
  184. .name = "dm9000",
  185. .id = -1,
  186. .num_resources = ARRAY_SIZE(dm9000_resources),
  187. .resource = dm9000_resources,
  188. };
  189. #endif
  190. #if defined(CONFIG_USB_SL811_HCD) || defined(CONFIG_USB_SL811_HCD_MODULE)
  191. static struct resource sl811_hcd_resources[] = {
  192. {
  193. .start = 0x20340000,
  194. .end = 0x20340000,
  195. .flags = IORESOURCE_MEM,
  196. }, {
  197. .start = 0x20340004,
  198. .end = 0x20340004,
  199. .flags = IORESOURCE_MEM,
  200. }, {
  201. .start = IRQ_PF4,
  202. .end = IRQ_PF4,
  203. .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
  204. },
  205. };
  206. #if defined(CONFIG_USB_SL811_BFIN_USE_VBUS)
  207. void sl811_port_power(struct device *dev, int is_on)
  208. {
  209. gpio_request(CONFIG_USB_SL811_BFIN_GPIO_VBUS, "usb:SL811_VBUS");
  210. gpio_direction_output(CONFIG_USB_SL811_BFIN_GPIO_VBUS, is_on);
  211. }
  212. #endif
  213. static struct sl811_platform_data sl811_priv = {
  214. .potpg = 10,
  215. .power = 250, /* == 500mA */
  216. #if defined(CONFIG_USB_SL811_BFIN_USE_VBUS)
  217. .port_power = &sl811_port_power,
  218. #endif
  219. };
  220. static struct platform_device sl811_hcd_device = {
  221. .name = "sl811-hcd",
  222. .id = 0,
  223. .dev = {
  224. .platform_data = &sl811_priv,
  225. },
  226. .num_resources = ARRAY_SIZE(sl811_hcd_resources),
  227. .resource = sl811_hcd_resources,
  228. };
  229. #endif
  230. #if defined(CONFIG_USB_ISP1362_HCD) || defined(CONFIG_USB_ISP1362_HCD_MODULE)
  231. static struct resource isp1362_hcd_resources[] = {
  232. {
  233. .start = 0x20360000,
  234. .end = 0x20360000,
  235. .flags = IORESOURCE_MEM,
  236. }, {
  237. .start = 0x20360004,
  238. .end = 0x20360004,
  239. .flags = IORESOURCE_MEM,
  240. }, {
  241. .start = IRQ_PF3,
  242. .end = IRQ_PF3,
  243. .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWEDGE,
  244. },
  245. };
  246. static struct isp1362_platform_data isp1362_priv = {
  247. .sel15Kres = 1,
  248. .clknotstop = 0,
  249. .oc_enable = 0,
  250. .int_act_high = 0,
  251. .int_edge_triggered = 0,
  252. .remote_wakeup_connected = 0,
  253. .no_power_switching = 1,
  254. .power_switching_mode = 0,
  255. };
  256. static struct platform_device isp1362_hcd_device = {
  257. .name = "isp1362-hcd",
  258. .id = 0,
  259. .dev = {
  260. .platform_data = &isp1362_priv,
  261. },
  262. .num_resources = ARRAY_SIZE(isp1362_hcd_resources),
  263. .resource = isp1362_hcd_resources,
  264. };
  265. #endif
  266. #if defined(CONFIG_CAN_BFIN) || defined(CONFIG_CAN_BFIN_MODULE)
  267. static unsigned short bfin_can_peripherals[] = {
  268. P_CAN0_RX, P_CAN0_TX, 0
  269. };
  270. static struct resource bfin_can_resources[] = {
  271. {
  272. .start = 0xFFC02A00,
  273. .end = 0xFFC02FFF,
  274. .flags = IORESOURCE_MEM,
  275. },
  276. {
  277. .start = IRQ_CAN_RX,
  278. .end = IRQ_CAN_RX,
  279. .flags = IORESOURCE_IRQ,
  280. },
  281. {
  282. .start = IRQ_CAN_TX,
  283. .end = IRQ_CAN_TX,
  284. .flags = IORESOURCE_IRQ,
  285. },
  286. {
  287. .start = IRQ_CAN_ERROR,
  288. .end = IRQ_CAN_ERROR,
  289. .flags = IORESOURCE_IRQ,
  290. },
  291. };
  292. static struct platform_device bfin_can_device = {
  293. .name = "bfin_can",
  294. .num_resources = ARRAY_SIZE(bfin_can_resources),
  295. .resource = bfin_can_resources,
  296. .dev = {
  297. .platform_data = &bfin_can_peripherals, /* Passed to driver */
  298. },
  299. };
  300. #endif
  301. #if defined(CONFIG_BFIN_MAC) || defined(CONFIG_BFIN_MAC_MODULE)
  302. #include <linux/bfin_mac.h>
  303. static const unsigned short bfin_mac_peripherals[] = P_MII0;
  304. static struct bfin_phydev_platform_data bfin_phydev_data[] = {
  305. {
  306. .addr = 1,
  307. .irq = PHY_POLL, /* IRQ_MAC_PHYINT */
  308. },
  309. };
  310. static struct bfin_mii_bus_platform_data bfin_mii_bus_data = {
  311. .phydev_number = 1,
  312. .phydev_data = bfin_phydev_data,
  313. .phy_mode = PHY_INTERFACE_MODE_MII,
  314. .mac_peripherals = bfin_mac_peripherals,
  315. };
  316. static struct platform_device bfin_mii_bus = {
  317. .name = "bfin_mii_bus",
  318. .dev = {
  319. .platform_data = &bfin_mii_bus_data,
  320. }
  321. };
  322. static struct platform_device bfin_mac_device = {
  323. .name = "bfin_mac",
  324. .dev = {
  325. .platform_data = &bfin_mii_bus,
  326. }
  327. };
  328. #endif
  329. #if defined(CONFIG_USB_NET2272) || defined(CONFIG_USB_NET2272_MODULE)
  330. static struct resource net2272_bfin_resources[] = {
  331. {
  332. .start = 0x20300000,
  333. .end = 0x20300000 + 0x100,
  334. .flags = IORESOURCE_MEM,
  335. }, {
  336. .start = 1,
  337. .flags = IORESOURCE_BUS,
  338. }, {
  339. .start = IRQ_PF7,
  340. .end = IRQ_PF7,
  341. .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
  342. },
  343. };
  344. static struct platform_device net2272_bfin_device = {
  345. .name = "net2272",
  346. .id = -1,
  347. .num_resources = ARRAY_SIZE(net2272_bfin_resources),
  348. .resource = net2272_bfin_resources,
  349. };
  350. #endif
  351. #if defined(CONFIG_MTD_NAND_PLATFORM) || defined(CONFIG_MTD_NAND_PLATFORM_MODULE)
  352. const char *part_probes[] = { "cmdlinepart", "RedBoot", NULL };
  353. static struct mtd_partition bfin_plat_nand_partitions[] = {
  354. {
  355. .name = "linux kernel(nand)",
  356. .size = 0x400000,
  357. .offset = 0,
  358. }, {
  359. .name = "file system(nand)",
  360. .size = MTDPART_SIZ_FULL,
  361. .offset = MTDPART_OFS_APPEND,
  362. },
  363. };
  364. #define BFIN_NAND_PLAT_CLE 2
  365. #define BFIN_NAND_PLAT_ALE 1
  366. static void bfin_plat_nand_cmd_ctrl(struct mtd_info *mtd, int cmd, unsigned int ctrl)
  367. {
  368. struct nand_chip *this = mtd->priv;
  369. if (cmd == NAND_CMD_NONE)
  370. return;
  371. if (ctrl & NAND_CLE)
  372. writeb(cmd, this->IO_ADDR_W + (1 << BFIN_NAND_PLAT_CLE));
  373. else
  374. writeb(cmd, this->IO_ADDR_W + (1 << BFIN_NAND_PLAT_ALE));
  375. }
  376. #define BFIN_NAND_PLAT_READY GPIO_PF3
  377. static int bfin_plat_nand_dev_ready(struct mtd_info *mtd)
  378. {
  379. return gpio_get_value(BFIN_NAND_PLAT_READY);
  380. }
  381. static struct platform_nand_data bfin_plat_nand_data = {
  382. .chip = {
  383. .nr_chips = 1,
  384. .chip_delay = 30,
  385. .part_probe_types = part_probes,
  386. .partitions = bfin_plat_nand_partitions,
  387. .nr_partitions = ARRAY_SIZE(bfin_plat_nand_partitions),
  388. },
  389. .ctrl = {
  390. .cmd_ctrl = bfin_plat_nand_cmd_ctrl,
  391. .dev_ready = bfin_plat_nand_dev_ready,
  392. },
  393. };
  394. #define MAX(x, y) (x > y ? x : y)
  395. static struct resource bfin_plat_nand_resources = {
  396. .start = 0x20212000,
  397. .end = 0x20212000 + (1 << MAX(BFIN_NAND_PLAT_CLE, BFIN_NAND_PLAT_ALE)),
  398. .flags = IORESOURCE_MEM,
  399. };
  400. static struct platform_device bfin_async_nand_device = {
  401. .name = "gen_nand",
  402. .id = -1,
  403. .num_resources = 1,
  404. .resource = &bfin_plat_nand_resources,
  405. .dev = {
  406. .platform_data = &bfin_plat_nand_data,
  407. },
  408. };
  409. static void bfin_plat_nand_init(void)
  410. {
  411. gpio_request(BFIN_NAND_PLAT_READY, "bfin_nand_plat");
  412. }
  413. #else
  414. static void bfin_plat_nand_init(void) {}
  415. #endif
  416. #if defined(CONFIG_MTD_PHYSMAP) || defined(CONFIG_MTD_PHYSMAP_MODULE)
  417. static struct mtd_partition stamp_partitions[] = {
  418. {
  419. .name = "bootloader(nor)",
  420. .size = 0x40000,
  421. .offset = 0,
  422. }, {
  423. .name = "linux kernel(nor)",
  424. .size = 0x180000,
  425. .offset = MTDPART_OFS_APPEND,
  426. }, {
  427. .name = "file system(nor)",
  428. .size = 0x400000 - 0x40000 - 0x180000 - 0x10000,
  429. .offset = MTDPART_OFS_APPEND,
  430. }, {
  431. .name = "MAC Address(nor)",
  432. .size = MTDPART_SIZ_FULL,
  433. .offset = 0x3F0000,
  434. .mask_flags = MTD_WRITEABLE,
  435. }
  436. };
  437. static struct physmap_flash_data stamp_flash_data = {
  438. .width = 2,
  439. .parts = stamp_partitions,
  440. .nr_parts = ARRAY_SIZE(stamp_partitions),
  441. #ifdef CONFIG_ROMKERNEL
  442. .probe_type = "map_rom",
  443. #endif
  444. };
  445. static struct resource stamp_flash_resource = {
  446. .start = 0x20000000,
  447. .end = 0x203fffff,
  448. .flags = IORESOURCE_MEM,
  449. };
  450. static struct platform_device stamp_flash_device = {
  451. .name = "physmap-flash",
  452. .id = 0,
  453. .dev = {
  454. .platform_data = &stamp_flash_data,
  455. },
  456. .num_resources = 1,
  457. .resource = &stamp_flash_resource,
  458. };
  459. #endif
  460. #if defined(CONFIG_MTD_M25P80) \
  461. || defined(CONFIG_MTD_M25P80_MODULE)
  462. static struct mtd_partition bfin_spi_flash_partitions[] = {
  463. {
  464. .name = "bootloader(spi)",
  465. .size = 0x00040000,
  466. .offset = 0,
  467. .mask_flags = MTD_CAP_ROM
  468. }, {
  469. .name = "linux kernel(spi)",
  470. .size = 0x180000,
  471. .offset = MTDPART_OFS_APPEND,
  472. }, {
  473. .name = "file system(spi)",
  474. .size = MTDPART_SIZ_FULL,
  475. .offset = MTDPART_OFS_APPEND,
  476. }
  477. };
  478. static struct flash_platform_data bfin_spi_flash_data = {
  479. .name = "m25p80",
  480. .parts = bfin_spi_flash_partitions,
  481. .nr_parts = ARRAY_SIZE(bfin_spi_flash_partitions),
  482. /* .type = "m25p64", */
  483. };
  484. /* SPI flash chip (m25p64) */
  485. static struct bfin5xx_spi_chip spi_flash_chip_info = {
  486. .enable_dma = 0, /* use dma transfer with this chip*/
  487. };
  488. #endif
  489. #if defined(CONFIG_INPUT_AD714X_SPI) || defined(CONFIG_INPUT_AD714X_SPI_MODULE)
  490. #include <linux/input/ad714x.h>
  491. static struct ad714x_slider_plat ad7147_spi_slider_plat[] = {
  492. {
  493. .start_stage = 0,
  494. .end_stage = 7,
  495. .max_coord = 128,
  496. },
  497. };
  498. static struct ad714x_button_plat ad7147_spi_button_plat[] = {
  499. {
  500. .keycode = BTN_FORWARD,
  501. .l_mask = 0,
  502. .h_mask = 0x600,
  503. },
  504. {
  505. .keycode = BTN_LEFT,
  506. .l_mask = 0,
  507. .h_mask = 0x500,
  508. },
  509. {
  510. .keycode = BTN_MIDDLE,
  511. .l_mask = 0,
  512. .h_mask = 0x800,
  513. },
  514. {
  515. .keycode = BTN_RIGHT,
  516. .l_mask = 0x100,
  517. .h_mask = 0x400,
  518. },
  519. {
  520. .keycode = BTN_BACK,
  521. .l_mask = 0x200,
  522. .h_mask = 0x400,