All of lore.kernel.org
 help / color / mirror / Atom feed
From: Bruno Randolf <br1@einfach.org>
To: Linus Walleij <linus.walleij@linaro.org>,
	Mika Westerberg <mika.westerberg@linux.intel.com>,
	Mathias Nyman <mathias.nyman@linux.intel.com>,
	David Cohen <david.a.cohen@intel.com>,
	Simon Guinot <simon.guinot@sequanux.org>
Cc: Wim Van Sebroeck <wim@iguana.be>,
	"linux-gpio@vger.kernel.org" <linux-gpio@vger.kernel.org>
Subject: Re: [PATCH] gpio: add GPIO support for SMSC SCH311x
Date: Fri, 29 Nov 2013 17:21:32 +0000	[thread overview]
Message-ID: <5298CD1C.9010704@einfach.org> (raw)
In-Reply-To: <CACRpkdaXO+tYRq=uyQiAopRDPwKv1_F4yZwCWr4-JL1xnio4Wg@mail.gmail.com>

Hello Linus!

Thank you for your review. I will try to address your concerns, as my
time and knowledge permits ;)

On 11/29/2013 02:40 PM, Linus Walleij wrote:
>> +       depends on X86
> 
> Really? What stops me from soldering this onto one of my ARM or
> MIPS boards?

I suppose nothing, but I don't know. Will remove it.

> ISA-style probing, yeah I had to accept this last time ...
> So no discovery on this system, no ACPI?

The system has ACPI, but GPIOs were not working... I don't know enough
about ACPI, but if someone tells me what to look for I can try to debug it.

>> +/* internal variables */
>> +static struct platform_device *sch311x_gpio_pdev;
>> +static struct platform_device *i2c_gpio_pdev;
>> +
>> +static struct {
>> +       unsigned short runtime_reg;     /* Runtime Register base address */
>> +       spinlock_t lock;                /* lock for io operations */
>> +} sch311x_gpio_data;
> 
> This is a singleton. What happens the day someone mounts two
> of these chips on a board?

Right, this part comes from the watchdog driver for the same chip
(watchdog/sch311x_wdt.c), so I thought I can do the same. That's not a
good excuse, I know...

> Please devm_kzalloc() a state container
> instead, look in other GPIO drivers for examples of this.

Do you have a good example?

>> +static inline void sch311x_sio_enter(int sio_config_port)
>> +{
>> +       outb(0x55, sio_config_port);
>> +}
> 
> 0x55?
> 
>> +static inline void sch311x_sio_exit(int sio_config_port)
>> +{
>> +       outb(0xaa, sio_config_port);
>> +}
> 
> 0xaa?

> Please #define thise magic values.

Again, comes from watchdog/sch311x_wdt.c... will #define.

>> +static int sch311x_gpio_get(struct gpio_chip *chip, unsigned offset)
>> +{
>> +       unsigned char data = inb(sch311x_gpio_data.runtime_reg + GP1);
>> +       return ((data >> offset) & 1);
> 
> Use this:
> 
> #include <linux/bitops.h>
> 
> return !!(data & BIT(offset));

Ah, thanks!!!

>> +#if 0
>> +       /* configure as "push/pull": output voltage is 3.3V */
>> +       outb(SCH311X_GPIO_CONF_OUT, sch311x_gpio_data.runtime_reg + sch311x_gpio_conf[offset]);
> 
> No #if 0 code! Delete this.

OK, sorry.

>> +#else
>> +       /* configure as "open drain": output voltage is 5V on an unconnected PIN */
>> +       outb(SCH311X_GPIO_CONF_OUT | SCH311X_GPIO_CONF_OPEN_DRAIN,
>> +            sch311x_gpio_data.runtime_reg + sch311x_gpio_conf[offset]);
> 
> So if you really only support push/pull, open drain and maybe even
> open source, then it's OK to use the GPIO subsystem. If you start
> doing more things, this becomes a matter of pin control.

It can just be configured as just push/pull or open drain. Is there any
way this can be configured within the GPIO subsystem?

> At the very least I want the driver split up in two files: one that
> adds the GPIO driver for an arbitrary number of pins, and one
> that adds this boards' configuration. You can put the latter in
> drivers/platform/x86 or wherever, just not in drivers/gpio.

OK, that makes sense.

bruno


  parent reply	other threads:[~2013-11-29 17:21 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-11-28  0:18 [PATCH] gpio: add GPIO support for SMSC SCH311x Bruno Randolf
2013-11-29 14:40 ` Linus Walleij
2013-11-29 15:02   ` Mika Westerberg
2013-11-29 19:55     ` Linus Walleij
2013-11-29 17:21   ` Bruno Randolf [this message]
2013-11-29 20:00     ` Linus Walleij
2013-11-29 20:37   ` Simon Guinot
2013-12-04 12:33     ` Linus Walleij
2013-11-29 18:56 ` Simon Guinot
2013-12-02 12:43   ` Bruno Randolf
2013-12-05 16:56     ` Simon Guinot
2013-12-10 10:18       ` Bruno Randolf
2013-12-10 11:44         ` Simon Guinot
2013-12-10 12:19           ` Bruno Randolf
  -- strict thread matches above, loose matches on Subject: below --
2013-12-04  0:23 Bruno Randolf
2013-12-04  1:06 ` David Cohen
2013-12-10 11:51 ` Linus Walleij
2013-12-10 17:05   ` Matthew Garrett
2013-12-11  4:05   ` Vivien Didelot
2013-12-12 19:50     ` Linus Walleij
2013-12-16  2:46       ` Vivien Didelot
2013-12-20  9:07         ` Linus Walleij

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=5298CD1C.9010704@einfach.org \
    --to=br1@einfach.org \
    --cc=david.a.cohen@intel.com \
    --cc=linus.walleij@linaro.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=mathias.nyman@linux.intel.com \
    --cc=mika.westerberg@linux.intel.com \
    --cc=simon.guinot@sequanux.org \
    --cc=wim@iguana.be \
    /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.