gpio.c 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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. #include <linux/kernel.h>
  15. #include <linux/types.h>
  16. #include <linux/module.h>
  17. #include <linux/interrupt.h>
  18. #include <asm/mach/arch.h>
  19. #include <asm/mach/map.h>
  20. #include <mach/regs-gpio.h>
  21. #include <mach/hardware.h>
  22. int s3c2412_gpio_set_sleepcfg(unsigned int pin, unsigned int state)
  23. {
  24. void __iomem *base = S3C24XX_GPIO_BASE(pin);
  25. unsigned long offs = S3C2410_GPIO_OFFSET(pin);
  26. unsigned long flags;
  27. unsigned long slpcon;
  28. offs *= 2;
  29. if (pin < S3C2410_GPIO_BANKB)
  30. return -EINVAL;
  31. if (pin >= S3C2410_GPIO_BANKF &&
  32. pin <= S3C2410_GPIO_BANKG)
  33. return -EINVAL;
  34. if (pin > (S3C2410_GPIO_BANKH + 32))
  35. return -EINVAL;
  36. local_irq_save(flags);
  37. slpcon = __raw_readl(base + 0x0C);
  38. slpcon &= ~(3 << offs);
  39. slpcon |= state << offs;
  40. __raw_writel(slpcon, base + 0x0C);
  41. local_irq_restore(flags);
  42. return 0;
  43. }
  44. EXPORT_SYMBOL(s3c2412_gpio_set_sleepcfg);