diff options
author | David S. Miller <davem@davemloft.net> | 2008-08-29 05:14:29 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2008-08-29 05:14:29 -0400 |
commit | db1a8611c8733711b40bbce11c87336e3e374634 (patch) | |
tree | 4a8ca5d6cb6852231d8d7789885bc5c5df547a7e /drivers | |
parent | 8ef2175c86821350775718bfe7d3490bbea2e3cf (diff) |
sunhme: Convert to pure OF driver.
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/net/sunhme.c | 243 | ||||
-rw-r--r-- | drivers/net/sunhme.h | 8 |
2 files changed, 97 insertions, 154 deletions
diff --git a/drivers/net/sunhme.c b/drivers/net/sunhme.c index d15da947c56a..dc46e97ac122 100644 --- a/drivers/net/sunhme.c +++ b/drivers/net/sunhme.c | |||
@@ -3,7 +3,7 @@ | |||
3 | * "Happy Meal Ethernet" found on SunSwift SBUS cards. | 3 | * "Happy Meal Ethernet" found on SunSwift SBUS cards. |
4 | * | 4 | * |
5 | * Copyright (C) 1996, 1998, 1999, 2002, 2003, | 5 | * Copyright (C) 1996, 1998, 1999, 2002, 2003, |
6 | 2006 David S. Miller (davem@davemloft.net) | 6 | * 2006, 2008 David S. Miller (davem@davemloft.net) |
7 | * | 7 | * |
8 | * Changes : | 8 | * Changes : |
9 | * 2000/11/11 Willy Tarreau <willy AT meta-x.org> | 9 | * 2000/11/11 Willy Tarreau <willy AT meta-x.org> |
@@ -42,8 +42,9 @@ | |||
42 | #include <asm/byteorder.h> | 42 | #include <asm/byteorder.h> |
43 | 43 | ||
44 | #ifdef CONFIG_SPARC | 44 | #ifdef CONFIG_SPARC |
45 | #include <linux/of.h> | ||
46 | #include <linux/of_device.h> | ||
45 | #include <asm/idprom.h> | 47 | #include <asm/idprom.h> |
46 | #include <asm/sbus.h> | ||
47 | #include <asm/openprom.h> | 48 | #include <asm/openprom.h> |
48 | #include <asm/oplib.h> | 49 | #include <asm/oplib.h> |
49 | #include <asm/prom.h> | 50 | #include <asm/prom.h> |
@@ -61,8 +62,8 @@ | |||
61 | #include "sunhme.h" | 62 | #include "sunhme.h" |
62 | 63 | ||
63 | #define DRV_NAME "sunhme" | 64 | #define DRV_NAME "sunhme" |
64 | #define DRV_VERSION "3.00" | 65 | #define DRV_VERSION "3.10" |
65 | #define DRV_RELDATE "June 23, 2006" | 66 | #define DRV_RELDATE "August 26, 2008" |
66 | #define DRV_AUTHOR "David S. Miller (davem@davemloft.net)" | 67 | #define DRV_AUTHOR "David S. Miller (davem@davemloft.net)" |
67 | 68 | ||
68 | static char version[] = | 69 | static char version[] = |
@@ -1206,7 +1207,8 @@ static void happy_meal_clean_rings(struct happy_meal *hp) | |||
1206 | 1207 | ||
1207 | rxd = &hp->happy_block->happy_meal_rxd[i]; | 1208 | rxd = &hp->happy_block->happy_meal_rxd[i]; |
1208 | dma_addr = hme_read_desc32(hp, &rxd->rx_addr); | 1209 | dma_addr = hme_read_desc32(hp, &rxd->rx_addr); |
1209 | hme_dma_unmap(hp, dma_addr, RX_BUF_ALLOC_SIZE, DMA_FROM_DEVICE); | 1210 | dma_unmap_single(hp->dma_dev, dma_addr, |
1211 | RX_BUF_ALLOC_SIZE, DMA_FROM_DEVICE); | ||
1210 | dev_kfree_skb_any(skb); | 1212 | dev_kfree_skb_any(skb); |
1211 | hp->rx_skbs[i] = NULL; | 1213 | hp->rx_skbs[i] = NULL; |
1212 | } | 1214 | } |
@@ -1224,10 +1226,10 @@ static void happy_meal_clean_rings(struct happy_meal *hp) | |||
1224 | for (frag = 0; frag <= skb_shinfo(skb)->nr_frags; frag++) { | 1226 | for (frag = 0; frag <= skb_shinfo(skb)->nr_frags; frag++) { |
1225 | txd = &hp->happy_block->happy_meal_txd[i]; | 1227 | txd = &hp->happy_block->happy_meal_txd[i]; |
1226 | dma_addr = hme_read_desc32(hp, &txd->tx_addr); | 1228 | dma_addr = hme_read_desc32(hp, &txd->tx_addr); |
1227 | hme_dma_unmap(hp, dma_addr, | 1229 | dma_unmap_single(hp->dma_dev, dma_addr, |
1228 | (hme_read_desc32(hp, &txd->tx_flags) | 1230 | (hme_read_desc32(hp, &txd->tx_flags) |
1229 | & TXFLAG_SIZE), | 1231 | & TXFLAG_SIZE), |
1230 | DMA_TO_DEVICE); | 1232 | DMA_TO_DEVICE); |
1231 | 1233 | ||
1232 | if (frag != skb_shinfo(skb)->nr_frags) | 1234 | if (frag != skb_shinfo(skb)->nr_frags) |
1233 | i++; | 1235 | i++; |
@@ -1269,7 +1271,8 @@ static void happy_meal_init_rings(struct happy_meal *hp) | |||
1269 | skb_put(skb, (ETH_FRAME_LEN + RX_OFFSET + 4)); | 1271 | skb_put(skb, (ETH_FRAME_LEN + RX_OFFSET + 4)); |
1270 | hme_write_rxd(hp, &hb->happy_meal_rxd[i], | 1272 | hme_write_rxd(hp, &hb->happy_meal_rxd[i], |
1271 | (RXFLAG_OWN | ((RX_BUF_ALLOC_SIZE - RX_OFFSET) << 16)), | 1273 | (RXFLAG_OWN | ((RX_BUF_ALLOC_SIZE - RX_OFFSET) << 16)), |
1272 | hme_dma_map(hp, skb->data, RX_BUF_ALLOC_SIZE, DMA_FROM_DEVICE)); | 1274 | dma_map_single(hp->dma_dev, skb->data, RX_BUF_ALLOC_SIZE, |
1275 | DMA_FROM_DEVICE)); | ||
1273 | skb_reserve(skb, RX_OFFSET); | 1276 | skb_reserve(skb, RX_OFFSET); |
1274 | } | 1277 | } |
1275 | 1278 | ||
@@ -1586,9 +1589,9 @@ static int happy_meal_init(struct happy_meal *hp) | |||
1586 | */ | 1589 | */ |
1587 | #ifdef CONFIG_SBUS | 1590 | #ifdef CONFIG_SBUS |
1588 | if ((hp->happy_flags & HFLAG_PCI) == 0) { | 1591 | if ((hp->happy_flags & HFLAG_PCI) == 0) { |
1589 | struct sbus_dev *sdev = hp->happy_dev; | 1592 | struct of_device *op = hp->happy_dev; |
1590 | if (sbus_can_dma_64bit()) { | 1593 | if (sbus_can_dma_64bit()) { |
1591 | sbus_set_sbus64(&sdev->ofdev.dev, | 1594 | sbus_set_sbus64(&op->dev, |
1592 | hp->happy_bursts); | 1595 | hp->happy_bursts); |
1593 | gcfg |= GREG_CFG_64BIT; | 1596 | gcfg |= GREG_CFG_64BIT; |
1594 | } | 1597 | } |
@@ -1950,7 +1953,7 @@ static void happy_meal_tx(struct happy_meal *hp) | |||
1950 | dma_len = hme_read_desc32(hp, &this->tx_flags); | 1953 | dma_len = hme_read_desc32(hp, &this->tx_flags); |
1951 | 1954 | ||
1952 | dma_len &= TXFLAG_SIZE; | 1955 | dma_len &= TXFLAG_SIZE; |
1953 | hme_dma_unmap(hp, dma_addr, dma_len, DMA_TO_DEVICE); | 1956 | dma_unmap_single(hp->dma_dev, dma_addr, dma_len, DMA_TO_DEVICE); |
1954 | 1957 | ||
1955 | elem = NEXT_TX(elem); | 1958 | elem = NEXT_TX(elem); |
1956 | this = &txbase[elem]; | 1959 | this = &txbase[elem]; |
@@ -2028,13 +2031,14 @@ static void happy_meal_rx(struct happy_meal *hp, struct net_device *dev) | |||
2028 | drops++; | 2031 | drops++; |
2029 | goto drop_it; | 2032 | goto drop_it; |
2030 | } | 2033 | } |
2031 | hme_dma_unmap(hp, dma_addr, RX_BUF_ALLOC_SIZE, DMA_FROM_DEVICE); | 2034 | dma_unmap_single(hp->dma_dev, dma_addr, RX_BUF_ALLOC_SIZE, DMA_FROM_DEVICE); |
2032 | hp->rx_skbs[elem] = new_skb; | 2035 | hp->rx_skbs[elem] = new_skb; |
2033 | new_skb->dev = dev; | 2036 | new_skb->dev = dev; |
2034 | skb_put(new_skb, (ETH_FRAME_LEN + RX_OFFSET + 4)); | 2037 | skb_put(new_skb, (ETH_FRAME_LEN + RX_OFFSET + 4)); |
2035 | hme_write_rxd(hp, this, | 2038 | hme_write_rxd(hp, this, |
2036 | (RXFLAG_OWN|((RX_BUF_ALLOC_SIZE-RX_OFFSET)<<16)), | 2039 | (RXFLAG_OWN|((RX_BUF_ALLOC_SIZE-RX_OFFSET)<<16)), |
2037 | hme_dma_map(hp, new_skb->data, RX_BUF_ALLOC_SIZE, DMA_FROM_DEVICE)); | 2040 | dma_map_single(hp->dma_dev, new_skb->data, RX_BUF_ALLOC_SIZE, |
2041 | DMA_FROM_DEVICE)); | ||
2038 | skb_reserve(new_skb, RX_OFFSET); | 2042 | skb_reserve(new_skb, RX_OFFSET); |
2039 | 2043 | ||
2040 | /* Trim the original skb for the netif. */ | 2044 | /* Trim the original skb for the netif. */ |
@@ -2049,10 +2053,9 @@ static void happy_meal_rx(struct happy_meal *hp, struct net_device *dev) | |||
2049 | 2053 | ||
2050 | skb_reserve(copy_skb, 2); | 2054 | skb_reserve(copy_skb, 2); |
2051 | skb_put(copy_skb, len); | 2055 | skb_put(copy_skb, len); |
2052 | hme_dma_sync_for_cpu(hp, dma_addr, len, DMA_FROM_DEVICE); | 2056 | dma_sync_single_for_cpu(hp->dma_dev, dma_addr, len, DMA_FROM_DEVICE); |
2053 | skb_copy_from_linear_data(skb, copy_skb->data, len); | 2057 | skb_copy_from_linear_data(skb, copy_skb->data, len); |
2054 | hme_dma_sync_for_device(hp, dma_addr, len, DMA_FROM_DEVICE); | 2058 | dma_sync_single_for_device(hp->dma_dev, dma_addr, len, DMA_FROM_DEVICE); |
2055 | |||
2056 | /* Reuse original ring buffer. */ | 2059 | /* Reuse original ring buffer. */ |
2057 | hme_write_rxd(hp, this, | 2060 | hme_write_rxd(hp, this, |
2058 | (RXFLAG_OWN|((RX_BUF_ALLOC_SIZE-RX_OFFSET)<<16)), | 2061 | (RXFLAG_OWN|((RX_BUF_ALLOC_SIZE-RX_OFFSET)<<16)), |
@@ -2284,7 +2287,7 @@ static int happy_meal_start_xmit(struct sk_buff *skb, struct net_device *dev) | |||
2284 | u32 mapping, len; | 2287 | u32 mapping, len; |
2285 | 2288 | ||
2286 | len = skb->len; | 2289 | len = skb->len; |
2287 | mapping = hme_dma_map(hp, skb->data, len, DMA_TO_DEVICE); | 2290 | mapping = dma_map_single(hp->dma_dev, skb->data, len, DMA_TO_DEVICE); |
2288 | tx_flags |= (TXFLAG_SOP | TXFLAG_EOP); | 2291 | tx_flags |= (TXFLAG_SOP | TXFLAG_EOP); |
2289 | hme_write_txd(hp, &hp->happy_block->happy_meal_txd[entry], | 2292 | hme_write_txd(hp, &hp->happy_block->happy_meal_txd[entry], |
2290 | (tx_flags | (len & TXFLAG_SIZE)), | 2293 | (tx_flags | (len & TXFLAG_SIZE)), |
@@ -2298,7 +2301,8 @@ static int happy_meal_start_xmit(struct sk_buff *skb, struct net_device *dev) | |||
2298 | * Otherwise we could race with the device. | 2301 | * Otherwise we could race with the device. |
2299 | */ | 2302 | */ |
2300 | first_len = skb_headlen(skb); | 2303 | first_len = skb_headlen(skb); |
2301 | first_mapping = hme_dma_map(hp, skb->data, first_len, DMA_TO_DEVICE); | 2304 | first_mapping = dma_map_single(hp->dma_dev, skb->data, first_len, |
2305 | DMA_TO_DEVICE); | ||
2302 | entry = NEXT_TX(entry); | 2306 | entry = NEXT_TX(entry); |
2303 | 2307 | ||
2304 | for (frag = 0; frag < skb_shinfo(skb)->nr_frags; frag++) { | 2308 | for (frag = 0; frag < skb_shinfo(skb)->nr_frags; frag++) { |
@@ -2306,10 +2310,9 @@ static int happy_meal_start_xmit(struct sk_buff *skb, struct net_device *dev) | |||
2306 | u32 len, mapping, this_txflags; | 2310 | u32 len, mapping, this_txflags; |
2307 | 2311 | ||
2308 | len = this_frag->size; | 2312 | len = this_frag->size; |
2309 | mapping = hme_dma_map(hp, | 2313 | mapping = dma_map_page(hp->dma_dev, this_frag->page, |
2310 | ((void *) page_address(this_frag->page) + | 2314 | this_frag->page_offset, len, |
2311 | this_frag->page_offset), | 2315 | DMA_TO_DEVICE); |
2312 | len, DMA_TO_DEVICE); | ||
2313 | this_txflags = tx_flags; | 2316 | this_txflags = tx_flags; |
2314 | if (frag == skb_shinfo(skb)->nr_frags - 1) | 2317 | if (frag == skb_shinfo(skb)->nr_frags - 1) |
2315 | this_txflags |= TXFLAG_EOP; | 2318 | this_txflags |= TXFLAG_EOP; |
@@ -2477,9 +2480,12 @@ static void hme_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info | |||
2477 | } | 2480 | } |
2478 | #ifdef CONFIG_SBUS | 2481 | #ifdef CONFIG_SBUS |
2479 | else { | 2482 | else { |
2480 | struct sbus_dev *sdev = hp->happy_dev; | 2483 | const struct linux_prom_registers *regs; |
2481 | sprintf(info->bus_info, "SBUS:%d", | 2484 | struct of_device *op = hp->happy_dev; |
2482 | sdev->slot); | 2485 | regs = of_get_property(op->node, "regs", NULL); |
2486 | if (regs) | ||
2487 | sprintf(info->bus_info, "SBUS:%d", | ||
2488 | regs->which_io); | ||
2483 | } | 2489 | } |
2484 | #endif | 2490 | #endif |
2485 | } | 2491 | } |
@@ -2505,63 +2511,21 @@ static const struct ethtool_ops hme_ethtool_ops = { | |||
2505 | static int hme_version_printed; | 2511 | static int hme_version_printed; |
2506 | 2512 | ||
2507 | #ifdef CONFIG_SBUS | 2513 | #ifdef CONFIG_SBUS |
2508 | void __devinit quattro_get_ranges(struct quattro *qp) | ||
2509 | { | ||
2510 | struct sbus_dev *sdev = qp->quattro_dev; | ||
2511 | int err; | ||
2512 | |||
2513 | err = prom_getproperty(sdev->prom_node, | ||
2514 | "ranges", | ||
2515 | (char *)&qp->ranges[0], | ||
2516 | sizeof(qp->ranges)); | ||
2517 | if (err == 0 || err == -1) { | ||
2518 | qp->nranges = 0; | ||
2519 | return; | ||
2520 | } | ||
2521 | qp->nranges = (err / sizeof(struct linux_prom_ranges)); | ||
2522 | } | ||
2523 | |||
2524 | static void __devinit quattro_apply_ranges(struct quattro *qp, struct happy_meal *hp) | ||
2525 | { | ||
2526 | struct sbus_dev *sdev = hp->happy_dev; | ||
2527 | int rng; | ||
2528 | |||
2529 | for (rng = 0; rng < qp->nranges; rng++) { | ||
2530 | struct linux_prom_ranges *rngp = &qp->ranges[rng]; | ||
2531 | int reg; | ||
2532 | |||
2533 | for (reg = 0; reg < 5; reg++) { | ||
2534 | if (sdev->reg_addrs[reg].which_io == | ||
2535 | rngp->ot_child_space) | ||
2536 | break; | ||
2537 | } | ||
2538 | if (reg == 5) | ||
2539 | continue; | ||
2540 | |||
2541 | sdev->reg_addrs[reg].which_io = rngp->ot_parent_space; | ||
2542 | sdev->reg_addrs[reg].phys_addr += rngp->ot_parent_base; | ||
2543 | } | ||
2544 | } | ||
2545 | |||
2546 | /* Given a happy meal sbus device, find it's quattro parent. | 2514 | /* Given a happy meal sbus device, find it's quattro parent. |
2547 | * If none exist, allocate and return a new one. | 2515 | * If none exist, allocate and return a new one. |
2548 | * | 2516 | * |
2549 | * Return NULL on failure. | 2517 | * Return NULL on failure. |
2550 | */ | 2518 | */ |
2551 | static struct quattro * __devinit quattro_sbus_find(struct sbus_dev *goal_sdev) | 2519 | static struct quattro * __devinit quattro_sbus_find(struct of_device *child) |
2552 | { | 2520 | { |
2553 | struct sbus_dev *sdev; | 2521 | struct device *parent = child->dev.parent; |
2522 | struct of_device *op; | ||
2554 | struct quattro *qp; | 2523 | struct quattro *qp; |
2555 | int i; | ||
2556 | 2524 | ||
2557 | for (qp = qfe_sbus_list; qp != NULL; qp = qp->next) { | 2525 | op = to_of_device(parent); |
2558 | for (i = 0, sdev = qp->quattro_dev; | 2526 | qp = dev_get_drvdata(&op->dev); |
2559 | (sdev != NULL) && (i < 4); | 2527 | if (qp) |
2560 | sdev = sdev->next, i++) { | 2528 | return qp; |
2561 | if (sdev == goal_sdev) | ||
2562 | return qp; | ||
2563 | } | ||
2564 | } | ||
2565 | 2529 | ||
2566 | qp = kmalloc(sizeof(struct quattro), GFP_KERNEL); | 2530 | qp = kmalloc(sizeof(struct quattro), GFP_KERNEL); |
2567 | if (qp != NULL) { | 2531 | if (qp != NULL) { |
@@ -2570,10 +2534,11 @@ static struct quattro * __devinit quattro_sbus_find(struct sbus_dev *goal_sdev) | |||
2570 | for (i = 0; i < 4; i++) | 2534 | for (i = 0; i < 4; i++) |
2571 | qp->happy_meals[i] = NULL; | 2535 | qp->happy_meals[i] = NULL; |
2572 | 2536 | ||
2573 | qp->quattro_dev = goal_sdev; | 2537 | qp->quattro_dev = child; |
2574 | qp->next = qfe_sbus_list; | 2538 | qp->next = qfe_sbus_list; |
2575 | qfe_sbus_list = qp; | 2539 | qfe_sbus_list = qp; |
2576 | quattro_get_ranges(qp); | 2540 | |
2541 | dev_set_drvdata(&op->dev, qp); | ||
2577 | } | 2542 | } |
2578 | return qp; | 2543 | return qp; |
2579 | } | 2544 | } |
@@ -2586,10 +2551,10 @@ static void __init quattro_sbus_register_irqs(void) | |||
2586 | struct quattro *qp; | 2551 | struct quattro *qp; |
2587 | 2552 | ||
2588 | for (qp = qfe_sbus_list; qp != NULL; qp = qp->next) { | 2553 | for (qp = qfe_sbus_list; qp != NULL; qp = qp->next) { |
2589 | struct sbus_dev *sdev = qp->quattro_dev; | 2554 | struct of_device *op = qp->quattro_dev; |
2590 | int err; | 2555 | int err; |
2591 | 2556 | ||
2592 | err = request_irq(sdev->irqs[0], | 2557 | err = request_irq(op->irqs[0], |
2593 | quattro_sbus_interrupt, | 2558 | quattro_sbus_interrupt, |
2594 | IRQF_SHARED, "Quattro", | 2559 | IRQF_SHARED, "Quattro", |
2595 | qp); | 2560 | qp); |
@@ -2605,9 +2570,9 @@ static void quattro_sbus_free_irqs(void) | |||
2605 | struct quattro *qp; | 2570 | struct quattro *qp; |
2606 | 2571 | ||
2607 | for (qp = qfe_sbus_list; qp != NULL; qp = qp->next) { | 2572 | for (qp = qfe_sbus_list; qp != NULL; qp = qp->next) { |
2608 | struct sbus_dev *sdev = qp->quattro_dev; | 2573 | struct of_device *op = qp->quattro_dev; |
2609 | 2574 | ||
2610 | free_irq(sdev->irqs[0], qp); | 2575 | free_irq(op->irqs[0], qp); |
2611 | } | 2576 | } |
2612 | } | 2577 | } |
2613 | #endif /* CONFIG_SBUS */ | 2578 | #endif /* CONFIG_SBUS */ |
@@ -2644,9 +2609,9 @@ static struct quattro * __devinit quattro_pci_find(struct pci_dev *pdev) | |||
2644 | #endif /* CONFIG_PCI */ | 2609 | #endif /* CONFIG_PCI */ |
2645 | 2610 | ||
2646 | #ifdef CONFIG_SBUS | 2611 | #ifdef CONFIG_SBUS |
2647 | static int __devinit happy_meal_sbus_probe_one(struct sbus_dev *sdev, int is_qfe) | 2612 | static int __devinit happy_meal_sbus_probe_one(struct of_device *op, int is_qfe) |
2648 | { | 2613 | { |
2649 | struct device_node *dp = sdev->ofdev.node; | 2614 | struct device_node *dp = op->node, *sbus_dp; |
2650 | struct quattro *qp = NULL; | 2615 | struct quattro *qp = NULL; |
2651 | struct happy_meal *hp; | 2616 | struct happy_meal *hp; |
2652 | struct net_device *dev; | 2617 | struct net_device *dev; |
@@ -2655,7 +2620,7 @@ static int __devinit happy_meal_sbus_probe_one(struct sbus_dev *sdev, int is_qfe | |||
2655 | DECLARE_MAC_BUF(mac); | 2620 | DECLARE_MAC_BUF(mac); |
2656 | 2621 | ||
2657 | if (is_qfe) { | 2622 | if (is_qfe) { |
2658 | qp = quattro_sbus_find(sdev); | 2623 | qp = quattro_sbus_find(op); |
2659 | if (qp == NULL) | 2624 | if (qp == NULL) |
2660 | goto err_out; | 2625 | goto err_out; |
2661 | for (qfe_slot = 0; qfe_slot < 4; qfe_slot++) | 2626 | for (qfe_slot = 0; qfe_slot < 4; qfe_slot++) |
@@ -2669,7 +2634,7 @@ static int __devinit happy_meal_sbus_probe_one(struct sbus_dev *sdev, int is_qfe | |||
2669 | dev = alloc_etherdev(sizeof(struct happy_meal)); | 2634 | dev = alloc_etherdev(sizeof(struct happy_meal)); |
2670 | if (!dev) | 2635 | if (!dev) |
2671 | goto err_out; | 2636 | goto err_out; |
2672 | SET_NETDEV_DEV(dev, &sdev->ofdev.dev); | 2637 | SET_NETDEV_DEV(dev, &op->dev); |
2673 | 2638 | ||
2674 | if (hme_version_printed++ == 0) | 2639 | if (hme_version_printed++ == 0) |
2675 | printk(KERN_INFO "%s", version); | 2640 | printk(KERN_INFO "%s", version); |
@@ -2697,57 +2662,50 @@ static int __devinit happy_meal_sbus_probe_one(struct sbus_dev *sdev, int is_qfe | |||
2697 | memcpy(dev->dev_addr, idprom->id_ethaddr, 6); | 2662 | memcpy(dev->dev_addr, idprom->id_ethaddr, 6); |
2698 | } | 2663 | } |
2699 | 2664 | ||
2700 | hp = dev->priv; | 2665 | hp = netdev_priv(dev); |
2701 | 2666 | ||
2702 | hp->happy_dev = sdev; | 2667 | hp->happy_dev = op; |
2703 | hp->dma_dev = &sdev->ofdev.dev; | 2668 | hp->dma_dev = &op->dev; |
2704 | 2669 | ||
2705 | spin_lock_init(&hp->happy_lock); | 2670 | spin_lock_init(&hp->happy_lock); |
2706 | 2671 | ||
2707 | err = -ENODEV; | 2672 | err = -ENODEV; |
2708 | if (sdev->num_registers != 5) { | ||
2709 | printk(KERN_ERR "happymeal: Device needs 5 regs, has %d.\n", | ||
2710 | sdev->num_registers); | ||
2711 | goto err_out_free_netdev; | ||
2712 | } | ||
2713 | |||
2714 | if (qp != NULL) { | 2673 | if (qp != NULL) { |
2715 | hp->qfe_parent = qp; | 2674 | hp->qfe_parent = qp; |
2716 | hp->qfe_ent = qfe_slot; | 2675 | hp->qfe_ent = qfe_slot; |
2717 | qp->happy_meals[qfe_slot] = dev; | 2676 | qp->happy_meals[qfe_slot] = dev; |
2718 | quattro_apply_ranges(qp, hp); | ||
2719 | } | 2677 | } |
2720 | 2678 | ||
2721 | hp->gregs = sbus_ioremap(&sdev->resource[0], 0, | 2679 | hp->gregs = of_ioremap(&op->resource[0], 0, |
2722 | GREG_REG_SIZE, "HME Global Regs"); | 2680 | GREG_REG_SIZE, "HME Global Regs"); |
2723 | if (!hp->gregs) { | 2681 | if (!hp->gregs) { |
2724 | printk(KERN_ERR "happymeal: Cannot map global registers.\n"); | 2682 | printk(KERN_ERR "happymeal: Cannot map global registers.\n"); |
2725 | goto err_out_free_netdev; | 2683 | goto err_out_free_netdev; |
2726 | } | 2684 | } |
2727 | 2685 | ||
2728 | hp->etxregs = sbus_ioremap(&sdev->resource[1], 0, | 2686 | hp->etxregs = of_ioremap(&op->resource[1], 0, |
2729 | ETX_REG_SIZE, "HME TX Regs"); | 2687 | ETX_REG_SIZE, "HME TX Regs"); |
2730 | if (!hp->etxregs) { | 2688 | if (!hp->etxregs) { |
2731 | printk(KERN_ERR "happymeal: Cannot map MAC TX registers.\n"); | 2689 | printk(KERN_ERR "happymeal: Cannot map MAC TX registers.\n"); |
2732 | goto err_out_iounmap; | 2690 | goto err_out_iounmap; |
2733 | } | 2691 | } |
2734 | 2692 | ||
2735 | hp->erxregs = sbus_ioremap(&sdev->resource[2], 0, | 2693 | hp->erxregs = of_ioremap(&op->resource[2], 0, |
2736 | ERX_REG_SIZE, "HME RX Regs"); | 2694 | ERX_REG_SIZE, "HME RX Regs"); |
2737 | if (!hp->erxregs) { | 2695 | if (!hp->erxregs) { |
2738 | printk(KERN_ERR "happymeal: Cannot map MAC RX registers.\n"); | 2696 | printk(KERN_ERR "happymeal: Cannot map MAC RX registers.\n"); |
2739 | goto err_out_iounmap; | 2697 | goto err_out_iounmap; |
2740 | } | 2698 | } |
2741 | 2699 | ||
2742 | hp->bigmacregs = sbus_ioremap(&sdev->resource[3], 0, | 2700 | hp->bigmacregs = of_ioremap(&op->resource[3], 0, |
2743 | BMAC_REG_SIZE, "HME BIGMAC Regs"); | 2701 | BMAC_REG_SIZE, "HME BIGMAC Regs"); |
2744 | if (!hp->bigmacregs) { | 2702 | if (!hp->bigmacregs) { |
2745 | printk(KERN_ERR "happymeal: Cannot map BIGMAC registers.\n"); | 2703 | printk(KERN_ERR "happymeal: Cannot map BIGMAC registers.\n"); |
2746 | goto err_out_iounmap; | 2704 | goto err_out_iounmap; |
2747 | } | 2705 | } |
2748 | 2706 | ||
2749 | hp->tcvregs = sbus_ioremap(&sdev->resource[4], 0, | 2707 | hp->tcvregs = of_ioremap(&op->resource[4], 0, |
2750 | TCVR_REG_SIZE, "HME Tranceiver Regs"); | 2708 | TCVR_REG_SIZE, "HME Tranceiver Regs"); |
2751 | if (!hp->tcvregs) { | 2709 | if (!hp->tcvregs) { |
2752 | printk(KERN_ERR "happymeal: Cannot map TCVR registers.\n"); | 2710 | printk(KERN_ERR "happymeal: Cannot map TCVR registers.\n"); |
2753 | goto err_out_iounmap; | 2711 | goto err_out_iounmap; |
@@ -2766,8 +2724,12 @@ static int __devinit happy_meal_sbus_probe_one(struct sbus_dev *sdev, int is_qfe | |||
2766 | if (qp != NULL) | 2724 | if (qp != NULL) |
2767 | hp->happy_flags |= HFLAG_QUATTRO; | 2725 | hp->happy_flags |= HFLAG_QUATTRO; |
2768 | 2726 | ||
2727 | sbus_dp = to_of_device(op->dev.parent)->node; | ||
2728 | if (is_qfe) | ||
2729 | sbus_dp = to_of_device(op->dev.parent->parent)->node; | ||
2730 | |||
2769 | /* Get the supported DVMA burst sizes from our Happy SBUS. */ | 2731 | /* Get the supported DVMA burst sizes from our Happy SBUS. */ |
2770 | hp->happy_bursts = of_getintprop_default(sdev->bus->ofdev.node, | 2732 | hp->happy_bursts = of_getintprop_default(sbus_dp, |
2771 | "burst-sizes", 0x00); | 2733 | "burst-sizes", 0x00); |
2772 | 2734 | ||
2773 | hp->happy_block = dma_alloc_coherent(hp->dma_dev, | 2735 | hp->happy_block = dma_alloc_coherent(hp->dma_dev, |
@@ -2802,19 +2764,13 @@ static int __devinit happy_meal_sbus_probe_one(struct sbus_dev *sdev, int is_qfe | |||
2802 | /* Happy Meal can do it all... */ | 2764 | /* Happy Meal can do it all... */ |
2803 | dev->features |= NETIF_F_SG | NETIF_F_HW_CSUM; | 2765 | dev->features |= NETIF_F_SG | NETIF_F_HW_CSUM; |
2804 | 2766 | ||
2805 | dev->irq = sdev->irqs[0]; | 2767 | dev->irq = op->irqs[0]; |
2806 | 2768 | ||
2807 | #if defined(CONFIG_SBUS) && defined(CONFIG_PCI) | 2769 | #if defined(CONFIG_SBUS) && defined(CONFIG_PCI) |
2808 | /* Hook up PCI register/dma accessors. */ | 2770 | /* Hook up SBUS register/descriptor accessors. */ |
2809 | hp->read_desc32 = sbus_hme_read_desc32; | 2771 | hp->read_desc32 = sbus_hme_read_desc32; |
2810 | hp->write_txd = sbus_hme_write_txd; | 2772 | hp->write_txd = sbus_hme_write_txd; |
2811 | hp->write_rxd = sbus_hme_write_rxd; | 2773 | hp->write_rxd = sbus_hme_write_rxd; |
2812 | hp->dma_map = (u32 (*)(void *, void *, long, int))dma_map_single; | ||
2813 | hp->dma_unmap = (void (*)(void *, u32, long, int))dma_unmap_single; | ||
2814 | hp->dma_sync_for_cpu = (void (*)(void *, u32, long, int)) | ||
2815 | dma_sync_single_for_cpu; | ||
2816 | hp->dma_sync_for_device = (void (*)(void *, u32, long, int)) | ||
2817 | dma_sync_single_for_device; | ||
2818 | hp->read32 = sbus_hme_read32; | 2774 | hp->read32 = sbus_hme_read32; |
2819 | hp->write32 = sbus_hme_write32; | 2775 | hp->write32 = sbus_hme_write32; |
2820 | #endif | 2776 | #endif |
@@ -2832,7 +2788,7 @@ static int __devinit happy_meal_sbus_probe_one(struct sbus_dev *sdev, int is_qfe | |||
2832 | goto err_out_free_coherent; | 2788 | goto err_out_free_coherent; |
2833 | } | 2789 | } |
2834 | 2790 | ||
2835 | dev_set_drvdata(&sdev->ofdev.dev, hp); | 2791 | dev_set_drvdata(&op->dev, hp); |
2836 | 2792 | ||
2837 | if (qfe_slot != -1) | 2793 | if (qfe_slot != -1) |
2838 | printk(KERN_INFO "%s: Quattro HME slot %d (SBUS) 10/100baseT Ethernet ", | 2794 | printk(KERN_INFO "%s: Quattro HME slot %d (SBUS) 10/100baseT Ethernet ", |
@@ -2853,15 +2809,15 @@ err_out_free_coherent: | |||
2853 | 2809 | ||
2854 | err_out_iounmap: | 2810 | err_out_iounmap: |
2855 | if (hp->gregs) | 2811 | if (hp->gregs) |
2856 | sbus_iounmap(hp->gregs, GREG_REG_SIZE); | 2812 | of_iounmap(&op->resource[0], hp->gregs, GREG_REG_SIZE); |
2857 | if (hp->etxregs) | 2813 | if (hp->etxregs) |
2858 | sbus_iounmap(hp->etxregs, ETX_REG_SIZE); | 2814 | of_iounmap(&op->resource[1], hp->etxregs, ETX_REG_SIZE); |
2859 | if (hp->erxregs) | 2815 | if (hp->erxregs) |
2860 | sbus_iounmap(hp->erxregs, ERX_REG_SIZE); | 2816 | of_iounmap(&op->resource[2], hp->erxregs, ERX_REG_SIZE); |
2861 | if (hp->bigmacregs) | 2817 | if (hp->bigmacregs) |
2862 | sbus_iounmap(hp->bigmacregs, BMAC_REG_SIZE); | 2818 | of_iounmap(&op->resource[3], hp->bigmacregs, BMAC_REG_SIZE); |
2863 | if (hp->tcvregs) | 2819 | if (hp->tcvregs) |
2864 | sbus_iounmap(hp->tcvregs, TCVR_REG_SIZE); | 2820 | of_iounmap(&op->resource[4], hp->tcvregs, TCVR_REG_SIZE); |
2865 | 2821 | ||
2866 | err_out_free_netdev: | 2822 | err_out_free_netdev: |
2867 | free_netdev(dev); | 2823 | free_netdev(dev); |
@@ -3021,7 +2977,7 @@ static int __devinit happy_meal_pci_probe(struct pci_dev *pdev, | |||
3021 | memset(hp, 0, sizeof(*hp)); | 2977 | memset(hp, 0, sizeof(*hp)); |
3022 | 2978 | ||
3023 | hp->happy_dev = pdev; | 2979 | hp->happy_dev = pdev; |
3024 | hp->dma_dev = pdev; | 2980 | hp->dma_dev = &pdev->dev; |
3025 | 2981 | ||
3026 | spin_lock_init(&hp->happy_lock); | 2982 | spin_lock_init(&hp->happy_lock); |
3027 | 2983 | ||
@@ -3108,7 +3064,7 @@ static int __devinit happy_meal_pci_probe(struct pci_dev *pdev, | |||
3108 | #endif | 3064 | #endif |
3109 | 3065 | ||
3110 | hp->happy_block = (struct hmeal_init_block *) | 3066 | hp->happy_block = (struct hmeal_init_block *) |
3111 | pci_alloc_consistent(pdev, PAGE_SIZE, &hp->hblock_dvma); | 3067 | dma_alloc_coherent(&pdev->dev, PAGE_SIZE, &hp->hblock_dvma, GFP_KERNEL); |
3112 | 3068 | ||
3113 | err = -ENODEV; | 3069 | err = -ENODEV; |
3114 | if (!hp->happy_block) { | 3070 | if (!hp->happy_block) { |
@@ -3138,16 +3094,10 @@ static int __devinit happy_meal_pci_probe(struct pci_dev *pdev, | |||
3138 | dev->features |= NETIF_F_SG | NETIF_F_HW_CSUM; | 3094 | dev->features |= NETIF_F_SG | NETIF_F_HW_CSUM; |
3139 | 3095 | ||
3140 | #if defined(CONFIG_SBUS) && defined(CONFIG_PCI) | 3096 | #if defined(CONFIG_SBUS) && defined(CONFIG_PCI) |
3141 | /* Hook up PCI register/dma accessors. */ | 3097 | /* Hook up PCI register/descriptor accessors. */ |
3142 | hp->read_desc32 = pci_hme_read_desc32; | 3098 | hp->read_desc32 = pci_hme_read_desc32; |
3143 | hp->write_txd = pci_hme_write_txd; | 3099 | hp->write_txd = pci_hme_write_txd; |
3144 | hp->write_rxd = pci_hme_write_rxd; | 3100 | hp->write_rxd = pci_hme_write_rxd; |
3145 | hp->dma_map = (u32 (*)(void *, void *, long, int))pci_map_single; | ||
3146 | hp->dma_unmap = (void (*)(void *, u32, long, int))pci_unmap_single; | ||
3147 | hp->dma_sync_for_cpu = (void (*)(void *, u32, long, int)) | ||
3148 | pci_dma_sync_single_for_cpu; | ||
3149 | hp->dma_sync_for_device = (void (*)(void *, u32, long, int)) | ||
3150 | pci_dma_sync_single_for_device; | ||
3151 | hp->read32 = pci_hme_read32; | 3101 | hp->read32 = pci_hme_read32; |
3152 | hp->write32 = pci_hme_write32; | 3102 | hp->write32 = pci_hme_write32; |
3153 | #endif | 3103 | #endif |
@@ -3218,12 +3168,10 @@ static void __devexit happy_meal_pci_remove(struct pci_dev *pdev) | |||
3218 | 3168 | ||
3219 | unregister_netdev(net_dev); | 3169 | unregister_netdev(net_dev); |
3220 | 3170 | ||
3221 | pci_free_consistent(hp->dma_dev, | 3171 | dma_free_coherent(hp->dma_dev, PAGE_SIZE, |
3222 | PAGE_SIZE, | 3172 | hp->happy_block, hp->hblock_dvma); |
3223 | hp->happy_block, | ||
3224 | hp->hblock_dvma); | ||
3225 | iounmap(hp->gregs); | 3173 | iounmap(hp->gregs); |
3226 | pci_release_regions(hp->dma_dev); | 3174 | pci_release_regions(hp->happy_dev); |
3227 | 3175 | ||
3228 | free_netdev(net_dev); | 3176 | free_netdev(net_dev); |
3229 | 3177 | ||
@@ -3266,33 +3214,32 @@ static void happy_meal_pci_exit(void) | |||
3266 | #endif | 3214 | #endif |
3267 | 3215 | ||
3268 | #ifdef CONFIG_SBUS | 3216 | #ifdef CONFIG_SBUS |
3269 | static int __devinit hme_sbus_probe(struct of_device *dev, const struct of_device_id *match) | 3217 | static int __devinit hme_sbus_probe(struct of_device *op, const struct of_device_id *match) |
3270 | { | 3218 | { |
3271 | struct sbus_dev *sdev = to_sbus_device(&dev->dev); | 3219 | struct device_node *dp = op->node; |
3272 | struct device_node *dp = dev->node; | ||
3273 | const char *model = of_get_property(dp, "model", NULL); | 3220 | const char *model = of_get_property(dp, "model", NULL); |
3274 | int is_qfe = (match->data != NULL); | 3221 | int is_qfe = (match->data != NULL); |
3275 | 3222 | ||
3276 | if (!is_qfe && model && !strcmp(model, "SUNW,sbus-qfe")) | 3223 | if (!is_qfe && model && !strcmp(model, "SUNW,sbus-qfe")) |
3277 | is_qfe = 1; | 3224 | is_qfe = 1; |
3278 | 3225 | ||
3279 | return happy_meal_sbus_probe_one(sdev, is_qfe); | 3226 | return happy_meal_sbus_probe_one(op, is_qfe); |
3280 | } | 3227 | } |
3281 | 3228 | ||
3282 | static int __devexit hme_sbus_remove(struct of_device *dev) | 3229 | static int __devexit hme_sbus_remove(struct of_device *op) |
3283 | { | 3230 | { |
3284 | struct happy_meal *hp = dev_get_drvdata(&dev->dev); | 3231 | struct happy_meal *hp = dev_get_drvdata(&op->dev); |
3285 | struct net_device *net_dev = hp->dev; | 3232 | struct net_device *net_dev = hp->dev; |
3286 | 3233 | ||
3287 | unregister_netdev(net_dev); | 3234 | unregister_netdev(net_dev); |
3288 | 3235 | ||
3289 | /* XXX qfe parent interrupt... */ | 3236 | /* XXX qfe parent interrupt... */ |
3290 | 3237 | ||
3291 | sbus_iounmap(hp->gregs, GREG_REG_SIZE); | 3238 | of_iounmap(&op->resource[0], hp->gregs, GREG_REG_SIZE); |
3292 | sbus_iounmap(hp->etxregs, ETX_REG_SIZE); | 3239 | of_iounmap(&op->resource[1], hp->etxregs, ETX_REG_SIZE); |
3293 | sbus_iounmap(hp->erxregs, ERX_REG_SIZE); | 3240 | of_iounmap(&op->resource[2], hp->erxregs, ERX_REG_SIZE); |
3294 | sbus_iounmap(hp->bigmacregs, BMAC_REG_SIZE); | 3241 | of_iounmap(&op->resource[3], hp->bigmacregs, BMAC_REG_SIZE); |
3295 | sbus_iounmap(hp->tcvregs, TCVR_REG_SIZE); | 3242 | of_iounmap(&op->resource[4], hp->tcvregs, TCVR_REG_SIZE); |
3296 | dma_free_coherent(hp->dma_dev, | 3243 | dma_free_coherent(hp->dma_dev, |
3297 | PAGE_SIZE, | 3244 | PAGE_SIZE, |
3298 | hp->happy_block, | 3245 | hp->happy_block, |
@@ -3300,7 +3247,7 @@ static int __devexit hme_sbus_remove(struct of_device *dev) | |||
3300 | 3247 | ||
3301 | free_netdev(net_dev); | 3248 | free_netdev(net_dev); |
3302 | 3249 | ||
3303 | dev_set_drvdata(&dev->dev, NULL); | 3250 | dev_set_drvdata(&op->dev, NULL); |
3304 | 3251 | ||
3305 | return 0; | 3252 | return 0; |
3306 | } | 3253 | } |
@@ -3333,7 +3280,7 @@ static int __init happy_meal_sbus_init(void) | |||
3333 | { | 3280 | { |
3334 | int err; | 3281 | int err; |
3335 | 3282 | ||
3336 | err = of_register_driver(&hme_sbus_driver, &sbus_bus_type); | 3283 | err = of_register_driver(&hme_sbus_driver, &of_bus_type); |
3337 | if (!err) | 3284 | if (!err) |
3338 | quattro_sbus_register_irqs(); | 3285 | quattro_sbus_register_irqs(); |
3339 | 3286 | ||
diff --git a/drivers/net/sunhme.h b/drivers/net/sunhme.h index 756e96e5ef4b..efd2ca0fcad3 100644 --- a/drivers/net/sunhme.h +++ b/drivers/net/sunhme.h | |||
@@ -405,15 +405,11 @@ struct happy_meal { | |||
405 | u32 (*read_desc32)(hme32 *); | 405 | u32 (*read_desc32)(hme32 *); |
406 | void (*write_txd)(struct happy_meal_txd *, u32, u32); | 406 | void (*write_txd)(struct happy_meal_txd *, u32, u32); |
407 | void (*write_rxd)(struct happy_meal_rxd *, u32, u32); | 407 | void (*write_rxd)(struct happy_meal_rxd *, u32, u32); |
408 | u32 (*dma_map)(void *, void *, long, int); | ||
409 | void (*dma_unmap)(void *, u32, long, int); | ||
410 | void (*dma_sync_for_cpu)(void *, u32, long, int); | ||
411 | void (*dma_sync_for_device)(void *, u32, long, int); | ||
412 | #endif | 408 | #endif |
413 | 409 | ||
414 | /* This is either a sbus_dev or a pci_dev. */ | 410 | /* This is either an of_device or a pci_dev. */ |
415 | void *happy_dev; | 411 | void *happy_dev; |
416 | void *dma_dev; | 412 | struct device *dma_dev; |
417 | 413 | ||
418 | spinlock_t happy_lock; | 414 | spinlock_t happy_lock; |
419 | 415 | ||