mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Eric Miao <eric.y.miao@gmail.com>
To: LKML <linux-kernel@vger.kernel.org>
Cc: linux-arm-kernel <linux-arm-kernel@lists.arm.linux.org.uk>,
	Eric Miao <eric.miao@marvell.com>
Subject: [PATCH] [ARM] pxa: add GPIO support for pxa168
Date: Thu, 19 Feb 2009 21:45:54 +0800	[thread overview]
Message-ID: <1235051161-8858-6-git-send-email-eric.y.miao@gmail.com> (raw)
In-Reply-To: <1235051161-8858-5-git-send-email-eric.y.miao@gmail.com>

From: Eric Miao <eric.miao@marvell.com>

Signed-off-by: Eric Miao <eric.miao@marvell.com>
---
 arch/arm/Kconfig                      |    2 +
 arch/arm/mach-mmp/include/mach/gpio.h |   36 +++++++++++++++++++++++++++++++++
 arch/arm/mach-mmp/pxa168.c            |   19 +++++++++++++++++
 3 files changed, 57 insertions(+), 0 deletions(-)
 create mode 100644 arch/arm/mach-mmp/include/mach/gpio.h

diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index 7eaf910..165d396 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -490,6 +490,8 @@ config ARCH_PXA
 config ARCH_MMP
 	bool "Marvell PXA168"
 	depends on MMU
+	select GENERIC_GPIO
+	select ARCH_REQUIRE_GPIOLIB
 	select HAVE_CLK
 	select COMMON_CLKDEV
 	select GENERIC_TIME
diff --git a/arch/arm/mach-mmp/include/mach/gpio.h b/arch/arm/mach-mmp/include/mach/gpio.h
new file mode 100644
index 0000000..0b1443b
--- /dev/null
+++ b/arch/arm/mach-mmp/include/mach/gpio.h
@@ -0,0 +1,36 @@
+#ifndef __ASM_MACH_GPIO_H
+#define __ASM_MACH_GPIO_H
+
+#include <mach/addr-map.h>
+#include <mach/irqs.h>
+#include <asm-generic/gpio.h>
+
+#define GPIO_REGS_VIRT	(APB_VIRT_BASE + 0x19000)
+
+#define BANK_OFF(n)	(((n) < 3) ? (n) << 2 : 0x100 + (((n) - 3) << 2))
+#define GPIO_REG(x)	(*((volatile u32 *)(GPIO_REGS_VIRT + (x))))
+
+#define NR_BUILTIN_GPIO	(128)
+
+#define gpio_to_bank(gpio)	((gpio) >> 5)
+#define gpio_to_irq(gpio)	(IRQ_GPIO_START + (gpio))
+#define irq_to_gpio(irq)	((irq) - IRQ_GPIO_START)
+
+
+#define __gpio_is_inverted(gpio)	(0)
+#define __gpio_is_occupied(gpio)	(0)
+
+/* NOTE: these macros are defined here to make optimization of
+ * gpio_{get,set}_value() to work when 'gpio' is a constant.
+ * Usage of these macros otherwise is no longer recommended,
+ * use generic GPIO API whenever possible.
+ */
+#define GPIO_bit(gpio)	(1 << ((gpio) & 0x1f))
+
+#define GPLR(x)		GPIO_REG(BANK_OFF((x) >> 5) + 0x00)
+#define GPDR(x)		GPIO_REG(BANK_OFF((x) >> 5) + 0x0c)
+#define GPSR(x)		GPIO_REG(BANK_OFF((x) >> 5) + 0x18)
+#define GPCR(x)		GPIO_REG(BANK_OFF((x) >> 5) + 0x24)
+
+#include <plat/gpio.h>
+#endif /* __ASM_MACH_GPIO_H */
diff --git a/arch/arm/mach-mmp/pxa168.c b/arch/arm/mach-mmp/pxa168.c
index 546db19..db2356b 100644
--- a/arch/arm/mach-mmp/pxa168.c
+++ b/arch/arm/mach-mmp/pxa168.c
@@ -12,19 +12,38 @@
 #include <linux/kernel.h>
 #include <linux/init.h>
 #include <linux/list.h>
+#include <linux/io.h>
+#include <linux/clk.h>
 
 #include <mach/addr-map.h>
 #include <mach/cputype.h>
 #include <mach/regs-apbc.h>
 #include <mach/irqs.h>
+#include <mach/gpio.h>
 #include <mach/dma.h>
 
 #include "common.h"
 #include "clock.h"
 
+#define APMASK(i)	(GPIO_REGS_VIRT + BANK_OFF(i) + 0x09c)
+
+static void __init pxa168_init_gpio(void)
+{
+	int i;
+
+	clk_enable(&clk_pxa168_gpio);
+
+	/* unmask GPIO edge detection for all 4 banks - APMASKx */
+	for (i = 0; i < 4; i++)
+		__raw_writel(0xffffffff, APMASK(i));
+
+	pxa_init_gpio(IRQ_PXA168_GPIOX, 0, 127, NULL);
+}
+
 void __init pxa168_init_irq(void)
 {
 	icu_init_irq();
+	pxa168_init_gpio();
 }
 
 /* clocks for external use */
-- 
1.6.0.4


  reply	other threads:[~2009-02-19 13:49 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-02-19 13:45 [PATCH 0/12] ARM: add base support for Marvell PXA168 Eric Miao
2009-02-19 13:45 ` [PATCH] [ARM] pxa: introduce plat-pxa for PXA common code and add DMA support Eric Miao
2009-02-19 13:45   ` [PATCH] [ARM] pxa: move common GPIO handling code into plat-pxa Eric Miao
2009-02-19 13:45     ` [PATCH] [ARM] pxa: move common MFP " Eric Miao
2009-02-19 13:45       ` [PATCH] [ARM] pxa: add base support for Marvell's PXA168 processor line Eric Miao
2009-02-19 13:45         ` Eric Miao [this message]
2009-02-19 13:45           ` [PATCH] [ARM] pxa: add MFP support for pxa168 Eric Miao
2009-02-19 13:45             ` [PATCH] [ARM] pxa: accept old ARM926 compatible CPUID " Eric Miao
2009-02-19 13:45               ` [PATCH] [ARM] pxa: allow reuse of serial driver " Eric Miao
2009-02-19 13:45                 ` [PATCH] [ARM] pxa/zylonite2: add support for console uart Eric Miao
2009-02-19 13:45                   ` [PATCH] [ARM] pxa/zylonite2: add support for debug ethernet Eric Miao
2009-02-19 13:46                     ` [PATCH] [ARM] pxa: add defconfig for pxa168-based platforms Eric Miao
2009-02-19 13:46                       ` [PATCH] MAINTAINERS: update pxa168 maintainers Eric Miao
2009-02-20  6:50                         ` Jason Chagas
2009-02-24  1:36                           ` Eric Miao
2009-02-19 13:58 ` [PATCH 0/12] ARM: add base support for Marvell PXA168 Eric Miao

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=1235051161-8858-6-git-send-email-eric.y.miao@gmail.com \
    --to=eric.y.miao@gmail.com \
    --cc=eric.miao@marvell.com \
    --cc=linux-arm-kernel@lists.arm.linux.org.uk \
    --cc=linux-kernel@vger.kernel.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 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®