mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-08-24 09:50:04 +00:00
![Al Viro](/assets/img/avatar_default.png)
It depends on tristate I2C and it's trivial to make modular. The current Kconfig allows I2C=m, I2C_ACORN=y, which doesn't work at all; alternatives are dependency on I2C=y and making I2C_ACORN itself a tristate. The latter is the right thing to do... Signed-off-by: Al Viro <viro@zeniv.linux.org.uk> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Acked-by: Russell King <rmk+kernel@arm.linux.org.uk>
97 lines
1.9 KiB
C
97 lines
1.9 KiB
C
/*
|
|
* linux/drivers/acorn/char/i2c.c
|
|
*
|
|
* Copyright (C) 2000 Russell King
|
|
*
|
|
* This program is free software; you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License version 2 as
|
|
* published by the Free Software Foundation.
|
|
*
|
|
* ARM IOC/IOMD i2c driver.
|
|
*
|
|
* On Acorn machines, the following i2c devices are on the bus:
|
|
* - PCF8583 real time clock & static RAM
|
|
*/
|
|
#include <linux/init.h>
|
|
#include <linux/i2c.h>
|
|
#include <linux/i2c-algo-bit.h>
|
|
|
|
#include <asm/hardware.h>
|
|
#include <asm/io.h>
|
|
#include <asm/hardware/ioc.h>
|
|
#include <asm/system.h>
|
|
|
|
#define FORCE_ONES 0xdc
|
|
#define SCL 0x02
|
|
#define SDA 0x01
|
|
|
|
/*
|
|
* We must preserve all non-i2c output bits in IOC_CONTROL.
|
|
* Note also that we need to preserve the value of SCL and
|
|
* SDA outputs as well (which may be different from the
|
|
* values read back from IOC_CONTROL).
|
|
*/
|
|
static u_int force_ones;
|
|
|
|
static void ioc_setscl(void *data, int state)
|
|
{
|
|
u_int ioc_control = ioc_readb(IOC_CONTROL) & ~(SCL | SDA);
|
|
u_int ones = force_ones;
|
|
|
|
if (state)
|
|
ones |= SCL;
|
|
else
|
|
ones &= ~SCL;
|
|
|
|
force_ones = ones;
|
|
|
|
ioc_writeb(ioc_control | ones, IOC_CONTROL);
|
|
}
|
|
|
|
static void ioc_setsda(void *data, int state)
|
|
{
|
|
u_int ioc_control = ioc_readb(IOC_CONTROL) & ~(SCL | SDA);
|
|
u_int ones = force_ones;
|
|
|
|
if (state)
|
|
ones |= SDA;
|
|
else
|
|
ones &= ~SDA;
|
|
|
|
force_ones = ones;
|
|
|
|
ioc_writeb(ioc_control | ones, IOC_CONTROL);
|
|
}
|
|
|
|
static int ioc_getscl(void *data)
|
|
{
|
|
return (ioc_readb(IOC_CONTROL) & SCL) != 0;
|
|
}
|
|
|
|
static int ioc_getsda(void *data)
|
|
{
|
|
return (ioc_readb(IOC_CONTROL) & SDA) != 0;
|
|
}
|
|
|
|
static struct i2c_algo_bit_data ioc_data = {
|
|
.setsda = ioc_setsda,
|
|
.setscl = ioc_setscl,
|
|
.getsda = ioc_getsda,
|
|
.getscl = ioc_getscl,
|
|
.udelay = 80,
|
|
.timeout = 100
|
|
};
|
|
|
|
static struct i2c_adapter ioc_ops = {
|
|
.id = I2C_HW_B_IOC,
|
|
.algo_data = &ioc_data,
|
|
};
|
|
|
|
static int __init i2c_ioc_init(void)
|
|
{
|
|
force_ones = FORCE_ONES | SCL | SDA;
|
|
|
|
return i2c_bit_add_bus(&ioc_ops);
|
|
}
|
|
|
|
module_init(i2c_ioc_init);
|