mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Arve Hjønnevåg" <arve@android.com>
To: Pavel Machek <pavel@ucw.cz>
Cc: H Hartley Sweeten <hartleys@visionengravers.com>,
	Ryan Mallon <ryan@bluewatersys.com>,
	Daniel Walker <dwalker@codeaurora.org>,
	Iliyan Malchev <malchev@google.com>,
	Brian Swetland <swetland@google.com>,
	kernel list <linux-kernel@vger.kernel.org>,
	linux-arm-kernel <linux-arm-kernel@lists.infradead.org>
Subject: Re: GPIO support for HTC Dream
Date: Fri, 11 Dec 2009 14:40:41 -0800	[thread overview]
Message-ID: <d6200be20912111440k427c5013j2b17191bcbae2d52@mail.gmail.com> (raw)
In-Reply-To: <20091211221015.GB24456@elf.ucw.cz>

On Fri, Dec 11, 2009 at 2:10 PM, Pavel Machek <pavel@ucw.cz> wrote:
> Hi!
>
> Ok, thanks to Ryan and everyone... You were right, the code was way
> too complex.
>
> Cleaning it up according to Hartley's great howto resulted in:
>
>  arch/arm/Kconfig                     |    1
>  arch/arm/mach-msm/board-dream-gpio.c |  327 +++++++++--------------------------
>  arch/arm/mach-msm/board-dream.c      |   24 --
>  arch/arm/mach-msm/generic_gpio.c     |  270 ----------------------------
>  arch/arm/mach-msm/gpio_chip.h        |   30 ---
>  kernel/printk.c                      |    6
>  6 files changed, 102 insertions(+), 556 deletions(-)
>
>> As Ryan says, using gpiolib will clean this up immensely.
>>
>> It appears the what you really have for gpio's is 7 8-bit ports that start
>> with gpio number 128.  Each port appears to only have one control register.
>> This register is written with a '1' to drive the gpio as a high output and
>> '0' to drive it as a low output or to use it as an input.  Not really
>> sure if this is correct since the code is a bit screwy.
>
> It seems it is, because it seems to work.
>
>> Your current code is written so that all of the gpio's are in one "chip".
>> Because of this you are having to calculate the 'reg' needed to access the
>> gpio whenever you need to read or write to a gpio.
>>
>> If you follow the ep93xx implementation you can break the whole thing down
>> into 'banks' and simplify everything.  Something like:
>
> ...and get 100 lines of results, instead of 600... Yep, thanks.
>
> Now, it will still need some cleanups -- I'm not sure if gpios are
> dream-specific or generic for whole msm.... I kind of assume they
> should be generic for msm. Google people, can you help?

I'm not exactly sure what you are asking. Gpios in general are not
dream specific, the code in board-dream-gpio.c is. Some gpios (e.g.
DREAM_4_BALL_UP_0) are used for a dream specific function, but point
to a gpio that is generic to the msm architecture.

>
>> static struct dream_gpio_chip dream_gpio_banks[] = {
>>       DREAM_GPIO_BANK("MISC2", 0x00, DREAM_GPIO_MISC2_BASE),
>>       DREAM_GPIO_BANK("MISC3", 0x02, DREAM_GPIO_MISC3_BASE),
>>       DREAM_GPIO_BANK("MISC4", 0x04, DREAM_GPIO_MISC4_BASE),
>>       DREAM_GPIO_BANK("MISC5", 0x06, DREAM_GPIO_MISC5_BASE),
>>       DREAM_GPIO_BANK("INT2", 0x08, DREAM_GPIO_INT2_BASE),
>>       DREAM_GPIO_BANK("MISC1", 0x0a, DREAM_GPIO_MISC1_BASE),
>>       DREAM_GPIO_BANK("VIRTUAL", 0x12, DREAM_GPIO_VIRTUAL_BASE),
>> };
>
> Yep, that did the trick.
>
>> With this you can now just access the dream_gpio_chip data in all
>> the member function using the to_dream_gpio_chip() macro.
>>
>> I agree with Ryan and think you would be better off in the long
>> run to re-code this and use gpiolib.  You might also want to break
>> out all the gpio interrupt stuff and submit it as a seperate patch.
>
> Will do. Here's how the patch looks now.
>
> diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
> index 1c4119c..8bb8546 100644
> --- a/arch/arm/Kconfig
> +++ b/arch/arm/Kconfig
> @@ -565,6 +565,8 @@ config ARCH_MSM
>        select CPU_V6
>        select GENERIC_TIME
>        select GENERIC_CLOCKEVENTS
> +       select GENERIC_GPIO
> +       select ARCH_REQUIRE_GPIOLIB

