28 #include <linux/kernel.h>
30 #include <linux/module.h>
34 #include <linux/pci.h>
35 #include <linux/wait.h>
38 #include <linux/i2c.h>
44 #include "../algos/i2c-algo-pcf.h"
46 #define DEFAULT_BASE 0x330
52 static int clock = 0x1c;
53 static int own = 0x55;
62 static int pcf_pending;
69 static void pcf_isa_setbyte(
void *
data,
int ctl,
int val)
78 pr_debug(
"%s: Write %p 0x%02X\n", pcf_isa_ops.name, address, val);
86 static int pcf_isa_getbyte(
void *data,
int ctl)
88 u8 __iomem *address = ctl ? (base_iomem + 1) : base_iomem;
91 pr_debug(
"%s: Read %p 0x%02X\n", pcf_isa_ops.name, address, val);
95 static int pcf_isa_getown(
void *data)
101 static int pcf_isa_getclock(
void *data)
106 static void pcf_isa_waitforpin(
void *data)
114 if (pcf_pending == 0) {
115 spin_unlock_irqrestore(&lock, flags);
119 if (pcf_pending == 1) {
122 spin_unlock_irqrestore(&lock, flags);
127 spin_unlock_irqrestore(&lock, flags);
144 static int pcf_isa_init(
void)
150 "in use\n", pcf_isa_ops.name, base);
156 pcf_isa_ops.name, base);
163 "is in use\n", pcf_isa_ops.name, base);
167 if (base_iomem ==
NULL) {
169 "failed\n", pcf_isa_ops.name, base);
174 pr_debug(
"%s: registers %#x remapped to %p\n", pcf_isa_ops.name, base,
178 if (
request_irq(irq, pcf_isa_handler, 0, pcf_isa_ops.name,
181 pcf_isa_ops.name, irq);
194 .setpcf = pcf_isa_setbyte,
195 .getpcf = pcf_isa_getbyte,
196 .getown = pcf_isa_getown,
197 .getclock = pcf_isa_getclock,
198 .waitforpin = pcf_isa_waitforpin,
204 .algo_data = &pcf_isa_data,
205 .name =
"i2c-elektor",
221 if (!pci_read_config_byte(cy693_dev, 0x47, &config)) {
223 dev_dbg(dev,
"found cy82c693, config "
224 "register 0x47 = 0x%02x\n", config);
236 if ((config & 0x7f) == 0x61) {
244 dev_info(dev,
"found API UP2000 like "
245 "board, will probe PCF8584 "
255 if (mmapped && base < 0xc8000) {
256 dev_err(dev,
"incorrect base address (%#x) specified "
257 "for mmapped I/O\n", base);
267 static int __devinit elektor_probe(
struct device *dev,
unsigned int id)
272 pcf_isa_ops.
dev.parent =
dev;
276 dev_info(dev,
"found device at %#x\n", base);
296 static int __devexit elektor_remove(
struct device *dev,
unsigned int id)
316 static struct isa_driver i2c_elektor_driver = {
317 .match = elektor_match,
318 .probe = elektor_probe,
322 .name =
"i2c-elektor",
326 static int __init i2c_pcfisa_init(
void)
331 static void __exit i2c_pcfisa_exit(
void)