aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/sunhme.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net/sunhme.c')
-rw-r--r--drivers/net/sunhme.c85
1 files changed, 34 insertions, 51 deletions
diff --git a/drivers/net/sunhme.c b/drivers/net/sunhme.c
index cd93fc5e826a..69cc77192961 100644
--- a/drivers/net/sunhme.c
+++ b/drivers/net/sunhme.c
@@ -34,6 +34,7 @@
34#include <linux/skbuff.h> 34#include <linux/skbuff.h>
35#include <linux/mm.h> 35#include <linux/mm.h>
36#include <linux/bitops.h> 36#include <linux/bitops.h>
37#include <linux/dma-mapping.h>
37 38
38#include <asm/system.h> 39#include <asm/system.h>
39#include <asm/io.h> 40#include <asm/io.h>
@@ -277,13 +278,13 @@ do { (__txd)->tx_addr = (__force hme32)(u32)(__addr); \
277} while(0) 278} while(0)
278#define hme_read_desc32(__hp, __p) ((__force u32)(hme32)*(__p)) 279#define hme_read_desc32(__hp, __p) ((__force u32)(hme32)*(__p))
279#define hme_dma_map(__hp, __ptr, __size, __dir) \ 280#define hme_dma_map(__hp, __ptr, __size, __dir) \
280 sbus_map_single((__hp)->dma_dev, (__ptr), (__size), (__dir)) 281 dma_map_single((__hp)->dma_dev, (__ptr), (__size), (__dir))
281#define hme_dma_unmap(__hp, __addr, __size, __dir) \ 282#define hme_dma_unmap(__hp, __addr, __size, __dir) \
282 sbus_unmap_single((__hp)->dma_dev, (__addr), (__size), (__dir)) 283 dma_unmap_single((__hp)->dma_dev, (__addr), (__size), (__dir))
283#define hme_dma_sync_for_cpu(__hp, __addr, __size, __dir) \ 284#define hme_dma_sync_for_cpu(__hp, __addr, __size, __dir) \
284 sbus_dma_sync_single_for_cpu((__hp)->dma_dev, (__addr), (__size), (__dir)) 285 dma_dma_sync_single_for_cpu((__hp)->dma_dev, (__addr), (__size), (__dir))
285#define hme_dma_sync_for_device(__hp, __addr, __size, __dir) \ 286#define hme_dma_sync_for_device(__hp, __addr, __size, __dir) \
286 sbus_dma_sync_single_for_device((__hp)->dma_dev, (__addr), (__size), (__dir)) 287 dma_dma_sync_single_for_device((__hp)->dma_dev, (__addr), (__size), (__dir))
287#else 288#else
288/* PCI only compilation */ 289/* PCI only compilation */
289#define hme_write32(__hp, __reg, __val) \ 290#define hme_write32(__hp, __reg, __val) \
@@ -316,25 +317,6 @@ static inline u32 hme_read_desc32(struct happy_meal *hp, hme32 *p)
316#endif 317#endif
317 318
318 319
319#ifdef SBUS_DMA_BIDIRECTIONAL
320# define DMA_BIDIRECTIONAL SBUS_DMA_BIDIRECTIONAL
321#else
322# define DMA_BIDIRECTIONAL 0
323#endif
324
325#ifdef SBUS_DMA_FROMDEVICE
326# define DMA_FROMDEVICE SBUS_DMA_FROMDEVICE
327#else
328# define DMA_TODEVICE 1
329#endif
330
331#ifdef SBUS_DMA_TODEVICE
332# define DMA_TODEVICE SBUS_DMA_TODEVICE
333#else
334# define DMA_FROMDEVICE 2
335#endif
336
337
338/* Oh yes, the MIF BitBang is mighty fun to program. BitBucket is more like it. */ 320/* Oh yes, the MIF BitBang is mighty fun to program. BitBucket is more like it. */
339static void BB_PUT_BIT(struct happy_meal *hp, void __iomem *tregs, int bit) 321static void BB_PUT_BIT(struct happy_meal *hp, void __iomem *tregs, int bit)
340{ 322{
@@ -1224,7 +1206,7 @@ static void happy_meal_clean_rings(struct happy_meal *hp)
1224 1206
1225 rxd = &hp->happy_block->happy_meal_rxd[i]; 1207 rxd = &hp->happy_block->happy_meal_rxd[i];
1226 dma_addr = hme_read_desc32(hp, &rxd->rx_addr); 1208 dma_addr = hme_read_desc32(hp, &rxd->rx_addr);
1227 hme_dma_unmap(hp, dma_addr, RX_BUF_ALLOC_SIZE, DMA_FROMDEVICE); 1209 hme_dma_unmap(hp, dma_addr, RX_BUF_ALLOC_SIZE, DMA_FROM_DEVICE);
1228 dev_kfree_skb_any(skb); 1210 dev_kfree_skb_any(skb);
1229 hp->rx_skbs[i] = NULL; 1211 hp->rx_skbs[i] = NULL;
1230 } 1212 }
@@ -1245,7 +1227,7 @@ static void happy_meal_clean_rings(struct happy_meal *hp)
1245 hme_dma_unmap(hp, dma_addr, 1227 hme_dma_unmap(hp, dma_addr,
1246 (hme_read_desc32(hp, &txd->tx_flags) 1228 (hme_read_desc32(hp, &txd->tx_flags)
1247 & TXFLAG_SIZE), 1229 & TXFLAG_SIZE),
1248 DMA_TODEVICE); 1230 DMA_TO_DEVICE);
1249 1231
1250 if (frag != skb_shinfo(skb)->nr_frags) 1232 if (frag != skb_shinfo(skb)->nr_frags)
1251 i++; 1233 i++;
@@ -1287,7 +1269,7 @@ static void happy_meal_init_rings(struct happy_meal *hp)
1287 skb_put(skb, (ETH_FRAME_LEN + RX_OFFSET + 4)); 1269 skb_put(skb, (ETH_FRAME_LEN + RX_OFFSET + 4));
1288 hme_write_rxd(hp, &hb->happy_meal_rxd[i], 1270 hme_write_rxd(hp, &hb->happy_meal_rxd[i],
1289 (RXFLAG_OWN | ((RX_BUF_ALLOC_SIZE - RX_OFFSET) << 16)), 1271 (RXFLAG_OWN | ((RX_BUF_ALLOC_SIZE - RX_OFFSET) << 16)),
1290 hme_dma_map(hp, skb->data, RX_BUF_ALLOC_SIZE, DMA_FROMDEVICE)); 1272 hme_dma_map(hp, skb->data, RX_BUF_ALLOC_SIZE, DMA_FROM_DEVICE));
1291 skb_reserve(skb, RX_OFFSET); 1273 skb_reserve(skb, RX_OFFSET);
1292 } 1274 }
1293 1275
@@ -1966,7 +1948,7 @@ static void happy_meal_tx(struct happy_meal *hp)
1966 dma_len = hme_read_desc32(hp, &this->tx_flags); 1948 dma_len = hme_read_desc32(hp, &this->tx_flags);
1967 1949
1968 dma_len &= TXFLAG_SIZE; 1950 dma_len &= TXFLAG_SIZE;
1969 hme_dma_unmap(hp, dma_addr, dma_len, DMA_TODEVICE); 1951 hme_dma_unmap(hp, dma_addr, dma_len, DMA_TO_DEVICE);
1970 1952
1971 elem = NEXT_TX(elem); 1953 elem = NEXT_TX(elem);
1972 this = &txbase[elem]; 1954 this = &txbase[elem];
@@ -2044,13 +2026,13 @@ static void happy_meal_rx(struct happy_meal *hp, struct net_device *dev)
2044 drops++; 2026 drops++;
2045 goto drop_it; 2027 goto drop_it;
2046 } 2028 }
2047 hme_dma_unmap(hp, dma_addr, RX_BUF_ALLOC_SIZE, DMA_FROMDEVICE); 2029 hme_dma_unmap(hp, dma_addr, RX_BUF_ALLOC_SIZE, DMA_FROM_DEVICE);
2048 hp->rx_skbs[elem] = new_skb; 2030 hp->rx_skbs[elem] = new_skb;
2049 new_skb->dev = dev; 2031 new_skb->dev = dev;
2050 skb_put(new_skb, (ETH_FRAME_LEN + RX_OFFSET + 4)); 2032 skb_put(new_skb, (ETH_FRAME_LEN + RX_OFFSET + 4));
2051 hme_write_rxd(hp, this, 2033 hme_write_rxd(hp, this,
2052 (RXFLAG_OWN|((RX_BUF_ALLOC_SIZE-RX_OFFSET)<<16)), 2034 (RXFLAG_OWN|((RX_BUF_ALLOC_SIZE-RX_OFFSET)<<16)),
2053 hme_dma_map(hp, new_skb->data, RX_BUF_ALLOC_SIZE, DMA_FROMDEVICE)); 2035 hme_dma_map(hp, new_skb->data, RX_BUF_ALLOC_SIZE, DMA_FROM_DEVICE));
2054 skb_reserve(new_skb, RX_OFFSET); 2036 skb_reserve(new_skb, RX_OFFSET);
2055 2037
2056 /* Trim the original skb for the netif. */ 2038 /* Trim the original skb for the netif. */
@@ -2065,9 +2047,9 @@ static void happy_meal_rx(struct happy_meal *hp, struct net_device *dev)
2065 2047
2066 skb_reserve(copy_skb, 2); 2048 skb_reserve(copy_skb, 2);
2067 skb_put(copy_skb, len); 2049 skb_put(copy_skb, len);
2068 hme_dma_sync_for_cpu(hp, dma_addr, len, DMA_FROMDEVICE); 2050 hme_dma_sync_for_cpu(hp, dma_addr, len, DMA_FROM_DEVICE);
2069 skb_copy_from_linear_data(skb, copy_skb->data, len); 2051 skb_copy_from_linear_data(skb, copy_skb->data, len);
2070 hme_dma_sync_for_device(hp, dma_addr, len, DMA_FROMDEVICE); 2052 hme_dma_sync_for_device(hp, dma_addr, len, DMA_FROM_DEVICE);
2071 2053
2072 /* Reuse original ring buffer. */ 2054 /* Reuse original ring buffer. */
2073 hme_write_rxd(hp, this, 2055 hme_write_rxd(hp, this,
@@ -2300,7 +2282,7 @@ static int happy_meal_start_xmit(struct sk_buff *skb, struct net_device *dev)
2300 u32 mapping, len; 2282 u32 mapping, len;
2301 2283
2302 len = skb->len; 2284 len = skb->len;
2303 mapping = hme_dma_map(hp, skb->data, len, DMA_TODEVICE); 2285 mapping = hme_dma_map(hp, skb->data, len, DMA_TO_DEVICE);
2304 tx_flags |= (TXFLAG_SOP | TXFLAG_EOP); 2286 tx_flags |= (TXFLAG_SOP | TXFLAG_EOP);
2305 hme_write_txd(hp, &hp->happy_block->happy_meal_txd[entry], 2287 hme_write_txd(hp, &hp->happy_block->happy_meal_txd[entry],
2306 (tx_flags | (len & TXFLAG_SIZE)), 2288 (tx_flags | (len & TXFLAG_SIZE)),
@@ -2314,7 +2296,7 @@ static int happy_meal_start_xmit(struct sk_buff *skb, struct net_device *dev)
2314 * Otherwise we could race with the device. 2296 * Otherwise we could race with the device.
2315 */ 2297 */
2316 first_len = skb_headlen(skb); 2298 first_len = skb_headlen(skb);
2317 first_mapping = hme_dma_map(hp, skb->data, first_len, DMA_TODEVICE); 2299 first_mapping = hme_dma_map(hp, skb->data, first_len, DMA_TO_DEVICE);
2318 entry = NEXT_TX(entry); 2300 entry = NEXT_TX(entry);
2319 2301
2320 for (frag = 0; frag < skb_shinfo(skb)->nr_frags; frag++) { 2302 for (frag = 0; frag < skb_shinfo(skb)->nr_frags; frag++) {
@@ -2325,7 +2307,7 @@ static int happy_meal_start_xmit(struct sk_buff *skb, struct net_device *dev)
2325 mapping = hme_dma_map(hp, 2307 mapping = hme_dma_map(hp,
2326 ((void *) page_address(this_frag->page) + 2308 ((void *) page_address(this_frag->page) +
2327 this_frag->page_offset), 2309 this_frag->page_offset),
2328 len, DMA_TODEVICE); 2310 len, DMA_TO_DEVICE);
2329 this_txflags = tx_flags; 2311 this_txflags = tx_flags;
2330 if (frag == skb_shinfo(skb)->nr_frags - 1) 2312 if (frag == skb_shinfo(skb)->nr_frags - 1)
2331 this_txflags |= TXFLAG_EOP; 2313 this_txflags |= TXFLAG_EOP;
@@ -2786,9 +2768,10 @@ static int __devinit happy_meal_sbus_probe_one(struct sbus_dev *sdev, int is_qfe
2786 hp->happy_bursts = of_getintprop_default(sdev->bus->ofdev.node, 2768 hp->happy_bursts = of_getintprop_default(sdev->bus->ofdev.node,
2787 "burst-sizes", 0x00); 2769 "burst-sizes", 0x00);
2788 2770
2789 hp->happy_block = sbus_alloc_consistent(hp->dma_dev, 2771 hp->happy_block = dma_alloc_coherent(hp->dma_dev,
2790 PAGE_SIZE, 2772 PAGE_SIZE,
2791 &hp->hblock_dvma); 2773 &hp->hblock_dvma,
2774 GFP_ATOMIC);
2792 err = -ENOMEM; 2775 err = -ENOMEM;
2793 if (!hp->happy_block) { 2776 if (!hp->happy_block) {
2794 printk(KERN_ERR "happymeal: Cannot allocate descriptors.\n"); 2777 printk(KERN_ERR "happymeal: Cannot allocate descriptors.\n");
@@ -2824,12 +2807,12 @@ static int __devinit happy_meal_sbus_probe_one(struct sbus_dev *sdev, int is_qfe
2824 hp->read_desc32 = sbus_hme_read_desc32; 2807 hp->read_desc32 = sbus_hme_read_desc32;
2825 hp->write_txd = sbus_hme_write_txd; 2808 hp->write_txd = sbus_hme_write_txd;
2826 hp->write_rxd = sbus_hme_write_rxd; 2809 hp->write_rxd = sbus_hme_write_rxd;
2827 hp->dma_map = (u32 (*)(void *, void *, long, int))sbus_map_single; 2810 hp->dma_map = (u32 (*)(void *, void *, long, int))dma_map_single;
2828 hp->dma_unmap = (void (*)(void *, u32, long, int))sbus_unmap_single; 2811 hp->dma_unmap = (void (*)(void *, u32, long, int))dma_unmap_single;
2829 hp->dma_sync_for_cpu = (void (*)(void *, u32, long, int)) 2812 hp->dma_sync_for_cpu = (void (*)(void *, u32, long, int))
2830 sbus_dma_sync_single_for_cpu; 2813 dma_sync_single_for_cpu;
2831 hp->dma_sync_for_device = (void (*)(void *, u32, long, int)) 2814 hp->dma_sync_for_device = (void (*)(void *, u32, long, int))
2832 sbus_dma_sync_single_for_device; 2815 dma_sync_single_for_device;
2833 hp->read32 = sbus_hme_read32; 2816 hp->read32 = sbus_hme_read32;
2834 hp->write32 = sbus_hme_write32; 2817 hp->write32 = sbus_hme_write32;
2835#endif 2818#endif
@@ -2844,7 +2827,7 @@ static int __devinit happy_meal_sbus_probe_one(struct sbus_dev *sdev, int is_qfe
2844 if (register_netdev(hp->dev)) { 2827 if (register_netdev(hp->dev)) {
2845 printk(KERN_ERR "happymeal: Cannot register net device, " 2828 printk(KERN_ERR "happymeal: Cannot register net device, "
2846 "aborting.\n"); 2829 "aborting.\n");
2847 goto err_out_free_consistent; 2830 goto err_out_free_coherent;
2848 } 2831 }
2849 2832
2850 dev_set_drvdata(&sdev->ofdev.dev, hp); 2833 dev_set_drvdata(&sdev->ofdev.dev, hp);
@@ -2860,11 +2843,11 @@ static int __devinit happy_meal_sbus_probe_one(struct sbus_dev *sdev, int is_qfe
2860 2843
2861 return 0; 2844 return 0;
2862 2845
2863err_out_free_consistent: 2846err_out_free_coherent:
2864 sbus_free_consistent(hp->dma_dev, 2847 dma_free_coherent(hp->dma_dev,
2865 PAGE_SIZE, 2848 PAGE_SIZE,
2866 hp->happy_block, 2849 hp->happy_block,
2867 hp->hblock_dvma); 2850 hp->hblock_dvma);
2868 2851
2869err_out_iounmap: 2852err_out_iounmap:
2870 if (hp->gregs) 2853 if (hp->gregs)
@@ -3308,10 +3291,10 @@ static int __devexit hme_sbus_remove(struct of_device *dev)
3308 sbus_iounmap(hp->erxregs, ERX_REG_SIZE); 3291 sbus_iounmap(hp->erxregs, ERX_REG_SIZE);
3309 sbus_iounmap(hp->bigmacregs, BMAC_REG_SIZE); 3292 sbus_iounmap(hp->bigmacregs, BMAC_REG_SIZE);
3310 sbus_iounmap(hp->tcvregs, TCVR_REG_SIZE); 3293 sbus_iounmap(hp->tcvregs, TCVR_REG_SIZE);
3311 sbus_free_consistent(hp->dma_dev, 3294 dma_free_coherent(hp->dma_dev,
3312 PAGE_SIZE, 3295 PAGE_SIZE,
3313 hp->happy_block, 3296 hp->happy_block,
3314 hp->hblock_dvma); 3297 hp->hblock_dvma);
3315 3298
3316 free_netdev(net_dev); 3299 free_netdev(net_dev);
3317 3300