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 EF2CAC4332F for ; Tue, 29 Mar 2022 00:03:42 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 3F95B839CC; Tue, 29 Mar 2022 02:03:39 +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="UIxGUTKp"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 00D6583B27; Tue, 29 Mar 2022 02:03:37 +0200 (CEST) Received: from EUR04-VI1-obe.outbound.protection.outlook.com (mail-vi1eur04on060f.outbound.protection.outlook.com [IPv6:2a01:111:f400:fe0e::60f]) (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 5EA3E839C7 for ; Tue, 29 Mar 2022 02:03:33 +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=P0TXCzmJERHJidIlDu9Eii6ZIOKaDT1QuXd1AcqESyRR7O/KVqwaDYB2KGzFlPLzO+YEqExpdNRXDcNx69qy42uMVyH7dIcA6raW4PLJHNNrP0CHl4p3ZMAGOKLLTN5ZyQP0xWOelx21JWVjzPQJPyp3VXci00URLIkJ+kg/0QX8heT1KuyMbCkSHcFVRlgvFS1FBq2hcuN4JIzWAw6oatT44su5xw0XEu2TNgAoPUR2nnTNBlTPEZX1TxlVi2SEYsD7J9p6Kj9VWHa6dp0MGIWT8JYj0kJNK4NjOnHXLCMzbi/aV7KYc6xifjncHP3hHLh+drR0O60g1Fco/5D2sQ== 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=8ounhwTWTr412a+mu5oBL+Yh8W1rWZLrMbA53ZD1Dn8=; b=STwxvnuaGSxd+LbYKhnePP5uuhV0DgC0Rqxs7UK+yTxPETIp78mD8a4iG0JcG1EwVYCbZWf97JwVagKiBqhvIecEg3JCnko+ixK1b4PZzfQT5A/6qwu+HifVi12oDC3cELsVkr+6PeJNSpRxg/v3FI3X7n3U/6Zlr8kVw5BC0VuWozAJ6b0o/XDm/wVwHGNn79xQ3Xe6jMCSg4HTOag3wbVW6jl1YbroIWoovMxGfFfRnemgFqR8KjeOdnxmJ1xG9cClpyaplzGCp5ejtFOP4TozRWClXMNpeSPrszBefDE40NByVrXZ/Chd4R7a/OtQaqA7boZXb8bjgw/51n6OaA== 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=8ounhwTWTr412a+mu5oBL+Yh8W1rWZLrMbA53ZD1Dn8=; b=UIxGUTKp//Z39aa7DG9pMfCSTjX762ecPHBAliee7YD4mEE15XNDWv/x49SfaPrJsVa+GafvO0LCQbRtF6MCrlCQQBryLCeyP+csQA0NW+KipP0N2NVkoXPEKPGtpAd2gyYHJaaxdA1PlIhjhxxK7qpKXJYf5A8uTN3stK5A31g= Received: from VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) by DB6PR04MB2967.eurprd04.prod.outlook.com (2603:10a6:6:a::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5102.22; Tue, 29 Mar 2022 00:03:31 +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; Tue, 29 Mar 2022 00:03:31 +0000 From: Vladimir Oltean To: "tharvey@gateworks.com" CC: u-boot , Joe Hershberger , Ramon Fried Subject: Re: [PATCH 1/2] net: dsa: fix phydev->speed being uninitialized for the CPU port fixed PHY Thread-Topic: [PATCH 1/2] net: dsa: fix phydev->speed being uninitialized for the CPU port fixed PHY Thread-Index: AQHX6WLGbgqP2emMnUmjsbRdEkVaQazQ/uQAgAAUnACAADFoAIAD9BCAgADZCACAABwSAA== Date: Tue, 29 Mar 2022 00:03:31 +0000 Message-ID: <20220329000330.7osi2nb26swagdtg@skbuf> References: <20211204230035.4136596-1-vladimir.oltean@nxp.com> <20211204230035.4136596-2-vladimir.oltean@nxp.com> <20220325180706.w3faqca3xt5jakcj@skbuf> <20220328092615.f4wbsmbkbf6cmhak@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: 8e9d0731-89e5-40b5-1b66-08da11178f46 x-ms-traffictypediagnostic: DB6PR04MB2967: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: 6X4t9pSMoM1MQeYxe5GmHiOp9t+kS8bDYEA7RAZ+uPrp0HELd6SFG9mXVzjBTooUhVcTfv619nNryTjuWqAFq2+a5FPS5UXb2y2w81p1W7TeB5dj9TUiYQE1Hf//Dmpt8JZuEM5MJwIi4wAjk50kRSLJ320LD/hVLaN+OGiy1bu/AKXWQtbCawmYC1HBHtRmCRg+SPDTIxbRMIn/qVA8Ydk756smcoKOIEEDEaE9QDxkEVs3qiG0LGH0RoBISCpt6m1dIVDSBA5z0fiFBRMxxOgWpFIQiSv7kDqxKOoz08YJ27WeKkyPnMfhmXLY9jcr+yP0uQb4aHy6LMwn+b/OWZEju4p3/Whwb9Elht/o8+Xmb8bC4+spJqYGbxyTos5MYArzJ0/0aWP7jEUzBtde3ewQz+U0aQegDviSK01fLdFE/IEjiODgSNVG92amN3pTZ9YaNMXmwd4UwQjhg8rqv1LxYY+6m/3LHs5qJmVklUabjxJbxd55y2RyKbAhKvh/8WvydDssnrLoMLYzAPZzID8Wb71YHVUXHKp7ba6kjENS3ggKG/PSFwFYrzjLPcgNvuOZ4LowIH+eO936yMREApzrBHkBAQBdHoqkDFUYsAB5HTUtRX3fgxvZFG2EylYuhggm9kB+/7b9hcB4eVCodTO26knNYvpPmqG//bLkcNPll69OPg2OgqiM0Rs0M1PxmkRBcxkMx8Okc1WOokNKqZMV/F/HkEqofcgMyjffStw= 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)(64756008)(66476007)(4326008)(8676002)(1076003)(66446008)(91956017)(38100700002)(66946007)(26005)(38070700005)(54906003)(76116006)(186003)(508600001)(6486002)(71200400001)(86362001)(316002)(6916009)(83380400001)(122000001)(6506007)(6512007)(2906002)(33716001)(8936002)(53546011)(66556008)(9686003)(44832011)(5660300002)(30864003)(9944002); DIR:OUT; SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?4+DGfVCMfa7YIFljHelEdfqoslUWrmxEEMi96KTxMA/fgenqTLBx1802H0yt?= =?us-ascii?Q?3b0avhpUW4ez56F5VZOMUVMGEWiCPof8tcXtzf9sl9sdG+fY4qiloMlW7gRC?= =?us-ascii?Q?lwzOUYWiNfyRDUb8QZT5Y4JJDka9lppeboT0TO3QMuxIOKE5jQHTpdXHlIIK?= =?us-ascii?Q?k3bqJDQ9Wg6u1ixGUXPAv2Lzfk/EmZEbYb6P9SQE4x0d32gfF+wohbLTOGjU?= =?us-ascii?Q?GiiU34LUaxirRaIG2M/5dr8SuAWsF4YYs737a8RtcQ2whZieSgkjVoODAElj?= =?us-ascii?Q?zKRVX9GKf75XxoVJNtDMpdNw8d46jGdSV4U8wNaR80JIzUy4pn7oYIJZFZVi?= =?us-ascii?Q?CWHeCm8ytUmTq66YcgIQSp0TsoLXtJue3uTaKdr6sw2R147V5OcDbe+DeUXy?= =?us-ascii?Q?wPP9fLqEaj9MPUo/smgzCHb4g/D44xlQdcjXnPwsdLIS2NYLQ+JjuVNNxtSF?= =?us-ascii?Q?UAaEZe4UrOjs4R8W6PLw6ivekxx7qrzVPcHFHwQSTCB5/cyuNfsm5sodsenU?= =?us-ascii?Q?Ci79gmCAGCQSwlplyla3GXga0UEXYUZkz7LjRaZE/UzPS2FCBtG8zjaQ0MLe?= =?us-ascii?Q?Je1rPKgWSHdv5jQMb7RzCDvBXJr1XsNCD7pDu4LaU8ZfeKbDEljvw96Zbz6J?= =?us-ascii?Q?XFoi2p46nfPWGC/8d44Mmp2IjOk/NsSELa5k/VTkywQZWMxqoMYjSgaiKDlg?= =?us-ascii?Q?snRzrWPpsPTKQ95RBHppe7ZTuFeZoR2ffG1+5QY7uu5yTLjh8WCALkQTFxoO?= =?us-ascii?Q?DUzEMyFuf+cL0IzFMtRhPPzHNQSxJKrxbal9Ryfiftyoow1QU8lG9VKlySP5?= =?us-ascii?Q?o35JUsJ4szjSxs3A4ye3cMI14kzxQq/bGswAoUS35QxQiuPkPQ6jt5Il1Mxn?= =?us-ascii?Q?kB8iJ3tpGs7E4yzucUxTopi5DBQP9C5B2iiwcTQKfRdijYJM2uCQ/1IUmFly?= =?us-ascii?Q?f1PRP1PFcQgPOh5VdDFN31vziD/t1rv0UV4m/Wf7DPUC+STB2BbptMxFeUTH?= =?us-ascii?Q?g7x3jtI34fXc7xPyrT/WpUROSe6QZOCSUkXDBvFCZCR3pJWzhJjpj96UHrKr?= =?us-ascii?Q?g6WmADKkIgYhSd37N5Kn0/883ftHUhEsnRXRDe9uY3DMhXShNYzlBFJmMYA1?= =?us-ascii?Q?MFBTTDFdYqQmw1i4KiY+E88QSc/v0zi1bG+LHLIz6MzQfrjt49nJ6Z/ASIS4?= =?us-ascii?Q?f2CojFqQz7w4eF/cus/PYAMfuLclxSkQXeaylbBQklki7DwFzQZL/NwlztFK?= =?us-ascii?Q?OJje4qsLcOHBWzVBIJZj5a23OzWQqir1JOP0WxQR+vrRDlAkU/0sAb9Es2M9?= =?us-ascii?Q?anhP9iOego9dDo+V3xlm1SI4Ga26C84BXpav6W8L7ufqz/ywg+Iq5VIlyZNX?= =?us-ascii?Q?N220RKCstoXSaHX0JgI+8Eo4kKcmsUEq8DGqLEH82LpGlIOF44o4XIi85PX5?= =?us-ascii?Q?aVVdpuzAJRj835JkmNyp/o5lOVvf+b2vo5JZtsr/xc6DJQVb9OIZM7pvWv5r?= =?us-ascii?Q?xgazweiWNGj+0bSkBAjMXtOcucpKiw5RAbu+VZqnhfVzE1eZDnPHmCSyXHvI?= =?us-ascii?Q?Bnc/Vus0/kOzDQBhQfbKpBIb5czrSSZxyZk4EAndtyL/Q2EbDc6gkC6o/AyU?= =?us-ascii?Q?ZLDowYZmNV1vVAKpqA5qKRhryV4e1KhjtG0iLzuWp0dgXadolh+x1OlzwVR6?= =?us-ascii?Q?7PwSMcOca/1zhdS1KIDaxKdJRrkOrfRb7vPaKNPW618AdZ6JbFCa7lDe74oB?= =?us-ascii?Q?3xohDqDIdtGdQ2ykk6V/ydOUEPvQLsc=3D?= Content-Type: text/plain; charset="us-ascii" Content-ID: <76A1B896DE170E4CBD71B2AD254CDF0A@eurprd04.prod.outlook.com> 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: 8e9d0731-89e5-40b5-1b66-08da11178f46 X-MS-Exchange-CrossTenant-originalarrivaltime: 29 Mar 2022 00:03:31.0440 (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: gn26DwutV6wRrEwfZqf6s/WGDCjY2up1/1bMQEGX+4VzsRt0w5v1RmYoH0JmuVpVkWkFsj1lTXLHqtRb7bgrGg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB6PR04MB2967 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 Mon, Mar 28, 2022 at 03:23:02PM -0700, Tim Harvey wrote: > On Mon, Mar 28, 2022 at 2:26 AM Vladimir Oltean = wrote: > > > > On Fri, Mar 25, 2022 at 02:03:56PM -0700, Tim Harvey wrote: > > > On Fri, Mar 25, 2022 at 11:07 AM Vladimir Oltean > > > wrote: > > > > > > > > Hi Tim, > > > > > > > > On Fri, Mar 25, 2022 at 09:53:20AM -0700, Tim Harvey wrote: > > > > > Vladimir, > > > > > > > > > > I came across this while looking for the best place to configure = cpu > > > > > port interface mode (ie rgmii id) for the mv88e61xx dsa driver I'= m > > > > > working on. Note that this patch causes port_probe to be called o= n the > > > > > cpu port 'before' the master device has been probed. I'm not sure= if > > > > > this is intended or not? > > > > > > > > > > In my case I was looking to configure the cpu port interface mode= when > > > > > the port was probed but I can't do that because it happens before= the > > > > > switch is probed because of some things that need to happen there= . > > > > > Best Regards, > > > > > > > > > > Tim > > > > > > > > You're past the DM_MDIO probing issues now? Glad to hear that. > > > > Probing the DSA CPU port before the master wasn't necessarily the > > > > intention, but then again, I'm not sure that there's a strict order= ing > > > > guarantee between the two that needs to be satisfied? > > > > > > > > What do you need exactly? We could probably always reverse the > > > > device_probe(master) call with the probing of the CPU port if the > > > > ordering turns out to be a real problem. I can regression-test the > > > > change on my boards, but I'd like to understand the need you have, = maybe > > > > even document it so that future changes are aware of it. > > > > > > Yes, I've got the mdio probing working now. The mv88e61xx driver > > > supports several chips that have different register offsets that need > > > to be known before indirect read/write and port read/write can be > > > used. That detection happens early on so I have it in the dsa_probe. = I > > > would prefer to configure the cpu port interface mode (mac mode, link > > > speed/duplex etc) once instead of doing it every time the cpu port > > > gets enabled so I want to put that in the dsa_probe but at that time = I > > > don't have the phy_device to determine interface mode (I suppose I > > > could get it from dt?). I noticed dsa_class calls ops->port_probe for > > > the cpu port early so that seemed like a great place to do all that, > > > but then I found my switch dsa_probe hadn't been called yet so I > > > haven't identified the switch and set the register offsets yet. > > > > > > I have worked around the fact that the port_probe is called for the > > > cpu port before the switch is probed I just wasn't sure if something > > > in this patch should be changed in case others fall into this trap in > > > the future. dsa_port_probe probes the master before calling > > > ops->port_probe with the comment 'We depend on the master device for > > > proper operation' so I just figured the same should be done for the > > > pre_probe. > > > > Sorry, that was quite a blunder, we should definitely ensure that > > U_BOOT_DRIVER :: probe gets called before dsa_ops :: port_probe. > > I've made a change moving the port_probe call for the CPU port to > > dsa_post_probe(), tested it in the sandbox, and it appears to work. > > >=20 > Ok, sounds good - did you submit this someplace? I haven't seen it. No, I didn't submit it anywhere. My thinking is that since the existing DSA drivers aren't critically affected by the calling order, you could include a change along those lines in your work for Marvell switches. > > > I hope to send a series in the next few days but I do have a few item= s > > > I still need to fix: > > > > > > 1. my board currently uses the mv88e61xx_hw_reset weak override to > > > configure LEDs, GPIO's using direct register writes as I need one of > > > the GPIO's to be configured as a 125MHz RGMII_RCLK and configure MAC > > > interface mode(rgmii delays). I've moved the mac interface config int= o > > > the driver based on the dt props (phy-mode and fixed-link subnode) bu= t > > > am still not sure how to go about dealing with the 'very custom' LED > > > and GPIO config without the hassle of defining new dt bindings. I was > > > hoping to use board_phy_config() but when that is called for the > > > switch the phy_id is a generic PHY_FIXED_ID and when called for the > > > ports the phydev->bus uses indirect register writes which can't be > > > used to configure the gpios. > > > > How are these configs handled in Linux? >=20 > Each of the 14 GPIO's for MV88E61xx can be configured as GPIO, > PTP_TRIG (PTP output trigger), PTP_EVREQ (PTP event request input), > PTP_EXTCLK (PTP ext clock input), SE_RCLK0 (SyncE RX clock 0 output), > SE_RCLK1 (SyncE RX clock 1 output), or CLK125 (125 MHz clock output). > Currently the only config handled in Linux is PTP_EVREQ for PTP > support. >=20 > Each port has 2 LED's which can be configured for 16 different > functions. The LED config is not handled at all the the Linux driver > (PHY LED config is spotty in general). >=20 > I think it makes sense to handle this in board_config_phy() and I can > do and avoid the issue of direct register access with something like: >=20 > int board_phy_config(struct phy_device *phydev) > { > unsigned short val; >=20 > /* Fixed PHY: for GW5904/GW5909 this is Marvell 88E6176 GbE Switc= h */ > if (phydev->phy_id =3D=3D 0xa5a55a5a && > ((board_type =3D=3D GW5904) || (board_type =3D=3D GW5909)= )) { > /* get the mdio parent bus so we have direct register acce= ss */ > struct mii_dev *bus =3D miiphy_get_dev_by_name("mdio"); >=20 > puts("MV88E61XX "); >=20 > /* GPIO[0] output CLK125 for RGMII_REFCLK: > * GPIO[7:0] Direction register is 0x62 of Scratch regist= ers: 1=3Dinput 0=3Doutput > * GPIO[0] Pin Control register is 0x68 of Scratch regist= ers: 7=3DCLK125 (Free running 125MHz clock output) > * Scratch register access is at 0x1a of GLOBAL2 register= (0x1c) > */ > bus->write(bus, 0x1c, 0, 0x1a, (1 << 15) | (0x62 << 8) | = 0xfe); > bus->write(bus, 0x1c, 0, 0x1a, (1 << 15) | (0x68 << 8) | = 7); >=20 > /* Port 0-3 LED configuration: Table 80/82 > * LED configuration: 7:4-green (8=3DActivity) 3:0 amber= (8=3DLink) > * LED Control is register 0x16 of port registers > * port registers are at 0x10 + port > */ > bus->write(bus, 0x10, 0, 0x16, 0x8088); > bus->write(bus, 0x11, 0, 0x16, 0x8088); > bus->write(bus, 0x12, 0, 0x16, 0x8088); > bus->write(bus, 0x13, 0, 0x16, 0x8088); >=20 > } > } >=20 > > > > > 2. While my switch mdio bus is probing now as well as my fec_dm_mdio > > > bus I'm not clear how to properly get the struct mii_dev * associated > > > with the fec_dm_mdio from the dsa switch. Currently I'm using > > > miiphy_get_dev_by_name("mdio") which is horrible. How do I get the > > > mii_bus or even the udevice of an dm_mdio bus associated with a dm_et= h > > > device? > > > > Hmm, isn't the MDIO bus udevice the dev->parent of the switch? >=20 > My dt is: >=20 > &fec { > pinctrl-names =3D "default"; > pinctrl-0 =3D <&pinctrl_enet>; > phy-mode =3D "rgmii-id"; > status =3D "okay"; >=20 > fixed-link { > speed =3D <1000>; > full-duplex; > }; >=20 > mdio { > #address-cells =3D <1>; > #size-cells =3D <0>; >=20 > switch@0 { > compatible =3D "marvell,mv88e6085"; > reg =3D <0>; >=20 > mdios { > #address-cells =3D <1>; > #size-cells =3D <0>; >=20 > sw_phy0: ethernet-phy@0 { > reg =3D <0x0>; > }; >=20 > sw_phy1: ethernet-phy@1 { > reg =3D <0x1>; > }; >=20 > sw_phy2: ethernet-phy@2 { > reg =3D <0x2>; > }; >=20 > sw_phy3: ethernet-phy@3 { > reg =3D <0x3>; > }; > }; >=20 > ports { > #address-cells =3D <1>; > #size-cells =3D <0>; >=20 > port@0 { > reg =3D <0>; > label =3D "lan4"; > phy-mode =3D "internal"; > phy-handle =3D <&sw_phy0>; > }; >=20 > port@1 { > reg =3D <1>; > label =3D "lan3"; > phy-mode =3D "internal"; > phy-handle =3D <&sw_phy1>; > }; >=20 > port@2 { > reg =3D <2>; > label =3D "lan2"; > phy-mode =3D "internal"; > phy-handle =3D <&sw_phy2>; > }; >=20 > port@3 { > reg =3D <3>; > label =3D "lan1"; > phy-mode =3D "internal"; > phy-handle =3D <&sw_phy3>; > }; >=20 > port@5 { > reg =3D <5>; > label =3D "cpu"; > ethernet =3D <&fec>; > phy-mode =3D "rgmii-id"; >=20 > fixed-link { > speed =3D <1000>; > full-duplex; > }; > }; > }; > }; > }; > }; >=20 > Assuming this looks correct to you the dm_fec_mdio UCLASS_MDIO gets > bound to the 'mdio' node and its parent is the fec eth device. So in > my switch probe the parent of the switch is the dm_fec_mdio device but > I'm not clear how to get to that udevice's strict mii_dev*. My confusion comes from the fact that I don't really understand why you want to get to the struct mii_dev. In DM world, that structure would be at dev_get_uclass_priv(dev->parent)->mii_bus from the perspective of the DM_DSA driver, but see below. > > Assuming that the reason you need this is for MDIO input/output towards > > the switch. Although my suggestion would be to wrap this I/O behind > > dm_mdio_read(struct udevice *dev /* MDIO child device */) and > > dm_mdio_write(struct udevice *dev), rather than poking inside struct > > udevice from the mv88e61xx driver. >=20 > I'm not clear what you mean by the above? What I meant by the above was that I was assuming you wouldn't attempt to configure the switch in any way outside of its DM_DSA driver, that is kind of the point of the device model. Which is also the point of me pointing out that the MDIO bus udevice is the dev->parent of the DM_DSA udevice, with no implications whatsoever to what you should do to access the switch "cleaner" from board/ files. I know of no clean way to mix DM code with board code, maybe others reading this could chime in. For LED control, perhaps you could come up with some "one size fits all" configuration which is done from the DM_DSA driver rather than the board files. Although you're probably doing this in the first place so that you don't have to do it in Linux, case in which... Generally the stance in the ARM DT world has been that Linux takes care of initializing the hardware up to the state it needs, assuming a blank slate, and the bootloader minimally initializes the peripherals it needs for a successful boot process. For the 125 MHz clock, "qca,clk-out-frequency" from drivers/net/phy/atheros= .c seems to me like a close enough precedent that's supported in U-Boot as well. I would propose some DT bindings and certainly make sure to run them by the Linux community first, even as an RFC, then do the same here once there is basic agreement. > My current pass at adding DSA support to the mv88e61xx driver is to > change the struct phy_device *phydev argument to struct udevice *dev > throughout (which actually isn't as messy as it seems) and I store the > struct mii_dev* in the switch priv structure to be used by the low > level functions needing mii. That is quite interesting, I would have expected quite the contrary. Since DSA uses the device model, and your switch is the first driver to probe on an MDIO bus (=3D> which also uses the device model, otherwise it wouldn't probe), the expectation would be to not make use of struct mii_dev, but rather go through the struct mdio_ops :: read and write methods of the DM_MDIO udevice (for which I see no existing wrapper functions, hence the prior reference to dm_mdio_read and dm_mdio_write as naming suggestions for these wrapper functions). The lack of these wrappers is probably explained due to the traditional lack of DM devices sitting on MDIO buses. This is probably why the code conversion doesn't seem messy to you.=