GPIO.txt 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  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. GPIOLIB
  12. -------
  13. With the event of the GPIOLIB in drivers/gpio, support for some
  14. of the GPIO functions such as reading and writing a pin will
  15. be removed in favour of this common access method.
  16. Once all the extant drivers have been converted, the functions
  17. listed below will be removed (they may be marked as __deprecated
  18. in the near future).
  19. - s3c2410_gpio_getpin
  20. - s3c2410_gpio_setpin
  21. Headers
  22. -------
  23. See arch/arm/mach-s3c2410/include/mach/regs-gpio.h for the list
  24. of GPIO pins, and the configuration values for them. This
  25. is included by using #include <mach/regs-gpio.h>
  26. The GPIO management functions are defined in the hardware
  27. header arch/arm/mach-s3c2410/include/mach/hardware.h which can be
  28. included by #include <mach/hardware.h>
  29. A useful amount of documentation can be found in the hardware
  30. header on how the GPIO functions (and others) work.
  31. Whilst a number of these functions do make some checks on what
  32. is passed to them, for speed of use, they may not always ensure
  33. that the user supplied data to them is correct.
  34. PIN Numbers
  35. -----------
  36. Each pin has an unique number associated with it in regs-gpio.h,
  37. eg S3C2410_GPA0 or S3C2410_GPF1. These defines are used to tell
  38. the GPIO functions which pin is to be used.
  39. Configuring a pin
  40. -----------------
  41. The following function allows the configuration of a given pin to
  42. be changed.
  43. void s3c2410_gpio_cfgpin(unsigned int pin, unsigned int function);
  44. Eg:
  45. s3c2410_gpio_cfgpin(S3C2410_GPA0, S3C2410_GPA0_ADDR0);
  46. s3c2410_gpio_cfgpin(S3C2410_GPE8, S3C2410_GPE8_SDDAT1);
  47. which would turn GPA0 into the lowest Address line A0, and set
  48. GPE8 to be connected to the SDIO/MMC controller's SDDAT1 line.
  49. Reading the current configuration
  50. ---------------------------------
  51. The current configuration of a pin can be read by using:
  52. s3c2410_gpio_getcfg(unsigned int pin);
  53. The return value will be from the same set of values which can be
  54. passed to s3c2410_gpio_cfgpin().
  55. Configuring a pull-up resistor
  56. ------------------------------
  57. A large proportion of the GPIO pins on the S3C2410 can have weak
  58. pull-up resistors enabled. This can be configured by the following
  59. function:
  60. void s3c2410_gpio_pullup(unsigned int pin, unsigned int to);
  61. Where the to value is zero to set the pull-up off, and 1 to enable
  62. the specified pull-up. Any other values are currently undefined.
  63. Getting the state of a PIN
  64. --------------------------
  65. The state of a pin can be read by using the function:
  66. unsigned int s3c2410_gpio_getpin(unsigned int pin);
  67. This will return either zero or non-zero. Do not count on this
  68. function returning 1 if the pin is set.
  69. Setting the state of a PIN
  70. --------------------------
  71. The value an pin is outputing can be modified by using the following:
  72. void s3c2410_gpio_setpin(unsigned int pin, unsigned int to);
  73. Which sets the given pin to the value. Use 0 to write 0, and 1 to
  74. set the output to 1.
  75. Getting the IRQ number associated with a PIN
  76. --------------------------------------------
  77. The following function can map the given pin number to an IRQ
  78. number to pass to the IRQ system.
  79. int s3c2410_gpio_getirq(unsigned int pin);
  80. Note, not all pins have an IRQ.
  81. Authour
  82. -------
  83. Ben Dooks, 03 October 2004
  84. (c) 2004 Ben Dooks, Simtec Electronics