Hi folks, Attached is an I2C driver using the new-style (Simon Vogl) interface for MPC8xx. It currently only works as a single master.
It basically works, but there are one or two things in the code I'm not too happy about, marked by "XXX", mostly to do with module support. It does contain a crude workaround for the problem I described in a recent message (subject: "I2C Problems"; date: 8 Nov 2000). I'm not sure if this workaround will NAKs in the middle of a transfer, as it has only been tested for transfers to/from absent slave addresses. It also fixes a "race on sleep" condition that was also present in the code I based the driver on (the version of iic.c that Kim Jorgensen posted and the modified version of that that Dan Winkler posted). Dan Malek's initial read-only iic.c also handled this race condition. It seems to work okay with or without the CPM IIC/SPI Microcode patch. (I don't need the patch as I'm using Ethernet on SCC2 and I don't use SPI.) Some notes on usage: This uses the "new" I2C interface which is present in the 2.4.x kernel, or you can install the kernel patches for earlier versions of the kernel (see http://voxel.at/prj/i2c/). The driver needs to be initialized after CPM initialisation, during or after the core I2C initialization. If initializing during the the core I2C initialization, you will need to add some lines to drivers/i2c/i2c-core.c as follows: #ifdef CONFIG_I2C_MPC8XX extern int i2c8xx_init(void); #endif Then in the i2c_init_all function in that file: #ifdef CONFIG_I2C_MPC8XX i2c8xx_init(); #endif You'll also need a boolean or tristate configuration option for CONFIG_I2C_MPC8XX and a boolean configuration option CONFIG_BROKEN_CPM_I2C to use my crude workaround for broken CPM I2C implementations. If installing the driver as a module, you'll also have to load the i2c-core.o module before my i2c-8xx.o. Not all the symbols required to load i2c-8xx.o as a module are currently exported, so you'll have to add the required symbols to arch/ppc/kernel/ksyms.c. Apart from the above, the main disadvantages with this driver are that it is bigger than the old one, as you also require i2c-core.o and possibly i2c-dev.o to get similar functionality. Also, you cannot change I2C bus speeds on a per file-descriptor basis (or at all, currently) as the driver does not have any VFS interface. There is an ioctl mechanism for changing things globally for the whole I2C bus, but I haven't implemented anything for that yet (possibilities include setting the bus speed and the I2C interface's own address). -- -=( Ian Abbott @ MEV Ltd. E-mail: <abbotti at mev.co.uk> )=- -=( Tel: +44 (0)161 477 1898 FAX: +44 (0)161 718 3587 )=- -------------- next part -------------- A non-text attachment was scrubbed... Name: i2c-8xx.c Type: application/octet-stream Size: 23128 bytes Desc: not available Url : http://ozlabs.org/pipermail/linuxppc-embedded/attachments/20001113/4aa79f43/attachment.obj
