Re: [PATCH 2/2] gpio: loongson-64bit: Add more gpio chip support

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Bartosz:

Thanks for your reply.

On Tue, Mar 4, 2025 at 6:36 PM Bartosz Golaszewski <brgl@xxxxxxxx> wrote:
>
> On Mon, Mar 3, 2025 at 8:46 AM Binbin Zhou <zhoubinbin@xxxxxxxxxxx> wrote:
> >
> > The Loongson-7A2000 and Loongson-3A6000 share the same gpio chip model.
> > Just add them through driver_data.
> >
> > Signed-off-by: Binbin Zhou <zhoubinbin@xxxxxxxxxxx>
> > ---
> >  drivers/gpio/gpio-loongson-64bit.c | 51 ++++++++++++++++++++++++++++++
> >  1 file changed, 51 insertions(+)
> >
> > diff --git a/drivers/gpio/gpio-loongson-64bit.c b/drivers/gpio/gpio-loongson-64bit.c
> > index f000cc0356c7..a9a93036f08f 100644
> > --- a/drivers/gpio/gpio-loongson-64bit.c
> > +++ b/drivers/gpio/gpio-loongson-64bit.c
> > @@ -254,6 +254,33 @@ static const struct loongson_gpio_chip_data loongson_gpio_ls7a_data = {
> >         .out_offset = 0x900,
> >  };
> >
> > +/* LS7A2000 chipset GPIO */
> > +static const struct loongson_gpio_chip_data loongson_gpio_ls7a2000_data0 = {
> > +       .label = "ls7a2000_gpio",
> > +       .mode = BYTE_CTRL_MODE,
> > +       .conf_offset = 0x800,
> > +       .in_offset = 0xa00,
> > +       .out_offset = 0x900,
> > +};
> > +
> > +/* LS7A2000 ACPI GPIO */
> > +static const struct loongson_gpio_chip_data loongson_gpio_ls7a2000_data1 = {
> > +       .label = "ls7a2000_gpio",
> > +       .mode = BYTE_CTRL_MODE,
> > +       .conf_offset = 0x4,
> > +       .in_offset = 0x8,
> > +       .out_offset = 0x0,
> > +};
>
> The naming convention here is a bit confusing, can't we have the
> naming of variables reflect the compatibles they refer to?
>
Emm...

I named them that way to be consistent with the previous naming.
Of course, we could name them something like
“ls7a2000_acpi_gpio_data”, which might be better understood.
Also, do we need to rename all instances of “loongson_gpio_chip_data”?

For example:
ls2k1000_cpu_gpio_data
ls2k0500_cpu_gpio0_data
ls2k0500_cpu_gpio1_data
ls2k2000_cpu_gpio_data
ls2k2000_bridge_gpio_data
ls2k2000_acpi_gpio_data
ls3a5000_cpu_gpio_data
ls3a6000_cpu_gpio_data
ls7a1000_bridge_gpio_data
ls7a2000_bridge_gpio_data
ls7a2000_gpio_gpio_data

> Bart
>
> > +
> > +/* Loongson-3A6000 node GPIO */
> > +static const struct loongson_gpio_chip_data loongson_gpio_ls3a6000_data = {
> > +       .label = "ls3a6000_gpio",
> > +       .mode = BIT_CTRL_MODE,
> > +       .conf_offset = 0x0,
> > +       .in_offset = 0xc,
> > +       .out_offset = 0x8,
> > +};
> > +
> >  static const struct of_device_id loongson_gpio_of_match[] = {
> >         {
> >                 .compatible = "loongson,ls2k-gpio",
> > @@ -287,6 +314,18 @@ static const struct of_device_id loongson_gpio_of_match[] = {
> >                 .compatible = "loongson,ls7a-gpio",
> >                 .data = &loongson_gpio_ls7a_data,
> >         },
> > +       {
> > +               .compatible = "loongson,ls7a2000-gpio1",
> > +               .data = &loongson_gpio_ls7a2000_data0,
> > +       },
> > +       {
> > +               .compatible = "loongson,ls7a2000-gpio2",
> > +               .data = &loongson_gpio_ls7a2000_data1,
> > +       },
> > +       {
> > +               .compatible = "loongson,ls3a6000-gpio",
> > +               .data = &loongson_gpio_ls3a6000_data,
> > +       },
> >         {}
> >  };
> >  MODULE_DEVICE_TABLE(of, loongson_gpio_of_match);
> > @@ -312,6 +351,18 @@ static const struct acpi_device_id loongson_gpio_acpi_match[] = {
> >                 .id = "LOON000C",
> >                 .driver_data = (kernel_ulong_t)&loongson_gpio_ls2k2000_data2,
> >         },
> > +       {
> > +               .id = "LOON000D",
> > +               .driver_data = (kernel_ulong_t)&loongson_gpio_ls7a2000_data0,
> > +       },
> > +       {
> > +               .id = "LOON000E",
> > +               .driver_data = (kernel_ulong_t)&loongson_gpio_ls7a2000_data1,
> > +       },
> > +       {
> > +               .id = "LOON000F",
> > +               .driver_data = (kernel_ulong_t)&loongson_gpio_ls3a6000_data,
> > +       },
> >         {}
> >  };
> >  MODULE_DEVICE_TABLE(acpi, loongson_gpio_acpi_match);
> > --
> > 2.47.1
> >



-- 
Thanks.
Binbin





[Index of Archives]     [Device Tree Compilter]     [Device Tree Spec]     [Linux Driver Backports]     [Video for Linux]     [Linux USB Devel]     [Linux PCI Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Yosemite Backpacking]


  Powered by Linux