Thread (129 messages) flat view 129 messages, 11 authors, 2007-07-19

Re: [PATCH 28/61] Add cpm2_set_pin().

From: Kumar Gala <hidden>
Date: 2007-07-18 15:02:14

On Jul 17, 2007, at 8:35 PM, Scott Wood wrote:
quoted hunk ↗ jump to hunk
This provides a generic way for board code to set up CPM pins, rather
than directly poking magic values into registers.

Signed-off-by: Scott Wood <redacted>
---
 arch/powerpc/sysdev/cpm2_common.c |   28 ++++++++++++++++++++++++++++
 include/asm-ppc/cpm2.h            |    8 ++++++++
 2 files changed, 36 insertions(+), 0 deletions(-)
diff --git a/arch/powerpc/sysdev/cpm2_common.c b/arch/powerpc/ 
sysdev/cpm2_common.c
index 7e3a983..0a62df7 100644
--- a/arch/powerpc/sysdev/cpm2_common.c
+++ b/arch/powerpc/sysdev/cpm2_common.c
@@ -338,3 +338,31 @@ void *cpm_dpram_addr(unsigned long offset)
 	return (void *)(im_dprambase + offset);
 }
 EXPORT_SYMBOL(cpm_dpram_addr);
+
+struct cpm2_ioports {
+	u32	dir, par, sor, odr, dat;
__be32?
+	u32	res[3];
+};
+
+void cpm2_set_pin(int port, int pin, int flags)
Can we make the function take a pointer to the port directly?
+{
+	struct cpm2_ioports __iomem *iop =
+		(struct cpm_ioports __iomem *)&cpm2_immr->im_ioport;
+
+	pin = 1 << (31 - pin);
+
+	if (flags & CPM_PIN_OUTPUT)
+		setbits32(&iop[port].dir, pin);
+	else
+		clrbits32(&iop[port].dir, pin);
+
+	if (!(flags & CPM_PIN_GPIO))
+		setbits32(&iop[port].par, pin);
+	else
+		clrbits32(&iop[port].par, pin);
+
+	if (flags & CPM_PIN_SECONDARY)
+		setbits32(&iop[port].sor, pin);
+	else
+		clrbits32(&iop[port].sor, pin);
should we only do this if !(flags & CPM_PIN_GPIO)?

Any reason we don't also set odr here?
quoted hunk ↗ jump to hunk
+}
diff --git a/include/asm-ppc/cpm2.h b/include/asm-ppc/cpm2.h
index 12a2860..0e7ffb6 100644
--- a/include/asm-ppc/cpm2.h
+++ b/include/asm-ppc/cpm2.h
@@ -1244,5 +1244,13 @@ enum cpm_clk {

 extern int cpm2_clk_setup(enum cpm_clk_target target, int clock,  
int mode);

+#define CPM_PIN_INPUT     0
+#define CPM_PIN_OUTPUT    1
+#define CPM_PIN_PRIMARY   0
+#define CPM_PIN_SECONDARY 2
+#define CPM_PIN_GPIO      4
+
+void cpm2_set_pin(int port, int pin, int flags);
+
 #endif /* __CPM2__ */
 #endif /* __KERNEL__ */
-- 
1.5.0.3

_______________________________________________
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help