2 * ARM IOC/IOMD i2c driver.
4 * Copyright (C) 2000 Russell King
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
10 * On Acorn machines, the following i2c devices are on the bus:
11 * - PCF8583 real time clock & static RAM
13 #include <linux/module.h>
14 #include <linux/i2c.h>
15 #include <linux/i2c-algo-bit.h>
18 #include <mach/hardware.h>
19 #include <asm/hardware/ioc.h>
21 #define FORCE_ONES 0xdc
26 * We must preserve all non-i2c output bits in IOC_CONTROL.
27 * Note also that we need to preserve the value of SCL and
28 * SDA outputs as well (which may be different from the
29 * values read back from IOC_CONTROL).
31 static u_int force_ones;
33 static void ioc_setscl(void *data, int state)
35 u_int ioc_control = ioc_readb(IOC_CONTROL) & ~(SCL | SDA);
36 u_int ones = force_ones;
45 ioc_writeb(ioc_control | ones, IOC_CONTROL);
48 static void ioc_setsda(void *data, int state)
50 u_int ioc_control = ioc_readb(IOC_CONTROL) & ~(SCL | SDA);
51 u_int ones = force_ones;
60 ioc_writeb(ioc_control | ones, IOC_CONTROL);
63 static int ioc_getscl(void *data)
65 return (ioc_readb(IOC_CONTROL) & SCL) != 0;
68 static int ioc_getsda(void *data)
70 return (ioc_readb(IOC_CONTROL) & SDA) != 0;
73 static struct i2c_algo_bit_data ioc_data = {
82 static struct i2c_adapter ioc_ops = {
84 .algo_data = &ioc_data,
87 static int __init i2c_ioc_init(void)
89 force_ones = FORCE_ONES | SCL | SDA;
91 return i2c_bit_add_numbered_bus(&ioc_ops);
94 module_init(i2c_ioc_init);
96 MODULE_AUTHOR("Russell King <linux@armlinux.org.uk>");
97 MODULE_DESCRIPTION("ARM IOC/IOMD i2c driver");
98 MODULE_LICENSE("GPL v2");