linux/arch/arm/mach-s3c2412/gpio.c
<<
>>
Prefs
   1/* linux/arch/arm/mach-s3c2412/gpio.c
   2 *
   3 * Copyright (c) 2007 Simtec Electronics
   4 *      Ben Dooks <ben@simtec.co.uk>
   5 *
   6 * http://armlinux.simtec.co.uk/.
   7 *
   8 * S3C2412/S3C2413 specific GPIO support
   9 *
  10 * This program is free software; you can redistribute it and/or modify
  11 * it under the terms of the GNU General Public License version 2 as
  12 * published by the Free Software Foundation.
  13*/
  14
  15#include <linux/kernel.h>
  16#include <linux/types.h>
  17#include <linux/module.h>
  18#include <linux/interrupt.h>
  19
  20#include <asm/mach/arch.h>
  21#include <asm/mach/map.h>
  22
  23#include <mach/regs-gpio.h>
  24
  25#include <mach/hardware.h>
  26
  27int s3c2412_gpio_set_sleepcfg(unsigned int pin, unsigned int state)
  28{
  29        void __iomem *base = S3C24XX_GPIO_BASE(pin);
  30        unsigned long offs = S3C2410_GPIO_OFFSET(pin);
  31        unsigned long flags;
  32        unsigned long slpcon;
  33
  34        offs *= 2;
  35
  36        if (pin < S3C2410_GPIO_BANKB)
  37                return -EINVAL;
  38
  39        if (pin >= S3C2410_GPIO_BANKF &&
  40            pin <= S3C2410_GPIO_BANKG)
  41                return -EINVAL;
  42
  43        if (pin > (S3C2410_GPIO_BANKH + 32))
  44                return -EINVAL;
  45
  46        local_irq_save(flags);
  47
  48        slpcon = __raw_readl(base + 0x0C);
  49
  50        slpcon &= ~(3 << offs);
  51        slpcon |= state << offs;
  52
  53        __raw_writel(slpcon, base + 0x0C);
  54
  55        local_irq_restore(flags);
  56
  57        return 0;
  58}
  59
  60EXPORT_SYMBOL(s3c2412_gpio_set_sleepcfg);
  61
lxr.linux.no kindly hosted by Redpill Linpro AS, provider of Linux consulting and operations services since 1995.