gpio.c 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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 <linux/gpio.h>
  19. #include <asm/mach/arch.h>
  20. #include <asm/mach/map.h>
  21. #include <mach/regs-gpio.h>
  22. #include <mach/hardware.h>
  23. #include <plat/gpio-core.h>
  24. int s3c2412_gpio_set_sleepcfg(unsigned int pin, unsigned int state)
  25. {
  26. struct s3c_gpio_chip *chip = s3c_gpiolib_getchip(pin);
  27. unsigned long offs = pin - chip->chip.base;
  28. unsigned long flags;
  29. unsigned long slpcon;
  30. offs *= 2;
  31. if (pin < S3C2410_GPB(0))
  32. return -EINVAL;
  33. if (pin >= S3C2410_GPF(0) &&
  34. pin <= S3C2410_GPG(16))
  35. return -EINVAL;
  36. if (pin > S3C2410_GPH(16))
  37. return -EINVAL;
  38. local_irq_save(flags);
  39. slpcon = __raw_readl(chip->base + 0x0C);
  40. slpcon &= ~(3 << offs);
  41. slpcon |= state << offs;
  42. __raw_writel(slpcon, chip->base + 0x0C);
  43. local_irq_restore(flags);
  44. return 0;
  45. }
  46. EXPORT_SYMBOL(s3c2412_gpio_set_sleepcfg);