Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge branch 'net-ll_temac-x86_64-support'

Esben Haabendal says:

====================
net: ll_temac: x86_64 support

This patch series adds support for use of ll_temac driver with
platform_data configuration and fixes endianess and 64-bit problems so
that it can be used on x86_64 platform.

A few bugfixes are also included.

Changes since v2:
- Fixed lp->indirect_mutex initialization regression for OF
platforms introduced in v2

Changes since v1:
- Make indirect_mutex specification mandatory when using platform_data
- Move header to include/linux/platform_data
- Enable COMPILE_TEST for XILINX_LL_TEMAC
- Rebased to v5.1-rc7
====================

Signed-off-by: David S. Miller <davem@davemloft.net>

+434 -205
+2 -3
drivers/net/ethernet/xilinx/Kconfig
··· 5 5 config NET_VENDOR_XILINX 6 6 bool "Xilinx devices" 7 7 default y 8 - depends on PPC || PPC32 || MICROBLAZE || ARCH_ZYNQ || MIPS 8 + depends on PPC || PPC32 || MICROBLAZE || ARCH_ZYNQ || MIPS || X86 || COMPILE_TEST 9 9 ---help--- 10 10 If you have a network (Ethernet) card belonging to this class, say Y. 11 11 ··· 33 33 34 34 config XILINX_LL_TEMAC 35 35 tristate "Xilinx LL TEMAC (LocalLink Tri-mode Ethernet MAC) driver" 36 - depends on (PPC || MICROBLAZE) 37 - depends on !64BIT || BROKEN 36 + depends on PPC || MICROBLAZE || X86 || COMPILE_TEST 38 37 select PHYLIB 39 38 ---help--- 40 39 This driver supports the Xilinx 10/100/1000 LocalLink TEMAC
+20 -6
drivers/net/ethernet/xilinx/ll_temac.h
··· 334 334 335 335 /* Connection to PHY device */ 336 336 struct device_node *phy_node; 337 + /* For non-device-tree devices */ 338 + char phy_name[MII_BUS_ID_SIZE + 3]; 339 + phy_interface_t phy_interface; 337 340 338 341 /* MDIO bus data */ 339 342 struct mii_bus *mii_bus; /* MII bus reference */ ··· 347 344 #ifdef CONFIG_PPC_DCR 348 345 dcr_host_t sdma_dcrs; 349 346 #endif 350 - u32 (*dma_in)(struct temac_local *, int); 351 - void (*dma_out)(struct temac_local *, int, u32); 347 + u32 (*temac_ior)(struct temac_local *lp, int offset); 348 + void (*temac_iow)(struct temac_local *lp, int offset, u32 value); 349 + u32 (*dma_in)(struct temac_local *lp, int reg); 350 + void (*dma_out)(struct temac_local *lp, int reg, u32 value); 352 351 353 352 int tx_irq; 354 353 int rx_irq; ··· 358 353 359 354 struct sk_buff **rx_skb; 360 355 spinlock_t rx_lock; 361 - struct mutex indirect_mutex; 356 + /* For synchronization of indirect register access. Must be 357 + * shared mutex between interfaces in same TEMAC block. 358 + */ 359 + struct mutex *indirect_mutex; 362 360 u32 options; /* Current options word */ 363 361 int last_link; 364 362 unsigned int temac_features; ··· 375 367 int tx_bd_next; 376 368 int tx_bd_tail; 377 369 int rx_bd_ci; 370 + 371 + /* DMA channel control setup */ 372 + u32 tx_chnl_ctrl; 373 + u32 rx_chnl_ctrl; 378 374 }; 379 375 376 + /* Wrappers for temac_ior()/temac_iow() function pointers above */ 377 + #define temac_ior(lp, o) ((lp)->temac_ior(lp, o)) 378 + #define temac_iow(lp, o, v) ((lp)->temac_iow(lp, o, v)) 379 + 380 380 /* xilinx_temac.c */ 381 - u32 temac_ior(struct temac_local *lp, int offset); 382 - void temac_iow(struct temac_local *lp, int offset, u32 value); 383 381 int temac_indirect_busywait(struct temac_local *lp); 384 382 u32 temac_indirect_in32(struct temac_local *lp, int reg); 385 383 void temac_indirect_out32(struct temac_local *lp, int reg, u32 value); 386 384 387 385 388 386 /* xilinx_temac_mdio.c */ 389 - int temac_mdio_setup(struct temac_local *lp, struct device_node *np); 387 + int temac_mdio_setup(struct temac_local *lp, struct platform_device *pdev); 390 388 void temac_mdio_teardown(struct temac_local *lp); 391 389 392 390 #endif /* XILINX_LL_TEMAC_H */
+349 -174
drivers/net/ethernet/xilinx/ll_temac_main.c
··· 33 33 #include <linux/module.h> 34 34 #include <linux/mutex.h> 35 35 #include <linux/netdevice.h> 36 + #include <linux/if_ether.h> 36 37 #include <linux/of.h> 37 38 #include <linux/of_device.h> 38 39 #include <linux/of_irq.h> ··· 52 51 #include <linux/slab.h> 53 52 #include <linux/interrupt.h> 54 53 #include <linux/dma-mapping.h> 54 + #include <linux/platform_data/xilinx-ll-temac.h> 55 55 56 56 #include "ll_temac.h" 57 57 ··· 63 61 * Low level register access functions 64 62 */ 65 63 66 - u32 temac_ior(struct temac_local *lp, int offset) 64 + u32 _temac_ior_be(struct temac_local *lp, int offset) 67 65 { 68 - return in_be32(lp->regs + offset); 66 + return ioread32be(lp->regs + offset); 69 67 } 70 68 71 - void temac_iow(struct temac_local *lp, int offset, u32 value) 69 + void _temac_iow_be(struct temac_local *lp, int offset, u32 value) 72 70 { 73 - out_be32(lp->regs + offset, value); 71 + return iowrite32be(value, lp->regs + offset); 72 + } 73 + 74 + u32 _temac_ior_le(struct temac_local *lp, int offset) 75 + { 76 + return ioread32(lp->regs + offset); 77 + } 78 + 79 + void _temac_iow_le(struct temac_local *lp, int offset, u32 value) 80 + { 81 + return iowrite32(value, lp->regs + offset); 74 82 } 75 83 76 84 int temac_indirect_busywait(struct temac_local *lp) ··· 92 80 WARN_ON(1); 93 81 return -ETIMEDOUT; 94 82 } 95 - msleep(1); 83 + usleep_range(500, 1000); 96 84 } 97 85 return 0; 98 86 } ··· 131 119 } 132 120 133 121 /** 134 - * temac_dma_in32 - Memory mapped DMA read, this function expects a 135 - * register input that is based on DCR word addresses which 136 - * are then converted to memory mapped byte addresses 122 + * temac_dma_in32_* - Memory mapped DMA read, these function expects a 123 + * register input that is based on DCR word addresses which are then 124 + * converted to memory mapped byte addresses. To be assigned to 125 + * lp->dma_in32. 137 126 */ 138 - static u32 temac_dma_in32(struct temac_local *lp, int reg) 127 + static u32 temac_dma_in32_be(struct temac_local *lp, int reg) 139 128 { 140 - return in_be32(lp->sdma_regs + (reg << 2)); 129 + return ioread32be(lp->sdma_regs + (reg << 2)); 130 + } 131 + 132 + static u32 temac_dma_in32_le(struct temac_local *lp, int reg) 133 + { 134 + return ioread32(lp->sdma_regs + (reg << 2)); 141 135 } 142 136 143 137 /** 144 - * temac_dma_out32 - Memory mapped DMA read, this function expects a 145 - * register input that is based on DCR word addresses which 146 - * are then converted to memory mapped byte addresses 138 + * temac_dma_out32_* - Memory mapped DMA read, these function expects 139 + * a register input that is based on DCR word addresses which are then 140 + * converted to memory mapped byte addresses. To be assigned to 141 + * lp->dma_out32. 147 142 */ 148 - static void temac_dma_out32(struct temac_local *lp, int reg, u32 value) 143 + static void temac_dma_out32_be(struct temac_local *lp, int reg, u32 value) 149 144 { 150 - out_be32(lp->sdma_regs + (reg << 2), value); 145 + iowrite32be(value, lp->sdma_regs + (reg << 2)); 146 + } 147 + 148 + static void temac_dma_out32_le(struct temac_local *lp, int reg, u32 value) 149 + { 150 + iowrite32(value, lp->sdma_regs + (reg << 2)); 151 151 } 152 152 153 153 /* DMA register access functions can be DCR based or memory mapped. ··· 211 187 212 188 /* 213 189 * temac_dcr_setup - This is a stub for when DCR is not supported, 214 - * such as with MicroBlaze 190 + * such as with MicroBlaze and x86 215 191 */ 216 192 static int temac_dcr_setup(struct temac_local *lp, struct platform_device *op, 217 193 struct device_node *np) ··· 249 225 dma_free_coherent(ndev->dev.parent, 250 226 sizeof(*lp->tx_bd_v) * TX_BD_NUM, 251 227 lp->tx_bd_v, lp->tx_bd_p); 252 - kfree(lp->rx_skb); 253 228 } 254 229 255 230 /** ··· 258 235 { 259 236 struct temac_local *lp = netdev_priv(ndev); 260 237 struct sk_buff *skb; 238 + dma_addr_t skb_dma_addr; 261 239 int i; 262 240 263 - lp->rx_skb = kcalloc(RX_BD_NUM, sizeof(*lp->rx_skb), GFP_KERNEL); 241 + lp->rx_skb = devm_kcalloc(&ndev->dev, RX_BD_NUM, sizeof(*lp->rx_skb), 242 + GFP_KERNEL); 264 243 if (!lp->rx_skb) 265 244 goto out; 266 245 ··· 281 256 goto out; 282 257 283 258 for (i = 0; i < TX_BD_NUM; i++) { 284 - lp->tx_bd_v[i].next = lp->tx_bd_p + 285 - sizeof(*lp->tx_bd_v) * ((i + 1) % TX_BD_NUM); 259 + lp->tx_bd_v[i].next = cpu_to_be32(lp->tx_bd_p 260 + + sizeof(*lp->tx_bd_v) * ((i + 1) % TX_BD_NUM)); 286 261 } 287 262 288 263 for (i = 0; i < RX_BD_NUM; i++) { 289 - lp->rx_bd_v[i].next = lp->rx_bd_p + 290 - sizeof(*lp->rx_bd_v) * ((i + 1) % RX_BD_NUM); 264 + lp->rx_bd_v[i].next = cpu_to_be32(lp->rx_bd_p 265 + + sizeof(*lp->rx_bd_v) * ((i + 1) % RX_BD_NUM)); 291 266 292 267 skb = netdev_alloc_skb_ip_align(ndev, 293 268 XTE_MAX_JUMBO_FRAME_SIZE); ··· 296 271 297 272 lp->rx_skb[i] = skb; 298 273 /* returns physical address of skb->data */ 299 - lp->rx_bd_v[i].phys = dma_map_single(ndev->dev.parent, 300 - skb->data, 301 - XTE_MAX_JUMBO_FRAME_SIZE, 302 - DMA_FROM_DEVICE); 303 - lp->rx_bd_v[i].len = XTE_MAX_JUMBO_FRAME_SIZE; 304 - lp->rx_bd_v[i].app0 = STS_CTRL_APP0_IRQONEND; 274 + skb_dma_addr = dma_map_single(ndev->dev.parent, skb->data, 275 + XTE_MAX_JUMBO_FRAME_SIZE, 276 + DMA_FROM_DEVICE); 277 + lp->rx_bd_v[i].phys = cpu_to_be32(skb_dma_addr); 278 + lp->rx_bd_v[i].len = cpu_to_be32(XTE_MAX_JUMBO_FRAME_SIZE); 279 + lp->rx_bd_v[i].app0 = cpu_to_be32(STS_CTRL_APP0_IRQONEND); 305 280 } 306 281 307 - lp->dma_out(lp, TX_CHNL_CTRL, 0x10220400 | 308 - CHNL_CTRL_IRQ_EN | 309 - CHNL_CTRL_IRQ_DLY_EN | 310 - CHNL_CTRL_IRQ_COAL_EN); 311 - /* 0x10220483 */ 312 - /* 0x00100483 */ 313 - lp->dma_out(lp, RX_CHNL_CTRL, 0xff070000 | 314 - CHNL_CTRL_IRQ_EN | 315 - CHNL_CTRL_IRQ_DLY_EN | 316 - CHNL_CTRL_IRQ_COAL_EN | 317 - CHNL_CTRL_IRQ_IOE); 318 - /* 0xff010283 */ 319 - 320 - lp->dma_out(lp, RX_CURDESC_PTR, lp->rx_bd_p); 321 - lp->dma_out(lp, RX_TAILDESC_PTR, 322 - lp->rx_bd_p + (sizeof(*lp->rx_bd_v) * (RX_BD_NUM - 1))); 323 - lp->dma_out(lp, TX_CURDESC_PTR, lp->tx_bd_p); 282 + /* Configure DMA channel (irq setup) */ 283 + lp->dma_out(lp, TX_CHNL_CTRL, lp->tx_chnl_ctrl | 284 + 0x00000400 | // Use 1 Bit Wide Counters. Currently Not Used! 285 + CHNL_CTRL_IRQ_EN | CHNL_CTRL_IRQ_ERR_EN | 286 + CHNL_CTRL_IRQ_DLY_EN | CHNL_CTRL_IRQ_COAL_EN); 287 + lp->dma_out(lp, RX_CHNL_CTRL, lp->rx_chnl_ctrl | 288 + CHNL_CTRL_IRQ_IOE | 289 + CHNL_CTRL_IRQ_EN | CHNL_CTRL_IRQ_ERR_EN | 290 + CHNL_CTRL_IRQ_DLY_EN | CHNL_CTRL_IRQ_COAL_EN); 324 291 325 292 /* Init descriptor indexes */ 326 293 lp->tx_bd_ci = 0; 327 294 lp->tx_bd_next = 0; 328 295 lp->tx_bd_tail = 0; 329 296 lp->rx_bd_ci = 0; 297 + 298 + /* Enable RX DMA transfers */ 299 + wmb(); 300 + lp->dma_out(lp, RX_CURDESC_PTR, lp->rx_bd_p); 301 + lp->dma_out(lp, RX_TAILDESC_PTR, 302 + lp->rx_bd_p + (sizeof(*lp->rx_bd_v) * (RX_BD_NUM - 1))); 303 + 304 + /* Prepare for TX DMA transfer */ 305 + lp->dma_out(lp, TX_CURDESC_PTR, lp->tx_bd_p); 330 306 331 307 return 0; 332 308 ··· 345 319 struct temac_local *lp = netdev_priv(ndev); 346 320 347 321 /* set up unicast MAC address filter set its mac address */ 348 - mutex_lock(&lp->indirect_mutex); 322 + mutex_lock(lp->indirect_mutex); 349 323 temac_indirect_out32(lp, XTE_UAW0_OFFSET, 350 324 (ndev->dev_addr[0]) | 351 325 (ndev->dev_addr[1] << 8) | ··· 356 330 temac_indirect_out32(lp, XTE_UAW1_OFFSET, 357 331 (ndev->dev_addr[4] & 0x000000ff) | 358 332 (ndev->dev_addr[5] << 8)); 359 - mutex_unlock(&lp->indirect_mutex); 333 + mutex_unlock(lp->indirect_mutex); 360 334 } 361 335 362 336 static int temac_init_mac_address(struct net_device *ndev, const void *address) ··· 385 359 u32 multi_addr_msw, multi_addr_lsw, val; 386 360 int i; 387 361 388 - mutex_lock(&lp->indirect_mutex); 362 + mutex_lock(lp->indirect_mutex); 389 363 if (ndev->flags & (IFF_ALLMULTI | IFF_PROMISC) || 390 364 netdev_mc_count(ndev) > MULTICAST_CAM_TABLE_NUM) { 391 365 /* ··· 424 398 temac_indirect_out32(lp, XTE_MAW1_OFFSET, 0); 425 399 dev_info(&ndev->dev, "Promiscuous mode disabled.\n"); 426 400 } 427 - mutex_unlock(&lp->indirect_mutex); 401 + mutex_unlock(lp->indirect_mutex); 428 402 } 429 403 430 404 static struct temac_option { ··· 516 490 struct temac_option *tp = &temac_options[0]; 517 491 int reg; 518 492 519 - mutex_lock(&lp->indirect_mutex); 493 + mutex_lock(lp->indirect_mutex); 520 494 while (tp->opt) { 521 495 reg = temac_indirect_in32(lp, tp->reg) & ~tp->m_or; 522 496 if (options & tp->opt) ··· 525 499 tp++; 526 500 } 527 501 lp->options |= options; 528 - mutex_unlock(&lp->indirect_mutex); 502 + mutex_unlock(lp->indirect_mutex); 529 503 530 504 return 0; 531 505 } ··· 544 518 545 519 dev_dbg(&ndev->dev, "%s()\n", __func__); 546 520 547 - mutex_lock(&lp->indirect_mutex); 521 + mutex_lock(lp->indirect_mutex); 548 522 /* Reset the receiver and wait for it to finish reset */ 549 523 temac_indirect_out32(lp, XTE_RXC1_OFFSET, XTE_RXC1_RXRST_MASK); 550 524 timeout = 1000; ··· 596 570 temac_indirect_out32(lp, XTE_TXC_OFFSET, 0); 597 571 temac_indirect_out32(lp, XTE_FCC_OFFSET, XTE_FCC_RXFLO_MASK); 598 572 599 - mutex_unlock(&lp->indirect_mutex); 573 + mutex_unlock(lp->indirect_mutex); 600 574 601 575 /* Sync default options with HW 602 576 * but leave receiver and transmitter disabled. */ ··· 624 598 /* hash together the state values to decide if something has changed */ 625 599 link_state = phy->speed | (phy->duplex << 1) | phy->link; 626 600 627 - mutex_lock(&lp->indirect_mutex); 601 + mutex_lock(lp->indirect_mutex); 628 602 if (lp->last_link != link_state) { 629 603 mii_speed = temac_indirect_in32(lp, XTE_EMCFG_OFFSET); 630 604 mii_speed &= ~XTE_EMCFG_LINKSPD_MASK; ··· 640 614 lp->last_link = link_state; 641 615 phy_print_status(phy); 642 616 } 643 - mutex_unlock(&lp->indirect_mutex); 617 + mutex_unlock(lp->indirect_mutex); 644 618 } 619 + 620 + #ifdef CONFIG_64BIT 621 + 622 + void ptr_to_txbd(void *p, struct cdmac_bd *bd) 623 + { 624 + bd->app3 = (u32)(((u64)p) >> 32); 625 + bd->app4 = (u32)((u64)p & 0xFFFFFFFF); 626 + } 627 + 628 + void *ptr_from_txbd(struct cdmac_bd *bd) 629 + { 630 + return (void *)(((u64)(bd->app3) << 32) | bd->app4); 631 + } 632 + 633 + #else 634 + 635 + void ptr_to_txbd(void *p, struct cmdac_bd *bd) 636 + { 637 + bd->app4 = (u32)p; 638 + } 639 + 640 + void *ptr_from_txbd(struct cdmac_bd *bd) 641 + { 642 + return (void *)(bd->app4); 643 + } 644 + 645 + #endif 645 646 646 647 static void temac_start_xmit_done(struct net_device *ndev) 647 648 { 648 649 struct temac_local *lp = netdev_priv(ndev); 649 650 struct cdmac_bd *cur_p; 650 651 unsigned int stat = 0; 652 + struct sk_buff *skb; 651 653 652 654 cur_p = &lp->tx_bd_v[lp->tx_bd_ci]; 653 - stat = cur_p->app0; 655 + stat = be32_to_cpu(cur_p->app0); 654 656 655 657 while (stat & STS_CTRL_APP0_CMPLT) { 656 - dma_unmap_single(ndev->dev.parent, cur_p->phys, cur_p->len, 657 - DMA_TO_DEVICE); 658 - if (cur_p->app4) 659 - dev_consume_skb_irq((struct sk_buff *)cur_p->app4); 658 + dma_unmap_single(ndev->dev.parent, be32_to_cpu(cur_p->phys), 659 + be32_to_cpu(cur_p->len), DMA_TO_DEVICE); 660 + skb = (struct sk_buff *)ptr_from_txbd(cur_p); 661 + if (skb) 662 + dev_consume_skb_irq(skb); 660 663 cur_p->app0 = 0; 661 664 cur_p->app1 = 0; 662 665 cur_p->app2 = 0; ··· 693 638 cur_p->app4 = 0; 694 639 695 640 ndev->stats.tx_packets++; 696 - ndev->stats.tx_bytes += cur_p->len; 641 + ndev->stats.tx_bytes += be32_to_cpu(cur_p->len); 697 642 698 643 lp->tx_bd_ci++; 699 644 if (lp->tx_bd_ci >= TX_BD_NUM) 700 645 lp->tx_bd_ci = 0; 701 646 702 647 cur_p = &lp->tx_bd_v[lp->tx_bd_ci]; 703 - stat = cur_p->app0; 648 + stat = be32_to_cpu(cur_p->app0); 704 649 } 705 650 706 651 netif_wake_queue(ndev); ··· 734 679 { 735 680 struct temac_local *lp = netdev_priv(ndev); 736 681 struct cdmac_bd *cur_p; 737 - dma_addr_t start_p, tail_p; 682 + dma_addr_t start_p, tail_p, skb_dma_addr; 738 683 int ii; 739 684 unsigned long num_frag; 740 685 skb_frag_t *frag; ··· 744 689 start_p = lp->tx_bd_p + sizeof(*lp->tx_bd_v) * lp->tx_bd_tail; 745 690 cur_p = &lp->tx_bd_v[lp->tx_bd_tail]; 746 691 747 - if (temac_check_tx_bd_space(lp, num_frag)) { 692 + if (temac_check_tx_bd_space(lp, num_frag + 1)) { 748 693 if (!netif_queue_stopped(ndev)) 749 694 netif_stop_queue(ndev); 750 695 return NETDEV_TX_BUSY; ··· 755 700 unsigned int csum_start_off = skb_checksum_start_offset(skb); 756 701 unsigned int csum_index_off = csum_start_off + skb->csum_offset; 757 702 758 - cur_p->app0 |= 1; /* TX Checksum Enabled */ 759 - cur_p->app1 = (csum_start_off << 16) | csum_index_off; 703 + cur_p->app0 |= cpu_to_be32(0x000001); /* TX Checksum Enabled */ 704 + cur_p->app1 = cpu_to_be32((csum_start_off << 16) 705 + | csum_index_off); 760 706 cur_p->app2 = 0; /* initial checksum seed */ 761 707 } 762 708 763 - cur_p->app0 |= STS_CTRL_APP0_SOP; 764 - cur_p->len = skb_headlen(skb); 765 - cur_p->phys = dma_map_single(ndev->dev.parent, skb->data, 766 - skb_headlen(skb), DMA_TO_DEVICE); 767 - cur_p->app4 = (unsigned long)skb; 709 + cur_p->app0 |= cpu_to_be32(STS_CTRL_APP0_SOP); 710 + skb_dma_addr = dma_map_single(ndev->dev.parent, skb->data, 711 + skb_headlen(skb), DMA_TO_DEVICE); 712 + cur_p->len = cpu_to_be32(skb_headlen(skb)); 713 + cur_p->phys = cpu_to_be32(skb_dma_addr); 714 + ptr_to_txbd((void *)skb, cur_p); 768 715 769 716 for (ii = 0; ii < num_frag; ii++) { 770 717 lp->tx_bd_tail++; ··· 774 717 lp->tx_bd_tail = 0; 775 718 776 719 cur_p = &lp->tx_bd_v[lp->tx_bd_tail]; 777 - cur_p->phys = dma_map_single(ndev->dev.parent, 778 - skb_frag_address(frag), 779 - skb_frag_size(frag), DMA_TO_DEVICE); 780 - cur_p->len = skb_frag_size(frag); 720 + skb_dma_addr = dma_map_single(ndev->dev.parent, 721 + skb_frag_address(frag), 722 + skb_frag_size(frag), 723 + DMA_TO_DEVICE); 724 + cur_p->phys = cpu_to_be32(skb_dma_addr); 725 + cur_p->len = cpu_to_be32(skb_frag_size(frag)); 781 726 cur_p->app0 = 0; 782 727 frag++; 783 728 } 784 - cur_p->app0 |= STS_CTRL_APP0_EOP; 729 + cur_p->app0 |= cpu_to_be32(STS_CTRL_APP0_EOP); 785 730 786 731 tail_p = lp->tx_bd_p + sizeof(*lp->tx_bd_v) * lp->tx_bd_tail; 787 732 lp->tx_bd_tail++; ··· 793 734 skb_tx_timestamp(skb); 794 735 795 736 /* Kick off the transfer */ 737 + wmb(); 796 738 lp->dma_out(lp, TX_TAILDESC_PTR, tail_p); /* DMA start */ 797 739 798 740 return NETDEV_TX_OK; ··· 806 746 struct sk_buff *skb, *new_skb; 807 747 unsigned int bdstat; 808 748 struct cdmac_bd *cur_p; 809 - dma_addr_t tail_p; 749 + dma_addr_t tail_p, skb_dma_addr; 810 750 int length; 811 751 unsigned long flags; 812 752 ··· 815 755 tail_p = lp->rx_bd_p + sizeof(*lp->rx_bd_v) * lp->rx_bd_ci; 816 756 cur_p = &lp->rx_bd_v[lp->rx_bd_ci]; 817 757 818 - bdstat = cur_p->app0; 758 + bdstat = be32_to_cpu(cur_p->app0); 819 759 while ((bdstat & STS_CTRL_APP0_CMPLT)) { 820 760 821 761 skb = lp->rx_skb[lp->rx_bd_ci]; 822 - length = cur_p->app4 & 0x3FFF; 762 + length = be32_to_cpu(cur_p->app4) & 0x3FFF; 823 763 824 - dma_unmap_single(ndev->dev.parent, cur_p->phys, length, 825 - DMA_FROM_DEVICE); 764 + dma_unmap_single(ndev->dev.parent, be32_to_cpu(cur_p->phys), 765 + XTE_MAX_JUMBO_FRAME_SIZE, DMA_FROM_DEVICE); 826 766 827 767 skb_put(skb, length); 828 768 skb->protocol = eth_type_trans(skb, ndev); ··· 833 773 (skb->protocol == htons(ETH_P_IP)) && 834 774 (skb->len > 64)) { 835 775 836 - skb->csum = cur_p->app3 & 0xFFFF; 776 + /* Convert from device endianness (be32) to cpu 777 + * endiannes, and if necessary swap the bytes 778 + * (back) for proper IP checksum byte order 779 + * (be16). 780 + */ 781 + skb->csum = htons(be32_to_cpu(cur_p->app3) & 0xFFFF); 837 782 skb->ip_summed = CHECKSUM_COMPLETE; 838 783 } 839 784 ··· 855 790 return; 856 791 } 857 792 858 - cur_p->app0 = STS_CTRL_APP0_IRQONEND; 859 - cur_p->phys = dma_map_single(ndev->dev.parent, new_skb->data, 860 - XTE_MAX_JUMBO_FRAME_SIZE, 861 - DMA_FROM_DEVICE); 862 - cur_p->len = XTE_MAX_JUMBO_FRAME_SIZE; 793 + cur_p->app0 = cpu_to_be32(STS_CTRL_APP0_IRQONEND); 794 + skb_dma_addr = dma_map_single(ndev->dev.parent, new_skb->data, 795 + XTE_MAX_JUMBO_FRAME_SIZE, 796 + DMA_FROM_DEVICE); 797 + cur_p->phys = cpu_to_be32(skb_dma_addr); 798 + cur_p->len = cpu_to_be32(XTE_MAX_JUMBO_FRAME_SIZE); 863 799 lp->rx_skb[lp->rx_bd_ci] = new_skb; 864 800 865 801 lp->rx_bd_ci++; ··· 868 802 lp->rx_bd_ci = 0; 869 803 870 804 cur_p = &lp->rx_bd_v[lp->rx_bd_ci]; 871 - bdstat = cur_p->app0; 805 + bdstat = be32_to_cpu(cur_p->app0); 872 806 } 873 807 lp->dma_out(lp, RX_TAILDESC_PTR, tail_p); 874 808 ··· 923 857 dev_err(lp->dev, "of_phy_connect() failed\n"); 924 858 return -ENODEV; 925 859 } 926 - 860 + phy_start(phydev); 861 + } else if (strlen(lp->phy_name) > 0) { 862 + phydev = phy_connect(lp->ndev, lp->phy_name, temac_adjust_link, 863 + lp->phy_interface); 864 + if (!phydev) { 865 + dev_err(lp->dev, "phy_connect() failed\n"); 866 + return -ENODEV; 867 + } 927 868 phy_start(phydev); 928 869 } 929 870 ··· 1050 977 .set_link_ksettings = phy_ethtool_set_link_ksettings, 1051 978 }; 1052 979 1053 - static int temac_of_probe(struct platform_device *op) 980 + static int temac_probe(struct platform_device *pdev) 1054 981 { 1055 - struct device_node *np; 982 + struct ll_temac_platform_data *pdata = dev_get_platdata(&pdev->dev); 983 + struct device_node *temac_np = dev_of_node(&pdev->dev), *dma_np; 1056 984 struct temac_local *lp; 1057 985 struct net_device *ndev; 986 + struct resource *res; 1058 987 const void *addr; 1059 988 __be32 *p; 989 + bool little_endian; 1060 990 int rc = 0; 1061 991 1062 992 /* Init network device structure */ 1063 - ndev = alloc_etherdev(sizeof(*lp)); 993 + ndev = devm_alloc_etherdev(&pdev->dev, sizeof(*lp)); 1064 994 if (!ndev) 1065 995 return -ENOMEM; 1066 996 1067 - platform_set_drvdata(op, ndev); 1068 - SET_NETDEV_DEV(ndev, &op->dev); 997 + platform_set_drvdata(pdev, ndev); 998 + SET_NETDEV_DEV(ndev, &pdev->dev); 1069 999 ndev->flags &= ~IFF_MULTICAST; /* clear multicast */ 1070 1000 ndev->features = NETIF_F_SG; 1071 1001 ndev->netdev_ops = &temac_netdev_ops; ··· 1090 1014 /* setup temac private info structure */ 1091 1015 lp = netdev_priv(ndev); 1092 1016 lp->ndev = ndev; 1093 - lp->dev = &op->dev; 1017 + lp->dev = &pdev->dev; 1094 1018 lp->options = XTE_OPTION_DEFAULTS; 1095 1019 spin_lock_init(&lp->rx_lock); 1096 - mutex_init(&lp->indirect_mutex); 1020 + 1021 + /* Setup mutex for synchronization of indirect register access */ 1022 + if (pdata) { 1023 + if (!pdata->indirect_mutex) { 1024 + dev_err(&pdev->dev, 1025 + "indirect_mutex missing in platform_data\n"); 1026 + return -EINVAL; 1027 + } 1028 + lp->indirect_mutex = pdata->indirect_mutex; 1029 + } else { 1030 + lp->indirect_mutex = devm_kmalloc(&pdev->dev, 1031 + sizeof(*lp->indirect_mutex), 1032 + GFP_KERNEL); 1033 + mutex_init(lp->indirect_mutex); 1034 + } 1097 1035 1098 1036 /* map device registers */ 1099 - lp->regs = of_iomap(op->dev.of_node, 0); 1100 - if (!lp->regs) { 1101 - dev_err(&op->dev, "could not map temac regs.\n"); 1102 - rc = -ENOMEM; 1103 - goto nodev; 1037 + res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 1038 + lp->regs = devm_ioremap_nocache(&pdev->dev, res->start, 1039 + resource_size(res)); 1040 + if (IS_ERR(lp->regs)) { 1041 + dev_err(&pdev->dev, "could not map TEMAC registers\n"); 1042 + return PTR_ERR(lp->regs); 1043 + } 1044 + 1045 + /* Select register access functions with the specified 1046 + * endianness mode. Default for OF devices is big-endian. 1047 + */ 1048 + little_endian = false; 1049 + if (temac_np) { 1050 + if (of_get_property(temac_np, "little-endian", NULL)) 1051 + little_endian = true; 1052 + } else if (pdata) { 1053 + little_endian = pdata->reg_little_endian; 1054 + } 1055 + if (little_endian) { 1056 + lp->temac_ior = _temac_ior_le; 1057 + lp->temac_iow = _temac_iow_le; 1058 + } else { 1059 + lp->temac_ior = _temac_ior_be; 1060 + lp->temac_iow = _temac_iow_be; 1104 1061 } 1105 1062 1106 1063 /* Setup checksum offload, but default to off if not specified */ 1107 1064 lp->temac_features = 0; 1108 - p = (__be32 *)of_get_property(op->dev.of_node, "xlnx,txcsum", NULL); 1109 - if (p && be32_to_cpu(*p)) { 1110 - lp->temac_features |= TEMAC_FEATURE_TX_CSUM; 1065 + if (temac_np) { 1066 + p = (__be32 *)of_get_property(temac_np, "xlnx,txcsum", NULL); 1067 + if (p && be32_to_cpu(*p)) 1068 + lp->temac_features |= TEMAC_FEATURE_TX_CSUM; 1069 + p = (__be32 *)of_get_property(temac_np, "xlnx,rxcsum", NULL); 1070 + if (p && be32_to_cpu(*p)) 1071 + lp->temac_features |= TEMAC_FEATURE_RX_CSUM; 1072 + } else if (pdata) { 1073 + if (pdata->txcsum) 1074 + lp->temac_features |= TEMAC_FEATURE_TX_CSUM; 1075 + if (pdata->rxcsum) 1076 + lp->temac_features |= TEMAC_FEATURE_RX_CSUM; 1077 + } 1078 + if (lp->temac_features & TEMAC_FEATURE_TX_CSUM) 1111 1079 /* Can checksum TCP/UDP over IPv4. */ 1112 1080 ndev->features |= NETIF_F_IP_CSUM; 1113 - } 1114 - p = (__be32 *)of_get_property(op->dev.of_node, "xlnx,rxcsum", NULL); 1115 - if (p && be32_to_cpu(*p)) 1116 - lp->temac_features |= TEMAC_FEATURE_RX_CSUM; 1117 1081 1118 - /* Find the DMA node, map the DMA registers, and decode the DMA IRQs */ 1119 - np = of_parse_phandle(op->dev.of_node, "llink-connected", 0); 1120 - if (!np) { 1121 - dev_err(&op->dev, "could not find DMA node\n"); 1122 - rc = -ENODEV; 1123 - goto err_iounmap; 1124 - } 1125 - 1126 - /* Setup the DMA register accesses, could be DCR or memory mapped */ 1127 - if (temac_dcr_setup(lp, op, np)) { 1128 - 1129 - /* no DCR in the device tree, try non-DCR */ 1130 - lp->sdma_regs = of_iomap(np, 0); 1131 - if (lp->sdma_regs) { 1132 - lp->dma_in = temac_dma_in32; 1133 - lp->dma_out = temac_dma_out32; 1134 - dev_dbg(&op->dev, "MEM base: %p\n", lp->sdma_regs); 1135 - } else { 1136 - dev_err(&op->dev, "unable to map DMA registers\n"); 1137 - of_node_put(np); 1138 - goto err_iounmap; 1082 + /* Setup LocalLink DMA */ 1083 + if (temac_np) { 1084 + /* Find the DMA node, map the DMA registers, and 1085 + * decode the DMA IRQs. 1086 + */ 1087 + dma_np = of_parse_phandle(temac_np, "llink-connected", 0); 1088 + if (!dma_np) { 1089 + dev_err(&pdev->dev, "could not find DMA node\n"); 1090 + return -ENODEV; 1139 1091 } 1092 + 1093 + /* Setup the DMA register accesses, could be DCR or 1094 + * memory mapped. 1095 + */ 1096 + if (temac_dcr_setup(lp, pdev, dma_np)) { 1097 + /* no DCR in the device tree, try non-DCR */ 1098 + lp->sdma_regs = devm_of_iomap(&pdev->dev, dma_np, 0, 1099 + NULL); 1100 + if (IS_ERR(lp->sdma_regs)) { 1101 + dev_err(&pdev->dev, 1102 + "unable to map DMA registers\n"); 1103 + of_node_put(dma_np); 1104 + return PTR_ERR(lp->sdma_regs); 1105 + } 1106 + if (of_get_property(dma_np, "little-endian", NULL)) { 1107 + lp->dma_in = temac_dma_in32_le; 1108 + lp->dma_out = temac_dma_out32_le; 1109 + } else { 1110 + lp->dma_in = temac_dma_in32_be; 1111 + lp->dma_out = temac_dma_out32_be; 1112 + } 1113 + dev_dbg(&pdev->dev, "MEM base: %p\n", lp->sdma_regs); 1114 + } 1115 + 1116 + /* Get DMA RX and TX interrupts */ 1117 + lp->rx_irq = irq_of_parse_and_map(dma_np, 0); 1118 + lp->tx_irq = irq_of_parse_and_map(dma_np, 1); 1119 + 1120 + /* Use defaults for IRQ delay/coalescing setup. These 1121 + * are configuration values, so does not belong in 1122 + * device-tree. 1123 + */ 1124 + lp->tx_chnl_ctrl = 0x10220000; 1125 + lp->rx_chnl_ctrl = 0xff070000; 1126 + 1127 + /* Finished with the DMA node; drop the reference */ 1128 + of_node_put(dma_np); 1129 + } else if (pdata) { 1130 + /* 2nd memory resource specifies DMA registers */ 1131 + res = platform_get_resource(pdev, IORESOURCE_MEM, 1); 1132 + lp->sdma_regs = devm_ioremap_nocache(&pdev->dev, res->start, 1133 + resource_size(res)); 1134 + if (IS_ERR(lp->sdma_regs)) { 1135 + dev_err(&pdev->dev, 1136 + "could not map DMA registers\n"); 1137 + return PTR_ERR(lp->sdma_regs); 1138 + } 1139 + if (pdata->dma_little_endian) { 1140 + lp->dma_in = temac_dma_in32_le; 1141 + lp->dma_out = temac_dma_out32_le; 1142 + } else { 1143 + lp->dma_in = temac_dma_in32_be; 1144 + lp->dma_out = temac_dma_out32_be; 1145 + } 1146 + 1147 + /* Get DMA RX and TX interrupts */ 1148 + lp->rx_irq = platform_get_irq(pdev, 0); 1149 + lp->tx_irq = platform_get_irq(pdev, 1); 1150 + 1151 + /* IRQ delay/coalescing setup */ 1152 + if (pdata->tx_irq_timeout || pdata->tx_irq_count) 1153 + lp->tx_chnl_ctrl = (pdata->tx_irq_timeout << 24) | 1154 + (pdata->tx_irq_count << 16); 1155 + else 1156 + lp->tx_chnl_ctrl = 0x10220000; 1157 + if (pdata->rx_irq_timeout || pdata->rx_irq_count) 1158 + lp->rx_chnl_ctrl = (pdata->rx_irq_timeout << 24) | 1159 + (pdata->rx_irq_count << 16); 1160 + else 1161 + lp->rx_chnl_ctrl = 0xff070000; 1140 1162 } 1141 1163 1142 - lp->rx_irq = irq_of_parse_and_map(np, 0); 1143 - lp->tx_irq = irq_of_parse_and_map(np, 1); 1144 - 1145 - of_node_put(np); /* Finished with the DMA node; drop the reference */ 1146 - 1147 - if (!lp->rx_irq || !lp->tx_irq) { 1148 - dev_err(&op->dev, "could not determine irqs\n"); 1149 - rc = -ENOMEM; 1150 - goto err_iounmap_2; 1164 + /* Error handle returned DMA RX and TX interrupts */ 1165 + if (lp->rx_irq < 0) { 1166 + if (lp->rx_irq != -EPROBE_DEFER) 1167 + dev_err(&pdev->dev, "could not get DMA RX irq\n"); 1168 + return lp->rx_irq; 1169 + } 1170 + if (lp->tx_irq < 0) { 1171 + if (lp->tx_irq != -EPROBE_DEFER) 1172 + dev_err(&pdev->dev, "could not get DMA TX irq\n"); 1173 + return lp->tx_irq; 1151 1174 } 1152 1175 1153 - 1154 - /* Retrieve the MAC address */ 1155 - addr = of_get_mac_address(op->dev.of_node); 1156 - if (!addr) { 1157 - dev_err(&op->dev, "could not find MAC address\n"); 1158 - rc = -ENODEV; 1159 - goto err_iounmap_2; 1176 + if (temac_np) { 1177 + /* Retrieve the MAC address */ 1178 + addr = of_get_mac_address(temac_np); 1179 + if (!addr) { 1180 + dev_err(&pdev->dev, "could not find MAC address\n"); 1181 + return -ENODEV; 1182 + } 1183 + temac_init_mac_address(ndev, addr); 1184 + } else if (pdata) { 1185 + temac_init_mac_address(ndev, pdata->mac_addr); 1160 1186 } 1161 - temac_init_mac_address(ndev, addr); 1162 1187 1163 - rc = temac_mdio_setup(lp, op->dev.of_node); 1188 + rc = temac_mdio_setup(lp, pdev); 1164 1189 if (rc) 1165 - dev_warn(&op->dev, "error registering MDIO bus\n"); 1190 + dev_warn(&pdev->dev, "error registering MDIO bus\n"); 1166 1191 1167 - lp->phy_node = of_parse_phandle(op->dev.of_node, "phy-handle", 0); 1168 - if (lp->phy_node) 1169 - dev_dbg(lp->dev, "using PHY node %pOF (%p)\n", np, np); 1192 + if (temac_np) { 1193 + lp->phy_node = of_parse_phandle(temac_np, "phy-handle", 0); 1194 + if (lp->phy_node) 1195 + dev_dbg(lp->dev, "using PHY node %pOF\n", temac_np); 1196 + } else if (pdata) { 1197 + snprintf(lp->phy_name, sizeof(lp->phy_name), 1198 + PHY_ID_FMT, lp->mii_bus->id, pdata->phy_addr); 1199 + lp->phy_interface = pdata->phy_interface; 1200 + } 1170 1201 1171 1202 /* Add the device attributes */ 1172 1203 rc = sysfs_create_group(&lp->dev->kobj, &temac_attr_group); 1173 1204 if (rc) { 1174 1205 dev_err(lp->dev, "Error creating sysfs files\n"); 1175 - goto err_iounmap_2; 1206 + goto err_sysfs_create; 1176 1207 } 1177 1208 1178 1209 rc = register_netdev(lp->ndev); ··· 1290 1107 1291 1108 return 0; 1292 1109 1293 - err_register_ndev: 1110 + err_register_ndev: 1294 1111 sysfs_remove_group(&lp->dev->kobj, &temac_attr_group); 1295 - err_iounmap_2: 1296 - if (lp->sdma_regs) 1297 - iounmap(lp->sdma_regs); 1298 - err_iounmap: 1299 - iounmap(lp->regs); 1300 - nodev: 1301 - free_netdev(ndev); 1302 - ndev = NULL; 1112 + err_sysfs_create: 1113 + if (lp->phy_node) 1114 + of_node_put(lp->phy_node); 1115 + temac_mdio_teardown(lp); 1303 1116 return rc; 1304 1117 } 1305 1118 1306 - static int temac_of_remove(struct platform_device *op) 1119 + static int temac_remove(struct platform_device *pdev) 1307 1120 { 1308 - struct net_device *ndev = platform_get_drvdata(op); 1121 + struct net_device *ndev = platform_get_drvdata(pdev); 1309 1122 struct temac_local *lp = netdev_priv(ndev); 1310 1123 1311 - temac_mdio_teardown(lp); 1312 1124 unregister_netdev(ndev); 1313 1125 sysfs_remove_group(&lp->dev->kobj, &temac_attr_group); 1314 - of_node_put(lp->phy_node); 1315 - lp->phy_node = NULL; 1316 - iounmap(lp->regs); 1317 - if (lp->sdma_regs) 1318 - iounmap(lp->sdma_regs); 1319 - free_netdev(ndev); 1126 + if (lp->phy_node) 1127 + of_node_put(lp->phy_node); 1128 + temac_mdio_teardown(lp); 1320 1129 return 0; 1321 1130 } 1322 1131 ··· 1321 1146 }; 1322 1147 MODULE_DEVICE_TABLE(of, temac_of_match); 1323 1148 1324 - static struct platform_driver temac_of_driver = { 1325 - .probe = temac_of_probe, 1326 - .remove = temac_of_remove, 1149 + static struct platform_driver temac_driver = { 1150 + .probe = temac_probe, 1151 + .remove = temac_remove, 1327 1152 .driver = { 1328 1153 .name = "xilinx_temac", 1329 1154 .of_match_table = temac_of_match, 1330 1155 }, 1331 1156 }; 1332 1157 1333 - module_platform_driver(temac_of_driver); 1158 + module_platform_driver(temac_driver); 1334 1159 1335 1160 MODULE_DESCRIPTION("Xilinx LL_TEMAC Ethernet driver"); 1336 1161 MODULE_AUTHOR("Yoshio Kashiwagi");
+31 -22
drivers/net/ethernet/xilinx/ll_temac_mdio.c
··· 14 14 #include <linux/of_address.h> 15 15 #include <linux/slab.h> 16 16 #include <linux/of_mdio.h> 17 + #include <linux/platform_data/xilinx-ll-temac.h> 17 18 18 19 #include "ll_temac.h" 19 20 ··· 29 28 /* Write the PHY address to the MIIM Access Initiator register. 30 29 * When the transfer completes, the PHY register value will appear 31 30 * in the LSW0 register */ 32 - mutex_lock(&lp->indirect_mutex); 31 + mutex_lock(lp->indirect_mutex); 33 32 temac_iow(lp, XTE_LSW0_OFFSET, (phy_id << 5) | reg); 34 33 rc = temac_indirect_in32(lp, XTE_MIIMAI_OFFSET); 35 - mutex_unlock(&lp->indirect_mutex); 34 + mutex_unlock(lp->indirect_mutex); 36 35 37 36 dev_dbg(lp->dev, "temac_mdio_read(phy_id=%i, reg=%x) == %x\n", 38 37 phy_id, reg, rc); ··· 50 49 /* First write the desired value into the write data register 51 50 * and then write the address into the access initiator register 52 51 */ 53 - mutex_lock(&lp->indirect_mutex); 52 + mutex_lock(lp->indirect_mutex); 54 53 temac_indirect_out32(lp, XTE_MGTDR_OFFSET, val); 55 54 temac_indirect_out32(lp, XTE_MIIMAI_OFFSET, (phy_id << 5) | reg); 56 - mutex_unlock(&lp->indirect_mutex); 55 + mutex_unlock(lp->indirect_mutex); 57 56 58 57 return 0; 59 58 } 60 59 61 - int temac_mdio_setup(struct temac_local *lp, struct device_node *np) 60 + int temac_mdio_setup(struct temac_local *lp, struct platform_device *pdev) 62 61 { 62 + struct ll_temac_platform_data *pdata = dev_get_platdata(&pdev->dev); 63 + struct device_node *np = dev_of_node(&pdev->dev); 63 64 struct mii_bus *bus; 64 65 u32 bus_hz; 65 66 int clk_div; 66 67 int rc; 67 68 struct resource res; 68 69 70 + /* Get MDIO bus frequency (if specified) */ 71 + bus_hz = 0; 72 + if (np) 73 + of_property_read_u32(np, "clock-frequency", &bus_hz); 74 + else if (pdata) 75 + bus_hz = pdata->mdio_clk_freq; 76 + 69 77 /* Calculate a reasonable divisor for the clock rate */ 70 78 clk_div = 0x3f; /* worst-case default setting */ 71 - if (of_property_read_u32(np, "clock-frequency", &bus_hz) == 0) { 79 + if (bus_hz != 0) { 72 80 clk_div = bus_hz / (2500 * 1000 * 2) - 1; 73 81 if (clk_div < 1) 74 82 clk_div = 1; ··· 87 77 88 78 /* Enable the MDIO bus by asserting the enable bit and writing 89 79 * in the clock config */ 90 - mutex_lock(&lp->indirect_mutex); 80 + mutex_lock(lp->indirect_mutex); 91 81 temac_indirect_out32(lp, XTE_MC_OFFSET, 1 << 6 | clk_div); 92 - mutex_unlock(&lp->indirect_mutex); 82 + mutex_unlock(lp->indirect_mutex); 93 83 94 - bus = mdiobus_alloc(); 84 + bus = devm_mdiobus_alloc(&pdev->dev); 95 85 if (!bus) 96 86 return -ENOMEM; 97 87 98 - of_address_to_resource(np, 0, &res); 99 - snprintf(bus->id, MII_BUS_ID_SIZE, "%.8llx", 100 - (unsigned long long)res.start); 88 + if (np) { 89 + of_address_to_resource(np, 0, &res); 90 + snprintf(bus->id, MII_BUS_ID_SIZE, "%.8llx", 91 + (unsigned long long)res.start); 92 + } else if (pdata && pdata->mdio_bus_id >= 0) { 93 + snprintf(bus->id, MII_BUS_ID_SIZE, "%.8llx", 94 + pdata->mdio_bus_id); 95 + } 96 + 101 97 bus->priv = lp; 102 98 bus->name = "Xilinx TEMAC MDIO"; 103 99 bus->read = temac_mdio_read; ··· 114 98 115 99 rc = of_mdiobus_register(bus, np); 116 100 if (rc) 117 - goto err_register; 101 + return rc; 118 102 119 - mutex_lock(&lp->indirect_mutex); 103 + mutex_lock(lp->indirect_mutex); 120 104 dev_dbg(lp->dev, "MDIO bus registered; MC:%x\n", 121 105 temac_indirect_in32(lp, XTE_MC_OFFSET)); 122 - mutex_unlock(&lp->indirect_mutex); 106 + mutex_unlock(lp->indirect_mutex); 123 107 return 0; 124 - 125 - err_register: 126 - mdiobus_free(bus); 127 - return rc; 128 108 } 129 109 130 110 void temac_mdio_teardown(struct temac_local *lp) 131 111 { 132 112 mdiobus_unregister(lp->mii_bus); 133 - mdiobus_free(lp->mii_bus); 134 - lp->mii_bus = NULL; 135 113 } 136 -
+32
include/linux/platform_data/xilinx-ll-temac.h
··· 1 + /* SPDX-License-Identifier: GPL-2.0 */ 2 + #ifndef __LINUX_XILINX_LL_TEMAC_H 3 + #define __LINUX_XILINX_LL_TEMAC_H 4 + 5 + #include <linux/if_ether.h> 6 + #include <linux/phy.h> 7 + 8 + struct ll_temac_platform_data { 9 + bool txcsum; /* Enable/disable TX checksum */ 10 + bool rxcsum; /* Enable/disable RX checksum */ 11 + u8 mac_addr[ETH_ALEN]; /* MAC address (6 bytes) */ 12 + /* Clock frequency for input to MDIO clock generator */ 13 + u32 mdio_clk_freq; 14 + unsigned long long mdio_bus_id; /* Unique id for MDIO bus */ 15 + int phy_addr; /* Address of the PHY to connect to */ 16 + phy_interface_t phy_interface; /* PHY interface mode */ 17 + bool reg_little_endian; /* Little endian TEMAC register access */ 18 + bool dma_little_endian; /* Little endian DMA register access */ 19 + /* Pre-initialized mutex to use for synchronizing indirect 20 + * register access. When using both interfaces of a single 21 + * TEMAC IP block, the same mutex should be passed here, as 22 + * they share the same DCR bus bridge. 23 + */ 24 + struct mutex *indirect_mutex; 25 + /* DMA channel control setup */ 26 + u8 tx_irq_timeout; /* TX Interrupt Delay Time-out */ 27 + u8 tx_irq_count; /* TX Interrupt Coalescing Threshold Count */ 28 + u8 rx_irq_timeout; /* RX Interrupt Delay Time-out */ 29 + u8 rx_irq_count; /* RX Interrupt Coalescing Threshold Count */ 30 + }; 31 + 32 + #endif /* __LINUX_XILINX_LL_TEMAC_H */