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 See include/asm-arm/arch-s3c2410/regs-gpio.h for the list
20 of GPIO pins, and the configuration values for them. This
21 is included by using #include <asm/arch/regs-gpio.h>
23 The GPIO management functions are defined in the hardware
24 header include/asm-arm/arch-s3c2410/hardware.h which can be
25 included by #include <asm/arch/hardware.h>
27 A useful ammount of documentation can be found in the hardware
28 header on how the GPIO functions (and others) work.
30 Whilst a number of these functions do make some checks on what
31 is passed to them, for speed of use, they may not always ensure
32 that the user supplied data to them is correct.
38 Each pin has an unique number associated with it in regs-gpio.h,
39 eg S3C2410_GPA0 or S3C2410_GPF1. These defines are used to tell
40 the GPIO functions which pin is to be used.
46 The following function allows the configuration of a given pin to
49 void s3c2410_gpio_cfgpin(unsigned int pin, unsigned int function);
53 s3c2410_gpio_cfgpin(S3C2410_GPA0, S3C2410_GPA0_ADDR0);
54 s3c2410_gpio_cfgpin(S3C2410_GPE8, S3C2410_GPE8_SDDAT1);
56 which would turn GPA0 into the lowest Address line A0, and set
57 GPE8 to be connected to the SDIO/MMC controller's SDDAT1 line.
60 Reading the current configuration
61 ---------------------------------
63 The current configuration of a pin can be read by using:
65 s3c2410_gpio_getcfg(unsigned int pin);
67 The return value will be from the same set of values which can be
68 passed to s3c2410_gpio_cfgpin().
71 Configuring a pull-up resistor
72 ------------------------------
74 A large proportion of the GPIO pins on the S3C2410 can have weak
75 pull-up resistors enabled. This can be configured by the following
78 void s3c2410_gpio_pullup(unsigned int pin, unsigned int to);
80 Where the to value is zero to set the pull-up off, and 1 to enable
81 the specified pull-up. Any other values are currently undefined.
84 Getting the state of a PIN
85 --------------------------
87 The state of a pin can be read by using the function:
89 unsigned int s3c2410_gpio_getpin(unsigned int pin);
91 This will return either zero or non-zero. Do not count on this
92 function returning 1 if the pin is set.
95 Setting the state of a PIN
96 --------------------------
98 The value an pin is outputing can be modified by using the following:
100 void s3c2410_gpio_setpin(unsigned int pin, unsigned int to);
102 Which sets the given pin to the value. Use 0 to write 0, and 1 to
106 Getting the IRQ number associated with a PIN
107 --------------------------------------------
109 The following function can map the given pin number to an IRQ
110 number to pass to the IRQ system.
112 int s3c2410_gpio_getirq(unsigned int pin);
114 Note, not all pins have an IRQ.
121 Ben Dooks, 03 October 2004
122 (c) 2004 Ben Dooks, Simtec Electronics