diff options
author | Scott Wood <scottwood@freescale.com> | 2007-07-16 14:32:24 -0400 |
---|---|---|
committer | Kumar Gala <galak@kernel.crashing.org> | 2007-10-04 12:02:18 -0400 |
commit | 7f21f52940212c25b4387c2450018e161043549a (patch) | |
tree | 9df63e5508151be0c6fd9e02b692f5ca1edf4394 /arch | |
parent | 2652d4ec4a363487d0106a8bf51f1b081dd7e397 (diff) |
[POWERPC] cpm2: Add cpm2_set_pin().
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>
Diffstat (limited to 'arch')
-rw-r--r-- | arch/powerpc/sysdev/cpm2_common.c | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/arch/powerpc/sysdev/cpm2_common.c b/arch/powerpc/sysdev/cpm2_common.c index c6dc0bf614b3..fc4c99565381 100644 --- a/arch/powerpc/sysdev/cpm2_common.c +++ b/arch/powerpc/sysdev/cpm2_common.c | |||
@@ -422,3 +422,36 @@ void *cpm_dpram_addr(unsigned long offset) | |||
422 | return (void *)(im_dprambase + offset); | 422 | return (void *)(im_dprambase + offset); |
423 | } | 423 | } |
424 | EXPORT_SYMBOL(cpm_dpram_addr); | 424 | EXPORT_SYMBOL(cpm_dpram_addr); |
425 | |||
426 | struct cpm2_ioports { | ||
427 | u32 dir, par, sor, odr, dat; | ||
428 | u32 res[3]; | ||
429 | }; | ||
430 | |||
431 | void cpm2_set_pin(int port, int pin, int flags) | ||
432 | { | ||
433 | struct cpm2_ioports __iomem *iop = | ||
434 | (struct cpm2_ioports __iomem *)&cpm2_immr->im_ioport; | ||
435 | |||
436 | pin = 1 << (31 - pin); | ||
437 | |||
438 | if (flags & CPM_PIN_OUTPUT) | ||
439 | setbits32(&iop[port].dir, pin); | ||
440 | else | ||
441 | clrbits32(&iop[port].dir, pin); | ||
442 | |||
443 | if (!(flags & CPM_PIN_GPIO)) | ||
444 | setbits32(&iop[port].par, pin); | ||
445 | else | ||
446 | clrbits32(&iop[port].par, pin); | ||
447 | |||
448 | if (flags & CPM_PIN_SECONDARY) | ||
449 | setbits32(&iop[port].sor, pin); | ||
450 | else | ||
451 | clrbits32(&iop[port].sor, pin); | ||
452 | |||
453 | if (flags & CPM_PIN_OPENDRAIN) | ||
454 | setbits32(&iop[port].odr, pin); | ||
455 | else | ||
456 | clrbits32(&iop[port].odr, pin); | ||
457 | } | ||