All of lore.kernel.org
 help / color / mirror / Atom feed
From: Arnd Bergmann <arnd@arndb.de>
To: linux-arm-kernel@lists.infradead.org
Subject: Re: [rtc-linux] [PATCH 8/8] ARM: vt8500: gpio: Devicetree support for arch-vt8500
Date: Wed, 08 Aug 2012 09:19:52 +0000	[thread overview]
Message-ID: <201208080919.52592.arnd@arndb.de> (raw)
In-Reply-To: <CACRpkdbYxpN9RCu8j8KMBgrb=-DsYZHq7hx-ifmHhJ0ZZcRYjw@mail.gmail.com>

On Wednesday 08 August 2012, Linus Walleij wrote:
> On Wed, Aug 8, 2012 at 3:39 AM, Tony Prisk <linux@prisktech.co.nz> wrote:
> 
> > Converted the existing arch-vt8500 gpio to a platform_device.
> > Added support for WM8505 and WM8650 GPIO controllers.
> (...)
> > +++ b/drivers/gpio/gpio-vt8500.c
> 
> This driver looks very one-bit-per-gpio typed. Are you sure you cannot
> just reuse drivers/gpio/gpio-generic.c? Make a compelling case please...
> 
> > +struct vt8500_gpio_bank_regs {
> > +       int     en;
> > +       int     dir;
> > +       int     data_out;
> > +       int     data_in;
> 
> Why are all these members int? They should be u8 from reading your code.
> 
> > +       int     ngpio;
> > +};

Not necessarily 8 bit, but definitely unsigned.

