From: Alex Elder <elder@riscstar.com>
To: Linus Walleij <linusw@kernel.org>
Cc: andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@google.com,
kuba@kernel.org, pabeni@redhat.com,
maxime.chevallier@bootlin.com, andersson@kernel.org,
konradybcio@kernel.org, robh@kernel.org, krzk+dt@kernel.org,
conor+dt@kernel.org, brgl@kernel.org, arnd@arndb.de,
gregkh@linuxfoundation.org, daniel@riscstar.com, wens@kernel.org,
netdev@vger.kernel.org, bpf@vger.kernel.org,
devicetree@vger.kernel.org, linux-gpio@vger.kernel.org,
linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH net-next 09/12] gpio: tc956x: add TC956x/QPS615 support
Date: Thu, 7 May 2026 07:20:58 -0500 [thread overview]
Message-ID: <cb788638-7cb0-469e-9c38-13452103f7c4@riscstar.com> (raw)
In-Reply-To: <CAD++jLkm4qn9hxQ9HjjnTWjvAiS+A+x1ATy7wamnm_YSP_qPEg@mail.gmail.com>
On 5/7/26 7:15 AM, Linus Walleij wrote:
> Hi Alex,
>
> thanks for your patch!
Thank you for your excellent feedback. I will plan to use
regmap-gpio (already suggested strongly by Andrew Lunn) and
that will be included in the next version of the series.
Once I've done this and tried your other patch I'll provide
a Tested-by for it.
-Alex
>
> On Fri, May 1, 2026 at 5:55 PM Alex Elder <elder@riscstar.com> wrote:
>
>> Toshiba TC956x is an Ethernet-AVB/TSN bridge and is essentially
>> a small and highly-specialized SoC. TC956x includes a GPIO block that
>> can be accessed, alongside several other peripherals, via two PCIe
>> endpoint functions. The PCIe function driver creates an auxiliary
>> device for the GPIO block, and that device gets bound to this auxiliary
>> device driver.
>>
>> Co-developed-by: Daniel Thompson <daniel@riscstar.com>
>> Signed-off-by: Daniel Thompson <daniel@riscstar.com>
>> Signed-off-by: Alex Elder <elder@riscstar.com>
> (...)
>
>> +config GPIO_TC956X
>> + tristate "Toshiba TC956X GPIO support"
>> + depends on TOSHIBA_TC956X_PCI
>> + default m if TOSHIBA_TC956X_PCI
>
> I think this driver can
>
> select GPIO_REGMAP
>
>> +#include <linux/auxiliary_bus.h>
>> +#include <linux/dev_printk.h>
>> +#include <linux/gpio/driver.h>
>> +#include <linux/module.h>
>> +#include <linux/platform_device.h>
>> +#include <linux/regmap.h>
>
> #include <linux/gpio/regmap.h>
>
>> +#define TC956X_GPIO_COUNT 37 /* Number of GPIOs (20-21 reserved) */
>
> I would just do 64 and flag > 37 as invalid.
>
>> +/*
>> + * struct tc956x_gpio - Information related to the embedded GPIO controller
>> + * @chip: GPIO chip structure
>> + * @regmap: MMIO register map for SFR GPIO region access
>> + * @input_only: Bitmap indicating which GPIOs are input-only
>> + */
>> +struct tc956x_gpio {
>> + struct gpio_chip chip;
>> + struct regmap *regmap;
>> + DECLARE_BITMAP(input_only, TC956X_GPIO_COUNT);
>
>> +static int tc956x_gpio_get_direction(struct gpio_chip *gc, unsigned int offset)
>> +static int tc956x_gpio_direction_input(struct gpio_chip *gc,
>> + unsigned int offset)
>> +static int tc956x_gpio_direction_output(struct gpio_chip *gc,
>> + unsigned int offset, int value)
>> +static int tc956x_gpio_get(struct gpio_chip *gc, unsigned int offset)
>> +static int tc956x_gpio_set(struct gpio_chip *gc, unsigned int offset, int value)
>
> REGMAP_GPIO can handle all of this for you with the right
> parameterization, study the drivers using this already such as
> those that appear when you type
> git grep 'gpio\/regmap\.h'
>
>
>> +static int tc956x_gpio_init_valid_mask(struct gpio_chip *gc,
>> + unsigned long *valid_mask,
>> + unsigned int ngpios)
>> +{
>> + /*
>> + * GPIOs 2 and 3 are used by the PCI power control driver, and
>> + * we don't allow them to be used. GPIOs 20 and 21 are reserved
>> + * (and not usable).
>> + */
>> + bitmap_fill(valid_mask, ngpios);
>> + bitmap_clear(valid_mask, 2, 2);
>> + bitmap_clear(valid_mask, 20, 2);
>> +
>> + return 0;
>> +}
>
> That's good use of this facility.
>
> I would say the chip has 64 lines and just
> bitmap_clear(valid_mask, 37, 64 - 37);
> but that's your pick. This probably works too.
>
>> + /* Mark GPIOs 22, 23, 24, 27, 28, 31, and 34 as input only */
>> + bitmap_set(gpio->input_only, 22, 3);
>> + bitmap_set(gpio->input_only, 27, 2);
>> + set_bit(31, gpio->input_only);
>> + set_bit(34, gpio->input_only);
>
> regmap-gpio can't currently handle selective input-only or
> output-only lines, but we can
> very easily make it.
>
> So I sent a patch for that (now in your inbox).
>
> Check if this fixed_direction_sparse bitmap will do the trick
> for you and provide Tested-by if it does, thanks!
>
> Yours,
> Linus Walleij
next prev parent reply other threads:[~2026-05-07 12:21 UTC|newest]
Thread overview: 92+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-01 15:54 [PATCH net-next 00/12] net: enable TC956x support Alex Elder
2026-05-01 15:54 ` [PATCH net-next 01/12] net: pcs: pcs-xpcs-regmap: support XPCS memory-mapped MDIO bus via regmap Alex Elder
2026-05-01 15:54 ` [PATCH net-next 02/12] net: pcs: pcs-xpcs: select operating mode for 10G-baseR capable PCS Alex Elder
2026-05-01 16:50 ` Andrew Lunn
2026-05-01 18:07 ` Alex Elder
2026-05-05 15:58 ` Daniel Thompson
2026-05-01 15:54 ` [PATCH net-next 03/12] net: pcs: pcs-xpcs: Preserve BMCR_ANENBLE during link up Alex Elder
2026-05-01 17:06 ` Andrew Lunn
2026-05-06 9:46 ` Daniel Thompson
2026-05-01 15:54 ` [PATCH net-next 04/12] net: stmmac: dma: create a separate dma_device pointer Alex Elder
2026-05-01 17:13 ` Andrew Lunn
2026-05-01 18:06 ` Alex Elder
2026-05-01 20:55 ` Andrew Lunn
2026-05-04 13:36 ` Alex Elder
2026-05-01 15:54 ` [PATCH net-next 05/12] net: stmmac: dwxgmac2: Add multi MSI interrupt mode Alex Elder
2026-05-01 17:21 ` Andrew Lunn
2026-05-01 15:54 ` [PATCH net-next 06/12] net: stmmac: dwxgmac2: Add XGMAC 3.01a support Alex Elder
2026-05-01 15:54 ` [PATCH net-next 07/12] net: stmmac: dwxgmac2: export symbols for XGMAC 3.01a DMA Alex Elder
2026-05-01 15:54 ` [PATCH net-next 08/12] dt-bindings: net: toshiba,tc965x-dwmac: add TC956x Ethernet bridge Alex Elder
2026-05-01 17:38 ` Andrew Lunn
2026-05-03 2:22 ` Alex Elder
2026-05-07 22:17 ` Alex Elder
2026-05-07 23:39 ` Rob Herring
2026-05-04 11:00 ` Krzysztof Kozlowski
2026-05-04 13:34 ` Alex Elder
2026-05-07 14:47 ` Daniel Thompson
2026-05-07 14:12 ` Bjorn Andersson
2026-05-07 14:19 ` Andrew Lunn
2026-05-07 16:12 ` Bjorn Andersson
2026-05-07 18:37 ` Alex Elder
2026-05-10 2:25 ` Bjorn Andersson
2026-05-07 23:41 ` Rob Herring
2026-05-01 15:54 ` [PATCH net-next 09/12] gpio: tc956x: add TC956x/QPS615 support Alex Elder
2026-05-01 18:36 ` Andrew Lunn
2026-05-03 1:45 ` Alex Elder
2026-05-03 2:48 ` Andrew Lunn
2026-05-07 18:39 ` Alex Elder
2026-05-03 3:05 ` Andrew Lunn
2026-05-06 18:21 ` Alex Elder
2026-05-06 19:43 ` Andrew Lunn
2026-05-06 20:25 ` Alex Elder
2026-05-06 21:43 ` Andrew Lunn
2026-05-06 22:41 ` Alex Elder
2026-05-03 3:42 ` Julian Braha
2026-05-06 18:51 ` Alex Elder
2026-05-04 12:46 ` Bartosz Golaszewski
2026-05-04 13:07 ` Alex Elder
2026-05-07 12:15 ` Linus Walleij
2026-05-07 12:20 ` Alex Elder [this message]
2026-05-01 15:54 ` [PATCH net-next 10/12] net: stmmac: " Alex Elder
2026-05-01 19:04 ` Andrew Lunn
2026-05-07 16:03 ` Daniel Thompson
2026-05-07 16:29 ` Andrew Lunn
2026-05-08 11:25 ` Daniel Thompson
2026-05-08 13:34 ` Andrew Lunn
2026-05-08 15:54 ` Daniel Thompson
2026-05-05 16:38 ` Mohd Ayaan Anwar
2026-05-05 16:46 ` Alex Elder
2026-05-06 2:30 ` Xilin Wu
2026-05-06 17:44 ` Alex Elder
2026-05-07 13:57 ` Xilin Wu
2026-05-07 14:14 ` Andrew Lunn
2026-05-06 12:59 ` Xilin Wu
2026-05-06 14:19 ` Andrew Lunn
2026-05-06 14:35 ` Xilin Wu
2026-05-06 14:45 ` Andrew Lunn
2026-05-06 15:38 ` Xilin Wu
2026-05-06 15:39 ` Daniel Thompson
2026-05-06 15:44 ` Xilin Wu
2026-05-06 15:56 ` Andrew Lunn
2026-05-06 16:00 ` Xilin Wu
2026-05-06 15:28 ` Daniel Thompson
2026-05-06 19:52 ` Andrew Lunn
2026-05-07 18:44 ` Alex Elder
2026-05-08 13:09 ` Xilin Wu
2026-05-08 13:36 ` Andrew Lunn
2026-05-08 13:41 ` Xilin Wu
2026-05-01 15:54 ` [PATCH net-next 11/12] misc: tc956x_pci: " Alex Elder
2026-05-01 21:07 ` Andrew Lunn
2026-05-03 2:06 ` Alex Elder
2026-05-02 16:45 ` Jakub Kicinski
2026-05-03 2:06 ` Alex Elder
2026-05-03 2:14 ` Jakub Kicinski
2026-05-03 2:23 ` Alex Elder
2026-05-01 15:54 ` [PATCH net-next 12/12] arm64: dts: qcom: qcs6490-rb3gen2: enable TC9564 with a single QCS8081 phy Alex Elder
2026-05-01 21:09 ` Andrew Lunn
2026-05-05 16:25 ` Daniel Thompson
2026-05-05 16:42 ` Mohd Ayaan Anwar
2026-05-05 16:46 ` Alex Elder
2026-05-08 14:03 ` Konrad Dybcio
2026-05-02 16:47 ` [PATCH net-next 00/12] net: enable TC956x support Jakub Kicinski
2026-05-03 2:07 ` Alex Elder
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=cb788638-7cb0-469e-9c38-13452103f7c4@riscstar.com \
--to=elder@riscstar.com \
--cc=andersson@kernel.org \
--cc=andrew+netdev@lunn.ch \
--cc=arnd@arndb.de \
--cc=bpf@vger.kernel.org \
--cc=brgl@kernel.org \
--cc=conor+dt@kernel.org \
--cc=daniel@riscstar.com \
--cc=davem@davemloft.net \
--cc=devicetree@vger.kernel.org \
--cc=edumazet@google.com \
--cc=gregkh@linuxfoundation.org \
--cc=konradybcio@kernel.org \
--cc=krzk+dt@kernel.org \
--cc=kuba@kernel.org \
--cc=linusw@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-gpio@vger.kernel.org \
--cc=maxime.chevallier@bootlin.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=robh@kernel.org \
--cc=wens@kernel.org \
/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