Ejemplo n.º 1
0
static inline void i2c_stop(struct efx_i2c_interface *i2c)
{
	EFX_WARN_ON_PARANOID(i2c->scl != 0);
	setsda(i2c, 0);
	setscl(i2c, 1);
	setsda(i2c, 1);
}
Ejemplo n.º 2
0
static inline void i2c_send_bit(struct efx_i2c_interface *i2c, int bit)
{
	EFX_WARN_ON_PARANOID(i2c->scl != 0);
	setsda(i2c, bit);
	setscl(i2c, 1);
	setscl(i2c, 0);
	setsda(i2c, 1);
}
Ejemplo n.º 3
0
static inline void stop(struct i2c *base)
{
	setsda(base, 0);	// set next data bit
	delay_quarter_clock();
	setscl(base, 1);	// this is like sending a 0 bit
	delay_half_clock();
	setsda(base, 1);	// but switch data during clock -> STOP
	delay_quarter_clock();
}
Ejemplo n.º 4
0
static inline void i2c_start(struct efx_i2c_interface *i2c)
{
	/* We may be restarting immediately after a {send,recv}_bit,
	 * so SCL will not necessarily already be high.
	 */
	EFX_WARN_ON_PARANOID(!i2c->sda);
	setscl(i2c, 1);
	setsda(i2c, 0);
	setscl(i2c, 0);
	setsda(i2c, 1);
}
Ejemplo n.º 5
0
static u8 wait_9bit(struct tc300k_data *data)
{
	int i;
	int buf;
	u8 send_buf = 0;

	gpio_direction_input(data->pdata->gpio_sda);
	s3c_gpio_setpull(data->pdata->gpio_sda, S3C_GPIO_PULL_NONE);
	getsda(data);
	ndelay(10);
	setscl(data, 1);
	ndelay(40);
	setscl(data, 0);
	ndelay(20);

	for (i = 0; i < 8; i++) {
		setscl(data, 1);
		ndelay(20);
		buf = getsda(data);
		ndelay(20);
		setscl(data, 0);
		ndelay(20);
		send_buf |= (buf & 0x01) << i;
	}
	setsda(data, 0);

	return send_buf;
}
Ejemplo n.º 6
0
static inline void busidle(struct i2c *base)
{
	/*
	 * float the SCL and SDA lines. The lines have pull-ups
	 */
	setscl(base, 1);
	setsda(base, 1);
}
Ejemplo n.º 7
0
static inline void start(struct i2c *base)
{
	busidle(base);
	delay_full_clock();
	setsda(base, 0);	// switch data during SCL=H -> this is START
	delay_quarter_clock();
	setscl(base, 0);	// switch clock -> prepare for bits
	//	printf("start\n");
}
Ejemplo n.º 8
0
static inline void i2c_release(struct efx_i2c_interface *i2c)
{
	EFX_WARN_ON_PARANOID(!i2c->scl);
	EFX_WARN_ON_PARANOID(!i2c->sda);
	/* Devices may time out if operations do not end */
	setscl(i2c, 1);
	setsda(i2c, 1);
	EFX_BUG_ON_PARANOID(getsda(i2c) != 1);
	EFX_BUG_ON_PARANOID(getscl(i2c) != 1);
}
Ejemplo n.º 9
0
static inline void write_bit(struct i2c *base, int bit)
{
//	printf("write bit %d\n", bit);
	setsda(base, bit);
	delay_quarter_clock();
	setscl(base, 1);
	delay_half_clock();
	setscl(base, 0);
	delay_quarter_clock();
}
Ejemplo n.º 10
0
static inline int read_bit(struct i2c *base)
{
	int bit;
	setsda(base, 1);	// so that we can read from the OC line...
	delay_quarter_clock();
	setscl(base, 1);
	delay_half_clock();
	setscl(base, 0);
	bit = getsda(base);
	delay_quarter_clock();
//	printf("read bit %d\n", bit);
	return bit;
}
Ejemplo n.º 11
0
static void send_9bit(struct tc300k_data *data, u8 buff)
{
	int i;

	setscl(data, 1);
	ndelay(20);
	setsda(data, 0);
	ndelay(20);
	setscl(data, 0);
	ndelay(20);

	for (i = 0; i < 8; i++) {
		setscl(data, 1);
		ndelay(20);
		setsda(data, (buff >> i) & 0x01);
		ndelay(20);
		setscl(data, 0);
		ndelay(20);
	}

	setsda(data, 0);
}
static inline void sdahi(struct i2c_algo_bit_data *adap)
{
	setsda(adap, 1);
	udelay((adap->udelay + 1) / 2);
}