devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: James Hogan <james.hogan@imgtec.com>
To: Linus Walleij <linus.walleij@linaro.org>
Cc: "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	Grant Likely <grant.likely@secretlab.ca>,
	Rob Herring <rob.herring@calxeda.com>,
	"devicetree-discuss@lists.ozlabs.org"
	<devicetree-discuss@lists.ozlabs.org>,
	Rob Landley <rob@landley.net>,
	"linux-doc@vger.kernel.org" <linux-doc@vger.kernel.org>
Subject: Re: [PATCH 6/8] gpio-tz1090: add TZ1090 gpio driver
Date: Fri, 26 Apr 2013 10:22:37 +0100	[thread overview]
Message-ID: <517A475D.8060606@imgtec.com> (raw)
In-Reply-To: <CACRpkdbzYpQqe4yabAwFSAG2rPstT8jM_--LssHi=ttUYtu1ug@mail.gmail.com>

Hi Linus,

Thanks for reviewing these patches.

On 26/04/13 00:01, Linus Walleij wrote:
> On Tue, Apr 23, 2013 at 4:33 PM, James Hogan <james.hogan@imgtec.com> wrote:
> 
>> Add a GPIO driver for the main GPIOs found in the TZ1090 (Comet) SoC.
>> This doesn't include low-power GPIOs as they're controlled separately
>> via the Powerdown Controller (PDC) registers.
>>
>> The driver is instantiated by device tree and supports interrupts for
>> all GPIOs.
>>
>> Signed-off-by: James Hogan <james.hogan@imgtec.com>
>> Cc: Grant Likely <grant.likely@secretlab.ca>
>> Cc: Rob Herring <rob.herring@calxeda.com>
>> Cc: Rob Landley <rob@landley.net>
>> Cc: Linus Walleij <linus.walleij@linaro.org>
>> Cc: linux-doc@vger.kernel.org
> 
> (...)
>> +  - #gpio-cells: Should be 2. The syntax of the gpio specifier used by client
>> +    nodes should have the following values.
>> +       <[phandle of the gpio controller node]
>> +        [gpio number within the gpio bank]
>> +        [standard Linux gpio flags]>
> 
> So when someone using this device tree for Symbian or Windows
> Mobile start to work, what does "standard Linux gpio flags" tell them?

well this is what of_gpio.h says:
> /*
>  * This is Linux-specific flags. By default controllers' and Linux' mapping
>  * match, but GPIO controllers are free to translate their own flags to
>  * Linux-specific in their .xlate callback. Though, 1:1 mapping is recommended.
>  */
> enum of_gpio_flags {
> 	OF_GPIO_ACTIVE_LOW = 0x1,
> };

So do you mean that the bindings docs should just explicitly state those
flag values rather than referring to Linux?

>> +  Bank subnode optional properties:
>> +  - gpio-ranges: Mapping to pin controller pins
> 
> Here you seem to use DT GPIO ranges, yet the pinctrl driver registers
> some GPIO range, care to explain how that fits together?

I'll look into this a bit deeper. I suspect the one in the pinctrl
driver shouldn't be there.

> +#include <asm/global_lock.h>
> 
> What on earth is that. I can only fear it. I don't like the
> looks of that thing.

Yes, it's not particularly pleasant.

The TZ1090 is designed for digital radios. It has a 2-threaded Meta HTP
as the CPU (which might typically run Linux on one thread and an RTOS
doing audio decode and driving the audio hardware on the other), and 2
UCCPs (these are Radio Processing Units each containing a small Meta
MTX, which will typically interface to a tuner chip and do things like
DAB/FM radio or WiFi).

So basically a bunch of global registers (e.g. pinctrl and gpio) are
shared between all 3 cores (up to 4 OSes). The __global_lock2 should do
all that is required to ensure exclusive access to the register (as long
as the other OSes do something similar when they access the same
registers). This is one of the reasons why there are 3 gpio banks with
separate interrupts, and each bank's interrupt is optional in this driver.

> 
> (...)
>> +/* Convenience register accessors */
>> +static void tz1090_gpio_write(struct tz1090_gpio_bank *bank,
>> +                             unsigned int reg_offs, u32 data)
>> +{
>> +       iowrite32(data, bank->reg + reg_offs);
>> +}
>> +
>> +static u32 tz1090_gpio_read(struct tz1090_gpio_bank *bank,
>> +                           unsigned int reg_offs)
>> +{
>> +       return ioread32(bank->reg + reg_offs);
>> +}
> 
> The pinctrl driver included the keyword "inline" for these so
> this should be consistent and do that too.

Okay

