GPIO.txt 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. S3C2410 GPIO Control
  2. ====================
  3. Introduction
  4. ------------
  5. The s3c2410 kernel provides an interface to configure and
  6. manipulate the state of the GPIO pins, and find out other
  7. information about them.
  8. There are a number of conditions attached to the configuration
  9. of the s3c2410 GPIO system, please read the Samsung provided
  10. data-sheet/users manual to find out the complete list.
  11. Headers
  12. -------
  13. See include/asm-arm/arch-s3c2410/regs-gpio.h for the list
  14. of GPIO pins, and the configuration values for them. This
  15. is included by using #include <asm/arch/regs-gpio.h>
  16. The GPIO management functions are defined in the hardware
  17. header include/asm-arm/arch-s3c2410/hardware.h which can be
  18. included by #include <asm/arch/hardware.h>
  19. A useful amount of documentation can be found in the hardware
  20. header on how the GPIO functions (and others) work.
  21. Whilst a number of these functions do make some checks on what
  22. is passed to them, for speed of use, they may not always ensure
  23. that the user supplied data to them is correct.
  24. PIN Numbers
  25. -----------
  26. Each pin has an unique number associated with it in regs-gpio.h,
  27. eg S3C2410_GPA0 or S3C2410_GPF1. These defines are used to tell
  28. the GPIO functions which pin is to be used.
  29. Configuring a pin
  30. -----------------
  31. The following function allows the configuration of a given pin to
  32. be changed.
  33. void s3c2410_gpio_cfgpin(unsigned int pin, unsigned int function);
  34. Eg:
  35. s3c2410_gpio_cfgpin(S3C2410_GPA0, S3C2410_GPA0_ADDR0);
  36. s3c2410_gpio_cfgpin(S3C2410_GPE8, S3C2410_GPE8_SDDAT1);
  37. which would turn GPA0 into the lowest Address line A0, and set
  38. GPE8 to be connected to the SDIO/MMC controller's SDDAT1 line.
  39. Reading the current configuration
  40. ---------------------------------
  41. The current configuration of a pin can be read by using:
  42. s3c2410_gpio_getcfg(unsigned int pin);
  43. The return value will be from the same set of values which can be
  44. passed to s3c2410_gpio_cfgpin().
  45. Configuring a pull-up resistor
  46. ------------------------------
  47. A large proportion of the GPIO pins on the S3C2410 can have weak
  48. pull-up resistors enabled. This can be configured by the following
  49. function:
  50. void s3c2410_gpio_pullup(unsigned int pin, unsigned int to);
  51. Where the to value is zero to set the pull-up off, and 1 to enable
  52. the specified pull-up. Any other values are currently undefined.
  53. Getting the state of a PIN
  54. --------------------------
  55. The state of a pin can be read by using the function:
  56. unsigned int s3c2410_gpio_getpin(unsigned int pin);
  57. This will return either zero or non-zero. Do not count on this
  58. function returning 1 if the pin is set.
  59. Setting the state of a PIN
  60. --------------------------
  61. The value an pin is outputing can be modified by using the following:
  62. void s3c2410_gpio_setpin(unsigned int pin, unsigned int to);
  63. Which sets the given pin to the value. Use 0 to write 0, and 1 to
  64. set the output to 1.
  65. Getting the IRQ number associated with a PIN
  66. --------------------------------------------
  67. The following function can map the given pin number to an IRQ
  68. number to pass to the IRQ system.
  69. int s3c2410_gpio_getirq(unsigned int pin);
  70. Note, not all pins have an IRQ.
  71. Authour
  72. -------
  73. Ben Dooks, 03 October 2004
  74. (c) 2004 Ben Dooks, Simtec Electronics