7 The s3c2410 kernel provides an interface to configure and
8 manipulate the state of the GPIO pins, and find out other
9 information about them.
11 There are a number of conditions attached to the configuration
12 of the s3c2410 GPIO system, please read the Samsung provided
13 data-sheet/users manual to find out the complete list.
19 With the event of the GPIOLIB in drivers/gpio, support for some
20 of the GPIO functions such as reading and writing a pin will
21 be removed in favour of this common access method.
23 Once all the extant drivers have been converted, the functions
24 listed below will be removed (they may be marked as __deprecated
34 See arch/arm/mach-s3c2410/include/mach/regs-gpio.h for the list
35 of GPIO pins, and the configuration values for them. This
36 is included by using #include <mach/regs-gpio.h>
38 The GPIO management functions are defined in the hardware
39 header arch/arm/mach-s3c2410/include/mach/hardware.h which can be
40 included by #include <mach/hardware.h>
42 A useful amount of documentation can be found in the hardware
43 header on how the GPIO functions (and others) work.
45 Whilst a number of these functions do make some checks on what
46 is passed to them, for speed of use, they may not always ensure
47 that the user supplied data to them is correct.
53 Each pin has an unique number associated with it in regs-gpio.h,
54 eg S3C2410_GPA0 or S3C2410_GPF1. These defines are used to tell
55 the GPIO functions which pin is to be used.
61 The following function allows the configuration of a given pin to
64 void s3c2410_gpio_cfgpin(unsigned int pin, unsigned int function);
68 s3c2410_gpio_cfgpin(S3C2410_GPA0, S3C2410_GPA0_ADDR0);
69 s3c2410_gpio_cfgpin(S3C2410_GPE8, S3C2410_GPE8_SDDAT1);
71 which would turn GPA0 into the lowest Address line A0, and set
72 GPE8 to be connected to the SDIO/MMC controller's SDDAT1 line.
75 Reading the current configuration
76 ---------------------------------
78 The current configuration of a pin can be read by using:
80 s3c2410_gpio_getcfg(unsigned int pin);
82 The return value will be from the same set of values which can be
83 passed to s3c2410_gpio_cfgpin().
86 Configuring a pull-up resistor
87 ------------------------------
89 A large proportion of the GPIO pins on the S3C2410 can have weak
90 pull-up resistors enabled. This can be configured by the following
93 void s3c2410_gpio_pullup(unsigned int pin, unsigned int to);
95 Where the to value is zero to set the pull-up off, and 1 to enable
96 the specified pull-up. Any other values are currently undefined.
99 Getting the state of a PIN
100 --------------------------
102 The state of a pin can be read by using the function:
104 unsigned int s3c2410_gpio_getpin(unsigned int pin);
106 This will return either zero or non-zero. Do not count on this
107 function returning 1 if the pin is set.
110 Setting the state of a PIN
111 --------------------------
113 The value an pin is outputing can be modified by using the following:
115 void s3c2410_gpio_setpin(unsigned int pin, unsigned int to);
117 Which sets the given pin to the value. Use 0 to write 0, and 1 to
121 Getting the IRQ number associated with a PIN
122 --------------------------------------------
124 The following function can map the given pin number to an IRQ
125 number to pass to the IRQ system.
127 int s3c2410_gpio_getirq(unsigned int pin);
129 Note, not all pins have an IRQ.
136 Ben Dooks, 03 October 2004
137 (c) 2004 Ben Dooks, Simtec Electronics