> +static inline void _tz1090_gpio_clear_bit(struct tz1090_gpio_bank *bank,
> +                                         unsigned int reg_offs,
> +                                         unsigned int offset)
> +{
> +       u32 value;
> +
> +       value = tz1090_gpio_read(bank, reg_offs);
> +       value &= ~(0x1 << offset);
> 
> I usually do this:
> 
> #include <linux/bitops.h>
> 
> value &= ~BIT(offset);

Good idea.

>> +/* caller must hold LOCK2 */
>> +static inline void _tz1090_gpio_mod_bit(struct tz1090_gpio_bank *bank,
>> +                                       unsigned int reg_offs,
>> +                                       unsigned int offset,
>> +                                       int val)
> 
> If val is used as it is, make it a bool.
> 
>> +{
>> +       u32 value;
>> +
>> +       value = tz1090_gpio_read(bank, reg_offs);
>> +       value &= ~(0x1 << offset);
>> +       value |= !!val << offset;
> 
> You're claming val to [0,1] obviously it's a bool.

It's often simply passing on things like the int output_value from the
direction_output and set callbacks. Is it necessary to confuse things by
making it a bool and then turning it back into an int to write into the
register?

> This is also very nice and handling the toggling edge in
> a working way.

Credit goes to some engineers from PURE for the toggling magic :-)

> Overall looking very nice, just needs som polishing, and I'm way
> scared about that global lock.

Thanks again for taking the time to review.

Cheers
James


  reply	other threads:[~2013-04-26  9:22 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-04-23 14:33 [PATCH 0/8] Add some TZ1090 SoC infrastructure James Hogan
2013-04-23 14:33 ` [PATCH 2/8] metag: minimal TZ1090 (Comet) " James Hogan
2013-04-23 15:25   ` Arnd Bergmann
2013-04-23 16:06     ` James Hogan
2013-04-24 13:26       ` Catalin Marinas
2013-04-24 14:51         ` James Hogan
2013-04-25 15:21           ` James Hogan
2013-04-23 14:33 ` [PATCH 3/8] irq-imgpdc: add ImgTec PDC irqchip driver James Hogan
2013-04-23 15:09   ` Thomas Gleixner
2013-04-24  9:14     ` James Hogan
2013-04-24  9:32       ` Thomas Gleixner
2013-04-25 11:25     ` James Hogan
2013-04-23 14:33 ` [PATCH 4/8] metag: tz1090: add <asm/soc-tz1090/gpio.h> James Hogan
2013-04-25 21:52   ` Linus Walleij
2013-04-23 14:33 ` [PATCH 5/8] pinctrl-tz1090: add TZ1090 pinctrl driver James Hogan
2013-04-25 22:39   ` Linus Walleij
2013-04-26 11:54     ` James Hogan
2013-05-03  9:13       ` Linus Walleij
2013-05-03 12:23         ` James Hogan
2013-05-03 13:03           ` Linus Walleij
2013-05-03 15:06             ` James Hogan
     [not found]               ` <5183D262.7000107-1AXoQHu6uovQT0dZR+AlfA@public.gmane.org>
2013-05-14 11:52                 ` Linus Walleij
2013-05-14 12:22                   ` James Hogan
2013-05-15 19:07                     ` Linus Walleij
2013-05-16  9:12                       ` James Hogan
2013-05-17  6:47                         ` Linus Walleij
2013-04-23 14:33 ` [PATCH 6/8] gpio-tz1090: add TZ1090 gpio driver James Hogan
2013-04-25 23:01   ` Linus Walleij
2013-04-26  9:22     ` James Hogan [this message]
2013-05-03  8:49       ` Linus Walleij
2013-05-03  9:09         ` James Hogan
2013-05-15 19:09           ` Linus Walleij
2013-04-23 14:33 ` [PATCH 7/8] pinctrl-tz1090-pdc: add TZ1090 PDC pinctrl driver James Hogan
     [not found] ` <1366727607-27444-1-git-send-email-james.hogan-1AXoQHu6uovQT0dZR+AlfA@public.gmane.org>
2013-04-23 14:33   ` [PATCH 1/8] metag: of_platform_populate from arch generic code James Hogan
2013-04-23 14:33   ` [PATCH 8/8] gpio-tz1090pdc: add TZ1090 PDC gpio driver James Hogan

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=517A475D.8060606@imgtec.com \
    --to=james.hogan@imgtec.com \
    --cc=devicetree-discuss@lists.ozlabs.org \
    --cc=grant.likely@secretlab.ca \
    --cc=linus.walleij@linaro.org \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rob.herring@calxeda.com \
    --cc=rob@landley.net \
    /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;
as well as URLs for NNTP newsgroup(s).