aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/ethernet/marvell/mvmdio.c (follow)
AgeCommit message (Collapse)AuthorFilesLines
2019-08-05drivers/net/ethernet/marvell/mvmdio.c: Fix non OF caseArnaud Patard (Rtp)1-9/+22
Orion5.x systems are still using machine files and not device-tree. Commit 96cb4342382290c9 ("net: mvmdio: allow up to three clocks to be specified for orion-mdio") has replaced devm_clk_get() with of_clk_get(), leading to a oops at boot and not working network, as reported in https://lists.debian.org/debian-arm/2019/07/msg00088.html and possibly in https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=908712. Link: https://lists.debian.org/debian-arm/2019/07/msg00088.html Fixes: 96cb4342382290c9 ("net: mvmdio: allow up to three clocks to be specified for orion-mdio") Signed-off-by: Arnaud Patard <arnaud.patard@rtp-net.org> Reviewed-by: Andrew Lunn <andrew@lunn.ch> Signed-off-by: David S. Miller <davem@davemloft.net>
2019-07-09net: mvmdio: defer probe of orion-mdio if a clock is not readyJosua Mayer1-0/+5
Defer probing of the orion-mdio interface when getting a clock returns EPROBE_DEFER. This avoids locking up the Armada 8k SoC when mdio is used before all clocks have been enabled. Signed-off-by: Josua Mayer <josua@solid-run.com> Reviewed-by: Andrew Lunn <andrew@lunn.ch> Signed-off-by: David S. Miller <davem@davemloft.net>
2019-07-09net: mvmdio: print warning when orion-mdio has too many clocksJosua Mayer1-0/+4
Print a warning when device tree specifies more than the maximum of four clocks supported by orion-mdio. Because reading from mdio can lock up the Armada 8k when a required clock is not initialized, it is important to notify the user when a specified clock is ignored. Signed-off-by: Josua Mayer <josua@solid-run.com> Reviewed-by: Andrew Lunn <andrew@lunn.ch> Signed-off-by: David S. Miller <davem@davemloft.net>
2019-07-09net: mvmdio: allow up to four clocks to be specified for orion-mdioJosua Mayer1-1/+1
Allow up to four clocks to be specified and enabled for the orion-mdio interface, which are required by the Armada 8k and defined in armada-cp110.dtsi. Fixes a hang in probing the mvmdio driver that was encountered on the Clearfog GT 8K with all drivers built as modules, but also affects other boards such as the MacchiatoBIN. Cc: stable@vger.kernel.org Fixes: 96cb43423822 ("net: mvmdio: allow up to three clocks to be specified for orion-mdio") Reviewed-by: Andrew Lunn <andrew@lunn.ch> Signed-off-by: Josua Mayer <josua@solid-run.com> Signed-off-by: David S. Miller <davem@davemloft.net>
2018-05-16drivers: net: Remove device_node checks with of_mdiobus_register()Florian Fainelli1-4/+1
A number of drivers have the following pattern: if (np) of_mdiobus_register() else mdiobus_register() which the implementation of of_mdiobus_register() now takes care of. Remove that pattern in drivers that strictly adhere to it. Signed-off-by: Florian Fainelli <f.fainelli@gmail.com> Reviewed-by: Grygorii Strashko <grygorii.strashko@ti.com> Reviewed-by: Fugang Duan <fugang.duan@nxp.com> Reviewed-by: Antoine Tenart <antoine.tenart@bootlin.com> Reviewed-by: Jose Abreu <joabreu@synopsys.com> Signed-off-by: David S. Miller <davem@davemloft.net>
2017-12-07net: mvmdio: disable/unprepare clocks in EPROBE_DEFER caseTobias Jordan1-1/+2
add appropriate calls to clk_disable_unprepare() by jumping to out_mdio in case orion_mdio_probe() returns -EPROBE_DEFER. Found by Linux Driver Verification project (linuxtesting.org). Fixes: 3d604da1e954 ("net: mvmdio: get and enable optional clock") Signed-off-by: Tobias Jordan <Tobias.Jordan@elektrobit.com> Reviewed-by: Andrew Lunn <andrew@lunn.ch> Signed-off-by: David S. Miller <davem@davemloft.net>
2017-06-16net: mvmdio: simplify the smi read and write error pathsAntoine Ténart1-10/+6
Cosmetic patch simplifying the smi read and write error paths. It also align their error paths with the ones of the xsmi functions. Signed-off-by: Antoine Tenart <antoine.tenart@free-electrons.com> Reviewed-by: Florian Fainelli <f.fainelli@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
2017-06-16net: mvmdio: add xmdio xsmi supportAntoine Ténart1-7/+105
This patch adds the xmdio xsmi interface support in the mvmdio driver. This interface is used in Ethernet controllers on Marvell 370, 7k and 8k (as of now). The xsmi interface supported by this driver complies with the IEEE 802.3 clause 45. The xSMI interface is used by 10GbE devices. Signed-off-by: Antoine Tenart <antoine.tenart@free-electrons.com> Reviewed-by: Florian Fainelli <f.fainelli@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
2017-06-16net: mvmdio: check the MII_ADDR_C45 bit is not set for smi operationsAntoine Ténart1-0/+6
Add a check for the read and write smi operations, to ensure the MII_ADDR_C45 bit isn't set. This will be needed as soon as the xSMI support is added to the mvmdio driver. Signed-off-by: Antoine Tenart <antoine.tenart@free-electrons.com> Reviewed-by: Florian Fainelli <f.fainelli@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
2017-06-16net: mvmdio: put the poll intervals in the ops structureAntoine Ténart1-2/+6
Put the two poll intervals (min and max) in the driver's ops structure. This is needed to add the xmdio support later. Signed-off-by: Antoine Tenart <antoine.tenart@free-electrons.com> Reviewed-by: Florian Fainelli <f.fainelli@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
2017-06-16net: mvmdio: introduce an ops structureAntoine Ténart1-11/+19
Introduce an ops structure to add an indirection on the is_done function, as this is needed to add the xMDIO support later. Signed-off-by: Antoine Tenart <antoine.tenart@free-electrons.com> Reviewed-by: Florian Fainelli <f.fainelli@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
2017-06-16net: mvmdio: remove duplicate lockingRussell King1-10/+0
The MDIO layer already provides per-bus locking, so there's no need for MDIO bus drivers to do their own internal locking. Remove this. Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk> Reviewed-by: Florian Fainelli <f.fainelli@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
2017-06-16net: mvmdio: use GENMASK for masksAntoine Ténart1-1/+1
Cosmetic patch to use the GENMASK helper for masks. Signed-off-by: Antoine Tenart <antoine.tenart@free-electrons.com> Reviewed-by: Florian Fainelli <f.fainelli@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
2017-06-16net: mvmdio: use tabs for definesAntoine Ténart1-13/+13
Cosmetic patch replacing spaces by tabs for defined values. Signed-off-by: Antoine Tenart <antoine.tenart@free-electrons.com> Reviewed-by: Florian Fainelli <f.fainelli@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
2017-06-16net: mvmdio: reorder headers alphabeticallyAntoine Ténart1-5/+5
Cosmetic fix reordering headers alphabetically. Signed-off-by: Antoine Tenart <antoine.tenart@free-electrons.com> Reviewed-by: Florian Fainelli <f.fainelli@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
2017-04-13net: mvmdio: allow up to three clocks to be specified for orion-mdioRussell King1-9/+24
Allow up to three clocks to be specified and enabled for the orion-mdio interface, which are required for this interface to be accessible on Armada 8k platforms. Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk> Reviewed-by: Andrew Lunn <andrew@lunn.ch> Signed-off-by: David S. Miller <davem@davemloft.net>
2017-04-13net: mvmdio: disable interrupt if resource size is too smallRussell King1-0/+6
Disable the MDIO interrupt, falling back to polled mode, if the resource size does not allow us to access the interrupt registers. All current DT bindings use a size of 0x84, which allows access, but verifying it is good practice. Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk> Reviewed-by: Andrew Lunn <andrew@lunn.ch> Signed-off-by: David S. Miller <davem@davemloft.net>
2017-04-13net: mvmdio: fix interrupt disable in remove pathRussell King1-1/+2
The pre-existing write to disable interrupts on the remove path happens whether we have an interrupt or not. While this may seem to be a good idea, this driver is re-used in many different implementations, some where the binding only specifies four bytes of register space. This access causes us to access registers outside of the binding. Make it conditional on the interrupt being present, which is the same condition used when enabling the interrupt in the first place. Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk> Reviewed-by: Andrew Lunn <andrew@lunn.ch> Signed-off-by: David S. Miller <davem@davemloft.net>
2017-04-13net: mvmdio: disable interrupts in driver failure pathRussell King1-0/+2
When the mvmdio driver has an interrupt, it enables the "done" interrupt after requesting its interrupt handler. However, probe failure results in the interrupt being left enabled. Disable it on the failure path. Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk> Reviewed-by: Andrew Lunn <andrew@lunn.ch> Signed-off-by: David S. Miller <davem@davemloft.net>
2016-10-03net: mvmdio: do not clk_disable_unprepare() NULL clockAlexey Khoroshilov1-2/+1
There is no need to clk_disable_unprepare(dev->clk) before it was initialized. Found by Linux Driver Verification project (linuxtesting.org). Signed-off-by: Alexey Khoroshilov <khoroshilov@ispras.ru> Signed-off-by: David S. Miller <davem@davemloft.net>
2016-01-07mdio: Move allocation of interrupts into coreAndrew Lunn1-9/+1
Have mdio_alloc() create the array of interrupt numbers, and initialize it to POLLING. This is what most MDIO drivers want, so allowing code to be removed from the drivers. Signed-off-by: Andrew Lunn <andrew@lunn.ch> Reviewed-by: Florian Fainelli <f.fainelli@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
2014-05-23net: mvmdio: Use devm_* API to simplify the codeEzequiel Garcia1-12/+6
This commit makes use of devm_kmalloc_array() for memory allocation and the recently introduced devm_mdiobus_alloc() API to simplify driver's code. While here, remove a redundant out of memory error message. Acked-by: Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com> Signed-off-by: Ezequiel Garcia <ezequiel.garcia@free-electrons.com> Signed-off-by: David S. Miller <davem@davemloft.net>
2014-05-02net: mvmdio: Check for a valid interrupt instead of an errorEzequiel Garcia1-1/+4
The following commit: commit 9ec36cafe43bf835f8f29273597a5b0cbc8267ef Author: Rob Herring <robh@kernel.org> Date: Wed Apr 23 17:57:41 2014 -0500 of/irq: do irq resolution in platform_get_irq changed platform_get_irq() which now returns EINVAL and EPROBE_DEFER, in addition to ENXIO. If there's no interrupt for mvmdio, platform_get_irq() returns EINVAL, but we currently check only for ENXIO. Fix this by looking for a positive integer, which is the proper way of validating a virtual interrupt number. While at it, add a proper handling for the deferral probe case. Signed-off-by: Ezequiel Garcia <ezequiel.garcia@free-electrons.com> Reviewed-by: Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
2014-03-28net: mvmdio: remove empty MDIO bus reset functionFlorian Fainelli1-6/+0
orion_mdio_reset() does nothing useful and is optional for the MDIO bus code, so let's just remove it. Signed-off-by: Florian Fainelli <f.fainelli@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
2014-01-16drivers/net: delete non-required instances of include <linux/init.h>Paul Gortmaker1-1/+0
None of these files are actually using any __init type directives and hence don't need to include <linux/init.h>. Most are just a left over from __devinit and __cpuinit removal, or simply due to code getting copied from one driver to the next. This covers everything under drivers/net except for wireless, which has been submitted separately. Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com> Signed-off-by: David S. Miller <davem@davemloft.net>
2013-12-19net: mvmdio: fix interrupt timeout handlingLeigh Brown1-0/+6
This version corrects the whitespace issue. orion_mdio_wait_ready uses wait_event_timeout to wait for the SMI interrupt to fire. wait_event_timeout waits for between "timeout - 1" and "timeout" jiffies. In this case a 1ms timeout when HZ is 1000 results in a wait of 0 to 1 jiffies, causing premature timeouts. This fix ensures a minimum timeout of 2 jiffies, ensuring wait_event_timeout will always wait at least 1 jiffie. Issue reported by Nicolas Schichan. Tested-by: Nicolas Schichan <nschichan@freebox.fr> Signed-off-by: Leigh Brown <leigh@solinno.co.uk> Signed-off-by: David S. Miller <davem@davemloft.net>
2013-10-29net: mvmdio: doc: mvmdio now used by mv643xx_ethLeigh Brown1-5/+3
Amend the documentation in the mvmdio driver to note the fact that it is now used by both the mvneta and mv643xx_eth drivers. Signed-off-by: Leigh Brown <leigh@solinno.co.uk> Signed-off-by: David S. Miller <davem@davemloft.net>
2013-10-29net: mvmdio: slight optimisation of orion_mdio_writeLeigh Brown1-6/+4
Make only a single call to mutex_unlock in orion_mdio_write. Signed-off-by: Leigh Brown <leigh@solinno.co.uk> Signed-off-by: David S. Miller <davem@davemloft.net>
2013-10-29net: mvmdio: orion_mdio_ready: remove manual pollLeigh Brown1-21/+13
Replace manual poll of MVMDIO_SMI_READ_VALID with a call to orion_mdio_wait_ready. This ensures a consistent timeout, eliminates a busy loop, and allows for use of interrupts on systems that support them. Signed-off-by: Leigh Brown <leigh@solinno.co.uk> Signed-off-by: David S. Miller <davem@davemloft.net>
2013-10-29net: mvmdio: make orion_mdio_wait_ready consistentLeigh Brown1-22/+30
Amend orion_mdio_wait_ready so that the same timeout is used when polling or using wait_event_timeout. Set the timeout to 1ms. Replace udelay with usleep_range to avoid a busy loop, and set the polling interval range as 45us to 55us, so that the first sleep will be enough in almost all cases. Generate the same log message at timeout when polling or using wait_event_timeout. Signed-off-by: Leigh Brown <leigh@solinno.co.uk> Signed-off-by: David S. Miller <davem@davemloft.net>
2013-04-08net: mvmdio: get and enable optional clockSebastian Hesselbarth1-0/+11
Marvell mdio driver uses internal registers that can be clock gated on some SoCs. This patch just adds optional clock handling, to allow to pass and enable the corresponding clock. Signed-off-by: Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com> Acked-by: Florian Fainelli <florian@openwrt.org> Signed-off-by: David S. Miller <davem@davemloft.net>
2013-03-24net: mvmdio: define module alias for platform deviceSimon Baatz1-0/+1
The mvmdio driver can be instantiated using device tree or as a classic platform device. In order to load the driver automatically by udev in the latter case, the driver needs to define a module alias for the platform device. Signed-off-by: Simon Baatz <gmbnomis@gmail.com> Acked-by: Florian Fainelli <florian@openwrt.org> Signed-off-by: David S. Miller <davem@davemloft.net>
2013-03-22net: mvmdio: enhance driver to support SMI error/done interruptsFlorian Fainelli1-18/+80
This patch enhances the "mvmdio" to support a SMI error/done interrupt line which can be used along with a wait queue instead of doing busy-waiting on the registers. This is a feature which is available in the mv643xx_eth SMI code and thus reduces again the gap between the two. Signed-off-by: Florian Fainelli <florian@openwrt.org> Signed-off-by: David S. Miller <davem@davemloft.net>
2013-03-22net: mvmdio: rename base register cookie from smireg to regsFlorian Fainelli1-7/+7
This patch renames the base register cookie in the mvmdio drive from "smireg" to "regs" since a subsequent patch is going to use an ioremap() cookie whose size is larger than a single register of 4 bytes. No functionnal code change introduced. Acked-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com> Signed-off-by: Florian Fainelli <florian@openwrt.org> Signed-off-by: David S. Miller <davem@davemloft.net>
2013-03-22net: mvmdio: allow platform device style registrationFlorian Fainelli1-7/+15
This patch changes the mvmdio driver not to use device tree helper functions such as of_mdiobus_register() and of_iomap() so we can instantiate this driver using a classic platform_device approach. Use the device manager helper to ioremap() the base register cookie so we get automatic freeing upon error and removal. This change is harmless for Device Tree platforms because they will get the driver be registered the same way as it was before. Signed-off-by: Florian Fainelli <florian@openwrt.org> Signed-off-by: David S. Miller <davem@davemloft.net>
2013-02-04ethernet: Remove unnecessary alloc/OOM messages, alloc cleanupsJoe Perches1-1/+0
alloc failures already get standardized OOM messages and a dump_stack. Convert kzalloc's with multiplies to kcalloc. Convert kmalloc's with multiplies to kmalloc_array. Fix a few whitespace defects. Convert a constant 6 to ETH_ALEN. Use parentheses around sizeof. Convert vmalloc/memset to vzalloc. Remove now unused size variables. Signed-off-by: Joe Perches <joe@perches.com> Signed-off-by: David S. Miller <davem@davemloft.net>
2012-12-22Drivers: network: more __dev* removalGreg KH1-3/+3
Remove some __dev* markings that snuck in the 3.8-rc1 merge window in the drivers/net/* directory. Cc: Bill Pemberton <wfp5p@virginia.edu> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Signed-off-by: David S. Miller <davem@davemloft.net>
2012-11-20net: mvmdio: adjust multiline comment to net/ styleThomas Petazzoni1-2/+1
As reported by checkpatch, the multiline comments for net/ and drivers/net/ have a slightly different format than the one used in the rest of the kernel, so we adjust our multiline comment accordingly. Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
2012-11-20net: mvmdio: use <linux/delay.h> instead of <asm/delay.h>Thomas Petazzoni1-2/+1
As suggested by checkpatch, using <linux/delay.h> instead of <asm/delay.h> is appropriate. Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
2012-11-16net: mvmdio: new Marvell MDIO driverThomas Petazzoni1-0/+230
This patch adds a separate driver for the MDIO interface of the Marvell Ethernet controllers. There are two reasons to have a separate driver rather than including it inside the MAC driver itself: *) The MDIO interface is shared by all Ethernet ports, so a driver must guarantee non-concurrent accesses to this MDIO interface. The most logical way is to have a separate driver that handles this single MDIO interface, used by all Ethernet ports. *) The MDIO interface is the same between the existing mv643xx_eth driver and the new mvneta driver. Even though it is for now only used by the mvneta driver, it will in the future be used by the mv643xx_eth driver as well. Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com> Acked-by: David S. Miller <davem@davemloft.net>