46 #include <linux/module.h>
47 #include <linux/pci.h>
50 #include <linux/slab.h>
53 #include "../media/pci/bt8xx/bt848.h"
56 #define BT8XXGPIO_NR_GPIOS 24
72 #define bgwrite(dat, adr) writel((dat), bg->mmio+(adr))
73 #define bgread(adr) readl(bg->mmio+(adr))
76 static int modparam_gpiobase = -1;
78 MODULE_PARM_DESC(gpiobase,
"The GPIO number base. -1 means dynamic, which is the default.");
81 static int bt8xxgpio_gpio_direction_input(
struct gpio_chip *
gpio,
unsigned nr)
97 spin_unlock_irqrestore(&bg->
lock, flags);
102 static int bt8xxgpio_gpio_get(
struct gpio_chip *
gpio,
unsigned nr)
110 spin_unlock_irqrestore(&bg->
lock, flags);
112 return !!(val & (1 <<
nr));
115 static int bt8xxgpio_gpio_direction_output(
struct gpio_chip *
gpio,
116 unsigned nr,
int val)
135 spin_unlock_irqrestore(&bg->
lock, flags);
140 static void bt8xxgpio_gpio_set(
struct gpio_chip *gpio,
141 unsigned nr,
int val)
156 spin_unlock_irqrestore(&bg->
lock, flags);
159 static void bt8xxgpio_gpio_setup(
struct bt8xxgpio *bg)
161 struct gpio_chip *
c = &bg->
gpio;
163 c->label = dev_name(&bg->
pdev->dev);
165 c->direction_input = bt8xxgpio_gpio_direction_input;
166 c->get = bt8xxgpio_gpio_get;
167 c->direction_output = bt8xxgpio_gpio_direction_output;
168 c->set = bt8xxgpio_gpio_set;
170 c->base = modparam_gpiobase;
175 static int bt8xxgpio_probe(
struct pci_dev *
dev,
202 pci_set_drvdata(dev, bg);
208 goto err_release_mem;
219 bt8xxgpio_gpio_setup(bg);
223 goto err_release_mem;
231 pci_set_drvdata(dev,
NULL);
242 struct bt8xxgpio *bg = pci_get_drvdata(pdev);
255 pci_set_drvdata(pdev,
NULL);
262 struct bt8xxgpio *bg = pci_get_drvdata(pdev);
274 spin_unlock_irqrestore(&bg->
lock, flags);
285 struct bt8xxgpio *bg = pci_get_drvdata(pdev);
301 bgwrite(bg->saved_data & bg->saved_outen,
304 spin_unlock_irqrestore(&bg->
lock, flags);
309 #define bt8xxgpio_suspend NULL
310 #define bt8xxgpio_resume NULL
322 static struct pci_driver bt8xxgpio_pci_driver = {
324 .id_table = bt8xxgpio_pci_tbl,
325 .probe = bt8xxgpio_probe,
326 .remove = bt8xxgpio_remove,