23 #include <linux/module.h>
26 #include <asm/reboot.h>
39 static void __iomem *tb0219_base;
42 #define tb0219_read(offset) readw(tb0219_base + (offset))
43 #define tb0219_write(offset, value) writew((value), tb0219_base + (offset))
45 #define TB0219_START 0x0a000000UL
46 #define TB0219_SIZE 0x20UL
48 #define TB0219_LED 0x00
49 #define TB0219_GPIO_INPUT 0x02
50 #define TB0219_GPIO_OUTPUT 0x04
51 #define TB0219_DIP_SWITCH 0x06
52 #define TB0219_MISC 0x08
53 #define TB0219_RESET 0x0e
54 #define TB0219_PCI_SLOT1_IRQ_STATUS 0x10
55 #define TB0219_PCI_SLOT2_IRQ_STATUS 0x12
56 #define TB0219_PCI_SLOT3_IRQ_STATUS 0x14
95 static inline char get_led(
void)
100 static inline char get_gpio_input_pin(
unsigned int pin)
105 if (values & (1 << pin))
111 static inline char get_gpio_output_pin(
unsigned int pin)
116 if (values & (1 << pin))
122 static inline char get_dip_switch(
unsigned int pin)
127 if (values & (1 << pin))
140 static inline int set_gpio_output_pin(
unsigned int pin,
char command)
145 if (command !=
'0' && command !=
'1')
151 value &= ~(1 <<
pin);
155 spin_unlock_irqrestore(&tb0219_lock, flags);
167 minor = iminor(file->
f_path.dentry->d_inode);
173 value = get_gpio_input_pin(minor - 16);
176 value = get_gpio_output_pin(minor - 32);
179 value = get_dip_switch(minor - 48);
194 static ssize_t tanbac_tb0219_write(
struct file *file,
const char __user *
data,
195 size_t len, loff_t *ppos)
203 minor = iminor(file->
f_path.dentry->d_inode);
215 for (i = 0; i < len; i++) {
224 retval = set_gpio_output_pin(minor - 32, c);
235 static int tanbac_tb0219_open(
struct inode *
inode,
struct file *file)
239 minor = iminor(inode);
253 static int tanbac_tb0219_release(
struct inode *inode,
struct file *file)
260 .read = tanbac_tb0219_read,
261 .write = tanbac_tb0219_write,
262 .open = tanbac_tb0219_open,
263 .release = tanbac_tb0219_release,
267 static void tb0219_restart(
char *command)
272 static void tb0219_pci_irq_init(
void)
295 if (tb0219_base ==
NULL) {
300 retval = register_chrdev(major,
"TB0219", &tb0219_fops);
311 tb0219_pci_irq_init();
336 .probe = tb0219_probe,
344 static int __init tanbac_tb0219_init(
void)
349 if (!tb0219_platform_device)
365 static void __exit tanbac_tb0219_exit(
void)