Please do not do this in a board specific change. You have not changed
the msm generic gpio support to use gpiolib.

-- 
Arve Hjønnevåg

  reply	other threads:[~2009-12-11 22:40 UTC|newest]

Thread overview: 59+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-12-08 10:28 Pavel Machek
2009-12-08 20:22 ` Ryan Mallon
2009-12-08 21:37   ` Pavel Machek
2009-12-08 21:53     ` Ryan Mallon
2009-12-10 16:26       ` Pavel Machek
2009-12-08 21:56     ` Arve Hjønnevåg
2009-12-09 11:32       ` Pavel Machek
2009-12-08 21:46   ` Pavel Machek
2009-12-08 22:03     ` Joe Perches
2009-12-09 11:46       ` Pavel Machek
2009-12-08 22:10     ` Ryan Mallon
2009-12-09 23:40       ` Ryan Mallon
2009-12-10 17:24         ` Pavel Machek
2009-12-10 17:41           ` Mark Brown
2009-12-10 19:49           ` Ryan Mallon
2009-12-10 23:14             ` H Hartley Sweeten
2009-12-11 19:58               ` Pavel Machek
2009-12-11 22:10               ` Pavel Machek
2009-12-11 22:40                 ` Arve Hjønnevåg [this message]
2009-12-11 23:12                   ` H Hartley Sweeten
2009-12-16 22:53                     ` Pavel Machek
2009-12-16 23:03                       ` Daniel Walker
2009-12-11 23:04                 ` H Hartley Sweeten
2009-12-14  6:45                   ` Pavel Machek
2009-12-14 17:54                     ` Daniel Walker
2009-12-14 18:12                       ` H Hartley Sweeten
2009-12-15  6:40                         ` Arve Hjønnevåg
2009-12-15 19:12                           ` Pavel Machek
2009-12-15 20:07                             ` Daniel Walker
2009-12-15 21:21                               ` Pavel Machek
2009-12-15 20:48                         ` Jamie Lokier
2009-12-15 21:07                           ` Brian Swetland
2009-12-14 19:00                     ` H Hartley Sweeten
2009-12-15 19:47                       ` Pavel Machek
2009-12-15 20:15                         ` H Hartley Sweeten
2009-12-15 20:47                           ` Pavel Machek
2009-12-15 21:16                           ` [patch] " Pavel Machek
2009-12-25 17:10                             ` Pavel Machek
2009-12-25 23:49                               ` Daniel Walker
2009-12-26  8:51                                 ` Pavel Machek
2009-12-15 20:24                         ` Ryan Mallon
2009-12-15 20:44                           ` Pavel Machek
2009-12-15  6:48                     ` Arve Hjønnevåg
2009-12-11 23:28                 ` Russell King - ARM Linux
2009-12-11 23:50                   ` H Hartley Sweeten
2009-12-14  6:24                   ` Pavel Machek
2009-12-10 16:57       ` Pavel Machek
2009-12-08 22:45 ` Russell King - ARM Linux
2009-12-09  0:39   ` Arve Hjønnevåg
2009-12-09 11:37     ` Pavel Machek
2009-12-09 11:42       ` Arve Hjønnevåg
2009-12-10 16:27         ` Pavel Machek
2009-12-09 16:18       ` Daniel Walker
2009-12-13 21:29         ` Pavel Machek
2009-12-13 21:38           ` Brian Swetland
2009-12-15 19:09             ` Pavel Machek
2009-12-14 17:40           ` Daniel Walker
2009-12-15 19:10             ` Pavel Machek
2009-12-09 11:41   ` Pavel Machek

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=d6200be20912111440k427c5013j2b17191bcbae2d52@mail.gmail.com \
    --to=arve@android.com \
    --cc=dwalker@codeaurora.org \
    --cc=hartleys@visionengravers.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=malchev@google.com \
    --cc=pavel@ucw.cz \
    --cc=ryan@bluewatersys.com \
    --cc=swetland@google.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®