summaryrefslogtreecommitdiffstats
path: root/drivers/net/designware.c
Commit message (Collapse)AuthorAgeFilesLines
* Merge branch 'for-next/misc'Sascha Hauer2019-02-131-9/+33
|\
| * net: designware: drop bad RX framesIan Abbott2019-02-051-9/+33
| | | | | | | | | | | | | | | | | | In dwc_ether_rx(), check the RX descriptor status for various error conditions. On error, issue a warning with the error status bits and drop the received frame. Signed-off-by: Ian Abbott <abbotti@mev.co.uk> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | net: designware: fix TX descriptor length corruptionIan Abbott2019-02-011-0/+2
|/ | | | | | | | | | | | | | | dwc_ether_send() sets the SIZE1 field of the TX descriptor incorrectly. It sets the SIZE1 field to a bit-wise OR of the old value and the new value. If the old value differs from the new value, the transmitted Ethernet frame will be longer than it should be and is likely to have an incorrect frame check sequence. As more and more Ethernet frames of different lengths are sent, more and more of the TX descriptors are affected (up to a maximum number of CONFIG_TX_DESCR_NUM, defined as 16 in "designware.h"). Fix it by setting the SIZE1 field of the TX descriptor to just the new value. Signed-off-by: Ian Abbott <abbotti@mev.co.uk> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* drivers: net: convert drivers to spdxOleksij Rempel2018-12-061-14/+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: designware: look for a child device node for MDIO busIan Abbott2018-11-021-0/+10
| | | | | | | | | | | | | | | | | | | | | The Designware driver registers a local MDIO bus for each MAC device, but without setting a device node pointer for the MDIO bus device. In this case, mdiobus_register() will use the MDIO bus's parent device node (if any) as the MDIO device node. If the MAC device node has a child node compatible with "snps,dwmac-mdio", let us use that as the MDIO bus device node. Otherwise, leave the MDIO bus device node pointer set to NULL and carry on as before. The upshot is that PHY device nodes can now be placed in an intermediate node for the MDIO bus instead of having to place them directly in the Designware MAC device node. (Tested on a Terasic DE0-Nano-SoC with a suitably modified device tree.) Signed-off-by: Ian Abbott <abbotti@mev.co.uk> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* net: designware: make sure DMA is disabled on kernel start.Oleksij Rempel2018-07-021-0/+8
| | | | | | | | Halt is not automatically executed if we start the kernel. So, we may have potentially memory corruptions. Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* net: designware: add warning for drvdataSteffen Trumtrar2018-01-111-1/+5
| | | | | | | | | Instead of silently using a wrong value, check if drvdata is defined before use. Print a warning if there is no drvdata found. Signed-off-by: Steffen Trumtrar <s.trumtrar@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* net: designware: move probe to generic driverSteffen Trumtrar2018-01-111-54/+6
| | | | | | | | | The designware ethernet core is used on multiple different SoCs. The linux kernel has a generic driver and SoC-specific drivers. Do the same here. Signed-off-by: Steffen Trumtrar <s.trumtrar@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* net: designware: add dwmac-3.72a compatibleSteffen Trumtrar2017-05-031-0/+3
| | | | | | | This compatible will be needed for Arria10. Signed-off-by: Steffen Trumtrar <s.trumtrar@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* net/designware: add explicit reset of {tx|rx}_currdescnumIan Abbott2016-11-091-0/+2
| | | | | | | | | | | | | | | | | Driver "init" function might be called multiple times. On every "init" Tx/Rx buffer descriptors are initialized: "descs_init" -> "{tx|rx}_descs_init". In its turn those init functions set MAC's "{tx|rx}desclistaddr" to point on the first buffer descriptor in the list. So CPU to start operation from the first buffer descriptor as well after every "init" we have to reset "{tx|rx}_currdescnum". [Original U-Boot patch by Alexey Brodkin <abrodkin@synopsys.com>] Signed-off-by: Ian Abbott <abbotti@mev.co.uk> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* net: designware: Respect "bus mode" register contents on SW resetIan Abbott2016-11-091-1/+1
| | | | | | | | | | | | | "bus mode" register contains lots of fields and some of them don't expect to be written with 0 (zero). So since we're only interested in resetting MAC (which is done with setting the least significant bit of this register with "0") I believe it's better to modify only 1 bit of the register. [Original U-Boot patch by Alexey Brodkin <abrodkin@synopsys.com>] Signed-off-by: Ian Abbott <abbotti@mev.co.uk> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* net/designware: Do not select MIIPORT for RGMII interfaceIan Abbott2016-11-091-1/+3
| | | | | | | | | Do not select MIIPORT for RGMII interface [Original U-Boot patch by Vipin Kumar <vipin.kumar@st.com>] Signed-off-by: Ian Abbott <abbotti@mev.co.uk> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* net/designware: Consecutive writes to the same register to be avoidedIan Abbott2016-11-091-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | There are a few registers where consecutive writes to the same location should be avoided or have a delay. According to Synopsys, here is a list of the registers and bit(s) where consecutive writes should be avoided or a delay is required: DMA Registers: Register 0 Bit 7 Register 6 All bits except for 24, 16-13, 2-1. GMAC Registers: Registers 0-3 All bits Registers 6-7 All bits Register 10 All bits Register 11 All bits except for 5-6. Registers 16-47 All bits Register 48 All bits except for 18-16, 14. Register 448 Bit 4. Register 459 Bits 0-3. [Original U-Boot patch by Dinh Nguyen <dinguyen@altera.com>] Signed-off-by: Ian Abbott <abbotti@mev.co.uk> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* include: Move designware eth platform_data to include/platform_dataSascha Hauer2016-04-151-1/+1
| | | | 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: designware: Don't hang in reset with powered down phyTrent Piepho2015-11-131-1/+24
| | | | | | | | | | | | | | | | | | | | | | | | | The dw MAC requires that all clock domains to be running for it to finish a MAC reset. This include the clock provided by the PHY. If the PHY is powered down, bit BMCR_PDOWN set, then it won't be generating a clock. And so the MAC never comes out of reset. On shutdown, Linux will put the PHY in powerdown mode, so it can easily be the case that the PHY is powered down on boot. See Linux kernel commit 2d871aa07136fe6e576bde63072cf33e2c664e95. Currently the MAC reset is done before the phy is probed. We can't power up the phy until it's probed, so the resets must be in the opposite order. The MAC reset is in device init but the PHY probe is in device open. Device init is done first, always, while open is done later, and only if the device is used. Rather than move the phy probe to init, this moves the MAC reset to open. It seems better to speed up boots that doesn't use ethernet by skipping MAC reset than to slow them down by adding PHY probe. Signed-off-by: Trent Piepho <tpiepho@kymetacorp.com> 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>
* of: use 'const void *' for struct of_device_id.dataAntony Pavlov2015-04-301-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* Merge branch 'for-next/streaming-dma'Sascha Hauer2015-03-091-10/+16
|\ | | | | | | | | Conflicts: drivers/mci/dw_mmc.c
| * net: designware: convert to streaming DMA opsLucas Stach2015-03-061-8/+11
| | | | | | | | | | | | | | | | | | 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/+4
| | | | | | | | | | | | | | | | | | 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>
* | net: designware: don't depend on CONFIG_OFTREELucas Stach2015-03-021-0/+3
|/ | | | | | | | | | | | This driver is written in a way that is should also work without DT, but it had a compile time dependency on CONFIG_OFTREE. Fixes: drivers/built-in.o: In function `dwc_probe_dt': drivers/net/designware.c:413: undefined reference to `of_get_phy_mode' Signed-off-by: Lucas Stach <dev@lynxeye.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* resource: Let dev_request_mem_region return an error pointerSascha Hauer2014-09-161-0/+4
| | | | | | For all users fix or add the error check. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* treewide: remove address of the Free Software FoundationAntony Pavlov2014-06-111-4/+0
| | | | | | | | | | | | | | | | | | The FSF address has changed; The FSF site says that address is Free Software Foundation 51 Franklin Street, Fifth Floor Boston, MA 02110-1301 USA (see http://www.fsf.org/about/contact/) Instead of updating it each time the address changes, just drop it completely treewide. Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* 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>
* drivers: treewide: Kill empty remove() implementationsAlexander Shiyan2014-04-021-5/+0
| | | | | Signed-off-by: Alexander Shiyan <shc_work@mail.ru> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* net: designware: remove backspaces from codeSascha Hauer2013-09-091-4/+4
| | | | Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* net: designware: Add decvicetree supportSascha Hauer2013-09-091-9/+45
| | | | Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* net: designware: make alt/enhanced descriptor runtime configurableSascha Hauer2013-09-091-30/+34
| | | | | | | | | | Instead of hardcoding the alternate/enhanced descriptor layout make it configurable during runtime. This is based on the value of the enh_desc variable which is currently hardcoded to zero. This should be configurable via device_id in the future. Since currently we have no in tree user of this driver this currently doesn't hurt. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* net: designware: use dma_alloc for descriptorsSascha Hauer2013-09-091-2/+2
| | | | Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* net: designware: Fix broken cache invalidateSascha Hauer2013-09-091-2/+3
| | | | | | | Move the cache invalidation of a received packet before we actually use it. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Use new device_platform_driver() macro for driversAlexander Shiyan2013-02-131-7/+1
| | | | | Signed-off-by: Alexander Shiyan <shc_work@mail.ru> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* designware: set parent for eth_device and miibusJean-Christophe PLAGNIOL-VILLARD2012-10-151-0/+2
| | | | | Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* net:designware: allow to pass the phy interfaceJean-Christophe PLAGNIOL-VILLARD2012-10-151-1/+3
| | | | | | | If none set use NA (0) as before. Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* designware: fix 100mps phy supportJean-Christophe PLAGNIOL-VILLARD2012-10-151-0/+10
| | | | | Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* net/designware: fix phylib supportJean-Christophe PLAGNIOL-VILLARD2012-10-041-1/+2
| | | | | | | | | | | | | | /opt/work/barebox/drivers/net/designware.c: In function 'dwc_update_linkspeed': /opt/work/barebox/drivers/net/designware.c:234:9: error: 'mac_p' undeclared (first use in this function) /opt/work/barebox/drivers/net/designware.c:234:9: note: each undeclared identifier is reported only once for each function it appears in /opt/work/barebox/drivers/net/designware.c: In function 'dwc_ether_open': /opt/work/barebox/drivers/net/designware.c:254:6: error: too few arguments to function 'phy_device_connect' /opt/work/barebox/include/linux/phy.h:252:5: note: declared here /opt/work/barebox/drivers/net/designware.c: At top level: /opt/work/barebox/drivers/net/designware.c:226:13: warning: 'dwc_update_linkspeed' defined but not used Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* net/designware: update version display to print user ID and Synosys IDJean-Christophe PLAGNIOL-VILLARD2012-10-041-1/+10
| | | | | | | So we can check it with the kernel one Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* switch all platform_bus device/driver registering to ↵Jean-Christophe PLAGNIOL-VILLARD2012-10-041-1/+1
| | | | | | | | platform_driver/device_register now register_driver and register_device are for bus only usage. Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
* net: introduce phylibJean-Christophe PLAGNIOL-VILLARD2012-09-251-29/+33
| | | | | | | | | | | | | | | | Adapt phylib from linux switch all the driver to it reimplement mii bus This will allow to have - phy drivers - to only connect the phy at then opening of the device - if the phy is not ready or not up fail on open Same behaviour as in linux and will allow to share code and simplify porting. Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
* drivers/net: add designware driverJohannes Stezenbach2012-06-261-0/+436
Straight forward port of Synopsys Designware ethernet driver from u-boot v2012.04.01. Signed-off-by: Johannes Stezenbach <js@sig21.net> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>