public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Marek Vasut <marex@denx.de>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 1/2 v4] ARM : Add GPIO Driver and IOMUX definition for S3C2440
Date: Wed, 2 May 2012 04:44:03 +0200	[thread overview]
Message-ID: <201205020444.03736.marex@denx.de> (raw)
In-Reply-To: <CALrBrZ0eBLRXfFSK+3r2Y_4T4PGr-K8fDbQq=w=6tZtM8UgTdg@mail.gmail.com>

Dear Minkyu Kang,

> Dear Gabriel Huau,
> 
> On 30 April 2012 23:11, Gabriel Huau <contact@huau-gabriel.fr> wrote:
> > It's now possible to use the gpio driver interface
> > for s3c2440. This patch add iomux definitions too.
> > 
> > Signed-off-by: Gabriel Huau <contact@huau-gabriel.fr>
> > ---
> > Changes for v2:
> >        - Modification of the coding style
> >        - Add my email address to copyright
> >        - Remove a typedef
> >        - Move some defines to driver file
> > 
> > Changes for v3:
> >        - Cleanup coding style
> >        - Changement of the commit message
> > 
> > Changes for v4:
> >        - Add a nice commit message
> > 
> >  arch/arm/include/asm/arch-s3c24x0/gpio.h  |  171
> > ++++++++++++++++++++++++ arch/arm/include/asm/arch-s3c24x0/iomux.h |
> >  200 +++++++++++++++++++++++++++++ drivers/gpio/Makefile                
> >     |    1 +
> >  drivers/gpio/s3c2440_gpio.c               |   94 ++++++++++++++
> >  4 files changed, 466 insertions(+)
> >  create mode 100644 arch/arm/include/asm/arch-s3c24x0/gpio.h
> >  create mode 100644 arch/arm/include/asm/arch-s3c24x0/iomux.h
> >  create mode 100644 drivers/gpio/s3c2440_gpio.c
> > 
> > diff --git a/drivers/gpio/s3c2440_gpio.c b/drivers/gpio/s3c2440_gpio.c
> > new file mode 100644
> > index 0000000..12a9043
> > --- /dev/null
> > +++ b/drivers/gpio/s3c2440_gpio.c
> > @@ -0,0 +1,94 @@
> > +/*
> > + * Copyright (C) 2012
> > + * Gabriel Huau <contact@huau-gabriel.fr>
> > + *
> > + * See file CREDITS for list of people who contributed to this
> > + * project.
> > + *
> > + * This program is free software; you can redistribute it and/or
> > + * modify it under the terms of the GNU General Public License as
> > + * published by the Free Software Foundation; either version 2 of
> > + * the License, or (at your option) any later version.
> > + *
> > + * This program is distributed in the hope that it will be useful,
> > + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> > + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> > + * GNU General Public License for more details.
> > + *
> > + * You should have received a copy of the GNU General Public License
> > + * along with this program; if not, write to the Free Software
> > + * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
> > + * MA 02111-1307 USA
> > + */
> > +#include <common.h>
> > +#include <asm/arch/s3c2440.h>
> > +#include <asm/gpio.h>
> > +#include <asm/io.h>
> > +
> > +#define GPIO_INPUT  0x0
> > +#define GPIO_OUTPUT 0x1
> > +
> > +/* 0x4 means that we want DAT and not CON register */
> > +#define GPIO_PORT(x)   ((((x) >> 5) & 0x3) + 0x4)
> > +#define GPIO_BIT(x)            ((x) & 0x3f)
> > +
> > +/*
> > + * It's how we calculate the full port address
> > + * We have to get the number of the port + 1 (Port A is at 0x56000001
> > ...) + * We move it at the second digit, and finally we add 0x4 because
> > we want + * to modify GPIO DAT and not CON
> > + */
> > +#define GPIO_FULLPORT(x) (S3C24X0_GPIO_BASE | ((GPIO_PORT(gpio) + 1) <<
> > 1)) +
> > +int gpio_set_value(unsigned gpio, int value)
> > +{
> > +       unsigned l = readl(GPIO_FULLPORT(gpio));
> > +       unsigned port = GPIO_FULLPORT(gpio);
> > +
> > +       /*
> > +        * All GPIO Port have a configuration on
> > +        * 2 bits excepted the first GPIO (A) which
> > +        * have only 1 bit of configuration.
> > +        */
> > +       if (value)
> > +               if (!GPIO_PORT(gpio))
> > +                       l |= (0x1 << GPIO_BIT(gpio));
> > +               else
> > +                       l |= (0x3 << GPIO_BIT(gpio));
> > +       else
> > +               if (!GPIO_PORT(gpio))
> > +                       l &= ~(0x1 << GPIO_BIT(gpio));
> > +               else
> > +                       l &= ~(0x3 << GPIO_BIT(gpio));
> 
> Need brace at this if..else statement.

I wanted to ask why, but ... C isn't python, good point ;-)

> > +       return writel(port, l);
> > +}
> > +
> > +int gpio_get_value(unsigned gpio)
> > +{
> > +       unsigned l = readl(GPIO_FULLPORT(gpio));
> > +
> > +       if (GPIO_PORT(gpio) == 0) /* PORT A */
> > +               return (l >> GPIO_BIT(gpio)) & 0x1;
> > +       return (l >> GPIO_BIT(gpio)) & 0x3;
> > +}
> > +
> > +int gpio_request(unsigned gpio, const char *label)
> > +{
> > +       return 0;
> > +}
> > +
> > +int gpio_free(unsigned gpio)
> > +{
> > +       return 0;
> > +}
> > +
> > +int gpio_direction_input(unsigned gpio)
> > +{
> > +       return writel(GPIO_FULLPORT(gpio), GPIO_INPUT << GPIO_BIT(gpio));
> > +}
> > +
> > +int gpio_direction_output(unsigned gpio, int value)
> > +{
> > +       writel(GPIO_FULLPORT(gpio), GPIO_OUTPUT << GPIO_BIT(gpio));
> > +       return gpio_set_value(gpio, value);
> > +}
> > --
> > 1.7.9.5
> > 
> > _______________________________________________
> > U-Boot mailing list
> > U-Boot at lists.denx.de
> > http://lists.denx.de/mailman/listinfo/u-boot
> 
> Thanks.
> Minkyu Kang.

  reply	other threads:[~2012-05-02  2:44 UTC|newest]