> > +static struct vt8500_gpio_data vt8500_data = {
> > +       .num_banks      = 7,
> > +       .banks  = {
> > +               VT8500_BANK(0x00, 0x20, 0x40, 0x60, 26),
> > +               VT8500_BANK(0x04, 0x24, 0x44, 0x64, 28),
> > +               VT8500_BANK(0x08, 0x28, 0x48, 0x68, 31),
> > +               VT8500_BANK(0x0C, 0x2C, 0x4C, 0x6C, 19),
> > +               VT8500_BANK(0x10, 0x30, 0x50, 0x70, 19),
> > +               VT8500_BANK(0x14, 0x34, 0x54, 0x74, 23),
> > +               VT8500_BANK(-1, 0x3C, 0x5C, 0x7C, 9),    /* external gpio */
> 
> What on earth are all those magic numbers?
> 
> I *guess* they're enabling some default GPIO settings etc.

No, they are the register offsets you quoted above, per bank. There
is no easy way to abstract these, and I suggested putting the
values into the source code rather than describing each bank
separately in the .dtsi file.

My feeling however is that the "vt8500_chip->regoff" is wrong, which
would mean only the first bank works. The code adds the same offsets
per bank once more that it sets in this bank table.

	Arnd

WARNING: multiple messages have this Message-ID (diff)
From: Arnd Bergmann <arnd@arndb.de>
To: Linus Walleij <linus.walleij@linaro.org>
Cc: vt8500-wm8505-linux-kernel@googlegroups.com,
	Tony Prisk <linux@prisktech.co.nz>,
	Russell King <linux@arm.linux.org.uk>,
	Alessandro Zummo <a.zummo@towertech.it>,
	Grant Likely <grant.likely@secretlab.ca>,
	Rob Herring <rob.herring@calxeda.com>,
	Alan Cox <alan@linux.intel.com>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Alan Stern <stern@rowland.harvard.edu>,
	Hauke Mehrtens <hauke@hauke-m.de>, Felipe Balbi <balbi@ti.com>,
	Neil Zhang <zhangwm@marvell.com>,
	Florian Tobias Schandinat <FlorianSchandinat@gmx.de>,
	Rob Landley <rob@landley.net>,
	Mark Brown <broonie@opensource.wolfsonmicro.com>,
	Stephen Warren <swarren@nvidia.com>,
	Eric Andersson <eric.andersson@unixphere.com>,
	Linus Walleij <linus.walleij@stericsson.com>,
	linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org,
	linux-fbdev@vger.kernel.org, linux-usb@vger.kernel.or
Subject: Re: [rtc-linux] [PATCH 8/8] ARM: vt8500: gpio: Devicetree support for arch-vt8500
Date: Wed, 8 Aug 2012 09:19:52 +0000	[thread overview]
Message-ID: <201208080919.52592.arnd@arndb.de> (raw)
In-Reply-To: <CACRpkdbYxpN9RCu8j8KMBgrb=-DsYZHq7hx-ifmHhJ0ZZcRYjw@mail.gmail.com>

On Wednesday 08 August 2012, Linus Walleij wrote:
> On Wed, Aug 8, 2012 at 3:39 AM, Tony Prisk <linux@prisktech.co.nz> wrote:
> 
> > Converted the existing arch-vt8500 gpio to a platform_device.
> > Added support for WM8505 and WM8650 GPIO controllers.
> (...)
> > +++ b/drivers/gpio/gpio-vt8500.c
> 
> This driver looks very one-bit-per-gpio typed. Are you sure you cannot
> just reuse drivers/gpio/gpio-generic.c? Make a compelling case please...
> 
> > +struct vt8500_gpio_bank_regs {
> > +       int     en;
> > +       int     dir;
> > +       int     data_out;
> > +       int     data_in;
> 
> Why are all these members int? They should be u8 from reading your code.
> 
> > +       int     ngpio;
> > +};

Not necessarily 8 bit, but definitely unsigned.

> > +static struct vt8500_gpio_data vt8500_data = {
> > +       .num_banks      = 7,
> > +       .banks  = {
> > +               VT8500_BANK(0x00, 0x20, 0x40, 0x60, 26),
> > +               VT8500_BANK(0x04, 0x24, 0x44, 0x64, 28),
> > +               VT8500_BANK(0x08, 0x28, 0x48, 0x68, 31),
> > +               VT8500_BANK(0x0C, 0x2C, 0x4C, 0x6C, 19),
> > +               VT8500_BANK(0x10, 0x30, 0x50, 0x70, 19),
> > +               VT8500_BANK(0x14, 0x34, 0x54, 0x74, 23),
> > +               VT8500_BANK(-1, 0x3C, 0x5C, 0x7C, 9),    /* external gpio */
> 
> What on earth are all those magic numbers?
> 
> I *guess* they're enabling some default GPIO settings etc.

No, they are the register offsets you quoted above, per bank. There
is no easy way to abstract these, and I suggested putting the
values into the source code rather than describing each bank
separately in the .dtsi file.

My feeling however is that the "vt8500_chip->regoff" is wrong, which
would mean only the first bank works. The code adds the same offsets
per bank once more that it sets in this bank table.

	Arnd

WARNING: multiple messages have this Message-ID (diff)
From: arnd@arndb.de (Arnd Bergmann)
To: linux-arm-kernel@lists.infradead.org
Subject: [rtc-linux] [PATCH 8/8] ARM: vt8500: gpio: Devicetree support for arch-vt8500
Date: Wed, 8 Aug 2012 09:19:52 +0000	[thread overview]
Message-ID: <201208080919.52592.arnd@arndb.de> (raw)
In-Reply-To: <CACRpkdbYxpN9RCu8j8KMBgrb=-DsYZHq7hx-ifmHhJ0ZZcRYjw@mail.gmail.com>

On Wednesday 08 August 2012, Linus Walleij wrote:
> On Wed, Aug 8, 2012 at 3:39 AM, Tony Prisk <linux@prisktech.co.nz> wrote:
> 
> > Converted the existing arch-vt8500 gpio to a platform_device.
> > Added support for WM8505 and WM8650 GPIO controllers.
> (...)
> > +++ b/drivers/gpio/gpio-vt8500.c
> 
> This driver looks very one-bit-per-gpio typed. Are you sure you cannot
> just reuse drivers/gpio/gpio-generic.c? Make a compelling case please...
> 
> > +struct vt8500_gpio_bank_regs {
> > +       int     en;
> > +       int     dir;
> > +       int     data_out;
> > +       int     data_in;
> 
> Why are all these members int? They should be u8 from reading your code.
> 
> > +       int     ngpio;
> > +};

Not necessarily 8 bit, but definitely unsigned.

> > +static struct vt8500_gpio_data vt8500_data = {
> > +       .num_banks      = 7,
> > +       .banks  = {
> > +               VT8500_BANK(0x00, 0x20, 0x40, 0x60, 26),
> > +               VT8500_BANK(0x04, 0x24, 0x44, 0x64, 28),
> > +               VT8500_BANK(0x08, 0x28, 0x48, 0x68, 31),
> > +               VT8500_BANK(0x0C, 0x2C, 0x4C, 0x6C, 19),
> > +               VT8500_BANK(0x10, 0x30, 0x50, 0x70, 19),
> > +               VT8500_BANK(0x14, 0x34, 0x54, 0x74, 23),
> > +               VT8500_BANK(-1, 0x3C, 0x5C, 0x7C, 9),    /* external gpio */
> 
> What on earth are all those magic numbers?
> 
> I *guess* they're enabling some default GPIO settings etc.

No, they are the register offsets you quoted above, per bank. There
is no easy way to abstract these, and I suggested putting the
values into the source code rather than describing each bank
separately in the .dtsi file.

My feeling however is that the "vt8500_chip->regoff" is wrong, which
would mean only the first bank works. The code adds the same offsets
per bank once more that it sets in this bank table.

	Arnd

WARNING: multiple messages have this Message-ID (diff)
From: Arnd Bergmann <arnd@arndb.de>
To: Linus Walleij <linus.walleij@linaro.org>
Cc: vt8500-wm8505-linux-kernel@googlegroups.com,
	Tony Prisk <linux@prisktech.co.nz>,
	Russell King <linux@arm.linux.org.uk>,
	Alessandro Zummo <a.zummo@towertech.it>,
	Grant Likely <grant.likely@secretlab.ca>,
	Rob Herring <rob.herring@calxeda.com>,
	Alan Cox <alan@linux.intel.com>,
	"Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
	Alan Stern <stern@rowland.harvard.edu>,
	Hauke Mehrtens <hauke@hauke-m.de>, Felipe Balbi <balbi@ti.com>,
	Neil Zhang <zhangwm@marvell.com>,
	Florian Tobias Schandinat <FlorianSchandinat@gmx.de>,
	Rob Landley <rob@landley.net>,
	Mark Brown <broonie@opensource.wolfsonmicro.com>,
	Stephen Warren <swarren@nvidia.com>,
	Eric Andersson <eric.andersson@unixphere.com>,
	Linus Walleij <linus.walleij@stericsson.com>,
	linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org,
	linux-fbdev@vger.kernel.org, linux-usb@vger.kernel.org,
	linux-serial@vger.kernel.org,
	devicetree-discuss@lists.ozlabs.org
Subject: Re: [rtc-linux] [PATCH 8/8] ARM: vt8500: gpio: Devicetree support for arch-vt8500
Date: Wed, 8 Aug 2012 09:19:52 +0000	[thread overview]
Message-ID: <201208080919.52592.arnd@arndb.de> (raw)
In-Reply-To: <CACRpkdbYxpN9RCu8j8KMBgrb=-DsYZHq7hx-ifmHhJ0ZZcRYjw@mail.gmail.com>

On Wednesday 08 August 2012, Linus Walleij wrote:
> On Wed, Aug 8, 2012 at 3:39 AM, Tony Prisk <linux@prisktech.co.nz> wrote:
> 
> > Converted the existing arch-vt8500 gpio to a platform_device.
> > Added support for WM8505 and WM8650 GPIO controllers.
> (...)
> > +++ b/drivers/gpio/gpio-vt8500.c
> 
> This driver looks very one-bit-per-gpio typed. Are you sure you cannot
> just reuse drivers/gpio/gpio-generic.c? Make a compelling case please...
> 
> > +struct vt8500_gpio_bank_regs {
> > +       int     en;
> > +       int     dir;
> > +       int     data_out;
> > +       int     data_in;
> 
> Why are all these members int? They should be u8 from reading your code.
> 
> > +       int     ngpio;
> > +};

Not necessarily 8 bit, but definitely unsigned.

> > +static struct vt8500_gpio_data vt8500_data = {
> > +       .num_banks      = 7,
> > +       .banks  = {
> > +               VT8500_BANK(0x00, 0x20, 0x40, 0x60, 26),
> > +               VT8500_BANK(0x04, 0x24, 0x44, 0x64, 28),
> > +               VT8500_BANK(0x08, 0x28, 0x48, 0x68, 31),
> > +               VT8500_BANK(0x0C, 0x2C, 0x4C, 0x6C, 19),
> > +               VT8500_BANK(0x10, 0x30, 0x50, 0x70, 19),
> > +               VT8500_BANK(0x14, 0x34, 0x54, 0x74, 23),
> > +               VT8500_BANK(-1, 0x3C, 0x5C, 0x7C, 9),    /* external gpio */
> 
> What on earth are all those magic numbers?
> 
> I *guess* they're enabling some default GPIO settings etc.

No, they are the register offsets you quoted above, per bank. There
is no easy way to abstract these, and I suggested putting the
values into the source code rather than describing each bank
separately in the .dtsi file.

My feeling however is that the "vt8500_chip->regoff" is wrong, which
would mean only the first bank works. The code adds the same offsets
per bank once more that it sets in this bank table.

	Arnd

  reply	other threads:[~2012-08-08  9:19 UTC|newest]

Thread overview: 79+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-08-08  1:39 [PATCH 0/8] *** ARM: Update arch-vt8500 to Devicetree *** Tony Prisk
2012-08-08  1:39 ` Tony Prisk
2012-08-08  1:39 ` Tony Prisk
2012-08-08  1:39 ` Tony Prisk
2012-08-08  1:39 ` [PATCH 1/8] arm: vt8500: Add device tree files for VIA/Wondermedia SoC's Tony Prisk
2012-08-08  1:39   ` Tony Prisk
2012-08-08  1:39   ` Tony Prisk
2012-08-08  1:39   ` Tony Prisk
2012-08-08 18:43   ` Stephen Warren
2012-08-08 18:43     ` Stephen Warren
2012-08-08 18:43     ` Stephen Warren
     [not found]     ` <5022B342.7080606-3lzwWm7+Weoh9ZMKESR00Q@public.gmane.org>
2012-08-08 20:08       ` Tony Prisk
2012-08-08 20:08         ` Tony Prisk
2012-08-08  1:39 ` [PATCH 2/8] rtc: vt8500: Add devicetree support for vt8500-rtc Tony Prisk
2012-08-08  1:39   ` Tony Prisk
2012-08-08  1:39   ` Tony Prisk
2012-08-08  1:39   ` Tony Prisk
2012-08-08  1:39 ` [PATCH 3/8] serial: vt8500: Add devicetree support for vt8500-serial Tony Prisk
2012-08-08  1:39   ` Tony Prisk
2012-08-08  1:39   ` Tony Prisk
2012-08-08  1:39   ` Tony Prisk
2012-08-08  1:39 ` [PATCH 4/8] usb: vt8500: Add devicetree support for vt8500-ehci and -uhci Tony Prisk
2012-08-08  1:39   ` Tony Prisk
2012-08-08  1:39   ` Tony Prisk
2012-08-08  1:39   ` Tony Prisk
2012-08-08  1:39 ` [PATCH 5/8] video: vt8500: Add devicetree support for vt8500-fb and wm8505-fb Tony Prisk
2012-08-08  1:39   ` Tony Prisk
2012-08-08  1:39   ` Tony Prisk
2012-08-08  1:39   ` Tony Prisk
2012-08-08 18:47   ` Stephen Warren
2012-08-08 18:47     ` Stephen Warren
2012-08-08 18:47     ` Stephen Warren
     [not found]     ` <5022B444.2020501-3lzwWm7+Weoh9ZMKESR00Q@public.gmane.org>
2012-08-08 19:37       ` Tony Prisk
2012-08-08 19:37         ` Tony Prisk
     [not found]         ` <76F764B079F92A4E843589C893D0A022D1DCA8D0-A1+cU8XkcJSYgi1/3OOQJ8krCUz0bFs7@public.gmane.org>
2012-08-15 19:21           ` Stephen Warren
2012-08-15 19:21             ` Stephen Warren
2012-08-08  1:39 ` [PATCH 6/8] arm: vt8500: Update arch-vt8500 to devicetree support Tony Prisk
2012-08-08  1:39   ` Tony Prisk
2012-08-08  1:39   ` Tony Prisk
2012-08-08  1:39   ` Tony Prisk
2012-08-08 18:58   ` Stephen Warren
2012-08-08 18:58     ` Stephen Warren
2012-08-08 18:58     ` Stephen Warren
     [not found]     ` <5022B6EE.7060006-3lzwWm7+Weoh9ZMKESR00Q@public.gmane.org>
2012-08-08 19:37       ` Tony Prisk
2012-08-08 19:37         ` Tony Prisk
2012-08-08  1:39 ` [PATCH 7/8] arm: vt8500: doc: Add device tree bindings for arch-vt8500 devices Tony Prisk
2012-08-08  1:39   ` Tony Prisk
2012-08-08  1:39   ` Tony Prisk
2012-08-08  1:39   ` Tony Prisk
2012-08-08  1:39 ` [PATCH 8/8] ARM: vt8500: gpio: Devicetree support for arch-vt8500 Tony Prisk
2012-08-08  1:39   ` Tony Prisk
2012-08-08  1:39   ` Tony Prisk
2012-08-08  1:39   ` Tony Prisk
2012-08-08  9:11   ` [rtc-linux] " Linus Walleij
2012-08-08  9:11     ` Linus Walleij
2012-08-08  9:11     ` Linus Walleij
2012-08-08  9:11     ` Linus Walleij
2012-08-08  9:19     ` Arnd Bergmann [this message]
2012-08-08  9:19       ` Arnd Bergmann
2012-08-08  9:19       ` Arnd Bergmann
2012-08-08  9:19       ` Arnd Bergmann
2012-08-08 14:28       ` Linus Walleij
2012-08-08 14:28         ` Linus Walleij
2012-08-08 14:28         ` Linus Walleij
2012-08-08 14:28         ` Linus Walleij
     [not found]         ` <CACRpkdabUWpDsBhz4ZEJNhEuqw-U+v-HrX7NcWoNLeuenv5t9A-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2012-08-08 19:46           ` Tony Prisk
2012-08-08 19:46             ` Tony Prisk
2012-08-08 18:38   ` Stephen Warren
2012-08-08 18:38     ` Stephen Warren
2012-08-08 18:38     ` Stephen Warren
2012-08-08 18:38     ` Stephen Warren
2012-08-08 19:17     ` Arnd Bergmann
2012-08-08 19:17       ` Arnd Bergmann
2012-08-08 19:17       ` Arnd Bergmann
2012-08-08 19:17       ` Arnd Bergmann
     [not found] ` <1344389967-8465-1-git-send-email-linux-ci5G2KO2hbZ+pU9mqzGVBQ@public.gmane.org>
2012-08-08  2:40   ` [PATCH 0/8] *** ARM: Update arch-vt8500 to Devicetree *** Tony Prisk
2012-08-08  2:40     ` Tony Prisk
2012-08-19  1:22 ` Marcos Silva Cunha
2012-08-19  1:22   ` Marcos Silva Cunha

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=201208080919.52592.arnd@arndb.de \
    --to=arnd@arndb.de \
    --cc=linux-arm-kernel@lists.infradead.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.