summaryrefslogtreecommitdiffstats
path: root/drivers/net/fec_imx.c
Commit message (Collapse)AuthorAgeFilesLines
* net: fec_imx: Fix resource rollback with regulator errorsStefan Riedmueller2019-10-141-2/+3
| | | | | | | | When the driver is not able to get or control the phy regulator memory resources are already acquired and need to be released during rollback. Signed-off-by: Stefan Riedmueller <s.riedmueller@phytec.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* net: fec_imx: add regulator supportOleksij Rempel2019-07-171-0/+19
| | | | | | | at least imx28-evk need it to work with devicetree Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* net: fec_imx: skip fec_halt if the FEC wasn't startedLucas Stach2019-02-111-0/+7
| | | | | | | | | | | | | If the FEC driver is enabled, but the ethernet device was never opened due to booting from another source the wait for graceful transmit stop will always fail. This introduces an unnecessary boot delay and prints a distracting warning. As there is no point in trying to shut down the FEC if it was never started, just skip all of fec_halt in that case. Signed-off-by: Lucas Stach <l.stach@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* net: fec_imx: fix timeout off by *1000 errorAhmad Fatoum2018-12-171-5/+5
| | | | | | | | | | | | | read*_poll_timeout's final timeout parameter is in microseconds, but the supplied arguments in fec_imx.c were in nanoseconds, which might lead to barebox getting seemingly stuck in fec_halt (loops for a thousand seconds instead of one). I've tested this still works on an i.MX6D by copying a file over TFTP and verifying the hash is correct. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> 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: fec_imx: Do not use DMA coherent memory for Rx buffersAndrey Smirnov2018-09-191-4/+25
| | | | | | | | | | | | Trying to do unaligned access of coherent memory on AArch64 will lead to an abort and some parts of our IP stack will do exactly that with received packet buffer by using memcpy() to extracts parts of it. Convert the driver to use regular memory for received data buffers to prevent the issue from happening. Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* net: fec_imx: Make use of readx_poll_timeout() macrosAndrey Smirnov2018-09-191-39/+22
| | | | | | | Condense a bit of code by using vairous readx_poll_timeout() macros. Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* net: fec_imx: Drop frame_lengthAndrey Smirnov2018-09-191-4/+3
| | | | | | | Drop frame_length in favour of just using len Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* net: fec_imx: Drop struct fec_frameAndrey Smirnov2018-09-191-12/+4
| | | | | | | | | Drop struct fec_frame since it doesn't have any real users in the code. It is only referenced in fec_recv() and is used by that function as a generic pointer. Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* net: fec_imx: Read data_length only onceAndrey Smirnov2018-09-191-14/+17
| | | | | | | | | Data length of a given Rx data descriptor isn't going to change until that descriptor is processed and given back to HW. Re-work the code to save and re-use that value instead. Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* net: fec_imx: Don't check bd_status & FEC_RBD_ERR twiceAndrey Smirnov2018-09-191-7/+5
| | | | | | | | Re-shuffle comparisons in order to avoid having to check for FEC_RBD_ERR in bd_status more than once. Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* net: fec_imx: Drop extra indentation level by exiting earlyAndrey Smirnov2018-09-191-26/+27
| | | | | | | | | Drop extra indentation level by exiting early which also allows us to check for bd_status & FEC_RBD_EMPTY instead of !(bd_status & FEC_RBD_EMPTY). Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* net: fec_imx: Return EFAULT when DMA mapping failsAndrey Smirnov2018-08-311-1/+1
| | | | | | | | | | | | | | | | | | | | EFAULT seems to be much more appropriate error code for DMA mapping failure, it also produces more informative message, compare: ping 192.168.53.7 WARNING: eth0: No MAC address set. Using random address 92:4e:f1:18:96:67 eth0: 100Mbps full duplex link detected ping failed: Bad address versus old message: ping 192.168.53.7 WARNING: eth0: No MAC address set. Using random address c6:b7:67:bb:4a:c3 eth0: 100Mbps full duplex link detected ping failed: I/O error Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* net: fec_imx: Specify that DMA is 32-bit onlyAndrey Smirnov2018-08-311-0/+2
| | | | | | | | FEC can only do a DMA transfer to 32-bit address space, so mark it as such. Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* net: fec_imx: Make use of IS_ALIGNEDAndrey Smirnov2018-06-111-1/+1
| | | | | Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* net: fec_imx: Use dma mapping functionsSascha Hauer2018-06-111-6/+9
| | | | | | | Rather than doing DMA on the input buffer address get a proper DMA address from the mapping functions. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* net: fec_imx: remove unnecessary DMA sync opsSascha Hauer2018-06-111-4/+0
| | | | | | | The fec receive buffers are coherently mapped, no need to dma_sync on them. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* i.MX: fec: add post PHY reset delay DT propertyMichael Grzeschik2017-06-071-1/+9
| | | | | | | | | | | | Some PHY require to wait for a bit after the reset GPIO has been toggled. This adds support for the DT property `phy-reset-post-delay` which gives the delay in milliseconds to wait after reset. If the DT property is not given, no delay is observed. Post reset delay greater than 1000ms are invalid. Signed-off-by: Michael Grzeschik <m.grzeschik@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* i.MX: fec: also enable optional clocksMichael Grzeschik2017-05-081-0/+29
| | | | | | | | This will also enable two more optional clocks. They can be found on mx6ul, mx6sx and mx28. Signed-off-by: Michael Grzeschik <m.grzeschik@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* i.MX: fec: Add support for Vybrid variantAndrey Smirnov2017-01-111-0/+3
| | | | | | | Add support for Vybrid variant of this IP block Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* i.MX: fec: Enable all clocks specified for FECAndrey Smirnov2017-01-111-10/+61
| | | | | | | | | For some i.MX variants more than just "ipg" clock need to be enabled for Ethernet to function, so change the code to enable all of the clock defined for FEC node (this is what analogous Linux driver does as well). Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* include: Move fec eth platform_data to include/platform_dataSascha Hauer2016-04-151-1/+1
| | | | Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* fec_imx: Unregister MDIO when probe failsAndrey Smirnov2016-03-171-2/+4
| | | | | Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* fec_imx: Deallocate DMA buffers when probe failsAndrey Smirnov2016-03-171-4/+17
| | | | | Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* fec_imx: Implement reset timeoutAndrey Smirnov2016-03-171-1/+6
| | | | | | | | | | Don't wait for more than one second for IP block to finish resetting. If the block is dead it makes more sence to continue execution in hopes that the rest of the processor is fine, rather than spin indefinetly inside of the fec_probe function Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* fec_imx: Use FEC_ECNTRL_RESET instead of a magic numberAndrey Smirnov2016-03-161-1/+1
| | | | | Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* fec_imx: Free phy_reset GPIO if when probe failsAndrey Smirnov2016-03-161-2/+5
| | | | | Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* fec_imx: Deallocate I/O resources if probe failsAndrey Smirnov2016-03-161-5/+9
| | | | | | | | | | Add a proper check for I/O memory resource allocation failure and replace dev_request_mem_region with dev_request_mem_resource so it would be possible to correctly deallocate device's I/O resources when probe fails. Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* fec_imx: Deallocate clocks when probe failsAndrey Smirnov2016-03-161-4/+10
| | | | | 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-1/+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: fec: fix indentation and whitspacesStefan Christ2015-11-191-4/+4
| | | | | Signed-off-by: Stefan Christ <s.christ@phytec.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* net: fec: implement dtb property phy-reset-durationStefan Christ2015-11-191-1/+4
| | | | | | | | Implement device tree property phy-reset-duration to adjust length of phy reset. Signed-off-by: Stefan Christ <s.christ@phytec.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* net: fec: set phy reset time to 1msStefan Christ2015-11-191-1/+1
| | | | | | | | According to the device tree bindings in dts/Bindings/net/fsl-fec.txt the default phy-reset time is 1ms. Signed-off-by: Stefan Christ <s.christ@phytec.de> 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>
* Merge branch 'for-next/of-device-id'Sascha Hauer2015-05-061-6/+6
|\
| * of: use 'const void *' for struct of_device_id.dataAntony Pavlov2015-04-301-6/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Since 2011 barebox' of_device_id struct uses unsigned long type for data field: struct of_device_id { char *compatible; unsigned long data; }; Almost always struct of_device_id.data field are used as pointer and need 'unsigned long' casting. E.g. see 'git grep -A 4 of_device_id drivers/' output: drivers/ata/sata-imx.c:static __maybe_unused struct of_device_id imx_sata_dt_ids[] = { drivers/ata/sata-imx.c- { drivers/ata/sata-imx.c- .compatible = "fsl,imx6q-ahci", drivers/ata/sata-imx.c- .data = (unsigned long)&data_imx6, drivers/ata/sata-imx.c- }, { Here is of_device_id struct in linux kernel v4.0: struct of_device_id { char name[32]; char type[32]; char compatible[128]; const void *data; }; Changing of_device_id.data type to 'const void *data' will increase barebox' linux kernel compatibility and decrease number of 'unsigned long' casts. Part of the patch was done using the 'coccinelle' tool with the following semantic patch: @rule1@ identifier dev; identifier type; identifier func; @@ func(...) { <... - dev_get_drvdata(dev, (unsigned long *)&type) + dev_get_drvdata(dev, (const void **)&type) ...> } @rule2@ identifier dev; identifier type; identifier func; identifier data; @@ func(...) { <... - dev_get_drvdata(dev, (unsigned long *)&type->data) + dev_get_drvdata(dev, (const void **)&type->data) ...> } Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | net: fec: Fix RGMII-IDMarkus Pargmann2015-05-011-1/+4
|/ | | | | | | | | RGMII-ID just defines transmitter internal delays. Otherwise it is the same as RGMII. As the differences only influence the behaviour of the phy, the fec driver should handle it the same way as RGMII. Signed-off-by: Markus Pargmann <mpa@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* net: fec: convert to streaming DMA opsLucas Stach2015-03-061-4/+9
| | | | | | | | | 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-2/+2
| | | | | | | | | 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/randconfig'Sascha Hauer2014-12-081-6/+0
|\
| * net: fec_imx: remove unused includesSascha Hauer2014-11-271-6/+0
| | | | | | | | Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | net: fec_imx: Add i.MX6sx compatible entrySascha Hauer2014-11-271-0/+3
|/ | | | Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/net-of-phy'Sascha Hauer2014-06-041-0/+5
|\
| * net: fec_imx: Add devicetree support for mdio busSascha Hauer2014-05-231-0/+5
| | | | | | | | | | | | | | The fec has a mdio bus. This adds support for a subnode in which the phys on this bus can be specified. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | Merge branch 'for-next/net'Sascha Hauer2014-06-041-1/+1
|\ \ | | | | | | | | | | | | Conflicts: drivers/net/dm9k.c
| * | net: Pass eth_device to net_receiveSascha Hauer2014-05-151-1/+1
| |/ | | | | | | | | | | | | So that barebox has the information which interface a packet came from. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | net: fec_imx: check return value of registration functionsSascha Hauer2014-05-211-2/+7
| | | | | | | | | | | | | | | | We do not care about releasing the resources in the error path, but at least check the return value of eth_register and mdiobus_register. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | net: fec_imx: mask mii register reads correctlySascha Hauer2014-05-211-1/+1
|/ | | | | | | mii registers are 16bit wide, so mask out the higher bits. The higher bits confuse mii-tool. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* ARM: i.mx53: Parse Reset GPIO pin in FEC driver from DevicetreeRostislav Lisovy2013-11-251-0/+17
| | | | | Signed-off-by: Rostislav Lisovy <lisovy@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>