Thread overview: 49+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-04-29 21:27 [U-Boot] [PATCH 0/2] Add support for MINI2440 (s3c2440) Gabriel Huau
2012-04-29 21:27 ` [U-Boot] [PATCH 1/2] Add GPIO Driver and IOMUX definition for S3C2440 Gabriel Huau
2012-04-29 23:29   ` Marek Vasut
2012-04-30 11:05     ` Gabriel Huau
2012-04-30 12:25       ` Marek Vasut
2012-04-30 13:18         ` Gabriel Huau
2012-04-29 21:27 ` [U-Boot] [PATCH 2/2 v5] Add support for MINI2440 (s3c2440) Gabriel Huau
2012-04-29 23:32   ` Marek Vasut
2012-04-29 21:32 ` [U-Boot] [PATCH 0/2] " Wolfgang Denk
2012-04-29 21:39   ` Gabriel Huau
2012-04-30  7:32     ` Wolfgang Denk
2012-04-29 23:26 ` Marek Vasut
2012-04-30 11:03 ` [U-Boot] [PATCH 1/2 v2] Add GPIO Driver and IOMUX definition for S3C2440 Gabriel Huau
2012-04-30 12:26   ` Marek Vasut
2012-04-30 11:07 ` [U-Boot] [PATCH 0/2] Add support for MINI2440 (s3c2440) Gabriel Huau
2012-04-30 11:35   ` Wolfgang Denk
2012-04-30 11:55     ` Gabriel Huau
2012-04-30 11:11 ` [U-Boot] [PATCH 2/2 v6] " Gabriel Huau
2012-04-30 12:29   ` Marek Vasut
2012-04-30 13:16 ` [U-Boot] [PATCH 1/2 v3] Add GPIO Driver and IOMUX definition for S3C2440 Gabriel Huau
2012-04-30 13:16   ` [U-Boot] [PATCH 2/2 v7] Add support for MINI2440 (s3c2440) Gabriel Huau
2012-04-30 13:21     ` Marek Vasut
2012-04-30 13:31       ` Gabriel Huau
2012-04-30 13:49         ` Marek Vasut
2012-04-30 13:20   ` [U-Boot] [PATCH 1/2 v3] Add GPIO Driver and IOMUX definition for S3C2440 Marek Vasut
2012-04-30 13:29     ` Gabriel Huau
2012-04-30 13:50       ` Marek Vasut
2012-04-30 13:38 ` [U-Boot] [PATCH 2/2 v8] Add support for MINI2440 (s3c2440) Gabriel Huau
2012-04-30 13:51   ` Marek Vasut
2012-05-02  0:15   ` Minkyu Kang
2012-04-30 14:11 ` [U-Boot] [PATCH 1/2 v4] ARM : Add GPIO Driver and IOMUX definition for S3C2440 Gabriel Huau
2012-04-30 14:11   ` [U-Boot] [PATCH 2/2 v9] ARM : Add support for MINI2440 (s3c2440) Gabriel Huau
2012-04-30 14:17     ` Marek Vasut
2012-05-02  0:17     ` Minkyu Kang
2012-04-30 14:16   ` [U-Boot] [PATCH 1/2 v4] ARM : Add GPIO Driver and IOMUX definition for S3C2440 Marek Vasut
2012-05-02  1:21   ` Minkyu Kang
2012-05-02  2:44     ` Marek Vasut [this message]
2012-05-02  6:16       ` Minkyu Kang
2012-05-02 18:40         ` Scott Wood
2012-05-02 20:16           ` Gabriel Huau
2012-05-02 20:21             ` Scott Wood
2012-04-30 15:44 ` [U-Boot] [PATCH 0/2] Add support for MINI2440 (s3c2440) Gabriel Huau
2012-05-02 20:48 ` [U-Boot] [PATCH 2/2 v10] ARM : " Gabriel Huau
2012-10-03  8:54   ` Albert ARIBAUD
2012-05-02 20:49 ` [U-Boot] [PATCH 1/2 v5] ARM : Add GPIO Driver and IOMUX definition for S3C2440 Gabriel Huau
2012-10-03  8:55   ` Albert ARIBAUD
2012-05-21 20:38 ` [U-Boot] [PATCH 0/2] Add support for MINI2440 (s3c2440) Gabriel Huau
2012-05-21 21:55   ` Wolfgang Denk
2012-05-22 18:04     ` Gabriel Huau

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=201205020444.03736.marex@denx.de \
    --to=marex@denx.de \
    --cc=u-boot@lists.denx.de \
    /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