From: Manuel Lauss <manuel.lauss@googlemail.com>
To: Ralf Baechle <ralf@linux-mips.org>
Cc: Linux-MIPS <linux-mips@linux-mips.org>
Subject: Re: [PATCH 0/5] Alchemy GPIO rewrite v7
Date: Tue, 09 Jun 2009 08:37:59 +0200 [thread overview]
Message-ID: <4A2E0347.3010009@gmail.com> (raw)
In-Reply-To: <20090608185516.GA15590@linux-mips.org>
Ralf Baechle wrote:
> Thanks, queued. Looking much better than earlier versions but there
> still are many magic numbers being used in the code.
Thanks!
Does the below patch address your concerns?
---
From: Manuel Lauss <manuel.lauss@gmail.com>
Subject: [PATCH] Alchemy: gpio: document magic numbers.
Signed-off-by: Manuel Lauss <manuel.lauss@gmail.com>
---
arch/mips/include/asm/mach-au1x00/au1000.h | 3 +++
arch/mips/include/asm/mach-au1x00/gpio-au1000.h | 13 +++++++++----
2 files changed, 12 insertions(+), 4 deletions(-)
diff --git a/arch/mips/include/asm/mach-au1x00/au1000.h b/arch/mips/include/asm/mach-au1x00/au1000.h
index 854e95f..b672390 100644
--- a/arch/mips/include/asm/mach-au1x00/au1000.h
+++ b/arch/mips/include/asm/mach-au1x00/au1000.h
@@ -1550,6 +1550,9 @@ enum soc_au1200_ints {
#define GPIO2_INTENABLE (GPIO2_BASE + 0x10)
#define GPIO2_ENABLE (GPIO2_BASE + 0x14)
+#define GPIO2_ENABLE_RESET (1 << 1) /* reset peripheral */
+#define GPIO2_ENABLE_CLK (1 << 0) /* clock enable */
+
/* Power Management */
#define SYS_SCRATCH0 0xB1900018
#define SYS_SCRATCH1 0xB190001C
diff --git a/arch/mips/include/asm/mach-au1x00/gpio-au1000.h b/arch/mips/include/asm/mach-au1x00/gpio-au1000.h
index 127d4ed..cc7a998 100644
--- a/arch/mips/include/asm/mach-au1x00/gpio-au1000.h
+++ b/arch/mips/include/asm/mach-au1x00/gpio-au1000.h
@@ -275,10 +275,15 @@ static inline void __alchemy_gpio2_mod_dir(int gpio, int to_out)
au_sync();
}
+/* GPIO2_OUTPUT expects the levels of output pins in bits 0-15;
+ * bits 16-31 indicate whether the level change should be carried out
+ * for a particular pin.
+ */
static inline void alchemy_gpio2_set_value(int gpio, int v)
{
unsigned long mask;
- mask = ((v) ? 0x00010001 : 0x00010000) << (gpio - ALCHEMY_GPIO2_BASE);
+ mask = (1 << 16) | (v ? 1 : 0); /* set up en | value */
+ mask <<= gpio - ALCHEMY_GPIO2_BASE;
au_writel(mask, GPIO2_OUTPUT);
au_sync();
}
@@ -420,9 +425,9 @@ static inline void alchemy_gpio2_disable_int(int gpio2)
*/
static inline void alchemy_gpio2_enable(void)
{
- au_writel(3, GPIO2_ENABLE); /* reset, clock enabled */
+ au_writel(GPIO2_ENABLE_RESET | GPIO2_ENABLE_CLK, GPIO2_ENABLE);
au_sync();
- au_writel(1, GPIO2_ENABLE); /* clock enabled */
+ au_writel(GPIO2_ENABLE_CLK, GPIO2_ENABLE);
au_sync();
}
@@ -433,7 +438,7 @@ static inline void alchemy_gpio2_enable(void)
*/
static inline void alchemy_gpio2_disable(void)
{
- au_writel(2, GPIO2_ENABLE); /* reset, clock disabled */
+ au_writel(GPIO2_ENABLE_RESET, GPIO2_ENABLE);
au_sync();
}
--
1.6.3.1
prev parent reply other threads:[~2009-06-09 6:37 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-06-06 12:09 [PATCH 0/5] Alchemy GPIO rewrite v7 Manuel Lauss
2009-06-06 12:09 ` [PATCH 1/5] Alchemy: remove unused au1000_gpio.h header Manuel Lauss
2009-06-06 12:09 ` [PATCH 2/5] Alchemy: rewrite GPIO support Manuel Lauss
2009-06-06 12:09 ` [PATCH 3/5] Alchemy: mtx-1: use linux gpio api Manuel Lauss
2009-06-06 12:09 ` [PATCH 4/5] Alchemy: xxs1500: " Manuel Lauss
2009-06-06 12:09 ` [PATCH 5/5] Alchemy: devboards: convert to gpio calls Manuel Lauss
2009-06-08 18:55 ` [PATCH 0/5] Alchemy GPIO rewrite v7 Ralf Baechle
2009-06-09 6:37 ` Manuel Lauss [this message]
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=4A2E0347.3010009@gmail.com \
--to=manuel.lauss@googlemail.com \
--cc=linux-mips@linux-mips.org \
--cc=ralf@linux-mips.org \
/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.