From mboxrd@z Thu Jan 1 00:00:00 1970 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 84697C433EF for ; Thu, 31 Mar 2022 19:36:36 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id AD2FB84015; Thu, 31 Mar 2022 21:36:28 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=nxp.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=nxp.com header.i=@nxp.com header.b="W2TbQxqM"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 9041184015; Thu, 31 Mar 2022 21:36:26 +0200 (CEST) Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05on20601.outbound.protection.outlook.com [IPv6:2a01:111:f400:7e1b::601]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 463DF8002B for ; Thu, 31 Mar 2022 21:36:22 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=nxp.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=vladimir.oltean@nxp.com ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=mZ7HfkyQPb3jVXgcmd1uDt8p1fhGsk6gk4OtKkwJxL78TPYB6eWCXls3/OEpmkLYrVd/DgAoQf1bnaFKDwjWj8lewlxHtAtuQ3qdaEnKlDydZu3Lb3inL13RltMmyrOTefx3Rj2mlQfDY0rLK4whYJk2jhPqAX/SItnnn8M50GyPeO686kj0H3jkyCTYa2aajRw7VDZ++xq5xqyKBvM49oOPtoe1x++UgkDMZ8uL2SVwlDcRVh62je413KVw2qhGRcVyc7xhxo4/prmR3TQY0HJFj9SVnWW73q9foVPAfoG+eRCoJQhRdaHEQgUrUSrB1NHlbMC1JSKOkkqiEhR4fQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=Pk2s+9HdE0bPuQXd3C0R24u5XJ0BkiJQwEwgFtFvkYU=; b=Coua4i3ksDhge5sHstzhzHsRSYx+vXjRgOmZ7pmaDuHBJ+0hrV04R91PGaJOeVCkP0EAp4j4blAjno4FBcBoz4E4sOckKWdZ6XyX4fvufku0TqMAevs7WIfP6rNk11YrdU9sCWzuLno2KqUJVx0w2pTWc0ndI3K8V9olP1Gzf366HvPavf9qhUtjgaLjDvo0QWiwRP+TQyxU7mG09SEEVERLQClP9xkJ5r0yQDdnXQE55GUA+ZREtc2qzYgUWskWaOxh5QrTTIDl1V6MUlPNEIgRu/6xCCZ/6M8HJ0RTwcq+VYBQ1rRLOGv+Bq4C2e7I/V506SMjWjbPmuacqGp3aw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Pk2s+9HdE0bPuQXd3C0R24u5XJ0BkiJQwEwgFtFvkYU=; b=W2TbQxqMi8d57MA8tuvlLW+a5LJ6ol/j7IXlkFtFDIsALQk9Dp9+i0Fh9uBgAxsOQgUPTd1acb9z0htIkLz5kXamjxTKHHc6Njh6nvCcWEiWQ7H2ikqdX+HeSvFWuEg+qnOM1axIRKY9eTGV1vQWYKzJg3dmfofGeRHisdHBbpo= Received: from VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) by VE1PR04MB6350.eurprd04.prod.outlook.com (2603:10a6:803:122::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5123.21; Thu, 31 Mar 2022 19:36:19 +0000 Received: from VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::f090:8a7e:c1e1:3d8e]) by VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::f090:8a7e:c1e1:3d8e%3]) with mapi id 15.20.5102.022; Thu, 31 Mar 2022 19:36:19 +0000 From: Vladimir Oltean To: "tharvey@gateworks.com" CC: Joe Hershberger , Ramon Fried , "u-boot@lists.denx.de" , Stefano Babic , Fabio Estevam , dl-uboot-imx Subject: Re: [PATCH 4/6] net: fec: add support for DM_MDIO Thread-Topic: [PATCH 4/6] net: fec: add support for DM_MDIO Thread-Index: AQHYQ7+4w9slmKurKkSJyqC+zfnZEazZunCAgAANPoCAAB4BAA== Date: Thu, 31 Mar 2022 19:36:19 +0000 Message-ID: <20220331193618.2ehdmjkgfa67y27j@skbuf> References: <20220329225240.1416-1-tharvey@gateworks.com> <20220329225240.1416-5-tharvey@gateworks.com> <20220331170131.lbl6scb4xj4kl5lv@skbuf> In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 6c13a1e7-7c21-4023-8947-08da134dbad7 x-ms-traffictypediagnostic: VE1PR04MB6350:EE_ x-ld-processed: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635,ExtAddr x-microsoft-antispam-prvs: x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: DPbM8IRbJ57VkeQEMFIW6yx9hle9C99YdT3SAAO6v72yH8djiwiXUex8MITUkvneC3r9fU86ytXwIhgSTnScwRAjKRUognmtaeqwIWN0IA0WAPGApbZxmG7vxOrUQDa3tqYwfivx1alyUC0BQJeNQ98z0l6eTtpKxTcoVaMEOn8USR3UV1VCnaoD3eXtb1yCODYeC/PyeSMXYuKxHNw3rrnWWFdgcYnTpwYTJHhfrF5MK+EMqnbetUHx0JoZ3ctJ5L1JQ/zcel95iVW0gsxQwyWuu/DoNnuWxhVu1pKo0vRaXy3b17EWP5zQsSos0d0sZxhQI/WfYTQJd0db9H6Cpv+rrPU+7ZstI96BdGAz+a2baYctVrAJArYwJvZv0Qv0bt+Hh8TmOEKfuMuZSH+NaCLbTHHfDZ86gibIMNKW8uoB9bPx/VM8gJvl8wfZlqzK2lhfJPHBRxieXxz7IJ7UR/Doq84aE+NoK7alJvnz/RksJuZqj7e+K/63EN0wJliQD7G4ioY80vgpx8ObI97zhx8sPlZw5uDF+z7+jq1Vpf+E/RDTIzA0HbBFbcAM+bS4dhAOsBOUxUpwSYnCw50idf/F2cznIRgn49A+Ti6wgzsWT1Ys2FEFfnD8xY8f3SBNLrsoJqaSraJxrGHo5vZwwXfd4eL8nnuDsyMk10uTTmt5SqIO3KuoQBWhfesH1cqiql+toCC1DeZnBy+TR1xJligfzJEWBDE0Lb43V7SAABTYZCND0JwvKvL/dbhGqUNks9wcajkPLfHaIKr2gaOr3oOjhZsU6tFjY8KjSyHaIQ70V0AKaVo4g/GyHUrJyh6ZgTOIFSgBbs2ldfs9ys28dg== x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:VI1PR04MB5136.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230001)(7916004)(4636009)(366004)(26005)(186003)(316002)(66946007)(66446008)(66556008)(66476007)(2906002)(64756008)(1076003)(44832011)(5660300002)(8676002)(76116006)(4326008)(6916009)(71200400001)(54906003)(86362001)(33716001)(38100700002)(122000001)(966005)(6486002)(9686003)(508600001)(38070700005)(8936002)(6506007)(6512007); DIR:OUT; SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?Lhy/Y4B7Z5X90f2spO8IzNdFc9LeNOD/2i8nKV8Itb2H1ZoAwtwyfs3LDHjV?= =?us-ascii?Q?2R1T6HYeLeFHZdkecW6OQzZ9nJ1t+iETmS8H3RDgL7p19t3yXak8WvvIXA55?= =?us-ascii?Q?xj2bi6nLqtqFWwkbQaU2G5+thFfQ6iegZ050pm/fk/sFy6J/vrv5RNklhckp?= =?us-ascii?Q?sxZeIPFAXd2y494kqPoooKJXNnV34VAmXk/Rkoj/k9kDS2EqZY7KChMfRHgO?= =?us-ascii?Q?ycltGGm4H13TE0U17KyRfa2LxB5H77BvCnXXAY5dnTBi4kozwyHAd3tFuxuq?= =?us-ascii?Q?wNJBg+yWmhs/TUT+8ZU6CyjrQzBrL2oaA+os7HWQ0dkPJwqz3I6ixnrICkFT?= =?us-ascii?Q?FR17rNBJDoMwbqtlcNxNz9M21kvtbl2Y+P3Vqve397kUBj5emyOTtPguiL0y?= =?us-ascii?Q?/SUAI2IlXYYZsgOhCAfWIVRmfNq76MdBJ65ZiRfL7FTd4aP7fEYCzA5Ljwu1?= =?us-ascii?Q?JkUxqNymektFZRFxASjmeXWTDVwpL6lG0WszJ0i+FLllzMfMK6Z5rM5ikUhF?= =?us-ascii?Q?kitqwtaaYhAPyEboJw31V35FXWd2TxR4wMugAAlTnRNaXnX76mfbmeT77pdW?= =?us-ascii?Q?MHkDfUTtwDTmGvw5jlViVJd39KYPeqmA723nGCI1ewDy0SEBQ1edBQa6ug8j?= =?us-ascii?Q?MQsxu8k1jCfW7JE1BO8EikqxnQxr/gxFn1AWS7q7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=?us-ascii?Q?hA9sw8OD8KhmE0/r2z6/W+uLSHL9hlKY5H7HicyjevLmFg8xTAPyxiSA1gr6?= =?us-ascii?Q?FoYiPpnBDgYi5ZAmCjmdDE0p5iT5Iv0B2XuOCN0Mq/rvOt/fn2z/mJWSSfwm?= =?us-ascii?Q?n6ZjO0cC3EGS4tsZqJ8m+b3G+k/4houfb7vJK56e9dR/WA6Xrf6FoYX06UOh?= =?us-ascii?Q?YlOro1GGrWozCSKSP4VNUTBg7MzLPqY=3D?= Content-Type: text/plain; charset="us-ascii" Content-ID: Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5136.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 6c13a1e7-7c21-4023-8947-08da134dbad7 X-MS-Exchange-CrossTenant-originalarrivaltime: 31 Mar 2022 19:36:19.3037 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: Dm4c+1OnEBcivVqPgpHuhmHzf0lbT3AYFSMnaJ0VYQHrj9pWT0ElW+oDTUPAfmoBrhen+jm2/0iG2Q+mR53WbQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VE1PR04MB6350 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.5 at phobos.denx.de X-Virus-Status: Clean On Thu, Mar 31, 2022 at 10:48:55AM -0700, Tim Harvey wrote: > > On which branch does this apply? The context above fecmxc_read_rom_hwad= dr() > > is different in the branches I've checked: > > https://source.denx.de/u-boot/u-boot/-/blob/master/drivers/net/fec_mxc.= c#L1276 > > https://source.denx.de/u-boot/custodians/u-boot-net/-/blob/next/drivers= /net/fec_mxc.c#L1276 > > >=20 > Sorry, I should have specified in my cover letter that this is on top > of next which removes the non dm-eth support from the driver which is > quite the cleanup. Ok, but now the next patch fails to apply to the 'next' branch: Applying: net: dsa: move cpu port probe to dsa_post_probe Applying: net: mdio-uclass: add wrappers for read/write/reset operations Applying: net: fec: add support for DM_MDIO Applying: net: add MV88E61xx DSA driver error: patch failed: drivers/net/Kconfig:428 error: drivers/net/Kconfig: patch does not apply error: patch failed: drivers/net/Makefile:66 error: drivers/net/Makefile: patch does not apply Patch failed at 0005 net: add MV88E61xx DSA driver > Also, after more testing I believe the dm-mdio driver code 'above' is > correct but the business of trying to use it and fallback 'below' is > wrong and needs work. It doesn't break current users of fec_mxc from > what I can tell but it also doesn't properly connect the dm_mdio > driver. Can you spell out what is wrong about the fallback logic? The whole thing with eth_phy_get_mdio_bus()/eth_phy_set_mdio_bus() has me so confused that I am not really following along anymore. > > > static int fecmxc_read_rom_hwaddr(struct udevice *dev) > > > { > > > struct fec_priv *priv =3D dev_get_priv(dev); > > > @@ -1088,7 +1164,7 @@ static int device_get_phy_addr(struct fec_priv = *priv, struct udevice *dev) > > > > > > static int fec_phy_init(struct fec_priv *priv, struct udevice *dev) > > > { > > > - struct phy_device *phydev; > > > + struct phy_device *phydev =3D NULL; > > > int addr; > > > > > > addr =3D device_get_phy_addr(priv, dev); > > > @@ -1096,7 +1172,12 @@ static int fec_phy_init(struct fec_priv *priv,= struct udevice *dev) > > > addr =3D CONFIG_FEC_MXC_PHYADDR; > > > #endif > > > > > > - phydev =3D phy_connect(priv->bus, addr, dev, priv->interface); > > > +#ifdef CONFIG_DM_MDIO > > > + if (priv->dm_mdio) > > > + phydev =3D dm_eth_phy_connect(dev); > > > +#endif > > > + if (!phydev) > > > + phydev =3D phy_connect(priv->bus, addr, dev, priv->inte= rface); > > > if (!phydev) > > > return -ENODEV; > > > > > > @@ -1227,11 +1308,19 @@ static int fecmxc_probe(struct udevice *dev) > > > > > > priv->dev_id =3D dev_seq(dev); > > > > > > +#ifdef CONFIG_DM_MDIO > > > + ret =3D dm_fec_bind_mdio(dev); > > > + if (!ret) { > > > + ret =3D fec_phy_init(priv, dev); > > > + if (!ret) > > > + priv->dm_mdio =3D true; > > > + } > > > +#endif > > > #ifdef CONFIG_DM_ETH_PHY > > > bus =3D eth_phy_get_mdio_bus(dev); > > > #endif > > > > > > - if (!bus) { > > > + if (!bus && !priv->dm_mdio) { > > > dm_mii_bus =3D false; > > > #ifdef CONFIG_FEC_MXC_MDIO_BASE > > > bus =3D fec_get_miibus((ulong)CONFIG_FEC_MXC_MDIO_BASE, > > > @@ -1240,7 +1329,7 @@ static int fecmxc_probe(struct udevice *dev) > > > bus =3D fec_get_miibus((ulong)priv->eth, dev_seq(dev)); > > > #endif > > > } > > > - if (!bus) { > > > + if (!bus && !priv->dm_mdio) { > > > ret =3D -ENOMEM; > > > goto err_mii; > > > } > > > @@ -1271,14 +1360,16 @@ static int fecmxc_probe(struct udevice *dev) > > > break; > > > } > > > > > > - ret =3D fec_phy_init(priv, dev); > > > - if (ret) > > > - goto err_phy; > > > + if (!priv->dm_mdio) { > > > + ret =3D fec_phy_init(priv, dev); > > > + if (ret) > > > + goto err_phy; > > > + } > > > > > > return 0; > > > > > > err_phy: > > > - if (!dm_mii_bus) { > > > + if (!dm_mii_bus && !priv->dm_mdio) { > > > mdio_unregister(bus); > > > free(bus); > > > } > > > @@ -1294,8 +1385,10 @@ static int fecmxc_remove(struct udevice *dev) > > > > > > free(priv->phydev); > > > fec_free_descs(priv); > > > - mdio_unregister(priv->bus); > > > - mdio_free(priv->bus); > > > + if (priv->bus) { > > > + mdio_unregister(priv->bus); > > > + mdio_free(priv->bus); > > > + } > > > > > > #ifdef CONFIG_DM_REGULATOR > > > if (priv->phy_supply) > > > diff --git a/drivers/net/fec_mxc.h b/drivers/net/fec_mxc.h > > > index 48faa33d66ec..c297880ccc54 100644 > > > --- a/drivers/net/fec_mxc.h > > > +++ b/drivers/net/fec_mxc.h > > > @@ -248,6 +248,7 @@ struct fec_priv { > > > uint8_t *tdb_ptr; > > > int dev_id; > > > struct mii_dev *bus; > > > + bool dm_mdio; > > > #ifdef CONFIG_PHYLIB > > > struct phy_device *phydev; > > > ofnode phy_of_node; > > > -- > > > 2.17.1 > > > >=20 > What I'm trying to accomplish here vs just simply using > dm_fec_bind_mdio(dev) and dm_eth_phy_connect(dev) is to provide a > fallback for the many users of fec_mxc that do not have a dt that > works with dm-mdio yet still have defconfig's that enable DM_MDIO. > Most of the users would not currently have an mdio subnode in the fec > node, nor have the required phy-mode 'and' phy-handle prop or > fixed-link subnode which would cause the dm_eth_phy_connect to fail. >=20 > Best Regards, >=20 > Tim=