Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

gpio: Add Tunnel Creek support to sch_gpio

Almost the same driver for both Poulsbo and Tunnel Creek.
The difference is in quantity of GPIOs powered by the core power
rail and by suspend power supply, default values for some GPIOs, etc.
Detect actual hardware by platform device ID assigned in lpc_sch
and set configuration accordingly.

Signed-off-by: Denis Turischev <denis@compulab.co.il>
Acked-by: Grant Likely <grant.likely@secretlab.ca>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>

authored by

Denis Turischev and committed by
Samuel Ortiz
f04ddfcd e967f77d

+44 -20
+5 -2
drivers/gpio/Kconfig
··· 100 100 Say yes here to support the NEC VR4100 series General-purpose I/O Uint 101 101 102 102 config GPIO_SCH 103 - tristate "Intel SCH GPIO" 103 + tristate "Intel SCH/TunnelCreek GPIO" 104 104 depends on GPIOLIB && PCI && X86 105 105 select MFD_CORE 106 106 select LPC_SCH 107 107 help 108 - Say yes here to support GPIO interface on Intel Poulsbo SCH. 108 + Say yes here to support GPIO interface on Intel Poulsbo SCH 109 + or Intel Tunnel Creek processor. 109 110 The Intel SCH contains a total of 14 GPIO pins. Ten GPIOs are 110 111 powered by the core power rail and are turned off during sleep 111 112 modes (S3 and higher). The remaining four GPIOs are powered by 112 113 the Intel SCH suspend power supply. These GPIOs remain 113 114 active during S3. The suspend powered GPIOs can be used to wake the 114 115 system from the Suspend-to-RAM state. 116 + The Intel Tunnel Creek processor has 5 GPIOs powered by the 117 + core power rail and 9 from suspend power supply. 115 118 116 119 This driver can also be built as a module. If so, the module 117 120 will be called sch-gpio.
+39 -18
drivers/gpio/sch_gpio.c
··· 25 25 #include <linux/errno.h> 26 26 #include <linux/acpi.h> 27 27 #include <linux/platform_device.h> 28 + #include <linux/pci_ids.h> 28 29 29 30 #include <linux/gpio.h> 30 31 ··· 188 187 static int __devinit sch_gpio_probe(struct platform_device *pdev) 189 188 { 190 189 struct resource *res; 191 - int err; 190 + int err, id; 191 + 192 + id = pdev->id; 193 + if (!id) 194 + return -ENODEV; 192 195 193 196 res = platform_get_resource(pdev, IORESOURCE_IO, 0); 194 197 if (!res) ··· 203 198 204 199 gpio_ba = res->start; 205 200 206 - sch_gpio_core.base = 0; 207 - sch_gpio_core.ngpio = 10; 208 - sch_gpio_core.dev = &pdev->dev; 201 + switch (id) { 202 + case PCI_DEVICE_ID_INTEL_SCH_LPC: 203 + sch_gpio_core.base = 0; 204 + sch_gpio_core.ngpio = 10; 209 205 210 - sch_gpio_resume.base = 10; 211 - sch_gpio_resume.ngpio = 4; 206 + sch_gpio_resume.base = 10; 207 + sch_gpio_resume.ngpio = 4; 208 + 209 + /* 210 + * GPIO[6:0] enabled by default 211 + * GPIO7 is configured by the CMC as SLPIOVR 212 + * Enable GPIO[9:8] core powered gpios explicitly 213 + */ 214 + outb(0x3, gpio_ba + CGEN + 1); 215 + /* 216 + * SUS_GPIO[2:0] enabled by default 217 + * Enable SUS_GPIO3 resume powered gpio explicitly 218 + */ 219 + outb(0x8, gpio_ba + RGEN); 220 + break; 221 + 222 + case PCI_DEVICE_ID_INTEL_ITC_LPC: 223 + sch_gpio_core.base = 0; 224 + sch_gpio_core.ngpio = 5; 225 + 226 + sch_gpio_resume.base = 5; 227 + sch_gpio_resume.ngpio = 9; 228 + break; 229 + 230 + default: 231 + return -ENODEV; 232 + } 233 + 234 + sch_gpio_core.dev = &pdev->dev; 212 235 sch_gpio_resume.dev = &pdev->dev; 213 236 214 237 err = gpiochip_add(&sch_gpio_core); ··· 246 213 err = gpiochip_add(&sch_gpio_resume); 247 214 if (err < 0) 248 215 goto err_sch_gpio_resume; 249 - 250 - /* 251 - * GPIO[6:0] enabled by default 252 - * GPIO7 is configured by the CMC as SLPIOVR 253 - * Enable GPIO[9:8] core powered gpios explicitly 254 - */ 255 - outb(0x3, gpio_ba + CGEN + 1); 256 - /* 257 - * SUS_GPIO[2:0] enabled by default 258 - * Enable SUS_GPIO3 resume powered gpio explicitly 259 - */ 260 - outb(0x8, gpio_ba + RGEN); 261 216 262 217 return 0; 263 218