diff options
Diffstat (limited to 'drivers/net/fsl-fman.c')
-rw-r--r-- | drivers/net/fsl-fman.c | 80 |
1 files changed, 45 insertions, 35 deletions
diff --git a/drivers/net/fsl-fman.c b/drivers/net/fsl-fman.c index 6d54fcc7c9..5262928480 100644 --- a/drivers/net/fsl-fman.c +++ b/drivers/net/fsl-fman.c @@ -1,4 +1,4 @@ -// SPDX-License-Identifier: GPL-2.0+ +// SPDX-License-Identifier: GPL-2.0-or-later /* * Copyright 2009-2012 Freescale Semiconductor, Inc. * Dave Liu <daveliu@freescale.com> @@ -101,7 +101,7 @@ struct fm_eth { struct fm_bmi_rx_port *rx_port; phy_interface_t enet_if; struct eth_device edev; - struct device_d *dev; + struct device *dev; struct fm_port_global_pram *rx_pram; /* Rx parameter table */ struct fm_port_global_pram *tx_pram; /* Tx parameter table */ struct fm_port_bd *rx_bd_ring; /* Rx BD ring base */ @@ -207,7 +207,7 @@ static int fm_upload_ucode(struct fm_imem *imem, return 0; } -static int fman_upload_firmware(struct device_d *dev, struct fm_imem *fm_imem) +static int fman_upload_firmware(struct device *dev, struct fm_imem *fm_imem) { int i, size, ret; const struct qe_firmware *firmware; @@ -398,7 +398,7 @@ static void fm_init_qmi(struct fm_qmi_common *qmi) out_be32(&qmi->fmqm_ie, FMQM_IE_CLEAR_ALL); } -static int fm_init_common(struct device_d *dev, struct ccsr_fman *reg) +static int fm_init_common(struct device *dev, struct ccsr_fman *reg) { int ret; @@ -583,7 +583,6 @@ static int fm_eth_rx_port_parameter_init(struct fm_eth *fm_eth) void *rx_bd_ring_base; void *rx_buf_pool; u32 bd_ring_base_lo, bd_ring_base_hi; - u32 buf_lo, buf_hi; struct fm_port_bd *rxbd; struct fm_port_qd *rxqd; struct fm_bmi_rx_port *bmi_rx_port = fm_eth->rx_port; @@ -620,9 +619,7 @@ static int fm_eth_rx_port_parameter_init(struct fm_eth *fm_eth) * RX_BD_RING_SIZE); /* alloc Rx buffer from main memory */ - rx_buf_pool = malloc(MAX_RXBUF_LEN * RX_BD_RING_SIZE); - if (!rx_buf_pool) - return -ENOMEM; + rx_buf_pool = dma_alloc(MAX_RXBUF_LEN * RX_BD_RING_SIZE); memset(rx_buf_pool, 0, MAX_RXBUF_LEN * RX_BD_RING_SIZE); @@ -633,18 +630,21 @@ static int fm_eth_rx_port_parameter_init(struct fm_eth *fm_eth) /* init Rx BDs ring */ for (i = 0; i < RX_BD_RING_SIZE; i++) { + dma_addr_t dma; + rxbd = &fm_eth->rx_bd_ring[i]; muram_writew(&rxbd->status, RxBD_EMPTY); muram_writew(&rxbd->len, 0); - buf_hi = upper_32_bits(virt_to_phys(rx_buf_pool + - i * MAX_RXBUF_LEN)); - buf_lo = lower_32_bits(virt_to_phys(rx_buf_pool + - i * MAX_RXBUF_LEN)); - dma_sync_single_for_device((unsigned long)rx_buf_pool + i * MAX_RXBUF_LEN, - MAX_RXBUF_LEN, DMA_FROM_DEVICE); - muram_writew(&rxbd->buf_ptr_hi, (u16)buf_hi); - out_be32(&rxbd->buf_ptr_lo, buf_lo); + + dma = dma_map_single(fm_eth->dev, + rx_buf_pool + i * MAX_RXBUF_LEN, + MAX_RXBUF_LEN, DMA_FROM_DEVICE); + if (dma_mapping_error(fm_eth->dev, dma)) + return -EFAULT; + + muram_writew(&rxbd->buf_ptr_hi, (u16)upper_32_bits(dma)); + out_be32(&rxbd->buf_ptr_lo, lower_32_bits(dma)); } /* set the Rx queue descriptor */ @@ -911,13 +911,13 @@ static int fm_eth_recv(struct eth_device *edev) data = (u8 *)((unsigned long)(buf_hi << 16) << 16 | buf_lo); len = muram_readw(&rxbd->len); - dma_sync_single_for_cpu((unsigned long)data, + dma_sync_single_for_cpu(fm_eth->dev, (unsigned long)data, len, DMA_FROM_DEVICE); net_receive(edev, data, len); - dma_sync_single_for_device((unsigned long)data, + dma_sync_single_for_device(fm_eth->dev, (unsigned long)data, len, DMA_FROM_DEVICE); } else { @@ -1058,7 +1058,7 @@ static int fm_eth_startup(struct fm_eth *fm_eth) return 0; } -static int fsl_fman_mdio_probe(struct device_d *dev) +static int fsl_fman_mdio_probe(struct device *dev) { struct resource *iores; int ret; @@ -1087,7 +1087,7 @@ static int fsl_fman_mdio_probe(struct device_d *dev) return 0; } -static int fsl_fman_port_probe(struct device_d *dev) +static int fsl_fman_port_probe(struct device *dev) { struct resource *iores; int ret; @@ -1121,15 +1121,15 @@ static int fsl_fman_port_probe(struct device_d *dev) static int fsl_fman_memac_port_bind(struct fm_eth *fm_eth, enum fman_port_type type) { - struct device_node *macnp = fm_eth->dev->device_node; + struct device_node *macnp = fm_eth->dev->of_node; struct device_node *portnp; - struct device_d *portdev; + struct device *portdev; struct fsl_fman_port *port; portnp = of_parse_phandle(macnp, "fsl,fman-ports", type); if (!portnp) { - dev_err(fm_eth->dev, "of_parse_phandle(%s, fsl,fman-ports) failed\n", - macnp->full_name); + dev_err(fm_eth->dev, "of_parse_phandle(%pOF, fsl,fman-ports) failed\n", + macnp); return -EINVAL; } @@ -1149,7 +1149,7 @@ static int fsl_fman_memac_port_bind(struct fm_eth *fm_eth, enum fman_port_type t return 0; } -static int fsl_fman_memac_probe(struct device_d *dev) +static int fsl_fman_memac_probe(struct device *dev) { struct resource *iores; struct fm_eth *fm_eth; @@ -1178,7 +1178,7 @@ static int fsl_fman_memac_probe(struct device_d *dev) if (ret) return ret; - phy_mode = of_get_phy_mode(dev->device_node); + phy_mode = of_get_phy_mode(dev->of_node); if (phy_mode < 0) return phy_mode; @@ -1209,14 +1209,14 @@ static int fsl_fman_memac_probe(struct device_d *dev) return 0; } -static void fsl_fman_memac_remove(struct device_d *dev) +static void fsl_fman_memac_remove(struct device *dev) { struct fm_eth *fm_eth = dev->priv; fm_eth_halt(&fm_eth->edev); } -static int fsl_fman_muram_probe(struct device_d *dev) +static int fsl_fman_muram_probe(struct device *dev) { struct resource *iores; @@ -1240,8 +1240,9 @@ static struct of_device_id fsl_fman_mdio_dt_ids[] = { }, { } }; +MODULE_DEVICE_TABLE(of, fsl_fman_mdio_dt_ids); -static struct driver_d fman_mdio_driver = { +static struct driver fman_mdio_driver = { .name = "fsl-fman-mdio", .probe = fsl_fman_mdio_probe, .of_compatible = DRV_OF_COMPAT(fsl_fman_mdio_dt_ids), @@ -1257,8 +1258,9 @@ static struct of_device_id fsl_fman_port_dt_ids[] = { }, { } }; +MODULE_DEVICE_TABLE(of, fsl_fman_port_dt_ids); -static struct driver_d fman_port_driver = { +static struct driver fman_port_driver = { .name = "fsl-fman-port", .probe = fsl_fman_port_probe, .of_compatible = DRV_OF_COMPAT(fsl_fman_port_dt_ids), @@ -1270,8 +1272,9 @@ static struct of_device_id fsl_fman_memac_dt_ids[] = { }, { } }; +MODULE_DEVICE_TABLE(of, fsl_fman_memac_dt_ids); -static struct driver_d fman_memac_driver = { +static struct driver fman_memac_driver = { .name = "fsl-fman-memac", .probe = fsl_fman_memac_probe, .remove = fsl_fman_memac_remove, @@ -1284,14 +1287,15 @@ static struct of_device_id fsl_fman_muram_dt_ids[] = { }, { } }; +MODULE_DEVICE_TABLE(of, fsl_fman_muram_dt_ids); -static struct driver_d fman_muram_driver = { +static struct driver fman_muram_driver = { .name = "fsl-fman-muram", .probe = fsl_fman_muram_probe, .of_compatible = DRV_OF_COMPAT(fsl_fman_muram_dt_ids), }; -static int fsl_fman_probe(struct device_d *dev) +static int fsl_fman_probe(struct device *dev) { struct resource *iores; struct ccsr_fman *reg; @@ -1306,7 +1310,7 @@ static int fsl_fman_probe(struct device_d *dev) reg = IOMEM(iores->start); dev->priv = reg; - ret = of_platform_populate(dev->device_node, NULL, dev); + ret = of_platform_populate(dev->of_node, NULL, dev); if (ret) return ret; @@ -1328,8 +1332,9 @@ static struct of_device_id fsl_fman_dt_ids[] = { }, { } }; +MODULE_DEVICE_TABLE(of, fsl_fman_dt_ids); -static struct driver_d fman_driver = { +static struct driver fman_driver = { .name = "fsl-fman", .probe = fsl_fman_probe, .of_compatible = DRV_OF_COMPAT(fsl_fman_dt_ids), @@ -1342,7 +1347,12 @@ static int fman_of_fixup(struct device_node *root, void *context) struct device_node *child, *child_bb; fman_bb = of_find_compatible_node(NULL, NULL, "fsl,fman"); + if (!fman_bb) + return 0; + fman = of_find_compatible_node(root, NULL, "fsl,fman"); + if (!fman) + return 0; /* * The dts files in the Linux tree have all network interfaces |