summaryrefslogtreecommitdiffstats
path: root/drivers/net/phy
Commit message (Collapse)AuthorAgeFilesLines
* net: phy: micrel: add support for ksz9131 phyMarc Kleine-Budde2024-03-131-0/+188
| | | | | | | | | | This imports the micrel KSZ9131 gigabit phy driver from Linux, commit 0316c7e66bbd16cf2d01a4e2f5afa6afb01278f2. Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de> Signed-off-by: Stefan Kerkmann <s.kerkmann@pengutronix.de> Link: https://lore.barebox.org/20240311-karo-imx8mp-som-board-upstreaming-v2-3-6ecda693adb2@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* net: phy: fix miibus parent device of_node not matching phy nodeSascha Hauer2024-03-132-8/+4
| | | | | | | | | | | | | | | The device node of a miibus parent device usually points to the ethernet device node whereas the parent device node of a phy device usually points to the mdio {} subnode between the ethernet node and the phy node, so both can't match. Ethernet drivers usually provide a pointer to the mdio {} subnode in miibus::dev.of_node, so use that to match against the phy nodes parent. This occured on a TQMa6UL where two FECs are registered, but both phys are connected to the FEC2. Link: https://lore.barebox.org/20240221150323.2715164-8-s.hauer@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* net: mdio_bus: associate OF nodes with their devicesAlvin Šipraga2024-01-021-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | barebox deep-probe will walk the device tree to ensure dependent devices have been probed. In so doing, it uses the device_node::dev pointer to check whether a given node has a device; if not, a device is created on demand. The behaviour is recursive, so parent nodes without an associated device will also have devices created on their behalf. The recursion stops when a parent with a device is found. Weird behaviour can ensure if, when devices with a device_node are registered, the device_node::dev field is not populated. This patch addresses a niche, benign, but also noisy error observed as a result of this behaviour. One mostly harmless consequence is that spurious devices can get created when a suitable one already exists. In my case, I have an MDIO-connected Ethernet switch with an internal MDIO bus and some internal PHYs. With deep-probe, but without these changes, the devinfo output looks as follows: `-- 30be0000.ethernet@30be0000.of `-- eth0 `-- miibus0 `-- mdio0-dev1d `-- 0x00000000-0x0000003f ( 64 Bytes): /dev/mdio0-phy1d `-- 30be0000.ethernet@30be0000:mdio:ethernet-switch@1d:ports:port@6.of `-- 30be0000.ethernet@30be0000:mdio:ethernet-switch@1d:ports:port@0.of `-- eth1 `-- 30be0000.ethernet@30be0000:mdio:ethernet-switch@1d:ports:port@1.of `-- eth2 `-- 30be0000.ethernet@30be0000:mdio:ethernet-switch@1d:ports:port@2.of `-- eth3 `-- 30be0000.ethernet@30be0000:mdio:ethernet-switch@1d:ports:port@3.of `-- eth4 `-- miibus1 `-- mdio1-phy00 `-- 0x00000000-0x0000003f ( 64 Bytes): /dev/mdio1-phy00 `-- mdio1-phy01 `-- 0x00000000-0x0000003f ( 64 Bytes): /dev/mdio1-phy01 `-- mdio1-phy02 `-- 0x00000000-0x0000003f ( 64 Bytes): /dev/mdio1-phy02 `-- mdio1-phy03 `-- 0x00000000-0x0000003f ( 64 Bytes): /dev/mdio1-phy03 `-- 30be0000.ethernet@30be0000:mdio.of `-- 30be0000.ethernet@30be0000:mdio:ethernet-switch@1d.of `-- 30be0000.ethernet@30be0000:mdio:ethernet-switch@1d:mdio.of Notice the last three devices with generic names; they are spurious creations of the deep-probe algorithm. In fact, the devices have already been created: real dev spurious dev -------- ------------ miibus0 30be0000.ethernet@30be0000:mdio.of mdio0-devid1d 30be0000.ethernet@30be0000:mdio:ethernet-switch@1d.of miibus1 30be0000.ethernet@30be0000:mdio:ethernet-switch@1d:mdio.of The only reason there aren't even more spurious devices created is that deep-probe stopped at 30be0000.ethernet@30be0000.of, a platform device whose device_node had its dev field populated correctly. But these so-called real devices are all created by mdio_bus, which only links one way, i.e. sets device::of_node, but not device_node::dev. This issue probably goes unnoticed on most boards because, while the call to of_device_ensure_probed() returns -ENODEV on the bottom listed node, the code in phy.c doesn't check the return code, and the real devices have already been probed, so no harm is done. I observed much more surprising behaviour on my board because the switch I am using, an RTL8365MB, has multiple possible management interfaces, for which barebox has two drivers: realtek-smi and realtek-mdio (for SMI- and MDIO-connected switches, respectively). The compatible strings are the same, "realtek,rtl8365mb", but the bus types are different: the former is a platform driver, the latter a phy (read: mdio) driver. In my bootloader I have both drivers built in, because some of my boards use SMI while others use MDIO. When I would run the command 'boot bnet', bringing up my network interface, DSA would call phy_device_connect() to connect my edev with its corresponding phy, and a deep-probe would kick off because the phy's parent's device_node::dev field was not populated. And during the creation of the spurious device for my (already probed) Ethernet switch, the platform code would find a compatible string match with realtek-smi and try to probe the device with that driver: Booting entry 'bnet' ERROR: gpiolib: _gpio_request: gpio-233 (30be0000.ethernet@30be0000:mdio:ethernet-switch@1d.of-reset) status -16 ERROR: realtek-smi 30be0000.ethernet@30be0000:mdio:ethernet-switch@1d.of: error Device or resource busy: failed to get RESET GPIO ERROR: realtek-smi 30be0000.ethernet@30be0000:mdio:ethernet-switch@1d.of: probe failed: Device or resource busy As stated above, my switch is connected over MDIO, not SMI, so I really should not be seeing any "realtek-smi" in my log. Nevertheless, because phy.c doesn't check for errors, the errors are benign and my network boot runs just fine. Dumping the stack around the above error print in the realtek-smi driver reveals exactly why things are going wrong: ERROR: gpiolib: _gpio_request: gpio-233 (30be0000.ethernet@30be0000:mdio:ethernet-switch@1d.of-reset) status -16 Call trace: [<7dd8f400>] (unwind_backtrace+0x0/0x90) [<7dd8f4a0>] (dump_stack+0x10/0x18) [<7dd2d4d4>] (realtek_smi_probe+0x16c/0x2f4) [<7dd1da28>] (platform_probe+0x48/0x4c) [<7dd1cf24>] (device_probe+0x80/0x13c) [<7dd1d028>] (match+0x48/0x58) [<7dd1d3c8>] (register_device+0x178/0x184) [<7dd1da80>] (platform_device_register+0x18/0x20) [<7dd5501c>] (of_platform_device_create+0x2b8/0x2e0) [<7dd55170>] (of_device_create_on_demand+0x84/0xc0) [<7dd5513c>] (of_device_create_on_demand+0x50/0xc0) [<7dd552e0>] (of_device_ensure_probed+0x40/0x6c) [<7dd21398>] (phy_device_connect+0x174/0x230) [<7dd1fd74>] (dsa_port_start+0x60/0x1f0) [<7dd7a0e4>] (eth_open+0x24/0x44) [<7dd7d7e4>] (ifup_edev+0x9c/0x2ec) [<7dd7dbe4>] (ifup_all+0x110/0x204) [<7dd7dd2c>] (do_ifup+0x54/0xd4) [<7dd09e78>] (execute_command+0x44/0x8c) ... The whole mess is rectified if the proper linking is done by mdio_bus, since it is responsible for creating all of the devices to begin with. So, make sure that the device_node::dev field is populated in all cases there. Note that while I also make this change in of_mdiobus_register_phy(), I did not actually observe any unwanted behaviour by not doing so - the problem above is specifically because it's not done in of_mdiobus_register() or of_mdiobus_register_device(). But this is only because of the way phys are looked up to begin with, so it seemed reasonable to do it for them as well. Signed-off-by: Alvin Šipraga <alsi@bang-olufsen.dk> Link: https://lore.barebox.org/20231222-realtek-mdio-fix-v1-4-6bbf80d6a756@bang-olufsen.dk Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* net: phy: add TI DP83TG720 1000BaseT1 PHY supportOleksij Rempel2023-12-133-0/+110
| | | | | | | | | | | Add driver for TI DP83TG720 driver support. Even if the PHY is capable of creating a link on it's own. It needs proper RGMII configuration and HW reset on link loss. Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de> Link: https://lore.barebox.org/20231206111118.1338567-1-o.rempel@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* net: phy: dp83867: Sync with LinuxSascha Hauer2023-09-211-151/+377
| | | | | | | | This updates the dp83867 phy driver to current Linux-6.5 for easier future updates. Link: https://lore.barebox.org/20230920112252.2782897-2-s.hauer@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* net: phy: at803x: disable extended next page bitMarco Felsch2023-08-141-1/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This commit ports Linux commit: | commit 3c51fa5d2afe7a4909b53af5019635326389dd29 | Author: Russell King <rmk+kernel@armlinux.org.uk> | Date: Tue Jan 12 22:59:43 2021 +0000 | | net: phy: ar803x: disable extended next page bit | | This bit is enabled by default and advertises support for extended | next page support. XNP is only needed for 10GBase-T and MultiGig | support which is not supported. Additionally, Cisco MultiGig switches | will read this bit and attempt 10Gb negotiation even though Next Page | support is disabled. This will cause timeouts when the interface is | forced to 100Mbps and auto-negotiation will fail. The interfaces are | only 1000Base-T and supporting auto-negotiation for this only requires | the Next Page bit to be set. | | Taken from: | https://github.com/SolidRun/linux-stable/commit/7406c5244b7ea6bc17a2afe8568277a8c4b126a9 | and adapted to mainline kernels by rmk. | | Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk> | Reviewed-by: Andrew Lunn <andrew@lunn.ch> | Link: https://lore.kernel.org/r/E1kzSdb-000417-FJ@rmk-PC.armlinux.org.uk | Signed-off-by: Jakub Kicinski <kuba@kernel.org> Signed-off-by: Marco Felsch <m.felsch@pengutronix.de> Reviewed-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20230811102657.271931-11-m.felsch@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* net: phy: at803x: add disable hibernation mode supportMarco Felsch2023-08-141-0/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This commit is based on Linux commit: | commit 9ecf04016c87bcb33b44e24489d33618e2592f41 | Author: Wei Fang <wei.fang@nxp.com> | Date: Thu Aug 18 11:00:54 2022 +0800 | | net: phy: at803x: add disable hibernation mode support | | When the cable is unplugged, the Atheros AR803x PHYs will enter | hibernation mode after about 10 seconds if the hibernation mode | is enabled and will not provide any clock to the MAC. But for | some MACs, this feature might cause unexpected issues due to the | logic of MACs. | Taking SYNP MAC (stmmac) as an example, if the cable is unplugged | and the "eth0" interface is down, the AR803x PHY will enter | hibernation mode. Then perform the "ifconfig eth0 up" operation, | the stmmac can't be able to complete the software reset operation | and fail to init it's own DMA. Therefore, the "eth0" interface is | failed to ifconfig up. Why does it cause this issue? The truth is | that the software reset operation of the stmmac is designed to | depend on the RX_CLK of PHY. | So, this patch offers an option for the user to determine whether | to disable the hibernation mode of AR803x PHYs. | | Signed-off-by: Wei Fang <wei.fang@nxp.com> | Reviewed-by: Andrew Lunn <andrew@lunn.ch> | Signed-off-by: Jakub Kicinski <kuba@kernel.org> The commit is adapted to always disable the hibernation mode instead of making it optional since bootloaders require no special power optimization. Signed-off-by: Marco Felsch <m.felsch@pengutronix.de> Link: https://lore.barebox.org/20230811102657.271931-10-m.felsch@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* net: phy: at803x: disable SmartEEEMarco Felsch2023-08-141-1/+18
| | | | | | | | | The SmartEEE functionality can cause strange connection issues. Disable it unconditional and leave it to the OS to enable it again. Signed-off-by: Marco Felsch <m.felsch@pengutronix.de> Link: https://lore.barebox.org/20230811102657.271931-9-m.felsch@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* net: phy: add deprecation warning to phy_{read,write,modify}_mmd_indirectMarco Felsch2023-08-141-0/+9
| | | | | | | | | Add deprecation warnings and point to the new APIs user should use instead. Signed-off-by: Marco Felsch <m.felsch@pengutronix.de> Link: https://lore.barebox.org/20230811102657.271931-8-m.felsch@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* net: phy: replace phy_{write,read,modify}_mmd_indirect with ↵Marco Felsch2023-08-143-49/+40
| | | | | | | | | | | | phy_{write,read,modify}_mmd Make use of the phy_{write,read,modify}_mmd API to align the code with Linux. This also fixes the r8169 driver since this driver did not adapt the parameters while porting from Linux. Signed-off-by: Marco Felsch <m.felsch@pengutronix.de> Link: https://lore.barebox.org/20230811102657.271931-7-m.felsch@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* net: phy: import phy_{read,write,modify}_mmd helpers from LinuxMarco Felsch2023-08-141-0/+109
| | | | | | | | | | | | Linux have added helper functions to access and modify the mmd registers. The helpers are clause22/45 agnostic and can handle both the same way. Since barebox does not have clause45 support we need to inform the user that this is not supported at the moment. Therefore we also need the is_c45 flag which is ported from Linux as well. Signed-off-by: Marco Felsch <m.felsch@pengutronix.de> Link: https://lore.barebox.org/20230811102657.271931-6-m.felsch@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* net: phy: mmd_phy_indirect: align parameters with LinuxMarco Felsch2023-08-141-5/+5
| | | | | | | | | Switch the prtad and devad to align it with Linux to make porting from Linux less error prone. While on it rename prtad with regnum. Signed-off-by: Marco Felsch <m.felsch@pengutronix.de> Link: https://lore.barebox.org/20230811102657.271931-4-m.felsch@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* net: phy: micrel: make use of MDIO_MMD register definesMarco Felsch2023-08-141-4/+8
| | | | | | | | | | Make use of the register definition instead of having magic numbers. No functional change. Signed-off-by: Marco Felsch <m.felsch@pengutronix.de> Reviewed-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20230811102657.271931-2-m.felsch@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* treewide: Print device nodes with %pOFSascha Hauer2023-07-032-6/+6
| | | | | | | We have the %pOF format specifier for printing device nodes. Use it where appropriate. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/misc'Sascha Hauer2023-06-226-6/+197
|\
| * nvmem: retire struct nvmem_bus for better Linux compatibilityAhmad Fatoum2023-06-131-6/+2
| | | | | | | | | | | | | | | | | | | | nvmem_bus is arguably a confusing name and serves no real purpose over just embedding its two members directly. That's what Linux currently does, so follow suit. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20230612125711.1086786-1-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * net: phy: add driver for MotorComm PHYYegor Yefremov2023-06-093-0/+135
| | | | | | | | | | | | | | | | The driver corresponds to the kernel 6.1.27. Signed-off-by: Yegor Yefremov <yegorslists@googlemail.com> Link: https://lore.barebox.org/20230606081718.2246807-1-yegorslists@googlemail.com Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * net: phy: dp83867: respect ti,clk-output-sel DT propertyRoland Hieber2023-06-061-0/+37
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | On some boards it is necessary to configure the PHY to provide the correct clock to the FEC. This ports the rest of the following two kernel commits: | commit 9708fb630d19ee51ae3aeb3a533e3010da0e8570 | Author: Wadim Egorov <w.egorov@phytec.de> | Date: Mi 2018-02-14 17:07:11 | | net: phy: dp83867: Add binding for the CLK_OUT pin muxing option | | The DP83867 has a muxing option for the CLK_OUT pin. It is possible | to set CLK_OUT for different channels. | Create a binding to select a specific clock for CLK_OUT pin. | | Signed-off-by: Wadim Egorov <w.egorov@phytec.de> | Signed-off-by: Daniel Schultz <d.schultz@phytec.de> | Reviewed-by: Andrew Lunn <andrew@lunn.ch> | Reviewed-by: Florian Fainelli <f.fainelli@gmail.com> | Signed-off-by: David S. Miller <davem@davemloft.net> | | commit 13c83cf8af0dcc6103982b4dc0b70826f0b54f21 | Author: Trent Piepho <tpiepho@impinj.com> | Date: Mi 2019-05-22 18:43:22 | | net: phy: dp83867: Add ability to disable output clock | | Generally, the output clock pin is only used for testing and only serves | as a source of RF noise after this. It could be used to daisy-chain | PHYs, but this is uncommon. Since the PHY can disable the output, make | doing so an option. I do this by adding another enumeration to the | allowed values of ti,clk-output-sel. | | The code was not using the value DP83867_CLK_O_SEL_REF_CLK as one might | expect: to select the REF_CLK as the output. Rather it meant "keep | clock output setting as is", which, depending on PHY strapping, might | not be outputting REF_CLK. | | Change this so DP83867_CLK_O_SEL_REF_CLK means enable REF_CLK output. | Omitting the property will leave the setting as is (which was the | previous behavior in this case). | | Out of range values were silently converted into | DP83867_CLK_O_SEL_REF_CLK. Change this so they generate an error. | | Cc: Andrew Lunn <andrew@lunn.ch> | Cc: Florian Fainelli <f.fainelli@gmail.com> | Cc: Heiner Kallweit <hkallweit1@gmail.com> | Signed-off-by: Trent Piepho <tpiepho@impinj.com> | Reviewed-by: Andrew Lunn <andrew@lunn.ch> | Signed-off-by: David S. Miller <davem@davemloft.net> Link: https://git.kernel.org/torvalds/c/9708fb630d19ee51ae3a Link: https://git.kernel.org/torvalds/c/13c83cf8af0dcc610398 Signed-off-by: Roland Hieber <rhi@pengutronix.de> Link: https://lore.barebox.org/20230605125748.3665121-2-rhi@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * net: phy: add phy_modify_mmd_indirect convenience functionRoland Hieber2023-06-061-0/+23
| | | | | | | | | | | | | | | | | | Add a read-modify-write convenience helper similar to phy_modify() for setting single bits in MMD registers. Signed-off-by: Roland Hieber <rhi@pengutronix.de> Link: https://lore.barebox.org/20230605125748.3665121-1-rhi@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | treewide: add MODULE_DEVICE_TABLE markersAhmad Fatoum2023-06-134-0/+4
|/ | | | | | | | | | | | | | | | 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>
* Merge branch 'for-next/rockchip'Sascha Hauer2023-05-241-0/+6
|\
| * phy: realtek: Add RTL8125 internal phy supportSascha Hauer2023-05-231-0/+6
| | | | | | | | Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | net: phy: print error messages to logJohannes Zink2023-05-221-2/+2
|/ | | | | | | | | | | | Previously the phy core did just print info and error messages to console, but they did not show up in the system log. Now the dev_info and dev_err macros are used instead of raw puts, they are now nicely formatted and show up in the log. Signed-off-by: Johannes Zink <j.zink@pengutronix.de> Link: https://lore.barebox.org/20230509060521.707205-1-j.zink@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* net: phy: remove duplicate definition of PHY_AN_TIMEOUTAhmad Fatoum2023-01-311-2/+0
| | | | | | | | Same macro is already defined in <linux/phy.h>. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20230130113405.2796838-1-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Rename struct driver_d to driverSascha Hauer2023-01-105-5/+5
| | | | | | | | | | | 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-1014-26/+26
| | | | | | | | | | | | | 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-1012-41/+43
| | | | | | | | | | | | | | | | | | | | 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>
* mdio_bus: do reset only on PHY devicesOleksij Rempel2022-10-041-3/+4
| | | | | | | | Do not reset MDIO devices. Device drivers should handle it. Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de> Link: https://lore.barebox.org/20220926081740.76968-1-o.rempel@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* net: add support for MDIO devicesOleksij Rempel2022-09-222-17/+86
| | | | | | | | | | | On the MDIO bus we can have PHYs and some other type of devices. Typical not_PHY MDIO devices do not have easy detectable ID and can't be used as-is by the PHY framework. So, add additional handler to register MDIO devices and drivers alongside with the PHY devices/drivers. Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de> Link: https://lore.barebox.org/20220920125533.2497108-2-o.rempel@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* net: port support for microchip SMI0 MDIO busOleksij Rempel2022-09-222-2/+14
| | | | | | | | | | | | | | | | | | | SMI0 is a mangled version of MDIO. The main low level difference is the MDIO C22 OP code is always 0, not 0x2 or 0x1 for Read/Write. The read/write information is instead encoded in the PHY address. Extend the bit-bang code to allow the op code to be overridden, but default to normal C22 values. Add an extra compatible to the mdio-gpio driver, and when this compatible is present, set the op codes to 0. A higher level driver, sitting on top of the basic MDIO bus driver can then implement the rest of the microchip SMI0 odderties. This code was ported from the kernel v6.0-rc2. Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de> Link: https://lore.barebox.org/20220920125533.2497108-1-o.rempel@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/misc'Sascha Hauer2022-09-141-0/+2
|\
| * mdio_bus: Configure pinctrl for phy devicesSascha Hauer2022-08-311-0/+2
| | | | | | | | | | | | | | | | | | | | Some phys registered from devicetree have pinctrl settings attached to them. Configure the pinctrl state to make sure they can be accessed before trying to reset and detect the phy devices. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de> Link: https://lore.barebox.org/20220830133826.1395373-1-s.hauer@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | net: phy: micrel: drop useless assignment of dummy readAhmad Fatoum2022-09-121-1/+1
|/ | | | | | | | | | | The result of the PHY read is never used and the comment suggests this is intentional. Still static analysis warns about this, so remove the variable assignment and leave the read. We cast it to (void) to avoid possible future __must_check warnings. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20220905095557.596891-5-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* treewide: Remove duplicate incudesAlexander Shiyan2022-06-101-1/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Fix warning fwterated by checkincludes.pl: ./net/nfs.c: libgen.h is included more than once. ./net/ifup.c: globalvar.h is included more than once. ./crypto/rsa.c: asm/types.h is included more than once. ./lib/decompress_unlz4.c: linux/decompress/mm.h is included more than once. ./scripts/stb_image.h: stdio.h is included more than once. ./scripts/kwbimage.c: unistd.h is included more than once. ./scripts/common.c: sys/types.h is included more than once. ./scripts/bareboximd.c: sys/types.h is included more than once. ./scripts/bareboximd.c: sys/mman.h is included more than once. ./fs/pstore/ram_core.c: linux/rslib.h is included more than once. ./fs/pstore/fs.c: fs.h is included more than once. ./fs/pstore/fs.c: linux/pstore.h is included more than once. ./fs/nfs.c: fs.h is included more than once. ./fs/uimagefs.c: fs.h is included more than once. ./fs/fs.c: command.h is included more than once. ./arch/sandbox/board/hostfile.c: linux/err.h is included more than once. ./arch/sandbox/board/devices.c: mach/linux.h is included more than once. ./arch/sandbox/os/common.c: signal.h is included more than once. ./arch/arm/boards/zii-imx51-rdu1/board.c: envfs.h is included more than once. ./arch/arm/boards/imx233-olinuxino/imx23-olinuxino.c: generated/mach-types.h is ./arch/arm/mach-stm32mp/ddrctrl.c: mach/stm32.h is included more than once. ./arch/arm/mach-imx/cpu_init.c: common.h is included more than once. ./arch/arm/mach-imx/imx8m.c: mach/imx8m-ccm-regs.h is included more than once. ./common/efi/payload/init.c: efi.h is included more than once. ./common/state/backend_format_raw.c: common.h is included more than once. ./common/state/backend_format_raw.c: crc.h is included more than once. ./common/hush.c: libbb.h is included more than once. ./drivers/spi/atmel-quadspi.c: linux/clk.h is included more than once. ./drivers/spi/atmel-quadspi.c: linux/err.h is included more than once. ./drivers/net/virtio.c: net.h is included more than once. ./drivers/net/phy/phy.c: linux/phy.h is included more than once. ./drivers/net/cpsw.c: net.h is included more than once. ./drivers/virtio/virtio_pci_common.h: linux/list.h is included more than once. ./drivers/usb/host/ohci-hcd.c: dma.h is included more than once. ./drivers/usb/gadget/fsl_udc.c: dma.h is included more than once. ./drivers/nvmem/eeprom_93xx46.c: spi/spi.h is included more than once. ./drivers/nvmem/eeprom_93xx46.c: of.h is included more than once. ./drivers/video/imx-ipu-v3/imx-ldb.c: linux/clk.h is included more than once. ./drivers/video/imx-ipu-v3/imx-hdmi.c: linux/clk.h is included more than once. ./drivers/video/omap.c: common.h is included more than once. ./drivers/mtd/nand/nand_s3c24xx.c: asm/sections.h is included more than once. ./drivers/clk/imx/clk-imx6sx.c: linux/clk.h is included more than once. ./drivers/clk/imx/clk-imx6sl.c: linux/clk.h is included more than once. ./commands/bootm.c: of.h is included more than once. Signed-off-by: Alexander Shiyan <eagle.alexander923@gmail.com> Link: https://lore.barebox.org/20220607051957.2497-1-eagle.alexander923@gmail.com Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/misc'Sascha Hauer2022-04-218-5/+103
|\
| * net: phy: add TI DP83TD510E T1L PHY supportOleksij Rempel2022-04-193-0/+52
| | | | | | | | | | | | | | | | Add basic driver for TI DP83TD510E T1L PHY Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de> Link: https://lore.barebox.org/20220414100442.1497017-1-o.rempel@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * net: phy: do not call adjust_link() form phy_device_attach()Oleksij Rempel2022-04-191-5/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | phy_device_attach() is usually called from eth_open() to enable interface, configure MAC, etc. Some times we have situations like this: 1. find and configure PHY 2. define PHY as clock provider for MAC 3. reset and configure MAC 4. detect link and speed and configure MAC accordingly. Which works as expected unless we use fixed PHY. Since fixed-phy was handled differently by the PHY code, we did step 4. before step 3. In this case we will loose MAC speed configuration at least on designware-eqos Ethernet controller. With this change, we handle real PHY and virtual fixed-PHY in the same way. So, adjust_link() (step 4.) will be called after edev->open() (step 3.) as it should be for both variants. Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de> Link: https://lore.barebox.org/20220414075530.1372003-1-o.rempel@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * net: phy: mv88e6xxx: add support for mv88e6250Steffen Trumtrar2022-03-283-0/+30
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | barebox port of the linux patch: commit 1f71836f5d96e4c87fad16db86d324bee47e1d30 Author: Rasmus Villemoes <rasmus.villemoes@prevas.dk> Date: Tue Jun 4 07:34:32 2019 +0000 net: dsa: mv88e6xxx: add support for mv88e6250 This adds support for the Marvell 88E6250. I've checked that each member in the ops-structure makes sense, and basic switchdev functionality works fine. It uses the new dual_chip option, and since its port registers start at SMI address 0x08 or 0x18 (i.e., always sw_addr + 0x08), we need to introduce a new compatible string in order for the auto-identification in mv88e6xxx_detect() to work. The chip has four per port 16-bits statistics registers, two of which correspond to the existing "sw_in_filtered" and "sw_out_filtered" (but at offsets 0x13 and 0x10 rather than 0x12 and 0x13, because why should this be easy...). Wiring up those four statistics seems to require introducing a STATS_TYPE_PORT_6250 bit or similar, which seems a tad ugly, so for now this just allows access to the STATS_TYPE_BANK0 ones. The chip does have ptp support, and the existing mv88e6352_{gpio,avb,ptp}_ops at first glance seem like they would work out-of-the-box, but for simplicity (and lack of testing) I'm eliding this. Reviewed-by: Andrew Lunn <andrew@lunn.ch> Signed-off-by: Rasmus Villemoes <rasmus.villemoes@prevas.dk> Signed-off-by: David S. Miller <davem@davemloft.net> Signed-off-by: Steffen Trumtrar <s.trumtrar@pengutronix.de> Link: https://lore.barebox.org/20220321131632.1307943-2-str@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * net: phy: mv88e6xxx: implement port_set_speed for mv88e6250Steffen Trumtrar2022-03-282-0/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | barebox port of the linux patch: commit a528e5be6b5f8026eda029b03340dcfa23c70824 Author: Rasmus Villemoes <rasmus.villemoes@prevas.dk> Date: Tue Jun 4 07:34:29 2019 +0000 net: dsa: mv88e6xxx: implement port_set_speed for mv88e6250 The data sheet also mentions the possibility of selecting 200 Mbps for the MII ports (ports 5 and 6) by setting the ForceSpd field to 0x2 (aka MV88E6065_PORT_MAC_CTL_SPEED_200). However, there's a note that "actual speed is determined by bit 8 above", and flipping back a page, one finds that bits 13:8 are reserved... So without further information on what bit 8 means, let's stick to supporting just 10 and 100 Mbps on all ports. Reviewed-by: Andrew Lunn <andrew@lunn.ch> Signed-off-by: Rasmus Villemoes <rasmus.villemoes@prevas.dk> Signed-off-by: David S. Miller <davem@davemloft.net> Signed-off-by: Steffen Trumtrar <s.trumtrar@pengutronix.de> Link: https://lore.barebox.org/20220321131632.1307943-1-str@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | net: phy: make sure MDIO bus is probed if we search for the PHYOleksij Rempel2022-04-141-0/+1
| | | | | | | | | | | | | | | | | | | | For DSA support we need to work with multiple MDIO buses. So, we need to make that MDIO bus node is probed before on on request of DSA switch registration. Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de> Link: https://lore.barebox.org/20220413082205.429509-10-o.rempel@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | net: phy: export of_phy_register_fixed_link() functionOleksij Rempel2022-04-141-2/+2
|/ | | | | | | | We will need this function by DSA framework Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de> Link: https://lore.barebox.org/20220413082205.429509-4-o.rempel@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* of: rename of_find_node_by_name() to of_find_node_by_name_address()Sascha Hauer2022-03-081-1/+1
| | | | | | | | | | | | | of_find_node_by_name() has the same name as the corresponding kernel function but a different semantics. A node name is comprised of the nodes name and a unit address, separated with '@'. Linux of_find_node_by_name() matches only the name before the '@' whereas the barebox function compares the full name. As several callers depend on the barebox semantics we can't just change the semantics, so rename the barebox function to of_find_node_by_name_address(). Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* drivers: migrate "GPL-2.0" license identifiers to SPDX 2.0Roland Hieber2021-11-2212-12/+12
| | | | | | | | | | "GPL-2.0-only" was introduced in SPDX 2.0, and the old identifier "GPL-2.0" is now considered deprecated; see <https://spdx.org/licenses>. Fixes: 28f4a6a4df76f0f1581d (2021-10-30, "drivers: add missing SPDX-License-Identifier") Signed-off-by: Roland Hieber <rhi@pengutronix.de> Link: https://lore.barebox.org/20211117113851.2022669-2-rhi@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/spdx'Sascha Hauer2021-11-1512-6/+12
|\
| * drivers: add missing SPDX-License-IdentifierAhmad Fatoum2021-11-0112-6/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This adds the suitable SPDX-License-Identifier to all files in drivers/ that previously lacked one. To aid manual inspection, following heuristics can be used: * No changes outside of comments/whitespace: git show -U0 HEAD | rg -v '^(@@|diff|index)|[-+]([-+]|//|#|[\s/]\*)' * -or-later come in pairs: git show --inter-hunk-context=19 HEAD | \ perl -0777 -F'/^@/gm' -ne 'for (@F) { @m = /later/g; print if @m & 1 }' Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20211030175632.2276077-4-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | net: phy: micrel: sync init code for ksz80xx variants with the kernel driverOleksij Rempel2021-11-111-22/+228
|/ | | | | | | | | | | | | Sync part of barebox micrel driver with the kernel v5.15-rc1. This change will affect most of by barebox supported 100Mbit/ksz80xx PHY variants and provide unified devicetree support for LED and clock configuration. At same time, NAND and broadcast configuration parts are synced as well to reduce the difference with the kernel driver. Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de> Link: https://lore.barebox.org/20211013121825.4278-2-o.rempel@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/misc'Sascha Hauer2021-06-161-5/+29
|\
| * net: phy: micrel: Add led-mode supportTrent Piepho2021-06-091-5/+29
| | | | | | | | | | | | | | | | | | | | | | | | Add code that will use the micrel,led-mode property to configure the led. It seems nearly every Micrel PHY equipped board has a custom phy fixup to do this. Maybe some of them won't be needed anymore. Signed-off-by: Trent Piepho <tpiepho@gmail.com> Link: https://lore.barebox.org/20210531150045.1214037-1-tpiepho@gmail.com Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | nvmem: provider: align read/write callback prototype with upstreamAhmad Fatoum2021-06-021-6/+5
|/ | | | | | | | | | | | | | barebox allocates a NVMEM device as part of nvmem_register, which it passes along to the callbacks. Callbacks then use dev->parent->priv to retrieve the driver private data. This indirection makes definition of nvmem helpers inconvenient, because they would need to hijack the ->priv member of the hardware device. Avoid this by passing along some private data pointer defined at registration time, just like Linux does. This will be used in a follow up commit. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20210531072406.5630-4-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* net: phy: at803x: fix incorrect use of FIELD_PREPAhmad Fatoum2021-03-251-4/+3
| | | | | | | | FIELD_PREP expects mask datatype to be a constant unsigned long. The mask constant already has the correct datatype, so pass it directly. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>