From: Oleksij Rempel <o.rempel@pengutronix.de>
To: barebox@lists.infradead.org
Cc: Oleksij Rempel <o.rempel@pengutronix.de>
Subject: [PATCH v1 5/8] ARM: boards: skov-imx6: rework switch detection
Date: Mon, 26 Sep 2022 10:17:37 +0200 [thread overview]
Message-ID: <20220926081740.76968-5-o.rempel@pengutronix.de> (raw)
In-Reply-To: <20220926081740.76968-1-o.rempel@pengutronix.de>
The KSZ8873 switch supports two ways of communication over MDIO bus:
1. Standard MDIO opcodes to talk with the switch PHYs only.
2. Not standard MDIO opcodes to talk with complete switch management and
PHYs.
Previous switch detection board code was using option 1. over FEC. Now,
with the switch driver we are using option 2. with GPIO bitbang MDIO
bus, since FEC do not support special opcodes.
To avoid duplicating switch driver functionality, we will let do switch
detection and validation to the switch driver and the board code should
only test if switch driver was probed.
Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de>
---
arch/arm/boards/skov-imx6/board.c | 27 ++++++++++-----------------
1 file changed, 10 insertions(+), 17 deletions(-)
diff --git a/arch/arm/boards/skov-imx6/board.c b/arch/arm/boards/skov-imx6/board.c
index 140689c87b..3c51b76735 100644
--- a/arch/arm/boards/skov-imx6/board.c
+++ b/arch/arm/boards/skov-imx6/board.c
@@ -133,9 +133,6 @@ copy_mac_from_eth0:
return eth_of_fixup_node_from_eth_device(root, node_path, ethname);
}
-#define SKOV_GPIO_MDIO_BUS 0
-#define SKOV_LAN1_PHY_ADDR 1
-
#define MAX_V_GPIO 8
struct board_description {
@@ -547,29 +544,25 @@ static void skov_init_board(const struct board_description *variant)
static int skov_switch_test(void)
{
- struct phy_device *phydev;
+ struct device_d *sw_dev;
struct device_d *eth0;
- struct mii_bus *mii;
int ret;
if (skov_board_no < 0)
return 0;
- /* On this boards, we have only one MDIO bus. So, it is enough to take
- * the first one.
- */
- mii = mdiobus_get_bus(SKOV_GPIO_MDIO_BUS);
- /* We can't read the switch ID, but we get get ID of the first PHY,
- * which is enough to test if the switch is attached.
+ /* Driver should be able to detect if device do actually
+ * exist. So, we need only to detect if driver is actually
+ * probed.
*/
- phydev = get_phy_device(mii, SKOV_LAN1_PHY_ADDR);
- if (IS_ERR(phydev))
- goto no_switch;
-
- if (phydev->phy_id != PHY_ID_KSZ886X)
+ sw_dev = of_find_device_by_node_path("/mdio/switch@0");
+ if (!sw_dev) {
+ pr_err("switch@0 device was not created!\n");
goto no_switch;
+ }
- return 0;
+ if (dev_is_probed(sw_dev))
+ return 0;
no_switch:
skov_have_switch = false;
--
2.30.2
next prev parent reply other threads:[~2022-09-26 8:19 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-09-26 8:17 [PATCH v1 1/8] mdio_bus: do reset only on PHY devices Oleksij Rempel
2022-09-26 8:17 ` [PATCH v1 2/8] driver: add dev_is_probed() helper function Oleksij Rempel
2022-09-26 8:17 ` [PATCH v1 3/8] net: ksz8873: add device validation to be able to detect missing switch Oleksij Rempel
2022-09-26 8:17 ` [PATCH v1 4/8] ARM: boards: skov-imx6: free used gpio devices pins Oleksij Rempel
2022-09-26 8:17 ` Oleksij Rempel [this message]
2022-09-26 8:17 ` [PATCH v1 6/8] ARM: boards: Skov-i.MX6: select KSZ8873 switch driver Oleksij Rempel
2022-09-26 8:17 ` [PATCH v1 7/8] ARM: dts: Skov i.MX6: start using mainlined kernel dts Oleksij Rempel
2022-09-26 8:17 ` [PATCH v1 8/8] net: dsa: do not wait for aneg is actually done on the port start Oleksij Rempel
2022-10-04 7:44 ` [PATCH v1 1/8] mdio_bus: do reset only on PHY devices Sascha Hauer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220926081740.76968-5-o.rempel@pengutronix.de \
--to=o.rempel@pengutronix.de \
--cc=barebox@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox