3/4 WIP I2C kernel patches-drivers
PATCH 1/1 3/4 WIP I2C kernel patches-drivers
Patch 3 is straight diff from linux-2.5.15 and i2c-2.5.3.
drivers/i2c/i2c-algo-8xx.c 2001-10-30 22:06:31.000000000 -0500 renamed from drivers/i2c/i2c-algo-8xx.c.orig 1969-12-31 19:00:00.000000000 -0500 +571 -0
@@ -0,0 +1,575 @@ +/* + * i2c-algo-8xx.c i2x driver algorithms for MPC8XX CPM + * Copyright (c) 1999 Dan Malek ([email protected]). + * + * moved into proper i2c interface; separated out platform specific + * parts into i2c-rpx.c + * Brad Parker ([email protected]) + */ + +// XXX todo +// timeout sleep? + +/* $Id: i2c-algo-8xx.c,v 1.4 2001/10/31 03:06:31 mds Exp $ */ + +#include <linux/kernel.h> +#include <linux/module.h> +#include <linux/delay.h> +#include <linux/slab.h> +#include <linux/version.h> +#include <linux/init.h> +#include <asm/uaccess.h> +#include <linux/ioport.h> +#include <linux/errno.h> +#include <linux/sched.h> + +#include <asm/mpc8xx.h> +#include "../../arch/ppc/8xx_io/commproc.h" + +#include <linux/i2c.h> +#include <linux/i2c-algo-8xx.h> + +#define CPM_MAX_READ 513 + +static wait_queue_head_t iic_wait; +static ushort r_tbase, r_rbase; + +int cpm_scan = 0; +int cpm_debug = 0; + +static void +cpm_iic_interrupt(void *dev_id) +{ + volatile i2c8xx_t *i2c = (i2c8xx_t *)dev_id; + + if (cpm_debug > 1) + printk("cpm_iic_interrupt(dev_id=%p)\n", dev_id); + + /* Chip errata, clear enable. + */ + i2c->i2c_i2mod = 0; + + /* Clear interrupt. + */ + i2c->i2c_i2cer = 0xff; + + /* Get 'me going again. + */ + wake_up_interruptible(&iic_wait); +} + +static void +cpm_iic_init(struct i2c_algo_8xx_data *cpm_adap) +{ + volatile iic_t *iip = cpm_adap->iip; + volatile i2c8xx_t *i2c = cpm_adap->i2c; + + if (cpm_debug) printk("cpm_iic_init() - iip=%p\n",iip); + + /* Initialize the parameter ram. + * We need to make sure many things are initialized to zero, + * especially in the case of a microcode patch. + */ + iip->iic_rstate = 0; + iip->iic_rdp = 0; + iip->iic_rbptr = 0; + iip->iic_rbc = 0; + iip->iic_rxtmp = 0; + iip->iic_tstate = 0; + iip->iic_tdp = 0; + iip->iic_tbptr = 0; + iip->iic_tbc = 0; + iip->iic_txtmp = 0; + + /* Set up the IIC parameters in the parameter ram. + */ + iip->iic_tbase = r_tbase = cpm_adap->dp_addr; + iip->iic_rbase = r_rbase = cpm_adap->dp_addr + sizeof(cbd_t)*2; + + iip->iic_tfcr = SMC_EB; + iip->iic_rfcr = SMC_EB; + + /* Set maximum receive size. + */ + iip->iic_mrblr = CPM_MAX_READ; + + /* Initialize Tx/Rx parameters. + */ + if (cpm_adap->reloc = 0) { + volatile cpm8xx_t *cp = cpm_adap->cp; + + cp->cp_cpcr + mk_cr_cmd(CPM_CR_CH_I2C, CPM_CR_INIT_TRX) | CPM_CR_FLG; + while (cp->cp_cpcr & CPM_CR_FLG); + } + + /* Select an arbitrary address. Just make sure it is unique. + */ + i2c->i2c_i2add = 0x34; + + /* Make clock run maximum slow. + */ + i2c->i2c_i2brg = 7; + + /* Disable interrupts. + */ + i2c->i2c_i2cmr = 0; + i2c->i2c_i2cer = 0xff; + + init_waitqueue_head(&iic_wait); + + /* Install interrupt handler. + */ + if (cpm_debug) { + printk ("%s[%d] Install ISR for IRQ %d\n", + __func__,__LINE__, CPMVEC_I2C); + } + (*cpm_adap->setisr)(CPMVEC_I2C, cpm_iic_interrupt, (void *)i2c); +} + + +static int +cpm_iic_shutdown(struct i2c_algo_8xx_data *cpm_adap) +{ + volatile i2c8xx_t *i2c = cpm_adap->i2c; + + /* Shut down IIC. + */ + i2c->i2c_i2mod = 0; + i2c->i2c_i2cmr = 0; + i2c->i2c_i2cer = 0xff; + + return(0); +} + +static void +cpm_reset_iic_params(volatile iic_t *iip) +{ + iip->iic_tbase = r_tbase; + iip->iic_rbase = r_rbase; + + iip->iic_tfcr = SMC_EB; + iip->iic_rfcr = SMC_EB; + + iip->iic_mrblr = CPM_MAX_READ; + + iip->iic_rstate = 0; + iip->iic_rdp = 0; + iip->iic_rbptr = 0; + iip->iic_rbc = 0; + iip->iic_rxtmp = 0; + iip->iic_tstate = 0; + iip->iic_tdp = 0; + iip->iic_tbptr = 0; + iip->iic_tbc = 0; + iip->iic_txtmp = 0; +} + +#define BD_SC_NAK ((ushort)0x0004) /* NAK - did not respond */ +#define CPM_CR_CLOSE_RXBD ((ushort)0x0007) + +static void force_close(struct i2c_algo_8xx_data *cpm) +{ + if (cpm->reloc = 0) { + volatile cpm8xx_t *cp = cpm->cp; + + if (cpm_debug) printk("force_close()\n"); + cp->cp_cpcr + mk_cr_cmd(CPM_CR_CH_I2C, CPM_CR_CLOSE_RXBD) | + CPM_CR_FLG; + + while (cp->cp_cpcr & CPM_CR_FLG); + } +} + + +/* Read from IIC... + * abyte = address byte, with r/w flag already set + */ +static int +cpm_iic_read(struct i2c_algo_8xx_data *cpm, u_char abyte, char *buf, int count) +{ + volatile iic_t *iip = cpm->iip; + volatile i2c8xx_t *i2c = cpm->i2c; + volatile cpm8xx_t *cp = cpm->cp; + volatile cbd_t *tbdf, *rbdf; + u_char *tb; + unsigned long flags; + + if (count >= CPM_MAX_READ) + return -EINVAL; + + /* check for and use a microcode relocation patch */ + if (cpm->reloc) { + cpm_reset_iic_params(iip); + } + + tbdf = (cbd_t *)&cp->cp_dpmem[iip->iic_tbase]; + rbdf = (cbd_t *)&cp->cp_dpmem[iip->iic_rbase]; + + /* To read, we need an empty buffer of the proper length. + * All that is used is the first byte for address, the remainder + * is just used for timing (and doesn't really have to exist). + */ + if (cpm->reloc) { + cpm_reset_iic_params(iip); + } + tb = cpm->temp; + tb = (u_char *)(((uint)tb + 15) & ~15); + tb[0] = abyte; /* Device address byte w/rw flag */ + + flush_dcache_range(tb, tb+1); + + if (cpm_debug) printk("cpm_iic_read(abyte=0x%x)\n", abyte); + + tbdf->cbd_bufaddr = __pa(tb); + tbdf->cbd_datlen = count + 1; + tbdf->cbd_sc + BD_SC_READY | BD_SC_INTRPT | BD_SC_LAST | + BD_SC_WRAP | BD_IIC_START; + + rbdf->cbd_datlen = 0; + rbdf->cbd_bufaddr = __pa(buf); + rbdf->cbd_sc = BD_SC_EMPTY | BD_SC_WRAP; + + invalidate_dcache_range(buf, buf+count); + + /* Chip bug, set enable here */ + save_flags(flags); cli(); + i2c->i2c_i2cmr = 0x13; /* Enable some interupts */ + i2c->i2c_i2cer = 0xff; + i2c->i2c_i2mod = 1; /* Enable */ + i2c->i2c_i2com = 0x81; /* Start master */ + + /* Wait for IIC transfer */ + interruptible_sleep_on(&iic_wait); + restore_flags(flags); + if (signal_pending(current)) + return -EIO; + + if (cpm_debug) { + printk("tx sc %04x, rx sc %04x\n", + tbdf->cbd_sc, rbdf->cbd_sc); + } + + if (tbdf->cbd_sc & BD_SC_NAK) { + printk("IIC read; no ack\n"); + return 0; + } + + if (rbdf->cbd_sc & BD_SC_EMPTY) { + printk("IIC read; complete but rbuf empty\n"); + force_close(cpm); + printk("tx sc %04x, rx sc %04x\n", + tbdf->cbd_sc, rbdf->cbd_sc); + } + + if (cpm_debug) printk("read %d bytes\n", rbdf->cbd_datlen); + + if (rbdf->cbd_datlen < count) { + printk("IIC read; short, wanted %d got %d\n", + count, rbdf->cbd_datlen); + return 0; + } + + + invalidate_dcache_range(buf, buf+count); + + return count; +} + +/* Write to IIC... + * addr = address byte, with r/w flag already set + */ +static int +cpm_iic_write(struct i2c_algo_8xx_data *cpm, u_char abyte, char *buf,int count) +{ + volatile iic_t *iip = cpm->iip; + volatile i2c8xx_t *i2c = cpm->i2c; + volatile cpm8xx_t *cp = cpm->cp; + volatile cbd_t *tbdf; + u_char *tb; + unsigned long flags; + + /* check for and use a microcode relocation patch */ + if (cpm->reloc) { + cpm_reset_iic_params(iip); + } + tb = cpm->temp; + tb = (u_char *)(((uint)tb + 15) & ~15); + *tb = abyte; /* Device address byte w/rw flag */ + + flush_dcache_range(tb, tb+1); + flush_dcache_range(buf, buf+count); + + if (cpm_debug) printk("cpm_iic_write(abyte=0x%x)\n", abyte); + + /* set up 2 descriptors */ + tbdf = (cbd_t *)&cp->cp_dpmem[iip->iic_tbase]; + + tbdf[0].cbd_bufaddr = __pa(tb); + tbdf[0].cbd_datlen = 1; + tbdf[0].cbd_sc = BD_SC_READY | BD_IIC_START; + + tbdf[1].cbd_bufaddr = __pa(buf); + tbdf[1].cbd_datlen = count; + tbdf[1].cbd_sc = BD_SC_READY | BD_SC_INTRPT | BD_SC_LAST | BD_SC_WRAP; + + /* Chip bug, set enable here */ + save_flags(flags); cli(); + i2c->i2c_i2cmr = 0x13; /* Enable some interupts */ + i2c->i2c_i2cer = 0xff; + i2c->i2c_i2mod = 1; /* Enable */ + i2c->i2c_i2com = 0x81; /* Start master */ + + /* Wait for IIC transfer */ + interruptible_sleep_on(&iic_wait); + restore_flags(flags); + if (signal_pending(current)) + return -EIO; + + if (cpm_debug) { + printk("tx0 sc %04x, tx1 sc %04x\n", + tbdf[0].cbd_sc, tbdf[1].cbd_sc); + } + + if (tbdf->cbd_sc & BD_SC_NAK) { + printk("IIC write; no ack\n"); + return 0; + } + + if (tbdf->cbd_sc & BD_SC_READY) { + printk("IIC write; complete but tbuf ready\n"); + return 0; + } + + return count; +} + +/* See if an IIC address exists.. + * addr = 7 bit address, unshifted + */ +static int +cpm_iic_tryaddress(struct i2c_algo_8xx_data *cpm, int addr) +{ + volatile iic_t *iip = cpm->iip; + volatile i2c8xx_t *i2c = cpm->i2c; + volatile cpm8xx_t *cp = cpm->cp; + volatile cbd_t *tbdf, *rbdf; + u_char *tb; + unsigned long flags, len; + + if (cpm_debug > 1) + printk("cpm_iic_tryaddress(cpm=%p,addr=%d)\n", cpm, addr); + + /* check for and use a microcode relocation patch */ + if (cpm->reloc) { + cpm_reset_iic_params(iip); + } + + if (cpm_debug && addr = 0) { + printk("iip %p, dp_addr 0x%x\n", cpm->iip, cpm->dp_addr); + printk("iic_tbase %d, r_tbase %d\n", iip->iic_tbase, r_tbase); + } + + tbdf = (cbd_t *)&cp->cp_dpmem[iip->iic_tbase]; + rbdf = (cbd_t *)&cp->cp_dpmem[iip->iic_rbase]; + + tb = cpm->temp; + tb = (u_char *)(((uint)tb + 15) & ~15); + + /* do a simple read */ + tb[0] = (addr << 1) | 1; /* device address (+ read) */ + len = 2; + + flush_dcache_range(tb, tb+1); + + tbdf->cbd_bufaddr = __pa(tb); + tbdf->cbd_datlen = len; + tbdf->cbd_sc + BD_SC_READY | BD_SC_INTRPT | BD_SC_LAST | + BD_SC_WRAP | BD_IIC_START; + + rbdf->cbd_datlen = 0; + rbdf->cbd_bufaddr = __pa(tb+2); + rbdf->cbd_sc = BD_SC_EMPTY | BD_SC_WRAP; + + save_flags(flags); cli(); + i2c->i2c_i2cmr = 0x13; /* Enable some interupts */ + i2c->i2c_i2cer = 0xff; + i2c->i2c_i2mod = 1; /* Enable */ + i2c->i2c_i2com = 0x81; /* Start master */ + + if (cpm_debug > 1) printk("about to sleep\n"); + + /* wait for IIC transfer */ + interruptible_sleep_on(&iic_wait); + restore_flags(flags); + if (signal_pending(current)) + return -EIO; + + if (cpm_debug > 1) printk("back from sleep\n"); + + if (tbdf->cbd_sc & BD_SC_NAK) { + if (cpm_debug > 1) printk("IIC try; no ack\n"); + return 0; + } + + if (tbdf->cbd_sc & BD_SC_READY) { + printk("IIC try; complete but tbuf ready\n"); + } + + return 1; +} + +static int cpm_xfer(struct i2c_adapter *i2c_adap, + struct i2c_msg msgs[], + int num) +{ + struct i2c_algo_8xx_data *adap = i2c_adap->algo_data; + struct i2c_msg *pmsg; + int i, ret; + u_char addr; + + for (i = 0; i < num; i++) { + pmsg = &msgs[i]; + + if (cpm_debug) + printk("i2c-algo-8xx.o: " + "#%d addr=0x%x flags=0x%x len=%d\n", + i, pmsg->addr, pmsg->flags, pmsg->len); + + addr = pmsg->addr << 1; + if (pmsg->flags & I2C_M_RD ) + addr |= 1; + if (pmsg->flags & I2C_M_REV_DIR_ADDR ) + addr ^= 1; + + if (!(pmsg->flags & I2C_M_NOSTART)) { + } + if (pmsg->flags & I2C_M_RD ) { + /* read bytes into buffer*/ + ret = cpm_iic_read(adap, addr, pmsg->buf, pmsg->len); + if (cpm_debug) + printk("i2c-algo-8xx.o: read %d bytes\n", ret); + if (ret < pmsg->len ) { + return (ret<0)? ret : -EREMOTEIO; + } + } else { + /* write bytes from buffer */ + ret = cpm_iic_write(adap, addr, pmsg->buf, pmsg->len); + if (cpm_debug) + printk("i2c-algo-8xx.o: wrote %d\n", ret); + if (ret < pmsg->len ) { + return (ret<0) ? ret : -EREMOTEIO; + } + } + } + return (num); +} + +static int algo_control(struct i2c_adapter *adapter, + unsigned int cmd, unsigned long arg) +{ + return 0; +} + +static u32 cpm_func(struct i2c_adapter *adap) +{ + return I2C_FUNC_SMBUS_EMUL | I2C_FUNC_10BIT_ADDR | + I2C_FUNC_PROTOCOL_MANGLING; +} + +/* -----exported algorithm data: ------------------------------------- */ + +static struct i2c_algorithm cpm_algo = { + "MPC8xx CPM algorithm", + I2C_ALGO_MPC8XX, + cpm_xfer, + NULL, + NULL, /* slave_xmit */ + NULL, /* slave_recv */ + algo_control, /* ioctl */ + cpm_func, /* functionality */ +}; + +/* + * registering functions to load algorithms at runtime + */ +int i2c_8xx_add_bus(struct i2c_adapter *adap) +{ + int i; + struct i2c_algo_8xx_data *cpm_adap = adap->algo_data; + + if (cpm_debug) + printk("i2c-algo-8xx.o: hw routines for %s registered.\n", + adap->name); + + /* register new adapter to i2c module... */ + + adap->id |= cpm_algo.id; + adap->algo = &cpm_algo; + +#ifdef MODULE + MOD_INC_USE_COUNT; +#endif + + i2c_add_adapter(adap); + cpm_iic_init(cpm_adap); + + /* scan bus */ + if (cpm_scan) { + printk(KERN_INFO " i2c-algo-8xx.o: scanning bus %s...\n", + adap->name); + for (i = 0; i < 128; i++) { + if (cpm_iic_tryaddress(cpm_adap, i)) { + printk("(%02x)",i<<1); + } + } + printk("\n"); + } + return 0; +} + + +int i2c_8xx_del_bus(struct i2c_adapter *adap) +{ + int res; + struct i2c_algo_8xx_data *cpm_adap = adap->algo_data; + + cpm_iic_shutdown(cpm_adap); + + if ((res = i2c_del_adapter(adap)) < 0) + return res; + + printk("i2c-algo-8xx.o: adapter unregistered: %s\n",adap->name); + +#ifdef MODULE + MOD_DEC_USE_COUNT; +#endif + return 0; +} + +EXPORT_SYMBOL(i2c_8xx_add_bus); +EXPORT_SYMBOL(i2c_8xx_del_bus); + +int __init i2c_algo_8xx_init (void) +{ + printk("i2c-algo-8xx.o: i2c mpc8xx algorithm module version %s (%s)\n", I2C_VERSION, I2C_DATE); + return 0; +} + + +#ifdef MODULE +MODULE_AUTHOR("Brad Parker <[email protected]>"); +MODULE_DESCRIPTION("I2C-Bus MPC8XX algorithm"); + +int init_module(void) +{ + return i2c_algo_8xx_init(); +} + +void cleanup_module(void) +{ +} +#endif
include/linux/i2c-algo-8xx.h 2001-05-14 22:14:58.000000000 -0400 renamed from dev/null 1994-07-17 19:46:18.000000000 -0400 +29 -0
@@ -0,0 +1,29 @@ +/* ------------------------------------------------------------------------- */ +/* i2c-algo-8xx.h i2c driver algorithms for MPX8XX CPM */ +/* ------------------------------------------------------------------------- */ + +/* $Id: i2c-algo-8xx.h,v 1.1 2001/05/15 02:14:58 mds Exp $ */ + +#ifndef I2C_ALGO_8XX_H +#define I2C_ALGO_8XX_H 1 + +#include <linux/i2c.h> + +struct i2c_algo_8xx_data { + uint dp_addr; + int reloc; + volatile i2c8xx_t *i2c; + volatile iic_t *iip; + volatile cpm8xx_t *cp; + + int (*setisr) (int irq, + void (*func)(int, void (*)(void *), void *), + void *data); + + u_char temp[513]; +}; + +int i2c_8xx_add_bus(struct i2c_adapter *); +int i2c_8xx_del_bus(struct i2c_adapter *); + +#endif /* I2C_ALGO_8XX_H */
drivers/i2c/i2c-algo-bit.c 2002-05-14 17:58:35.000000000 -0400 renamed from drivers/i2c/i2c-algo-bit.c.orig 2002-05-09 18:21:26.000000000 -0400 +47 -45
295 lines not on this page · raw message
drivers/i2c/i2c-algo-pcf.c 2002-05-14 18:04:41.000000000 -0400 renamed from drivers/i2c/i2c-algo-pcf.c.orig 2002-05-09 18:25:27.000000000 -0400 +35 -35
247 lines not on this page · raw message
drivers/i2c/i2c-algo-ppc405.c 2002-05-14 18:04:54.000000000 -0400 renamed from drivers/i2c/i2c-algo-ppc405.c.orig 1969-12-31 19:00:00.000000000 -0500 +1040 -0
1,040 lines not on this page · raw message
include/linux/i2c-algo-ppc405.h 2001-05-30 23:13:25.000000000 -0400 renamed from dev/null 1994-07-17 19:46:18.000000000 -0400 +55 -0
55 lines not on this page · raw message
drivers/i2c/i2c-elektor.c 2002-05-14 18:01:00.000000000 -0400 renamed from drivers/i2c/i2c-elektor.c.orig 2002-05-09 18:21:40.000000000 -0400 +18 -14
@@ -35,11 +35,10 @@ #include <linux/pci.h> #include <asm/irq.h> #include <asm/io.h> - #include <linux/i2c.h> #include <linux/i2c-algo-pcf.h> #include <linux/i2c-elektor.h> -#include "i2c-pcf8584.h" +#include <linux/i2c-pcf8584.h> #define DEFAULT_BASE 0x330
@@ -74,11 +73,12 @@ { int address = ctl ? (base + 1) : base; - if (ctl && irq) { + /* enable irq if any specified for serial operation */ + if (ctl && irq && (val & I2C_PCF_ESO)) { val |= I2C_PCF_ENI; } - DEB3(printk("i2c-elektor.o: Write 0x%X 0x%02X\n", address, val & 255)); + DEB3(printk(KERN_DEBUG "i2c-elektor.o: Write 0x%X 0x%02X\n", address, val & 255)); switch (mmapped) { case 0: /* regular I/O */
@@ -99,7 +99,7 @@ int address = ctl ? (base + 1) : base; int val = mmapped ? readb(address) : inb(address); - DEB3(printk("i2c-elektor.o: Read 0x%X 0x%02X\n", address, val)); + DEB3(printk(KERN_DEBUG "i2c-elektor.o: Read 0x%X 0x%02X\n", address, val)); return (val); }
@@ -142,7 +142,7 @@ { if (!mmapped) { if (check_region(base, 2) < 0 ) { - printk("i2c-elektor.o: requested I/O region (0x%X:2) is in use.\n", base); + printk(KERN_ERR "i2c-elektor.o: requested I/O region (0x%X:2) is in use.\n", base); return -ENODEV; } else { request_region(base, 2, "i2c (isa bus adapter)");
@@ -150,7 +150,7 @@ } if (irq > 0) { if (request_irq(irq, pcf_isa_handler, 0, "PCF8584", 0) < 0) { - printk("i2c-elektor.o: Request irq%d failed\n", irq); + printk(KERN_ERR "i2c-elektor.o: Request irq%d failed\n", irq); irq = 0; } else enable_irq(irq);
@@ -159,7 +159,7 @@ } -static void __exit pcf_isa_exit(void) +static void pcf_isa_exit(void) { if (irq > 0) { disable_irq(irq);
@@ -238,7 +238,7 @@ /* yeap, we've found cypress, let's check config */ if (!pci_read_config_byte(cy693_dev, 0x47, &config)) { - DEB3(printk("i2c-elektor.o: found cy82c693, config register 0x47 = 0x%02x.\n", config)); + DEB3(printk(KERN_DEBUG "i2c-elektor.o: found cy82c693, config register 0x47 = 0x%02x.\n", config)); /* UP2000 board has this register set to 0xe1, but the most significant bit as seems can be
@@ -260,7 +260,7 @@ 8.25 MHz (PCI/4) clock (this can be read from cypress) */ clock = I2C_PCF_CLK | I2C_PCF_TRNS90; - printk("i2c-elektor.o: found API UP2000 like board, will probe PCF8584 later.\n"); + printk(KERN_INFO "i2c-elektor.o: found API UP2000 like board, will probe PCF8584 later.\n"); } } }
@@ -269,11 +269,11 @@ /* sanity checks for mmapped I/O */ if (mmapped && base < 0xc8000) { - printk("i2c-elektor.o: incorrect base address (0x%0X) specified for mmapped I/O.\n", base); + printk(KERN_ERR "i2c-elektor.o: incorrect base address (0x%0X) specified for mmapped I/O.\n", base); return -ENODEV; } - printk("i2c-elektor.o: i2c pcf8584-isa adapter module\n"); + printk(KERN_INFO "i2c-elektor.o: i2c pcf8584-isa adapter module version %s (%s)\n", I2C_VERSION, I2C_DATE); if (base = 0) { base = DEFAULT_BASE;
@@ -283,13 +283,15 @@ init_waitqueue_head(&pcf_wait); #endif if (pcf_isa_init() = 0) { - if (i2c_pcf_add_bus(&pcf_isa_ops) < 0) + if (i2c_pcf_add_bus(&pcf_isa_ops) < 0) { + pcf_isa_exit(); return -ENODEV; + } } else { return -ENODEV; } - printk("i2c-elektor.o: found device at %#x.\n", base); + printk(KERN_ERR "i2c-elektor.o: found device at %#x.\n", base); return 0; }
@@ -300,7 +302,9 @@ #ifdef MODULE MODULE_AUTHOR("Hans Berglund <[email protected]>"); MODULE_DESCRIPTION("I2C-Bus adapter routines for PCF8584 ISA bus adapter"); +#ifdef MODULE_LICENSE MODULE_LICENSE("GPL"); +#endif MODULE_PARM(base, "i"); MODULE_PARM(irq, "i");
drivers/i2c/i2c-elv.c 2002-05-14 18:01:25.000000000 -0400 renamed from drivers/i2c/i2c-elv.c.orig 2002-05-09 18:25:30.000000000 -0400 +8 -8
@@ -21,7 +21,7 @@ /* With some changes from Ky?sti M?lkki <[email protected]> and even Frodo Looijaard <[email protected]> */ -/* $Id: i2c-elv.c,v 1.17 2001/07/29 02:44:25 mds Exp $ */ +/* $Id: i2c-elv.c,v 1.21 2001/11/19 18:45:02 mds Exp $ */ #include <linux/kernel.h> #include <linux/module.h>
@@ -29,9 +29,7 @@ #include <linux/slab.h> #include <linux/version.h> #include <linux/init.h> - #include <asm/uaccess.h> - #include <linux/ioport.h> #include <asm/io.h> #include <linux/errno.h>
@@ -95,14 +93,14 @@ } else { /* test for ELV adap. */ if (inb(base+1) & 0x80) { /* BUSY should be high */ - DEBINIT(printk("i2c-elv.o: Busy was low.\n")); + DEBINIT(printk(KERN_DEBUG "i2c-elv.o: Busy was low.\n")); return -ENODEV; } else { outb(0x0c,base+2); /* SLCT auf low */ udelay(400); if ( !(inb(base+1) && 0x10) ) { outb(0x04,base+2); - DEBINIT(printk("i2c-elv.o: Select was high.\n")); + DEBINIT(printk(KERN_DEBUG "i2c-elv.o: Select was high.\n")); return -ENODEV; } }
@@ -115,7 +113,7 @@ return 0; } -static void __exit bit_elv_exit(void) +static void bit_elv_exit(void) { release_region( base , (base = 0x3bc)? 3 : 8 ); }
@@ -170,7 +168,7 @@ int __init i2c_bitelv_init(void) { - printk("i2c-elv.o: i2c ELV parallel port adapter module\n"); + printk(KERN_INFO "i2c-elv.o: i2c ELV parallel port adapter module version %s (%s)\n", I2C_VERSION, I2C_DATE); if (base=0) { /* probe some values */ base�FAULT_BASE;
@@ -190,7 +188,7 @@ return -ENODEV; } } - printk("i2c-elv.o: found device at %#x.\n",base); + printk(KERN_DEBUG "i2c-elv.o: found device at %#x.\n",base); return 0; }
@@ -200,7 +198,9 @@ #ifdef MODULE MODULE_AUTHOR("Simon G. Vogl <[email protected]>"); MODULE_DESCRIPTION("I2C-Bus adapter routines for ELV parallel port adapter"); +#ifdef MODULE_LICENSE MODULE_LICENSE("GPL"); +#endif MODULE_PARM(base, "i");
drivers/i2c/i2c-pcf-epp.c 2002-05-14 18:01:51.000000000 -0400 renamed from drivers/i2c/i2c-pcf-epp.c.orig 1969-12-31 19:00:00.000000000 -0500 +315 -0
315 lines not on this page · raw message
include/linux/i2c-pcf8584.h 2001-10-01 20:07:37.000000000 -0400 renamed from dev/null 1994-07-17 19:46:18.000000000 -0400 +78 -0
78 lines not on this page · raw message
drivers/i2c/i2c-philips-par.c 2002-05-14 18:02:15.000000000 -0400 renamed from drivers/i2c/i2c-philips-par.c.orig 2002-05-09 18:21:56.000000000 -0400 +12 -8
@@ -21,7 +21,7 @@ /* With some changes from Ky?sti M?lkki <[email protected]> and even Frodo Looijaard <[email protected]> */ -/* $Id: i2c-philips-par.c,v 1.18 2000/07/06 19:21:49 frodo Exp $ */ +/* $Id: i2c-philips-par.c,v 1.23 2002/02/06 08:50:58 simon Exp $ */ #include <linux/kernel.h> #include <linux/ioport.h>
@@ -29,7 +29,6 @@ #include <linux/init.h> #include <linux/stddef.h> #include <linux/parport.h> - #include <linux/i2c.h> #include <linux/i2c-algo-bit.h>
@@ -190,18 +189,18 @@ struct i2c_par *adapter = kmalloc(sizeof(struct i2c_par), GFP_KERNEL); if (!adapter) { - printk("i2c-philips-par: Unable to malloc.\n"); + printk(KERN_ERR "i2c-philips-par: Unable to malloc.\n"); return; } - printk("i2c-philips-par.o: attaching to %s\n", port->name); + printk(KERN_DEBUG "i2c-philips-par.o: attaching to %s\n", port->name); adapter->pdev = parport_register_device(port, "i2c-philips-par", NULL, NULL, NULL, PARPORT_FLAG_EXCL, NULL); if (!adapter->pdev) { - printk("i2c-philips-par: Unable to register with parport.\n"); + printk(KERN_ERR "i2c-philips-par: Unable to register with parport.\n"); return; }
@@ -210,15 +209,18 @@ adapter->bit_lp_data = type ? bit_lp_data2 : bit_lp_data; adapter->bit_lp_data.data = port; + if (parport_claim_or_block(adapter->pdev) < 0 ) { + printk(KERN_ERR "i2c-philips-par: Could not claim parallel port.\n"); + return; + } /* reset hardware to sane state */ - parport_claim_or_block(adapter->pdev); bit_lp_setsda(port, 1); bit_lp_setscl(port, 1); parport_release(adapter->pdev); if (i2c_bit_add_bus(&adapter->adapter) < 0) { - printk("i2c-philips-par: Unable to register with I2C.\n"); + printk(KERN_ERR "i2c-philips-par: Unable to register with I2C.\n"); parport_unregister_device(adapter->pdev); kfree(adapter); return; /* No good */
@@ -264,7 +266,7 @@ #if LINUX_VERSION_CODE < KERNEL_VERSION(2,3,4) struct parport *port; #endif - printk("i2c-philips-par.o: i2c Philips parallel port adapter module\n"); + printk(KERN_INFO "i2c-philips-par.o: i2c Philips parallel port adapter module version %s (%s)\n", I2C_VERSION, I2C_DATE); #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,3,4) parport_register_driver(&i2c_driver);
@@ -291,7 +293,9 @@ MODULE_AUTHOR("Simon G. Vogl <[email protected]>"); MODULE_DESCRIPTION("I2C-Bus adapter routines for Philips parallel port adapter"); +#ifdef MODULE_LICENSE MODULE_LICENSE("GPL"); +#endif MODULE_PARM(type, "i");
drivers/i2c/i2c-ppc405.c 2002-05-14 18:02:35.000000000 -0400 renamed from drivers/i2c/i2c-ppc405.c.orig 1969-12-31 19:00:00.000000000 -0500 +399 -0
118 lines not on this page · raw message
include/linux/i2c-ppc405.h 2001-05-30 23:13:25.000000000 -0400 renamed from dev/null 1994-07-17 19:46:18.000000000 -0400 +125 -0
125 lines not on this page · raw message
include/linux/i2c-ppc405adap.h 2001-05-30 23:13:25.000000000 -0400 renamed from dev/null 1994-07-17 19:46:18.000000000 -0400 +46 -0
46 lines not on this page · raw message
drivers/i2c/i2c-pport.c 2002-05-14 18:03:19.000000000 -0400 renamed from drivers/i2c/i2c-pport.c.orig 1969-12-31 19:00:00.000000000 -0500 +254 -0
254 lines not on this page · raw message
drivers/i2c/i2c-rpx.c 2001-09-08 12:27:03.000000000 -0400 renamed from drivers/i2c/i2c-rpx.c.orig 1969-12-31 19:00:00.000000000 -0500 +133 -0
133 lines not on this page · raw message
drivers/i2c/i2c-velleman.c 2002-05-14 18:04:11.000000000 -0400 renamed from drivers/i2c/i2c-velleman.c.orig 2002-05-09 18:23:06.000000000 -0400 +7 -6
Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
Signature · 2 lines
Albert Cranford Deerfield Beach FL USA [email protected]
Part of the diff is not shown here. View the raw message.
PATCH 1/1 3/4 WIP I2C kernel patches-drivers
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
"albert" = Albert Cranford <[email protected]> writes:
More commets
albert> @@ -49,8 +48,8 @@
albert> /* respectively. This makes sure that the algorithm works. Some chips */
albert> /* might not like this, as they have an internal timeout of some mils */ albert> /*
albert> -#define SLO_IO jif=jiffies;while(time_before_eq(jiffies, jif+i2c_table[minor].veryslow))\
albert> - cond_resched();
albert> +#define SLO_IO jif=jiffies;while(jiffies<=jif+i2c_table[minor].veryslow)\
albert> + if (need_resched) schedule();
albert> */
albert> @@ -117,12 +116,13 @@
albert> * while they are processing data internally. albert> */
albert> setscl(adap,1);
albert> - if (time_after_eq(jiffies, start+adap->timeout)) {
albert> + if (start+adap->timeout <= jiffies) {
albert> return -ETIMEDOUT;
albert> }
albert> - cond_resched();
albert> + if (current->need_resched)
albert> + schedule();
this three changes are bogus, the good changes are the ones in the kernel.
albert> @@ -620,7 +620,9 @@
albert> #ifdef MODULE
albert> MODULE_AUTHOR("Simon G. Vogl <[email protected]>"); albert> MODULE_DESCRIPTION("I2C-Bus bit-banging algorithm"); albert> +#ifdef MODULE_LICENSE
albert> MODULE_LICENSE("GPL");
albert> +#endif
Again, compat cruft.
albert> /* check to see S1 now used as R/W ctrl - albert> PCF8584 does that when ESO is zero */
albert> - /* PCF also resets PIN bit */
albert> - if ((temp = get_pcf(adap, 1)) != (0)) {
albert> - DEB2(printk("i2c-algo-pcf.o: PCF detection failed -- can't select S0 (0x%02x).\n", temp));
albert> + if (((temp = get_pcf(adap, 1)) & 0x7f) != (0)) {
albert> + DEB2(printk(KERN_ERR "i2c-algo-pcf.o: PCF detection failed -- can't select S0 (0x%02x).\n", temp));
albert> return -ENXIO; /* definetly not PCF8584 */ albert> }
If someone knows why this needs to be & with 0x7f will be nice, i.e. one place where a commet will be on order.
albert> @@ -535,7 +533,9 @@
albert> #ifdef MODULE
albert> MODULE_AUTHOR("Hans Berglund <[email protected]>"); albert> MODULE_DESCRIPTION("I2C-Bus PCF8584 algorithm"); albert> +#ifdef MODULE_LICENSE
albert> MODULE_LICENSE("GPL");
albert> +#endif
Again not needed.
albert> -static void __exit pcf_isa_exit(void)
albert> +static void pcf_isa_exit(void)
albert> {
albert> if (irq > 0) {
albert> disable_irq(irq);
Wrong change, that is an exit function.
albert> @@ -300,7 +302,9 @@
albert> #ifdef MODULE
albert> MODULE_AUTHOR("Hans Berglund <[email protected]>");
albert> MODULE_DESCRIPTION("I2C-Bus adapter routines for PCF8584 ISA bus adapter"); albert> +#ifdef MODULE_LICENSE
albert> MODULE_LICENSE("GPL");
albert> +#endif
not needed again.
albert> -static void __exit bit_elv_exit(void) albert> +static void bit_elv_exit(void) albert> {
albert> release_region( base , (base = 0x3bc)? 3 : 8 ); albert> }
also exit function.
albert> @@ -200,7 +198,9 @@
albert> #ifdef MODULE
albert> MODULE_AUTHOR("Simon G. Vogl <[email protected]>"); albert> MODULE_DESCRIPTION("I2C-Bus adapter routines for ELV parallel port adapter"); albert> +#ifdef MODULE_LICENSE
albert> MODULE_LICENSE("GPL");
albert> +#endif
Not needed again.
albert> --- linux/drivers/i2c/i2c-philips-par.c.orig 2002-05-09 18:21:56.000000000 -0400
albert> +++ linux/drivers/i2c/i2c-philips-par.c 2002-05-14 18:02:15.000000000 -0400 albert> +#ifdef MODULE_LICENSE
albert> MODULE_LICENSE("GPL");
albert> +#endif
Not needed again.
albert> -static void __exit bit_velle_exit(void) albert> +static void bit_velle_exit(void) albert> {
albert> release_region( base , (base = 0x3bc)? 3 : 8 ); albert> }
it is really an exit function.
albert> #ifdef MODULE
albert> MODULE_AUTHOR("Simon G. Vogl <[email protected]>"); albert> MODULE_DESCRIPTION("I2C-Bus adapter routines for Velleman K8000 adapter"); albert> +#ifdef MODULE_LICENSE
albert> MODULE_LICENSE("GPL");
albert> +#endif
Not needed.
Later, Juan.
Signature · 2 lines
In theory, practice and theory are the same, but in practice they are different -- Larry McVoy