blob: ea7ccfc4b274f5dcf269d9d239c8aeaf36cb4a6c [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001 S3C2410 GPIO Control
2 ====================
3
4Introduction
5------------
6
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.
10
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.
14
15
Ben Dooksf47c32f2008-08-08 21:22:40 +010016GPIOLIB
17-------
18
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.
22
23 Once all the extant drivers have been converted, the functions
24 listed below will be removed (they may be marked as __deprecated
25 in the near future).
26
27 - s3c2410_gpio_getpin
28 - s3c2410_gpio_setpin
29
30
Linus Torvalds1da177e2005-04-16 15:20:36 -070031Headers
32-------
33
Russell Kinga09e64f2008-08-05 16:14:15 +010034 See arch/arm/mach-s3c2410/include/mach/regs-gpio.h for the list
Linus Torvalds1da177e2005-04-16 15:20:36 -070035 of GPIO pins, and the configuration values for them. This
Russell Kinga09e64f2008-08-05 16:14:15 +010036 is included by using #include <mach/regs-gpio.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070037
38 The GPIO management functions are defined in the hardware
Russell Kinga09e64f2008-08-05 16:14:15 +010039 header arch/arm/mach-s3c2410/include/mach/hardware.h which can be
40 included by #include <mach/hardware.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070041
Matt LaPlante3f6dee92006-10-03 22:45:33 +020042 A useful amount of documentation can be found in the hardware
Linus Torvalds1da177e2005-04-16 15:20:36 -070043 header on how the GPIO functions (and others) work.
44
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.
48
49
50PIN Numbers
51-----------
52
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.
56
57
58Configuring a pin
59-----------------
60
61 The following function allows the configuration of a given pin to
62 be changed.
63
64 void s3c2410_gpio_cfgpin(unsigned int pin, unsigned int function);
65
66 Eg:
67
68 s3c2410_gpio_cfgpin(S3C2410_GPA0, S3C2410_GPA0_ADDR0);
69 s3c2410_gpio_cfgpin(S3C2410_GPE8, S3C2410_GPE8_SDDAT1);
70
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.
73
74
75Reading the current configuration
76---------------------------------
77
78 The current configuration of a pin can be read by using:
79
80 s3c2410_gpio_getcfg(unsigned int pin);
81
82 The return value will be from the same set of values which can be
83 passed to s3c2410_gpio_cfgpin().
84
85
86Configuring a pull-up resistor
87------------------------------
88
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
91 function:
92
93 void s3c2410_gpio_pullup(unsigned int pin, unsigned int to);
94
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.
97
98
99Getting the state of a PIN
100--------------------------
101
102 The state of a pin can be read by using the function:
103
104 unsigned int s3c2410_gpio_getpin(unsigned int pin);
105
106 This will return either zero or non-zero. Do not count on this
107 function returning 1 if the pin is set.
108
109
110Setting the state of a PIN
111--------------------------
112
113 The value an pin is outputing can be modified by using the following:
114
115 void s3c2410_gpio_setpin(unsigned int pin, unsigned int to);
116
117 Which sets the given pin to the value. Use 0 to write 0, and 1 to
118 set the output to 1.
119
120
121Getting the IRQ number associated with a PIN
122--------------------------------------------
123
124 The following function can map the given pin number to an IRQ
125 number to pass to the IRQ system.
126
127 int s3c2410_gpio_getirq(unsigned int pin);
128
129 Note, not all pins have an IRQ.
130
131
132Authour
133-------
134
135
136Ben Dooks, 03 October 2004
137(c) 2004 Ben Dooks, Simtec Electronics