004-tulip_pci_split.patch 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452
  1. --- a/drivers/net/ethernet/dec/tulip/tulip_core.c
  2. +++ b/drivers/net/ethernet/dec/tulip/tulip_core.c
  3. @@ -207,6 +207,7 @@ struct tulip_chip_table tulip_tbl[] = {
  4. };
  5. +#ifdef CONFIG_TULIP_PCI
  6. static const struct pci_device_id tulip_pci_tbl[] = {
  7. { 0x1011, 0x0009, PCI_ANY_ID, PCI_ANY_ID, 0, 0, DC21140 },
  8. { 0x1011, 0x0019, PCI_ANY_ID, PCI_ANY_ID, 0, 0, DC21143 },
  9. @@ -250,7 +251,7 @@ static const struct pci_device_id tulip_
  10. { } /* terminate list */
  11. };
  12. MODULE_DEVICE_TABLE(pci, tulip_pci_tbl);
  13. -
  14. +#endif
  15. /* A full-duplex map for media types. */
  16. const char tulip_media_cap[32] =
  17. @@ -268,11 +269,14 @@ static void tulip_down(struct net_device
  18. static struct net_device_stats *tulip_get_stats(struct net_device *dev);
  19. static int private_ioctl(struct net_device *dev, struct ifreq *rq, int cmd);
  20. static void set_rx_mode(struct net_device *dev);
  21. +#ifdef CONFIG_TULIP_PCI
  22. static void tulip_set_wolopts(struct pci_dev *pdev, u32 wolopts);
  23. +#endif
  24. #ifdef CONFIG_NET_POLL_CONTROLLER
  25. static void poll_tulip(struct net_device *dev);
  26. #endif
  27. +#ifdef CONFIG_TULIP_PCI
  28. static void tulip_set_power_state (struct tulip_private *tp,
  29. int sleep, int snooze)
  30. {
  31. @@ -289,7 +293,7 @@ static void tulip_set_power_state (struc
  32. }
  33. }
  34. -
  35. +#endif
  36. static void tulip_up(struct net_device *dev)
  37. {
  38. @@ -303,6 +307,7 @@ static void tulip_up(struct net_device *
  39. napi_enable(&tp->napi);
  40. #endif
  41. +#ifdef CONFIG_TULIP_PCI
  42. /* Wake the chip from sleep/snooze mode. */
  43. tulip_set_power_state (tp, 0, 0);
  44. @@ -310,6 +315,7 @@ static void tulip_up(struct net_device *
  45. pci_enable_wake(tp->pdev, PCI_D3hot, 0);
  46. pci_enable_wake(tp->pdev, PCI_D3cold, 0);
  47. tulip_set_wolopts(tp->pdev, 0);
  48. +#endif
  49. /* On some chip revs we must set the MII/SYM port before the reset!? */
  50. if (tp->mii_cnt || (tp->mtable && tp->mtable->has_mii))
  51. @@ -317,18 +323,22 @@ static void tulip_up(struct net_device *
  52. /* Reset the chip, holding bit 0 set at least 50 PCI cycles. */
  53. iowrite32(0x00000001, ioaddr + CSR0);
  54. +#ifdef CONFIG_TULIP_PCI
  55. pci_read_config_dword(tp->pdev, PCI_COMMAND, &reg); /* flush write */
  56. +#endif
  57. udelay(100);
  58. /* Deassert reset.
  59. Wait the specified 50 PCI cycles after a reset by initializing
  60. Tx and Rx queues and the address filter list. */
  61. iowrite32(tp->csr0, ioaddr + CSR0);
  62. +#ifdef CONFIG_TULIP_PCI
  63. pci_read_config_dword(tp->pdev, PCI_COMMAND, &reg); /* flush write */
  64. +#endif
  65. udelay(100);
  66. if (tulip_debug > 1)
  67. - netdev_dbg(dev, "tulip_up(), irq==%d\n", tp->pdev->irq);
  68. + netdev_dbg(dev, "tulip_up(), irq==%d\n", tp->irq);
  69. iowrite32(tp->rx_ring_dma, ioaddr + CSR3);
  70. iowrite32(tp->tx_ring_dma, ioaddr + CSR4);
  71. @@ -362,9 +372,11 @@ static void tulip_up(struct net_device *
  72. *setup_frm++ = eaddrs[1]; *setup_frm++ = eaddrs[1];
  73. *setup_frm++ = eaddrs[2]; *setup_frm++ = eaddrs[2];
  74. +#ifdef CONFIG_TULIP_PCI
  75. mapping = pci_map_single(tp->pdev, tp->setup_frame,
  76. sizeof(tp->setup_frame),
  77. PCI_DMA_TODEVICE);
  78. +#endif
  79. tp->tx_buffers[tp->cur_tx].skb = NULL;
  80. tp->tx_buffers[tp->cur_tx].mapping = mapping;
  81. @@ -520,7 +532,7 @@ tulip_open(struct net_device *dev)
  82. tulip_init_ring (dev);
  83. - retval = request_irq(tp->pdev->irq, tulip_interrupt, IRQF_SHARED,
  84. + retval = request_irq(tp->irq, tulip_interrupt, IRQF_SHARED,
  85. dev->name, dev);
  86. if (retval)
  87. goto free_ring;
  88. @@ -644,8 +656,10 @@ static void tulip_init_ring(struct net_d
  89. tp->rx_buffers[i].skb = skb;
  90. if (skb == NULL)
  91. break;
  92. +#ifdef CONFIG_TULIP_PCI
  93. mapping = pci_map_single(tp->pdev, skb->data,
  94. PKT_BUF_SZ, PCI_DMA_FROMDEVICE);
  95. +#endif
  96. tp->rx_buffers[i].mapping = mapping;
  97. tp->rx_ring[i].status = cpu_to_le32(DescOwned); /* Owned by Tulip chip */
  98. tp->rx_ring[i].buffer1 = cpu_to_le32(mapping);
  99. @@ -678,8 +692,10 @@ tulip_start_xmit(struct sk_buff *skb, st
  100. entry = tp->cur_tx % TX_RING_SIZE;
  101. tp->tx_buffers[entry].skb = skb;
  102. +#ifdef CONFIG_TULIP_PCI
  103. mapping = pci_map_single(tp->pdev, skb->data,
  104. skb->len, PCI_DMA_TODEVICE);
  105. +#endif
  106. tp->tx_buffers[entry].mapping = mapping;
  107. tp->tx_ring[entry].buffer1 = cpu_to_le32(mapping);
  108. @@ -730,16 +746,19 @@ static void tulip_clean_tx_ring(struct t
  109. if (tp->tx_buffers[entry].skb == NULL) {
  110. /* test because dummy frames not mapped */
  111. if (tp->tx_buffers[entry].mapping)
  112. +#ifdef CONFIG_TULIP_PCI
  113. pci_unmap_single(tp->pdev,
  114. tp->tx_buffers[entry].mapping,
  115. sizeof(tp->setup_frame),
  116. PCI_DMA_TODEVICE);
  117. +#endif
  118. continue;
  119. }
  120. -
  121. +#ifdef CONFIG_TULIP_PCI
  122. pci_unmap_single(tp->pdev, tp->tx_buffers[entry].mapping,
  123. tp->tx_buffers[entry].skb->len,
  124. PCI_DMA_TODEVICE);
  125. +#endif
  126. /* Free the original skb. */
  127. dev_kfree_skb_irq(tp->tx_buffers[entry].skb);
  128. @@ -790,7 +809,9 @@ static void tulip_down (struct net_devic
  129. dev->if_port = tp->saved_if_port;
  130. /* Leave the driver in snooze, not sleep, mode. */
  131. +#ifdef CONFIG_TULIP_PCI
  132. tulip_set_power_state (tp, 0, 1);
  133. +#endif
  134. }
  135. static void tulip_free_ring (struct net_device *dev)
  136. @@ -811,8 +832,10 @@ static void tulip_free_ring (struct net_
  137. /* An invalid address. */
  138. tp->rx_ring[i].buffer1 = cpu_to_le32(0xBADF00D0);
  139. if (skb) {
  140. +#ifdef CONFIG_TULIP_PCI
  141. pci_unmap_single(tp->pdev, mapping, PKT_BUF_SZ,
  142. PCI_DMA_FROMDEVICE);
  143. +#endif
  144. dev_kfree_skb (skb);
  145. }
  146. }
  147. @@ -821,8 +844,10 @@ static void tulip_free_ring (struct net_
  148. struct sk_buff *skb = tp->tx_buffers[i].skb;
  149. if (skb != NULL) {
  150. +#ifdef CONFIG_TULIP_PCI
  151. pci_unmap_single(tp->pdev, tp->tx_buffers[i].mapping,
  152. skb->len, PCI_DMA_TODEVICE);
  153. +#endif
  154. dev_kfree_skb (skb);
  155. }
  156. tp->tx_buffers[i].skb = NULL;
  157. @@ -843,7 +868,7 @@ static int tulip_close (struct net_devic
  158. netdev_dbg(dev, "Shutting down ethercard, status was %02x\n",
  159. ioread32 (ioaddr + CSR5));
  160. - free_irq (tp->pdev->irq, dev);
  161. + free_irq (tp->irq, dev);
  162. tulip_free_ring (dev);
  163. @@ -874,7 +899,9 @@ static void tulip_get_drvinfo(struct net
  164. struct tulip_private *np = netdev_priv(dev);
  165. strlcpy(info->driver, DRV_NAME, sizeof(info->driver));
  166. strlcpy(info->version, DRV_VERSION, sizeof(info->version));
  167. +#ifdef CONFIG_TULIP_PCI
  168. strlcpy(info->bus_info, pci_name(np->pdev), sizeof(info->bus_info));
  169. +#endif
  170. }
  171. @@ -887,7 +914,9 @@ static int tulip_ethtool_set_wol(struct
  172. return -EOPNOTSUPP;
  173. tp->wolinfo.wolopts = wolinfo->wolopts;
  174. - device_set_wakeup_enable(&tp->pdev->dev, tp->wolinfo.wolopts);
  175. +#ifdef CONFIG_TULIP_PCI
  176. + device_set_wakeup_enable(tp->kdev, tp->wolinfo.wolopts);
  177. +#endif
  178. return 0;
  179. }
  180. @@ -1165,9 +1194,11 @@ static void set_rx_mode(struct net_devic
  181. tp->tx_buffers[entry].skb = NULL;
  182. tp->tx_buffers[entry].mapping =
  183. +#ifdef CONFIG_TULIP_PCI
  184. pci_map_single(tp->pdev, tp->setup_frame,
  185. sizeof(tp->setup_frame),
  186. PCI_DMA_TODEVICE);
  187. +#endif
  188. /* Put the setup frame on the Tx list. */
  189. if (entry == TX_RING_SIZE-1)
  190. tx_flags |= DESC_RING_WRAP; /* Wrap ring. */
  191. @@ -1264,19 +1295,22 @@ out:
  192. netdev_dbg(dev, "MWI config cacheline=%d, csr0=%08x\n",
  193. cache, csr0);
  194. }
  195. -#endif
  196. /*
  197. * Chips that have the MRM/reserved bit quirk and the burst quirk. That
  198. * is the DM910X and the on chip ULi devices
  199. */
  200. +#endif
  201. +#ifdef CONFIG_TULIP_PCI
  202. static int tulip_uli_dm_quirk(struct pci_dev *pdev)
  203. {
  204. if (pdev->vendor == 0x1282 && pdev->device == 0x9102)
  205. return 1;
  206. return 0;
  207. }
  208. +#endif
  209. +
  210. static const struct net_device_ops tulip_netdev_ops = {
  211. .ndo_open = tulip_open,
  212. @@ -1294,6 +1328,7 @@ static const struct net_device_ops tulip
  213. #endif
  214. };
  215. +#ifdef CONFIG_TULIP_PCI
  216. const struct pci_device_id early_486_chipsets[] = {
  217. { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82424) },
  218. { PCI_DEVICE(PCI_VENDOR_ID_SI, PCI_DEVICE_ID_SI_496) },
  219. @@ -1471,6 +1506,8 @@ static int tulip_init_one(struct pci_dev
  220. }
  221. }
  222. tp->pdev = pdev;
  223. + tp->kdev = &pdev->dev;
  224. + tp->irq = irq;
  225. tp->base_addr = ioaddr;
  226. tp->revision = pdev->revision;
  227. tp->csr0 = csr0;
  228. @@ -1801,6 +1838,7 @@ err_out_free_netdev:
  229. }
  230. +#ifdef CONFIG_TULIP_PCI
  231. /* set the registers according to the given wolopts */
  232. static void tulip_set_wolopts (struct pci_dev *pdev, u32 wolopts)
  233. {
  234. @@ -1829,6 +1867,7 @@ static void tulip_set_wolopts (struct pc
  235. iowrite32(tmp, ioaddr + CSR13);
  236. }
  237. }
  238. +#endif
  239. #ifdef CONFIG_PM
  240. @@ -1943,6 +1982,7 @@ static void tulip_remove_one(struct pci_
  241. /* pci_power_off (pdev, -1); */
  242. }
  243. +#endif /* CONFIG_TULIP_PCI */
  244. #ifdef CONFIG_NET_POLL_CONTROLLER
  245. /*
  246. @@ -1964,7 +2004,8 @@ static void poll_tulip (struct net_devic
  247. }
  248. #endif
  249. -static struct pci_driver tulip_driver = {
  250. +#ifdef CONFIG_TULIP_PCI
  251. +static struct pci_driver tulip_pci_driver = {
  252. .name = DRV_NAME,
  253. .id_table = tulip_pci_tbl,
  254. .probe = tulip_init_one,
  255. @@ -1974,10 +2015,12 @@ static struct pci_driver tulip_driver =
  256. .resume = tulip_resume,
  257. #endif /* CONFIG_PM */
  258. };
  259. +#endif
  260. static int __init tulip_init (void)
  261. {
  262. + int ret = 0;
  263. #ifdef MODULE
  264. pr_info("%s", version);
  265. #endif
  266. @@ -1987,13 +2030,18 @@ static int __init tulip_init (void)
  267. tulip_max_interrupt_work = max_interrupt_work;
  268. /* probe for and init boards */
  269. - return pci_register_driver(&tulip_driver);
  270. +#ifdef CONFIG_TULIP_PCI
  271. + ret = pci_register_driver(&tulip_pci_driver);
  272. +#endif
  273. + return ret;
  274. }
  275. static void __exit tulip_cleanup (void)
  276. {
  277. - pci_unregister_driver (&tulip_driver);
  278. +#ifdef CONFIG_TULIP_PCI
  279. + pci_unregister_driver (&tulip_pci_driver);
  280. +#endif
  281. }
  282. --- a/drivers/net/ethernet/dec/tulip/interrupt.c
  283. +++ b/drivers/net/ethernet/dec/tulip/interrupt.c
  284. @@ -73,10 +73,11 @@ int tulip_refill_rx(struct net_device *d
  285. netdev_alloc_skb(dev, PKT_BUF_SZ);
  286. if (skb == NULL)
  287. break;
  288. -
  289. +#ifdef CONFIG_TULIP_PCI
  290. mapping = pci_map_single(tp->pdev, skb->data, PKT_BUF_SZ,
  291. PCI_DMA_FROMDEVICE);
  292. - if (dma_mapping_error(&tp->pdev->dev, mapping)) {
  293. +#endif
  294. + if (dma_mapping_error(tp->kdev, mapping)) {
  295. dev_kfree_skb(skb);
  296. tp->rx_buffers[entry].skb = NULL;
  297. break;
  298. @@ -210,9 +211,11 @@ int tulip_poll(struct napi_struct *napi,
  299. if (pkt_len < tulip_rx_copybreak &&
  300. (skb = netdev_alloc_skb(dev, pkt_len + 2)) != NULL) {
  301. skb_reserve(skb, 2); /* 16 byte align the IP header */
  302. +#ifdef CONFIG_TULIP_PCI
  303. pci_dma_sync_single_for_cpu(tp->pdev,
  304. tp->rx_buffers[entry].mapping,
  305. pkt_len, PCI_DMA_FROMDEVICE);
  306. +#endif
  307. #if ! defined(__alpha__)
  308. skb_copy_to_linear_data(skb, tp->rx_buffers[entry].skb->data,
  309. pkt_len);
  310. @@ -222,9 +225,11 @@ int tulip_poll(struct napi_struct *napi,
  311. tp->rx_buffers[entry].skb->data,
  312. pkt_len);
  313. #endif
  314. +#ifdef CONFIG_TULIP_PCI
  315. pci_dma_sync_single_for_device(tp->pdev,
  316. tp->rx_buffers[entry].mapping,
  317. pkt_len, PCI_DMA_FROMDEVICE);
  318. +#endif
  319. } else { /* Pass up the skb already on the Rx ring. */
  320. char *temp = skb_put(skb = tp->rx_buffers[entry].skb,
  321. pkt_len);
  322. @@ -239,9 +244,10 @@ int tulip_poll(struct napi_struct *napi,
  323. skb->head, temp);
  324. }
  325. #endif
  326. -
  327. +#ifdef CONFIG_TULIP_PCI
  328. pci_unmap_single(tp->pdev, tp->rx_buffers[entry].mapping,
  329. PKT_BUF_SZ, PCI_DMA_FROMDEVICE);
  330. +#endif
  331. tp->rx_buffers[entry].skb = NULL;
  332. tp->rx_buffers[entry].mapping = 0;
  333. @@ -597,10 +603,12 @@ irqreturn_t tulip_interrupt(int irq, voi
  334. if (tp->tx_buffers[entry].skb == NULL) {
  335. /* test because dummy frames not mapped */
  336. if (tp->tx_buffers[entry].mapping)
  337. +#ifdef CONFIG_TULIP_PCI
  338. pci_unmap_single(tp->pdev,
  339. tp->tx_buffers[entry].mapping,
  340. sizeof(tp->setup_frame),
  341. PCI_DMA_TODEVICE);
  342. +#endif
  343. continue;
  344. }
  345. @@ -628,10 +636,11 @@ irqreturn_t tulip_interrupt(int irq, voi
  346. dev->stats.collisions += (status >> 3) & 15;
  347. dev->stats.tx_packets++;
  348. }
  349. -
  350. +#ifdef CONFIG_TULIP_PCI
  351. pci_unmap_single(tp->pdev, tp->tx_buffers[entry].mapping,
  352. tp->tx_buffers[entry].skb->len,
  353. PCI_DMA_TODEVICE);
  354. +#endif
  355. /* Free the original skb. */
  356. dev_kfree_skb_irq(tp->tx_buffers[entry].skb);
  357. --- a/drivers/net/ethernet/dec/tulip/Kconfig
  358. +++ b/drivers/net/ethernet/dec/tulip/Kconfig
  359. @@ -40,8 +40,12 @@ config DE2104X_DSL
  360. Default is 0, and range is 0 to 31.
  361. config TULIP
  362. + tristate
  363. +
  364. +config TULIP_PCI
  365. tristate "DECchip Tulip (dc2114x) PCI support"
  366. depends on PCI
  367. + select TULIP
  368. select CRC32
  369. ---help---
  370. This driver is developed for the SMC EtherPower series Ethernet
  371. @@ -58,7 +62,7 @@ config TULIP
  372. config TULIP_MWI
  373. bool "New bus configuration"
  374. - depends on TULIP
  375. + depends on TULIP_PCI
  376. ---help---
  377. This configures your Tulip card specifically for the card and
  378. system cache line size type you are using.
  379. @@ -69,7 +73,7 @@ config TULIP_MWI
  380. config TULIP_MMIO
  381. bool "Use PCI shared mem for NIC registers"
  382. - depends on TULIP
  383. + depends on TULIP_PCI
  384. ---help---
  385. Use PCI shared memory for the NIC registers, rather than going through
  386. the Tulip's PIO (programmed I/O ports). Faster, but could produce
  387. --- a/drivers/net/ethernet/dec/tulip/tulip.h
  388. +++ b/drivers/net/ethernet/dec/tulip/tulip.h
  389. @@ -447,6 +447,8 @@ struct tulip_private {
  390. int cur_index; /* Current media index. */
  391. int saved_if_port;
  392. struct pci_dev *pdev;
  393. + struct device *kdev;
  394. + int irq;
  395. int ttimer;
  396. int susp_rx;
  397. unsigned long nir;