26 #include <linux/kernel.h>
27 #include <linux/module.h>
29 #include <linux/slab.h>
30 #include <linux/device.h>
32 #include <linux/pci.h>
35 #define MODULE_NAME "vx855_gpio"
43 #define NR_VX855_GPI 14
44 #define NR_VX855_GPO 13
45 #define NR_VX855_GPIO 15
47 #define NR_VX855_GPInO (NR_VX855_GPI + NR_VX855_GPO)
48 #define NR_VX855_GP (NR_VX855_GPI + NR_VX855_GPO + NR_VX855_GPIO)
98 static int vx855gpio_direction_input(
struct gpio_chip *
gpio,
118 spin_unlock_irqrestore(&vg->
lock, flags);
123 static int vx855gpio_get(
struct gpio_chip *gpio,
unsigned int nr)
131 if (reg_in & gpi_i_bit(nr))
148 static void vx855gpio_set(
struct gpio_chip *gpio,
unsigned int nr,
173 spin_unlock_irqrestore(&vg->
lock, flags);
176 static int vx855gpio_direction_output(
struct gpio_chip *gpio,
177 unsigned int nr,
int val)
186 vx855gpio_set(gpio, nr, val);
191 static const char *vx855gpio_names[
NR_VX855_GP] = {
192 "VX855_GPI0",
"VX855_GPI1",
"VX855_GPI2",
"VX855_GPI3",
"VX855_GPI4",
193 "VX855_GPI5",
"VX855_GPI6",
"VX855_GPI7",
"VX855_GPI8",
"VX855_GPI9",
194 "VX855_GPI10",
"VX855_GPI11",
"VX855_GPI12",
"VX855_GPI13",
195 "VX855_GPO0",
"VX855_GPO1",
"VX855_GPO2",
"VX855_GPO3",
"VX855_GPO4",
196 "VX855_GPO5",
"VX855_GPO6",
"VX855_GPO7",
"VX855_GPO8",
"VX855_GPO9",
197 "VX855_GPO10",
"VX855_GPO11",
"VX855_GPO12",
198 "VX855_GPIO0",
"VX855_GPIO1",
"VX855_GPIO2",
"VX855_GPIO3",
199 "VX855_GPIO4",
"VX855_GPIO5",
"VX855_GPIO6",
"VX855_GPIO7",
200 "VX855_GPIO8",
"VX855_GPIO9",
"VX855_GPIO10",
"VX855_GPIO11",
201 "VX855_GPIO12",
"VX855_GPIO13",
"VX855_GPIO14"
204 static void vx855gpio_gpio_setup(
struct vx855_gpio *vg)
206 struct gpio_chip *
c = &vg->
gpio;
208 c->label =
"VX855 South Bridge";
210 c->direction_input = vx855gpio_direction_input;
211 c->direction_output = vx855gpio_direction_output;
212 c->get = vx855gpio_get;
213 c->set = vx855gpio_set;
218 c->names = vx855gpio_names;
231 if (!res_gpi || !res_gpo)
238 platform_set_drvdata(pdev, vg);
240 dev_info(&pdev->
dev,
"found VX855 GPIO controller\n");
256 "GPI I/O resource busy, probably claimed by ACPI\n");
263 "GPO I/O resource busy, probably claimed by ACPI\n");
267 vx855gpio_gpio_setup(vg);
271 dev_err(&pdev->
dev,
"failed to register GPIOs\n");
282 platform_set_drvdata(pdev,
NULL);
289 struct vx855_gpio *vg = platform_get_drvdata(pdev);
293 dev_err(&pdev->
dev,
"unable to remove gpio_chip?\n");
304 platform_set_drvdata(pdev,
NULL);
314 .probe = vx855gpio_probe,