From: Bastien Curutchet <bastien.curutchet@bootlin.com>
To: Andrew Lunn <andrew@lunn.ch>
Cc: "Woojung Huh" <woojung.huh@microchip.com>,
UNGLinuxDriver@microchip.com,
"Vladimir Oltean" <olteanv@gmail.com>,
"David S. Miller" <davem@davemloft.net>,
"Eric Dumazet" <edumazet@google.com>,
"Jakub Kicinski" <kuba@kernel.org>,
"Paolo Abeni" <pabeni@redhat.com>,
"Rob Herring" <robh@kernel.org>,
"Krzysztof Kozlowski" <krzk+dt@kernel.org>,
"Conor Dooley" <conor+dt@kernel.org>,
"Marek Vasut" <marex@denx.de>,
"Thomas Petazzoni" <thomas.petazzoni@bootlin.com>,
"Miquèl Raynal" <miquel.raynal@bootlin.com>,
"Pascal Eberhard" <pascal.eberhard@se.com>,
netdev@vger.kernel.org, devicetree@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH net-next 2/2] net: dsa: microchip: configure strap pins during reset
Date: Thu, 11 Sep 2025 10:04:00 +0200 [thread overview]
Message-ID: <9c543fa2-1ac1-463b-bb1d-f89be61f7ece@bootlin.com> (raw)
In-Reply-To: <14114502-f087-4d3b-a91e-cff0dfe59045@lunn.ch>
Hi Andrew,
On 9/10/25 6:46 PM, Andrew Lunn wrote:
>> Support the KSZ8463's strap configuration that enforces SPI as
>> communication bus, since it is the only bus supported by the driver.
>
> So this is the key sentence for this patchset, which should of been in
> patch 0/X. You have a chicken/egg problem. You cannot talk to the
> switch to put it into SPI mode because you cannot talk to the switch
> using SPI.
>
> The current patch descriptions, and the patches themselves don't make
> this clear. They just vaguely mention configuration via strapping.
>
Indeed, that wasn't clear, sorry. My intention was to keep it somewhat
'generic', since other KSZ switches also use strap configurations. I
thought the DT property could be re-used by others to enforce different
kinds of strap configurations.
But I agree with you, it's probably better to have something KSZ8463
specific.
>> +static int ksz_configure_strap(struct ksz_device *dev)
>
> Please make it clear this function straps the switch for SPI. If
> somebody does add support for I2C, they need to understand that...
>
>> +{
>> + struct pinctrl_state *state = NULL;
>> + struct pinctrl *pinctrl;
>> + int ret;
>> +
>> + if (of_device_is_compatible(dev->dev->of_node, "microchip,ksz8463")) {
>
> I would not hide this here. Please move this if into
> ksz_switch_register(). I also think this function should have the
> ksz8463 prefix, since how you strap other devices might differ. So
> ksz8463_configure_straps_spi() ?
>
Ack.
>> + struct gpio_desc *rxd0;
>> + struct gpio_desc *rxd1;
>> +
>> + rxd0 = devm_gpiod_get_index_optional(dev->dev, "strap", 0, GPIOD_OUT_LOW);
>> + if (IS_ERR(rxd0))
>> + return PTR_ERR(rxd0);
>> +
>> + rxd1 = devm_gpiod_get_index_optional(dev->dev, "strap", 1, GPIOD_OUT_HIGH);
>> + if (IS_ERR(rxd1))
>> + return PTR_ERR(rxd1);
>> +
>> + /* If at least one strap definition is missing we don't do anything */
>> + if (!rxd0 || !rxd1)
>> + return 0;
>
> I would say, if you have one, not two, the DT blob is broken, and you
> should return -EINVAL.
>
Ack.
>> +
>> + pinctrl = devm_pinctrl_get(dev->dev);
>> + if (IS_ERR(pinctrl))
>> + return PTR_ERR(pinctrl);
>> +
>> + state = pinctrl_lookup_state(pinctrl, "reset");
>> + if (IS_ERR(state))
>> + return PTR_ERR(state);
>> +
>> + ret = pinctrl_select_state(pinctrl, state);
>> + if (ret)
>> + return ret;
>> + }
>> +
>> + return 0;
>> +}
>> +
>> int ksz_switch_register(struct ksz_device *dev)
>> {
>> const struct ksz_chip_data *info;
>> @@ -5353,10 +5392,18 @@ int ksz_switch_register(struct ksz_device *dev)
>> return PTR_ERR(dev->reset_gpio);
>>
>> if (dev->reset_gpio) {
>> + ret = ksz_configure_strap(dev);
>> + if (ret)
>> + return ret;
>> +
>> gpiod_set_value_cansleep(dev->reset_gpio, 1);
>> usleep_range(10000, 12000);
>> gpiod_set_value_cansleep(dev->reset_gpio, 0);
>> msleep(100);
>> +
>> + ret = pinctrl_select_default_state(dev->dev);
>> + if (ret)
>> + return ret;
>
> This does not look symmetrical. Maybe put the
> pinctrl_select_default_state() inside a function called
> ksz8463_release_straps_spi()?
>
>
Ack.
Best regards,
--
Bastien Curutchet, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
next prev parent reply other threads:[~2025-09-11 8:04 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-09-10 14:55 [PATCH net-next 0/2] net: dsa: microchip: Add strap configuration " Bastien Curutchet
2025-09-10 14:55 ` [PATCH net-next 1/2] dt-bindings: net: dsa: microchip: Add strap description Bastien Curutchet
2025-09-10 14:55 ` [PATCH net-next 2/2] net: dsa: microchip: configure strap pins during reset Bastien Curutchet
2025-09-10 15:38 ` Miquel Raynal
2025-09-11 11:22 ` Bastien Curutchet
2025-09-10 16:46 ` Andrew Lunn
2025-09-11 8:04 ` Bastien Curutchet [this message]
2025-09-11 10:53 ` Parthiban.Veerasooran
2025-09-10 16:27 ` [PATCH net-next 0/2] net: dsa: microchip: Add strap configuration " Andrew Lunn
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=9c543fa2-1ac1-463b-bb1d-f89be61f7ece@bootlin.com \
--to=bastien.curutchet@bootlin.com \
--cc=UNGLinuxDriver@microchip.com \
--cc=andrew@lunn.ch \
--cc=conor+dt@kernel.org \
--cc=davem@davemloft.net \
--cc=devicetree@vger.kernel.org \
--cc=edumazet@google.com \
--cc=krzk+dt@kernel.org \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=marex@denx.de \
--cc=miquel.raynal@bootlin.com \
--cc=netdev@vger.kernel.org \
--cc=olteanv@gmail.com \
--cc=pabeni@redhat.com \
--cc=pascal.eberhard@se.com \
--cc=robh@kernel.org \
--cc=thomas.petazzoni@bootlin.com \
--cc=woojung.huh@microchip.com \
/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
all inboxes | Powered by JetHome®