Received: by 2002:a05:6358:a55:b0:ec:fcf4:3ecf with SMTP id 21csp2426681rwb; Fri, 20 Jan 2023 02:52:04 -0800 (PST) X-Google-Smtp-Source: AMrXdXv1+0RABWZfaXHrurL6K1UXF/C3QHdX0qSsIbtj5jUH1T7ILfqDoYwfdvHS8VGzewdm+lLV X-Received: by 2002:a17:906:f20d:b0:864:1902:6f3c with SMTP id gt13-20020a170906f20d00b0086419026f3cmr14881839ejb.38.1674211924596; Fri, 20 Jan 2023 02:52:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674211924; cv=none; d=google.com; s=arc-20160816; b=zuUFWgl7RoIkCDHKN3PtjOUI+ZuwartY6AcGxBaqvwMmG0i2f7o0djdWB8gy44vipq u4shqDXLdl4minelgLoXbLaDzCbIvJbJ7rt9/oXb/fFwyGkPez03MufIiNztZ9Gl8db8 7PcHauFUzo4ZR/8kY1xiEgSGTNq9PdTUA3X/hiDUlKmX+rwxxm/WopS9UnPjiu64JC5l +3aHzgHYnGMrftgVzJTatXgGw/MXpjSWgcIyhwcV+hSEYWdHBidD7lMaSVAl4l+6iOmW wMva+KsCpLbMxDWZk9SiN+JP/Jh6cUbtEBlURHpaaQyj1nM60od6IzPRn2H0VVmFCH9X IZaQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:in-reply-to:date:subject :cc:to:from:user-agent:references:dkim-signature; bh=e4mt5lGPeAiHXoegntNYO5GB6SA6d9P+daV7EOX7KxE=; b=xm1WR0rK69nTn6+KRdccknf33CPLrn4UCPDt/Rzf0sVC6Ql3jyZIrlbVyLZmJG8pKb IyCo1FJwfSzq/4WTXli5xNnGcVqloLEpLEMrjWCp9f8bGHj+yCdqN3VmkKY4wxcm5fke Vu9+Og65wDk7Thn5mBGqgtJOx7w6rwdKS/eig/VytW1LR/eMkWR9XSR0rgbInu91L6WA 6AfaI2+c2sGwgoxGtFFpd05BEiRvZbl+x82y7/VmF35d8ghngtCq5z/FCTv1ZdlkOa6H AB9/OTj15fXt1L2TtXU3NliB7suD1krGmSSZC0NoraanCCDcH60JljHCcKcV7A4X5Xb4 X1EA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@baylibre-com.20210112.gappssmtp.com header.s=20210112 header.b=fUjHtccI; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id qb29-20020a1709077e9d00b00870a4c96667si17714101ejc.177.2023.01.20.02.51.52; Fri, 20 Jan 2023 02:52:04 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@baylibre-com.20210112.gappssmtp.com header.s=20210112 header.b=fUjHtccI; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229539AbjATK1T (ORCPT + 48 others); Fri, 20 Jan 2023 05:27:19 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38864 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229470AbjATK1R (ORCPT ); Fri, 20 Jan 2023 05:27:17 -0500 Received: from mail-wm1-x330.google.com (mail-wm1-x330.google.com [IPv6:2a00:1450:4864:20::330]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 01277BAF1F for ; Fri, 20 Jan 2023 02:26:50 -0800 (PST) Received: by mail-wm1-x330.google.com with SMTP id k16so3637685wms.2 for ; Fri, 20 Jan 2023 02:26:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20210112.gappssmtp.com; s=20210112; h=mime-version:message-id:in-reply-to:date:subject:cc:to:from :user-agent:references:from:to:cc:subject:date:message-id:reply-to; bh=e4mt5lGPeAiHXoegntNYO5GB6SA6d9P+daV7EOX7KxE=; b=fUjHtccIWB0vyjuM9shK7iOBnKRcjVRyDKG0+xnJ/+VnAf+laV6pKo7tbZ3ksh8PvH DTpqVBt9YxlTy9n6MPUwHXfZ17dkV9yIPWutuUoJu1xJKHVVNMqdVkVp71GC8ya2gIrM eKdkevkw7tLtIFyHILfqruPo7R105xSjIPdWcI+57E+FGKb1pzNud70c4jQxXTrpbH5g 0MuACQyEH65XIdgQYsrV8x7ILK0SztEBKHhA8qS4PiGT/5AJcMjRPWZSU7O7U19qxeM6 AqiHyd94dI/VIZPCUrv69g6vEPxL73eyTPX7/XkYMkKowY3ofeEkr6zxH/d9UwiJo5pd XOnA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=mime-version:message-id:in-reply-to:date:subject:cc:to:from :user-agent:references:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=e4mt5lGPeAiHXoegntNYO5GB6SA6d9P+daV7EOX7KxE=; b=Zb2mDe2kbDy1H/gcMn2IUyBb2qMvFDeE7g8iTjVHmvX/LwL1i6UpU5PzKefcGnp5ap MY0kFO0AGEFZfJqH4t5wd+D5W2Pb9O+1mW64u73hixC0XIsW5P8BImAscVS3myZRalpU wZ4asXRFdk5UwfL1FozajGaoiEi4Hi6VFggY88ycDG4ibiKifCAJGC019iu2VONtXRGE 23Wb0lV/jFL8YMyRPOtq6sfX78/AceK8VlWnLFjIUzpFdAFd8EEyH2vPJ6jC4KBzKap8 2Eo0RgS7F3ypGJIwf43f1J63zE27Jre31PXGGjPy+j52j5rzpPzSDzJ5MXcTcee2gDru D7zw== X-Gm-Message-State: AFqh2kpxs9d2HIcmmBmqBrmSW8fdUzCnA8ow/FuPt98yG6B88jnDWsYE Wxrlf3/wc6Fu3yWzp1rvBCXGgQ== X-Received: by 2002:a05:600c:3ac8:b0:3da:f67c:aca6 with SMTP id d8-20020a05600c3ac800b003daf67caca6mr13518984wms.34.1674210407420; Fri, 20 Jan 2023 02:26:47 -0800 (PST) Received: from localhost (laubervilliers-658-1-213-31.w90-63.abo.wanadoo.fr. [90.63.244.31]) by smtp.gmail.com with ESMTPSA id z4-20020a05600c0a0400b003db01178b62sm2095567wmp.40.2023.01.20.02.26.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 Jan 2023 02:26:46 -0800 (PST) References: <20230116091637.272923-1-jbrunet@baylibre.com> <20230116091637.272923-3-jbrunet@baylibre.com> <1jmt6eye1m.fsf@starbuckisacylon.baylibre.com> User-agent: mu4e 1.8.10; emacs 28.2 From: Jerome Brunet To: Andrew Lunn Cc: netdev@vger.kernel.org, "David S. Miller" , linux-amlogic@lists.infradead.org, Kevin Hilman , Neil Armstrong , Da Xue , devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH net-next 2/2] net: mdio: add amlogic gxl mdio mux support Date: Fri, 20 Jan 2023 11:16:20 +0100 In-reply-to: Message-ID: <1jcz79wlgc.fsf@starbuckisacylon.baylibre.com> MIME-Version: 1.0 Content-Type: text/plain X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu 19 Jan 2023 at 18:17, Andrew Lunn wrote: >> >> + >> >> + /* Set the internal phy id */ >> >> + writel_relaxed(FIELD_PREP(REG2_PHYID, 0x110181), >> >> + priv->regs + ETH_REG2); >> > >> > So how does this play with what Heiner has been reporting recently? >> >> What Heiner reported recently is related to the g12 family, not the gxl >> which this driver address. >> >> That being said, the g12 does things in a similar way - the glue >> is just a bit different: >> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/net/mdio/mdio-mux-meson-g12a.c?h=v6.2-rc4#n165 >> >> > What is the reset default? Who determined this value? >> >> It's the problem, the reset value is 0. That is why GXL does work with the >> internal PHY if the bootloader has not initialized it before the kernel >> comes up ... and there is no guarantee that it will. >> >> The phy id value is arbitrary, same as the address. They match what AML >> is using internally. > > Please document where these values have come from. In the future we > might need to point a finger when it all goes horribly wrong. > OK >> They have been kept to avoid making a mess if a vendor bootloader is >> used with the mainline kernel, I guess. >> >> I suppose any value could be used here, as long as it matches the value >> in the PHY driver: >> >> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/net/phy/meson-gxl.c?h=v6.2-rc4#n253 > > Some Marvell Ethernet switches with integrated PHYs have IDs with the > vendor part set to Marvell, but the lower part is 0. The date sheet > even says this is deliberate, you need to look at some other register > in the switches address space to determine what the part is. That > works O.K in the vendor crap monolithic driver, but not for Linux > which separates the drivers up. So we have to intercept the reads and > fill in the lower part. And we have no real knowledge if the PHYs are > all the same, or there are differences. So we put in the switch ID, > and the PHY driver then has an entry per switch. That gives us some > future wiggle room if we find the PHYs are actually different. > > Is there any indication in the datasheets that the PHY is the exact > same one as in the g12? Are we really safe to reuse this value between > different SoCs? There is zero information about the PHY in the datasheet. The gxl and g12 don't use the same ID values. The PHY ip is very similar but slightly different between the 2. (see https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/net/phy/meson-gxl.c) My guess is the g12 as another version of the IP, with some bug fixed. The integration (clocking scheme mostly) is also different, which is why the mux/glue is different. > > I actually find it an odd feature. Does the datasheet say anything > about Why you can set the ID in software? The ID describes the > hardware, and software configuration should not be able to change the > hardware in any meaningful way. Again, zero information. It is a bought IP (similar to the Rockchip judging by the PHY driver). I'm not surprised the provider of the IP would make the ID easy to configure. AML chose to keep that configurable through the glue, instead of fixing it. This is how it is. > >> >> + /* Enable the internal phy */ >> >> + val |= REG3_PHYEN; >> >> + writel_relaxed(val, priv->regs + ETH_REG3); >> >> + writel_relaxed(0, priv->regs + ETH_REG4); >> >> + >> >> + /* The phy needs a bit of time to come up */ >> >> + mdelay(10); >> > >> > What do you mean by 'come up'? Not link up i assume. But maybe it will >> > not respond to MDIO requests? >> >> Yes this MDIO multiplexer is also the glue that provides power and >> clocks to the internal PHY. Once the internal PHY is selected, it needs >> a bit a of time before it is usuable. > > O.K, please reword it to indicate power up, not link up. > Sure > Andrew