All of lore.kernel.org
 help / color / mirror / Atom feed
From: Hauke Mehrtens <hauke@hauke-m.de>
To: Florian Fainelli <florian@openwrt.org>
Cc: john@phrozen.org, ralf@linux-mips.org, linux-mips@linux-mips.org,
	linux-wireless@vger.kernel.org, zajec5@gmail.com, m@bues.ch
Subject: Re: [PATCH 4/8] bcma: add GPIO driver
Date: Tue, 20 Nov 2012 23:32:46 +0100	[thread overview]
Message-ID: <50AC050E.3070206@hauke-m.de> (raw)
In-Reply-To: <1849463.Q1jRPkmcje@flexo>

On 11/20/2012 10:42 AM, Florian Fainelli wrote:
> Hi Hauke,
> 
> This driver looks good to me, a couple of minor comments below.
> 
> On Monday 19 November 2012 23:57:53 Hauke Mehrtens wrote:
>> Register a GPIO driver to access the GPIOs provided by the chip.
>> The GPIOs of the SoC should always start at 0 and the other GPIOs could
>> start at a random position. There is just one SoC in a system and when
>> they start at 0 the number is predictable.
>>
>> Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
>> ---
> [snip]
>> +#ifdef CONFIG_BCMA_DRIVER_GPIO
>> +/* driver_gpio.c */
>> +int bcma_gpio_init(struct bcma_drv_cc *cc);
>> +#else
>> +static inline int bcma_gpio_init(struct bcma_drv_cc *cc)
>> +{
>> +	return 0;
>> +}
>> +#endif /* CONFIG_BCMA_DRIVER_GPIO */
> 
> I wonder if it would not make more sense here to return -ENODEV or -ENOTSUPP
> so we can identify a kernel not being built with BCMA GPIO support.

I added that and changed the logging for such a message to debug level,
but I do not know if this would confuse people just using bcma/ssb for
their wireless pcie cards.

>> +
>>  #endif
>> diff --git a/drivers/bcma/driver_gpio.c b/drivers/bcma/driver_gpio.c
>> new file mode 100644
>> index 0000000..2b9e404
>> --- /dev/null
>> +++ b/drivers/bcma/driver_gpio.c
>> @@ -0,0 +1,95 @@
>> +/*
>> + * Broadcom specific AMBA
>> + * GPIO driver
>> + *
>> + * Copyright 2011, Broadcom Corporation
>> + * Copyright 2012, Hauke Mehrtens <hauke@hauke-m.de>
>> + *
>> + * Licensed under the GNU/GPL. See COPYING for details.
>> + */
>> +
>> +#include <linux/gpio.h>
>> +#include <linux/export.h>
>> +#include <linux/bcma/bcma.h>
>> +
>> +#include "bcma_private.h"
>> +
>> +static inline struct bcma_drv_cc *bcma_gpio_get_cc(struct gpio_chip *chip)
>> +{
>> +	return container_of(chip, struct bcma_drv_cc, gpio);
>> +}
>> +
>> +static int bcma_gpio_get_value(struct gpio_chip *chip, unsigned gpio)
>> +{
>> +	struct bcma_drv_cc *cc = bcma_gpio_get_cc(chip);
>> +
>> +	return !!bcma_chipco_gpio_in(cc, 1 << gpio);
>> +}
>> +
>> +static void bcma_gpio_set_value(struct gpio_chip *chip, unsigned gpio,
>> +				int value)
>> +{
>> +	struct bcma_drv_cc *cc = bcma_gpio_get_cc(chip);
>> +
>> +	bcma_chipco_gpio_out(cc, 1 << gpio, value ? 1 << gpio : 0);
> 
> This is a little confusing at first, because most GPIO "drivers" actually just
> pass the value directly.

The bcma_chipco_gpio API exposes the raw registers, and the conversion
of the generic GPIO API to these registers is done here. Should I change
something here?

> [snip]
> 
>> +int bcma_gpio_init(struct bcma_drv_cc *cc)
>> +{
>> +	struct gpio_chip *chip = &cc->gpio;
>> +
>> +	chip->label		= "bcma_gpio";
>> +	chip->owner		= THIS_MODULE;
>> +	chip->request		= bcma_gpio_request;
>> +	chip->free		= bcma_gpio_free;
>> +	chip->get		= bcma_gpio_get_value;
>> +	chip->set		= bcma_gpio_set_value;
>> +	chip->direction_input	= bcma_gpio_direction_input;
>> +	chip->direction_output	= bcma_gpio_direction_output;
>> +	chip->ngpio		= 16;
>> +	if (cc->core->bus->hosttype == BCMA_HOSTTYPE_SOC)
>> +		chip->base		= 0;
>> +	else
>> +		chip->base		= -1;
> 
> You might want to add a comment to explain why base auto-assignment is not used
> when the host type is SOC.

I added a comment.

> --
> Florian
> 

  reply	other threads:[~2012-11-20 22:33 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-11-19 22:57 [PATCH 0/8] bcma/ssb/BCM47XX: add GPIO driver to ssb/bcma Hauke Mehrtens
2012-11-19 22:57 ` [PATCH 1/8] bcma: add locking around GPIO register accesses Hauke Mehrtens
2012-11-20  8:10   ` John Crispin
2012-11-20 21:05     ` Hauke Mehrtens
2012-11-19 22:57 ` [PATCH 2/8] bcma: add bcma_chipco_gpio_pull{up,down} Hauke Mehrtens
2012-11-19 22:57 ` [PATCH 3/8] bcma: add comment to bcma_chipco_gpio_control Hauke Mehrtens
2012-11-19 22:57 ` [PATCH 4/8] bcma: add GPIO driver Hauke Mehrtens
2012-11-20  9:42   ` Florian Fainelli
2012-11-20 22:32     ` Hauke Mehrtens [this message]
2012-11-19 22:57 ` [PATCH 5/8] ssb: add ssb_chipco_gpio_pull{up,down} Hauke Mehrtens
2012-11-19 22:57 ` [PATCH 6/8] ssb: add locking around gpio register accesses Hauke Mehrtens
2012-11-19 22:57 ` [PATCH 7/8] ssb: add GPIO driver Hauke Mehrtens
2012-11-19 23:18   ` [PATCH v2 " Hauke Mehrtens
2012-11-20  8:12   ` [PATCH " John Crispin
2012-11-20 21:07     ` Hauke Mehrtens
2012-11-19 22:57 ` [PATCH 8/8] MIPS: BCM47XX: remove " Hauke Mehrtens
2012-11-20  9:44   ` Florian Fainelli

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=50AC050E.3070206@hauke-m.de \
    --to=hauke@hauke-m.de \
    --cc=florian@openwrt.org \
    --cc=john@phrozen.org \
    --cc=linux-mips@linux-mips.org \
    --cc=linux-wireless@vger.kernel.org \
    --cc=m@bues.ch \
    --cc=ralf@linux-mips.org \
    --cc=zajec5@gmail.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 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.