gpio.c 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. /* linux/arch/arm/mach-s3c2410/gpio.c
  2. *
  3. * Copyright (c) 2004-2006 Simtec Electronics
  4. * Ben Dooks <ben@simtec.co.uk>
  5. *
  6. * S3C2410 GPIO support
  7. *
  8. * This program is free software; you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License as published by
  10. * the Free Software Foundation; either version 2 of the License, or
  11. * (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program; if not, write to the Free Software
  20. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  21. */
  22. #include <linux/kernel.h>
  23. #include <linux/init.h>
  24. #include <linux/module.h>
  25. #include <linux/interrupt.h>
  26. #include <linux/ioport.h>
  27. #include <asm/hardware.h>
  28. #include <asm/irq.h>
  29. #include <asm/io.h>
  30. #include <asm/arch/regs-gpio.h>
  31. int s3c2410_gpio_irqfilter(unsigned int pin, unsigned int on,
  32. unsigned int config)
  33. {
  34. void __iomem *reg = S3C24XX_EINFLT0;
  35. unsigned long flags;
  36. unsigned long val;
  37. if (pin < S3C2410_GPG8 || pin > S3C2410_GPG15)
  38. return -1;
  39. config &= 0xff;
  40. pin -= S3C2410_GPG8;
  41. reg += pin & ~3;
  42. local_irq_save(flags);
  43. /* update filter width and clock source */
  44. val = __raw_readl(reg);
  45. val &= ~(0xff << ((pin & 3) * 8));
  46. val |= config << ((pin & 3) * 8);
  47. __raw_writel(val, reg);
  48. /* update filter enable */
  49. val = __raw_readl(S3C24XX_EXTINT2);
  50. val &= ~(1 << ((pin * 4) + 3));
  51. val |= on << ((pin * 4) + 3);
  52. __raw_writel(val, S3C24XX_EXTINT2);
  53. local_irq_restore(flags);
  54. return 0;
  55. }
  56. EXPORT_SYMBOL(s3c2410_gpio_irqfilter);