2 * linux/drivers/acorn/char/i2c.c
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 * ARM IOC/IOMD i2c driver.
12 * On Acorn machines, the following i2c devices are on the bus:
13 * - PCF8583 real time clock & static RAM
15 #include <linux/init.h>
16 #include <linux/i2c.h>
17 #include <linux/i2c-algo-bit.h>
20 #include <mach/hardware.h>
21 #include <asm/hardware/ioc.h>
23 #define FORCE_ONES 0xdc
28 * We must preserve all non-i2c output bits in IOC_CONTROL.
29 * Note also that we need to preserve the value of SCL and
30 * SDA outputs as well (which may be different from the
31 * values read back from IOC_CONTROL).
33 static u_int force_ones
;
35 static void ioc_setscl(void *data
, int state
)
37 u_int ioc_control
= ioc_readb(IOC_CONTROL
) & ~(SCL
| SDA
);
38 u_int ones
= force_ones
;
47 ioc_writeb(ioc_control
| ones
, IOC_CONTROL
);
50 static void ioc_setsda(void *data
, int state
)
52 u_int ioc_control
= ioc_readb(IOC_CONTROL
) & ~(SCL
| SDA
);
53 u_int ones
= force_ones
;
62 ioc_writeb(ioc_control
| ones
, IOC_CONTROL
);
65 static int ioc_getscl(void *data
)
67 return (ioc_readb(IOC_CONTROL
) & SCL
) != 0;
70 static int ioc_getsda(void *data
)
72 return (ioc_readb(IOC_CONTROL
) & SDA
) != 0;
75 static struct i2c_algo_bit_data ioc_data
= {
84 static struct i2c_adapter ioc_ops
= {
86 .algo_data
= &ioc_data
,
89 static int __init
i2c_ioc_init(void)
91 force_ones
= FORCE_ONES
| SCL
| SDA
;
93 return i2c_bit_add_numbered_bus(&ioc_ops
);
96 module_init(i2c_ioc_init
);