28 #include <linux/module.h>
29 #include <linux/kernel.h>
31 #include <linux/pci.h>
34 #define PMBASE_OFFSET 0xb0
35 #define PMBASE_SIZE 0x30
37 #define AMD_REG_GPIO(i) (0x10 + (i))
39 #define AMD_GPIO_LTCH_STS 0x40
40 #define AMD_GPIO_RTIN 0x20
41 #define AMD_GPIO_DEBOUNCE 0x10
42 #define AMD_GPIO_MODE_MASK 0x0c
43 #define AMD_GPIO_MODE_IN 0x00
44 #define AMD_GPIO_MODE_OUT 0x04
46 #define AMD_GPIO_MODE_ALTFN 0x08
47 #define AMD_GPIO_X_MASK 0x03
48 #define AMD_GPIO_X_IN_ACTIVEHI 0x01
49 #define AMD_GPIO_X_IN_LATCH 0x02
50 #define AMD_GPIO_X_OUT_LOW 0x00
51 #define AMD_GPIO_X_OUT_HI 0x01
52 #define AMD_GPIO_X_OUT_CLK0 0x02
53 #define AMD_GPIO_X_OUT_CLK1 0x03
78 #define to_agp(chip) container_of(chip, struct amd_gpio, chip)
80 static int amd_gpio_request(
struct gpio_chip *
chip,
unsigned offset)
87 dev_dbg(&agp->
pdev->dev,
"Requested gpio %d, data %x\n", offset, agp->
orig[offset]);
92 static void amd_gpio_free(
struct gpio_chip *
chip,
unsigned offset)
96 dev_dbg(&agp->
pdev->dev,
"Freed gpio %d, data %x\n", offset, agp->
orig[offset]);
101 static void amd_gpio_set(
struct gpio_chip *chip,
unsigned offset,
int value)
111 spin_unlock_irqrestore(&agp->
lock, flags);
113 dev_dbg(&agp->
pdev->dev,
"Setting gpio %d, value %d, reg=%02x\n", offset, !!value, temp);
116 static int amd_gpio_get(
struct gpio_chip *chip,
unsigned offset)
123 dev_dbg(&agp->
pdev->dev,
"Getting gpio %d, reg=%02x\n", offset, temp);
128 static int amd_gpio_dirout(
struct gpio_chip *chip,
unsigned offset,
int value)
138 spin_unlock_irqrestore(&agp->
lock, flags);
140 dev_dbg(&agp->
pdev->dev,
"Dirout gpio %d, value %d, reg=%02x\n", offset, !!value, temp);
145 static int amd_gpio_dirin(
struct gpio_chip *chip,
unsigned offset)
155 spin_unlock_irqrestore(&agp->
lock, flags);
157 dev_dbg(&agp->
pdev->dev,
"Dirin gpio %d, reg=%02x\n", offset, temp);
168 .request = amd_gpio_request,
169 .free = amd_gpio_free,
172 .direction_output = amd_gpio_dirout,
173 .direction_input = amd_gpio_dirin,
177 static int __init amd_gpio_init(
void)
202 err = pci_read_config_dword(pdev, 0x58, &gp.
pmbase);
210 dev_err(&pdev->
dev,
"AMD GPIO region 0x%x already in use!\n",
233 static void __exit amd_gpio_exit(
void)