]> pilppa.com Git - linux-2.6-omap-h63xx.git/commitdiff
[POWERPC] cpm2: Add cpm2_set_pin().
authorScott Wood <scottwood@freescale.com>
Mon, 16 Jul 2007 18:32:24 +0000 (13:32 -0500)
committerKumar Gala <galak@kernel.crashing.org>
Thu, 4 Oct 2007 16:02:18 +0000 (11:02 -0500)
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 <scottwood@freescale.com>
Signed-off-by: Kumar Gala <galak@kernel.crashing.org>
arch/powerpc/sysdev/cpm2_common.c
include/asm-powerpc/cpm2.h

index c6dc0bf614b3458c6910191f2b6f451a4cbbfeae..fc4c995653810a1d59a6f93826428063859d00f1 100644 (file)
@@ -422,3 +422,36 @@ 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;
+       u32 res[3];
+};
+
+void cpm2_set_pin(int port, int pin, int flags)
+{
+       struct cpm2_ioports __iomem *iop =
+               (struct cpm2_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);
+
+       if (flags & CPM_PIN_OPENDRAIN)
+               setbits32(&iop[port].odr, pin);
+       else
+               clrbits32(&iop[port].odr, pin);
+}
index 41a45db0c8b1a2ef21638d24d503234bb3ddf9c4..d7b57ac55892a2f99def04431ee94b6fa6937770 100644 (file)
@@ -1247,5 +1247,14 @@ enum cpm_clk {
 extern int cpm2_clk_setup(enum cpm_clk_target target, int clock, int mode);
 extern int cpm2_smc_clk_setup(enum cpm_clk_target target, int clock);
 
+#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
+#define CPM_PIN_OPENDRAIN 8
+
+void cpm2_set_pin(int port, int pin, int flags);
+
 #endif /* __CPM2__ */
 #endif /* __KERNEL__ */