Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 99CEAC77B7E for ; Thu, 1 Jun 2023 10:00:51 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 627D9862E8; Thu, 1 Jun 2023 12:00:38 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=denx.de Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=denx.de; s=phobos-20191101; t=1685613639; bh=beFtB3vt/mA8gn+1J3XS85rugVboUT9FhR8Yhw4DWm4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=lWN13v3kWjO4thCR70DVxtD6BVSXHYQ+d6dpq8X/GH7yRdhT1EqQcrff0xro9+by0 ATDv2vpWk5KZvn1IrPxMm/o5lEuMeZ90+dwdfm+xntWd1dY7jR198CccXvWH/IFjcX nTSrZoJL0W2nBOWAINHKRCqtFJZhdGpnY9GB+hmC/mWoE+KqD8NfwNz2QH4GecXVgX CaLxVDNXorLy1FKKFfCDs7AwcH7TUIGEuQ9g+yxEgpQQcglvnItg+dQjSMaFNIJCA7 zZ3d17ZGAp+uHkIhWWzX5LP13c/98nBf7JYBifI3h+ZO8Qrv4I3rH9iYm6xq/zA1ml XZgwCxoFUe0YQ== Received: from localhost.localdomain (85-222-111-42.dynamic.chello.pl [85.222.111.42]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: lukma@denx.de) by phobos.denx.de (Postfix) with ESMTPSA id 1394F86152; Thu, 1 Jun 2023 12:00:29 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=denx.de; s=phobos-20191101; t=1685613629; bh=beFtB3vt/mA8gn+1J3XS85rugVboUT9FhR8Yhw4DWm4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=sswyaedp0WLdnp22mVprsuiKpUkQ1dZeiLxAAAVrxCMmu/VQQHza1YeQgUaq/i8CL xhXJVmLuL8Zd11hTxO9yyvim02l8Uh/PDzssBxTY6mHRm9MXWKp6upmBpVMfXDJ8ls k2D9TCeIdNAHyCcs5U87vKAfhpSkHKMYSRUlKX2ollYmg3C9gF2P/L+TY3I7hcOJgW Uyn09B4M4ICC/49j2mTOEEla2Ivy60BRJlx3Z91KcxRKaQRju8GFkQAu2Ty6yu18xm P7UyC+EendkTG8NwQdJqR6raUiK+9MBFuGpoHYF2mzs8n+/1ZEsbVxvIazfgW1dCVx /96lW2muRPxKA== From: Lukasz Majewski To: u-boot@lists.denx.de, Tom Rini Cc: Anatolij Gustschin , Lukasz Majewski , Ramon Fried , Joe Hershberger , Marek Vasut , Michal Simek Subject: [PATCH v1 1/6] net: mv88e61xx: Add support for checking addressing mode Date: Thu, 1 Jun 2023 12:00:00 +0200 Message-Id: <20230601100005.2216345-2-lukma@denx.de> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230601100005.2216345-1-lukma@denx.de> References: <20230601100005.2216345-1-lukma@denx.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean Some Marvell switch devices are dual chip ones, like mv88e6020, which use direct MDIO addressing to access its ports' registers. Such approach allows connecting two such devices in a single MDIO bus with simple addressing scheme. Signed-off-by: Lukasz Majewski Reviewed-by: Ramon Fried --- drivers/net/phy/mv88e61xx.c | 42 +++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/drivers/net/phy/mv88e61xx.c b/drivers/net/phy/mv88e61xx.c index 85778106eddc..31f9b57456d6 100644 --- a/drivers/net/phy/mv88e61xx.c +++ b/drivers/net/phy/mv88e61xx.c @@ -194,6 +194,7 @@ struct mv88e61xx_phy_priv { u8 phy_ctrl1_en_det_shift; /* 'EDet' bit field offset */ u8 phy_ctrl1_en_det_width; /* Width of 'EDet' bit field */ u8 phy_ctrl1_en_det_ctrl; /* 'EDet' control value */ + u8 direct_access; /* Access switch device directly */ }; static inline int smi_cmd(int cmd, int addr, int reg) @@ -920,6 +921,40 @@ static int mv88e61xx_priv_reg_offs_pre_init(struct phy_device *phydev) return -ENODEV; } +static int mv88e61xx_check_addressing(struct phy_device *phydev) +{ + if (!CONFIG_IS_ENABLED(OF_CONTROL)) + return 0; + + /* + * Some devices - like mv88e6020 are dual chip - i.e. two + * such devices can be directly accessed via SMI bus. + * The addressing depends on R0_LED/ADDR4 pin value duing + * bootstrap. + * + * This means that there is no need for indirect access. + */ + struct mv88e61xx_phy_priv *priv = phydev->priv; + + /* + * As this function is called very early and hence the phydev + * is not yet initialized we use aliast and DTS to asses if + * device shall be directly accessed or not. + */ + ofnode sw0; + int ret; + + sw0 = ofnode_get_aliases_node("switch0"); + if (!ofnode_valid(sw0)) + return -ENODEV; + + ret = ofnode_device_is_compatible(sw0, "marvell,mv88e6020"); + if (ret) + priv->direct_access = 1; + + return 0; +} + static int mv88e61xx_probe(struct phy_device *phydev) { struct mii_dev *smi_wrapper; @@ -974,6 +1009,8 @@ static int mv88e61xx_probe(struct phy_device *phydev) phydev->priv = priv; + mv88e61xx_check_addressing(phydev); + res = mv88e61xx_priv_reg_offs_pre_init(phydev); if (res < 0) return res; @@ -1180,6 +1217,11 @@ int get_phy_id(struct mii_dev *bus, int smi_addr, int devad, u32 *phy_id) temp_phy.priv = &temp_priv; temp_mii.priv = &temp_phy; + mv88e61xx_check_addressing(&temp_phy); + /* For direct access the phy address equals to smi_addr */ + if (temp_priv.direct_access) + temp_phy.addr = smi_addr; + /* * get_phy_id() can be called by framework before mv88e61xx driver * probing, in this case the global register offsets are not -- 2.30.2