summaryrefslogtreecommitdiffstats
path: root/drivers/net/macb.c
Commit message (Collapse)AuthorAgeFilesLines
* net: macb: use DMA-capable memory for receive bufferAhmad Fatoum4 days1-2/+2
| | | | | | | | | | | | The driver supports older MACB-compatible NICs as well as the newer GEM-compatible NICs. Both use DMA, but the older MACB support failed to allocate the single receive buffer with suitable alignment. Use net_alloc_packet() to fix that. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20240424064058.3608016-15-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* net: macb: convert to volatile accessesSteffen Trumtrar2023-12-051-32/+21
| | | | | | | | | | Instead of directly reading from memory addresses and inserting sw barriers to be sure that the compiler will not move loads/stores behind this point, just use proper volatile writel/readl accesses. Signed-off-by: Steffen Trumtrar <s.trumtrar@pengutronix.de> Link: https://lore.barebox.org/20231201-v2023-08-0-topic-macb-v4-2-b4f5d64de1ad@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* net: macb: fix dma_alloc for rx_bufferSteffen Trumtrar2023-12-051-29/+54
| | | | | | | | | | | | | rx_buffer gets dma_alloc'ed but is never dma_map'ed and therefor not flushed before it is initially used. Map the rx_buffer when the macb is initialized and unmap it on ether_halt. While at it, cleanup the dma_alloc_coherent rx_ring/tx_ring, too. Signed-off-by: Steffen Trumtrar <s.trumtrar@pengutronix.de> Link: https://lore.barebox.org/20231201-v2023-08-0-topic-macb-v4-1-b4f5d64de1ad@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/dma-streaming-interface'Sascha Hauer2023-06-221-11/+11
|\
| * net: macb: remove const from dev pointer in macb_deviceDenis Orlov2023-06-061-1/+1
| | | | | | | | | | | | | | | | | | | | Otherwise, it leads to a bunch of warnings on passing those pointers to dma_*() functions. As every other driver seem to be having non-const dev pointers in their private structs, do the same here. Signed-off-by: Denis Orlov <denorl2009@gmail.com> Link: https://lore.barebox.org/20230604215002.20240-3-denorl2009@gmail.com Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * dma: rework dma_sync_single_for_*() interfaceDenis Orlov2023-06-061-10/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Currently, a lot of code handles dma_addr_t values as if they actually hold CPU addresses. However, this is not always true. For example, MIPS architecture requires an explicit conversion from the physical address space to some virtual address space segment to get a valid CPU-side pointer. Another issue is that DMA ranges that may be specified in a device tree will not work this way. To get from a virtual address to a dma handle and vice versa we need to add/subtract some offset, which is calculated from "dma-ranges" property. Only dma_map_single() was doing this, but dma_sync_single_for_*() also should. Improve the interface by adding 'struct device' as the first argument to the dma_sync_single_for_*(). This allows to do cpu_to_dma/dma_to_cpu() conversions in common code and call into arch-specific code with proper cpu-side addresses. To make things more clear, make the virtual address argument of those arch-side functions be properly represented with a void* type. Apply the required changes in device drivers that use the affected functions, making them pass the appropriate device pointer. Signed-off-by: Denis Orlov <denorl2009@gmail.com> Link: https://lore.barebox.org/20230604215002.20240-2-denorl2009@gmail.com Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | treewide: add MODULE_DEVICE_TABLE markersAhmad Fatoum2023-06-131-0/+1
|/ | | | | | | | | | | | | | | | Syncing device trees with Linux upstream can lead to breakage, when the device trees are switched to newer bindings, which are not yet supported in barebox. To make it easier to spot such issues, we want to start applying some heuristics to flag possibly problematic DT changes. One step towards being able to do that is to know what nodes barebox actually consumes. Most of the nodes have a compatible entry, which is matched by an array of of_device_id, so let's have MODULE_DEVICE_TABLE point at it for future extraction. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20230612125908.1087340-1-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* net: macb: Adjust zynq compatibles to upstream device treesSascha Hauer2023-03-211-2/+2
| | | | | | | | Linux v6.3-rc1 renamed the zynq macb compatibles from cdns,zynq-gem to xlnx,zynq-gem and cdns,zynqmp-gem to xlnx,zynqmp-gem. Adjust the compatibles in the driver accordingly. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* net: macb: match atmel,sama5d4-gem compatibleAhmad Fatoum2023-01-121-0/+1
| | | | | | | | | | After adjustments for SAMA5D2, driver readily works on SAMA5D4 if we have the appropriate of_device_id entry. Add it. Acked-by: Sam Ravnborg <sam@ravnborg.org> Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20230109130822.1657470-5-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Rename struct driver_d to driverSascha Hauer2023-01-101-1/+1
| | | | | | | | | | | The '_d' suffix was originally meant to distinguish barebox struct names from Linux struct names. struct driver doesn't exist in Linux, so we can rename it and remove the meaningless suffix. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de> Reviewed-by: Marco Felsch <m.felsch@pengutronix.de> Link: https://lore.barebox.org/20221214123512.189688-4-s.hauer@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Rename struct device_d to deviceSascha Hauer2023-01-101-6/+6
| | | | | | | | | | | | | The '_d' suffix was originally introduced in case we want to import Linux struct device as a separate struct into barebox. Over time it became clear that this won't happen, instead barebox struct device_d is basically the same as Linux struct device. Rename the struct name accordingly to make porting Linux code easier. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de> Reviewed-by: Marco Felsch <m.felsch@pengutronix.de> Link: https://lore.barebox.org/20221214123512.189688-3-s.hauer@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Rename device_d::device_node to device_d::of_nodeSascha Hauer2023-01-101-4/+4
| | | | | | | | | | | | | | | | | | | | Linux struct device has the member of_node for the device_node pointer. Rename this in barebox accordingly to minimize the necessary changes when porting Linux code. This was done with the semantic patch: @@ struct device_d E; @@ - E.device_node + E.of_node @@ struct device_d *E; @@ - E->device_node + E->of_node Plus some manual adjustments. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de> Reviewed-by: Marco Felsch <m.felsch@pengutronix.de> Link: https://lore.barebox.org/20221214123512.189688-2-s.hauer@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* net: macb: Allocate own receive bufferSascha Hauer2022-09-191-4/+8
| | | | | | | | | Use a driver private buffer as network receive buffer rather than the globally allocated ones which will be removed soon. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de> Link: https://lore.barebox.org/20220919080133.877651-3-s.hauer@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* net: macb: add SiFive supportAhmad Fatoum2021-06-091-0/+120
| | | | | | | | | | | | | | | The Ethernet controller on the SiFive SoCs needs some special TX clock setup. Port the relevant Linux v5.12 bits to enable it. As the macb driver is used for some old at91 boards that aren't yet ported to the common clock framework, that new setup code has to be in an #ifdef. Tested on qemu-system-riscv64 -M sifive_u with dhcp. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20210531065815.18641-1-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* net: macb: add tx clock rate for 10 MBit linkMichael Tretter2021-03-221-0/+3
| | | | | | | | | | | If the phy reports a 10 MBit link, which can happen during link negotiation, the macb prints a warning, because it does not know the clock rate for the TX clock. Implement setting the TX clock rate for 10 MBit to avoid the warnings. Signed-off-by: Michael Tretter <m.tretter@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* net: macb: fix compiler warning for 64 bit systemsMichael Tretter2020-10-191-1/+1
| | | | | | | | | | | | | | On arm64 the compiler prints the following warning, when the macb driver is enabled: warning: cast from pointer to integer of different size Add the same explicit cast as implemented for all other dma addresses in the macb driver. Fixes: befd110b5922 ("net: macb: init multiple dummy TX queues") Signed-off-by: Michael Tretter <m.tretter@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* net: macb: adjust clk_tx rate for link speed changesMichael Tretter2020-10-191-0/+35
| | | | | | | | | | | | | Changes of the link speed might require an adjustment of the clk_tx. Read the clk_tx from the device tree and change the rate if the link speed changes. If the clk_tx rate is already correct, changing the clock is not required and, thus, not being able to get the clock rate is not fatal. Signed-off-by: Michael Tretter <m.tretter@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* net: macb: reduce DEBUG output to make it more usefulMichael Tretter2020-10-191-18/+0
| | | | | | | | | | | | The macb debugging output printed the function entry for various functions. Especially for *_recv() this debugging flooded the serial output while conveying very little information. Remove printing of the function calls to make enabling debugging for the macb driver more useful. Signed-off-by: Michael Tretter <m.tretter@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* net: macb: fix wrong return values on some errorsAhmad Fatoum2020-10-021-1/+1
| | | | | | | | Coccinelle detected that the IS_ERR and ERR_PTR are mismatched. Fix it. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* net: macb: add Zynq compatibleLucas Stach2019-11-111-0/+1
| | | | | | | Add compatible for the GEM on the Zynq 7000 device. Signed-off-by: Lucas Stach <dev@lynxeye.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* net: macb: handle more clocksLucas Stach2019-11-111-2/+22
| | | | | | | | | Both pclk and hclk are required clocks in the DT binding. rx_clk and tx_clk are optional, but must be enabled if a system has separate gates for them. Signed-off-by: Lucas Stach <dev@lynxeye.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* net: macb: extend support to Microchip SAMA5D2Ahmad Fatoum2019-08-161-0/+1
| | | | | | | | Tested on Microchip SAMA5D27 SOM1 EK1 Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* net: macb: init multiple dummy TX queuesOleksij Rempel2019-08-161-6/+26
| | | | | | | | | Microchip SAMA5D27 has more then one TX queue. So it will go in to TX timeout if only one was initialized. Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de> Tested-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* net: macb: dma_sync_* receive buffersLadislav Michl2019-06-041-7/+20
| | | | | | | | | Receive buffers are properly synchronized only if Cadence is GEM. Fix it for MACB as well. Fixes: 86dc5259e25d (net: macb: no need for coherent memory for receive buffer) Signed-off-by: Ladislav Michl <ladis@linux-mips.org> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/ultrascale'Sascha Hauer2019-01-151-0/+1
|\
| * zynqmp: enable macb Ethernet supportThomas Hämmerle2019-01-091-0/+1
| | | | | | | | | | Signed-off-by: Thomas Haemmerle <thomas.haemmerle@wolfvision.net> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | macb: disable second priority queue for zynqmp gem supportThomas Hämmerle2019-01-091-0/+21
| | | | | | | | | | | | | | | | | | Provide descriptors for second priority rx and tx queues and disable the the queues if hardware is GEM. Otherwise the function macb_send() will run into a timeout. Signed-off-by: Thomas Haemmerle <thomas.haemmerle@wolfvision.net> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | macb: fix memory leakage due to double allocation of rx_bufferThomas Hämmerle2019-01-091-2/+0
| | | | | | | | | | | | | | | | | | Remove memory allocation of rx buffer in function macb_init_rx_buffer_size, which caused a memory leak since it also is alocated in macb_probe(). Signed-off-by: Thomas Haemmerle <thomas.haemmerle@wolfvision.net> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | macb: fix check if hw is gemThomas Hämmerle2019-01-091-1/+1
| | | | | | | | | | | | | | | | Fix check for peripheral version in MACB_MID register to treat Xilinx ZynqMP as GEM. All MIDs >= 2 indicate a GEM not only MID == 2. Signed-off-by: Thomas Haemmerle <thomas.haemmerle@wolfvision.net> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | macb: fix format specifiers for debug outputThomas Hämmerle2019-01-091-1/+1
|/ | | | | | | | Fixes compiler warning "format '%d' expects argument of type 'int', but argument 4 has type 'size_t {aka long unsigned int}' [-Wformat=]". Signed-off-by: Thomas Haemmerle <thomas.haemmerle@wolfvision.net> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* drivers: net: convert drivers to spdxOleksij Rempel2018-12-061-11/+1
| | | | | | Signed-off-by: Oleksij Rempel <linux@rempel-privat.de> Reviewed-by: Roland Hieber <r.hieber@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* net: macb: Add compatible for atmel,sama5d3-gemSascha Hauer2018-11-021-0/+1
| | | | | | | The macb driver works with the gigabit MAC found on Atmel sama5d3 SoCs. Add a compatible for it. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* net: macb: add remove callbackSascha Hauer2018-11-021-0/+8
| | | | | | | The macb driver does DMA and thus should be quiesced on shutdown. Add the remove callback. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* net: macb: simplify private data allocationSascha Hauer2018-11-021-3/+4
| | | | | | | | Instead of allocating struct macb_device and a struct eth_device separately just use the eth_device structure that is already embedded in struct macb_device but currently unused. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* net: macb: remove unused variableSascha Hauer2018-11-021-2/+1
| | | | | | tx_tail is unused. Remove it. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* net: macb: no need for coherent memory for receive bufferSascha Hauer2018-11-021-2/+1
| | | | | | | The receive buffers are properly synchronized with dma_sync_*, no need to use coherent memory for them. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* macb: fix clock probing with DTSam Ravnborg2017-07-201-2/+2
| | | | | | | | | | | | | | | With DT enabled the following was logged: macb fffbc000.ethernet: no macb_clk macb fffbc000.ethernet: probe failed: Invalid argument The clock probed was with the name used in a non-DT setup. Fix so we use a proper name ("pclk") with DT, and keep current fuctionality without DT. Signed-off-by: Sam Ravnborg <sam@ravnborg.org> Acked-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
* net: macb: Add DT supportAndrey Smirnov2017-03-301-14/+42
| | | | | | Acked-by: Sam Ravnborg <sam@ravnborg.org> Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* driver: replace dev_request_mem_region with dev_request_mem_resourceSascha Hauer2016-03-071-3/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | dev_request_mem_region doesn't work properly one some SoCs on which PTR_ERR() values clash with valid return values from dev_request_mem_region. Replace them with dev_request_mem_resource where possible. This patch has been generated with the following semantic patch: // <smpl> @@ expression d; expression n; expression io; identifier func; @@ func(...) { +struct resource *iores; <+... -io = dev_request_mem_region(d, n); -if (IS_ERR(io)) { +iores = dev_request_mem_resource(d, n); +if (IS_ERR(iores)) { ... - return PTR_ERR(io); -} + return PTR_ERR(iores); +} +io = IOMEM(iores->start); ...+> } @@ expression d; expression n; expression io; identifier func; @@ func(...) { +struct resource *iores; <+... -io = dev_request_mem_region(d, n); -if (IS_ERR(io)) { +iores = dev_request_mem_resource(d, n); +if (IS_ERR(iores)) - return PTR_ERR(io); -} + return PTR_ERR(iores); +io = IOMEM(iores->start); ...+> } @@ expression d; expression n; expression io; identifier func; @@ func(...) { +struct resource *iores; <+... -io = dev_request_mem_region(d, n); -if (IS_ERR(io)) { - ret = PTR_ERR(io); +iores = dev_request_mem_resource(d, n); +if (IS_ERR(iores)) { + ret = PTR_ERR(iores); ... } +io = IOMEM(iores->start); ...+> } @@ expression d; expression n; expression io; identifier func; @@ func(...) { +struct resource *iores; <+... -io = dev_request_mem_region(d, n); +iores = dev_request_mem_resource(d, n); +if (IS_ERR(iores)) + return PTR_ERR(iores); +io = IOMEM(iores->start); ...+> } @@ identifier func; @@ func(...) { <+... struct resource *iores; -struct resource *iores; ...+> } // </smpl> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* net: Make set_ethaddr argument constSascha Hauer2015-06-261-1/+1
| | | | | | | The set_ethaddr callback should not modify the MAC address passed to it, so make it const. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* net: macb: convert to streaming DMA opsLucas Stach2015-03-061-2/+6
| | | | | | | | | Move to the common streaming DMA ops in order to get rid of the direct usage of the ARM MMU functions for the cache maintenance. Signed-off-by: Lucas Stach <dev@lynxeye.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* ARM: move DMA alloc functions to dma.hLucas Stach2015-03-061-0/+1
| | | | | | | | | | This better separates the DMA from the MMU functionality. Also move all drivers that only depends on asm/mmu.h for the alloc functions over to the common header. Signed-off-by: Lucas Stach <dev@lynxeye.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* ARM: change dma_alloc/free_coherent to match other architecturesLucas Stach2015-03-061-4/+6
| | | | | | | | | As a lot drivers currently rely on the 1:1 virt->phys mapping on ARM we define DMA_ADDRESS_BROKEN to mark them. In order to use them on other architectures with a different mapping they need proper fixing. Signed-off-by: Lucas Stach <dev@lynxeye.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/resource-err-ptr'Sascha Hauer2014-10-021-0/+2
|\
| * resource: Let dev_request_mem_region return an error pointerSascha Hauer2014-09-161-0/+2
| | | | | | | | | | | | For all users fix or add the error check. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | net: macb: enable GEM with only FE featureBo Shen2014-09-241-2/+4
|/ | | | | | | | | | | | If the GEM is used, however only FE featuren enabled, then it can not support FBLDO configured as 16, and no RGMII/GMII configuratin bit. So, in order to support GEM only with FE feature enabled, we do: - using default value for FBLDO. - using same bit for RMII/MII configuration as GEM for RGMII/GMII. Signed-off-by: Bo Shen <voice.shen@atmel.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* net: Pass eth_device to net_receiveSascha Hauer2014-05-151-2/+2
| | | | | | | So that barebox has the information which interface a packet came from. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* macb: add support to read the mac address from registerJean-Christophe PLAGNIOL-VILLARD2013-10-061-0/+22
| | | | | | | check the 4 mac address register and return at the first valid Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* net: macb: turn off endian_swp_pkt_enSteffen Trumtrar2013-04-031-0/+1
| | | | | | | | | | The core has a bit for swapping packet data endianism. Reset default from Cadence is off. Xilinx however, that uses this core on the Zynq SoCs, opted for on. Turn it off for all devices. Signed-off-by: Steffen Trumtrar <s.trumtrar@pengutronix.de> Cc: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* macb: rename platform dataJosh Cartwright2013-04-031-2/+2
| | | | | | | | | | The macb/gem core is used by the Zynq SoC. In preparation of sharing the macb driver between at91 and Zynq, rename the platform data to 'struct macb_platform_data', and move the definition to a common location. Signed-off-by: Josh Cartwright <joshc@eso.teric.us> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>