mirror of
https://github.com/edk2-porting/linux-next.git
synced 2024-12-19 02:34:01 +08:00
424ed67c7d
The original i2c-algo-bit implementation uses a 33/66 SCL duty cycle when bits are being written on the bus. While the I2C specification doesn't forbid it, this prevents us from driving the I2C bus to its max speed, limiting us to 66 kbps max on standard I2C busses. Implementing a 50/50 duty cycle instead lets us max out the bandwidth up to the theoretical max of 100 kbps on standard I2C busses. This is particularly important when large amounts of data need to be transfered over the bus, as is the case with some TV adapters when the firmware is being uploaded. In fact this change even allows, at least in theory, fast-mode I2C support at 125, 166 and 250 kbps. There's no way to reach the theoretical max of 400 kbps with this implementation. But I don't think we want to put efforts in that direction anyway: software-driven I2C is very CPU-intensive and bad for latency. Other timing changes: * Don't set SDA high explicitly on error, we're going to issue a stop condition before we leave anyway. * If an error occurs when sending the slave address, yield the CPU before retrying, and remove the additional delay after the new start condition. Signed-off-by: Jean Delvare <khali@linux-fr.org>
52 lines
2.1 KiB
C
52 lines
2.1 KiB
C
/* ------------------------------------------------------------------------- */
|
|
/* i2c-algo-bit.h i2c driver algorithms for bit-shift adapters */
|
|
/* ------------------------------------------------------------------------- */
|
|
/* Copyright (C) 1995-99 Simon G. Vogl
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
it under the terms of the GNU General Public License as published by
|
|
the Free Software Foundation; either version 2 of the License, or
|
|
(at your option) any later version.
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
GNU General Public License for more details.
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
along with this program; if not, write to the Free Software
|
|
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
|
|
/* ------------------------------------------------------------------------- */
|
|
|
|
/* With some changes from Kyösti Mälkki <kmalkki@cc.hut.fi> and even
|
|
Frodo Looijaard <frodol@dds.nl> */
|
|
|
|
#ifndef _LINUX_I2C_ALGO_BIT_H
|
|
#define _LINUX_I2C_ALGO_BIT_H
|
|
|
|
/* --- Defines for bit-adapters --------------------------------------- */
|
|
/*
|
|
* This struct contains the hw-dependent functions of bit-style adapters to
|
|
* manipulate the line states, and to init any hw-specific features. This is
|
|
* only used if you have more than one hw-type of adapter running.
|
|
*/
|
|
struct i2c_algo_bit_data {
|
|
void *data; /* private data for lowlevel routines */
|
|
void (*setsda) (void *data, int state);
|
|
void (*setscl) (void *data, int state);
|
|
int (*getsda) (void *data);
|
|
int (*getscl) (void *data);
|
|
|
|
/* local settings */
|
|
int udelay; /* half clock cycle time in us,
|
|
minimum 2 us for fast-mode I2C,
|
|
minimum 5 us for standard-mode I2C and SMBus,
|
|
maximum 50 us for SMBus */
|
|
int timeout; /* in jiffies */
|
|
};
|
|
|
|
int i2c_bit_add_bus(struct i2c_adapter *);
|
|
int i2c_bit_add_numbered_bus(struct i2c_adapter *);
|
|
|
|
#endif /* _LINUX_I2C_ALGO_BIT_H */
|