Esempio n. 1
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;
}
Esempio 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);
}
Esempio n. 3
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();
}
Esempio 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);
}
Esempio n. 5
0
static inline int i2c_recv_bit(struct efx_i2c_interface *i2c)
{
	int bit;

	EFX_WARN_ON_PARANOID(i2c->scl != 0);
	EFX_WARN_ON_PARANOID(!i2c->sda);
	setscl(i2c, 1);
	bit = getsda(i2c);
	setscl(i2c, 0);
	return bit;
}
Esempio n. 6
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;
}
Esempio n. 7
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);
}
/*
 * Raise scl line, and do checking for delays. This is necessary for slower
 * devices.
 */
static int sclhi(struct i2c_algo_bit_data *adap)
{
	unsigned long start;

	setscl(adap, 1);

	/* Not all adapters have scl sense line... */
	if (!adap->getscl)
		goto done;

	start = jiffies;
	while (!getscl(adap)) {
		/* This hw knows how to read the clock line, so we wait
		 * until it actually gets high.  This is safer as some
		 * chips may hold it low ("clock stretching") while they
		 * are processing data internally.
		 */
<<<<<<< HEAD
		if (time_after(jiffies, start + adap->timeout)) {
			/* Test one last time, as we may have been preempted
			 * between last check and timeout test.
			 */
			if (getscl(adap))
				break;
			return -ETIMEDOUT;
		}
=======
		if (time_after(jiffies, start + adap->timeout))
Esempio n. 9
0
void i2c_bitbang_init(struct i2c *base)
{
	writew(I2C_SYSTEST_ST_EN | I2C_SYSTEST_FREE | (3 << I2C_SYSTEST_TMODE_SHIFT), &base->systest);
	busidle(base);
//	printf("i2c-bb init base=%08x\n", base);
#if OLD
	printf("I2C_SYSTEST1 *0x4807003C = %04x\n", readw(0x4807003C));
	printf("I2C_SYSTEST2 *0x4807203C = %04x\n", readw(0x4807203C));
	printf("I2C_SYSTEST3 *0x4806003C = %04x\n", readw(0x4806003C));
	setscl(base, 0);
	delay_full_clock();
	printf("I2C_SYSTEST2 *0x4807203C = %04x\n", readw(0x4807203C));
	setscl(base, 1);
	delay_full_clock();
	printf("I2C_SYSTEST2 *0x4807203C = %04x\n", readw(0x4807203C));
#endif
}
Esempio n. 10
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);
}
Esempio n. 11
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();
}
Esempio n. 12
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");
}
Esempio n. 13
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);
}
Esempio n. 14
0
/* Wiggle plot subroutine for vertical plotting */
void wigplot(float *dataptr, int nt, int ntr)
{
	float scalet;		/* time axis scale			*/
	float scalex;		/* trace axis scale			*/
	float sizet;		/* length of t-axis (inches)		*/
	float sizex;		/* length of x-axis (inches)		*/
	float zerot;		/* base of plot to bot. of screen	*/
	float zerox;		/* left of plot to left of screen	*/
	int fill;		/* fill flag				*/
	float overlap;		/* maximum trace overlap		*/
	int plotfat;		/* line thickness of traces		*/
	register int i;		/* counter				*/


	/* Get parameters */
	if (!igetpar("fill", &fill))		fill = FILL;

	if (!fgetpar("overlap", &overlap))	overlap = OVERLAP;

	if (!fgetpar("zerot", &zerot))		zerot = ZEROT;
	if (!fgetpar("zerox", &zerox))		zerox = ZEROX;

	if (!fgetpar("sizet", &sizet))		sizet = SIZET;
	if (!fgetpar("sizex", &sizex))		sizex = SIZEX;

	scalet = -sizet/nt;
	scalex = sizex/MAX(ntr, 8);

	if (!igetpar("plotfat", &plotfat))	plotfat = PLOTFAT;

	setscl(scalex, scalet);
	set0(zerox, zerot + sizet);

	/* Draw wiggle traces */
	setcol(RED);  
	setfat(plotfat);
	setscl(scalex*overlap, scalet);
	for (i = 0; i < ntr; i++) {
		setu0(-(float) i / overlap, 0.0);
		vertwig(dataptr + nt*i, nt, fill);
	}
}
static void mlx90615_set_power(struct mlx90615_data *mlx90615, int onoff)
{
	pr_info("[BODYTEMP] %s : %s\n", __func__, (onoff)?"ON":"OFF");

	if (onoff) {
		setscl(mlx90615, 1);

		if (mlx90615->power > 0)
			gpio_set_value(mlx90615->power, 1);
		else {
			mlx90615_power_parse_dt(&mlx90615->i2c_client->dev,
				mlx90615);
		}
		udelay(100);
		setscl(mlx90615, 0);
		msleep(50);
		setscl(mlx90615, 1);
		msleep(20);
	} else
		if (mlx90615->power > 0)
			gpio_set_value(mlx90615->power, 0);
}
Esempio n. 16
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 scllo(struct i2c_algo_bit_data *adap)
{
	setscl(adap, 0);
	udelay(adap->udelay / 2);
}
Esempio n. 18
0
void subplot(float *data, int nt, int nx, string title,
	string label1, string label2, float truemax, float max)
{
	int i,plotfat,axisfat,dtict,ntict,nticx;
	float sizet,sizex,scalet,scalex,zerot,zerox,margint,marginx,dticx;
	float dash,gap,truedticx,xmin,dx;
	int titlsz,lablsz,ticsz,hcopy,dashflag;
	char tval[8];		/* tic value string			*/

	zerot = 0.5;		fgetpar("zerox",&zerot);
	zerox = 1.0;		fgetpar("zeroy",&zerox);

	sizet = 8.0;		fgetpar("sizex",&sizet);
	sizex = 5.0;		fgetpar("sizey",&sizex);

	dashflag = 0; 		igetpar("dash",&dashflag);

	nticx = 1; 		igetpar("nticy",&nticx);
	ntict = 5;		fgetpar("nticx",&ntict);

	dtict = nt/ntict;
	if (dtict>10) dtict -= dtict%10;
	igetpar("dticx",&dtict);

	margint = 0.01;		fgetpar("marginx",&margint);
	marginx = 0.04;		fgetpar("marginy",&marginx);

	ticsz = 3;		igetpar("ticsz",&ticsz);

	hcopy = 0;		igetpar("hcopy",&hcopy);
	if ( hcopy == 1 ) {
		sizet=4.5; 
		sizex=3.5;
		ticsz=2;
	}

	scalet = sizet/nt;	
	scalex = 0.5*sizex;
	setscl(scalet,scalex);
	set0(zerot, zerox + 0.5*sizex );
	setfat(axisfat);


	/* ZERO LINE*/
	setcol(3);  
	umove( 0.0,         0.0 );
	udraw( (float)nt,   0.0 );

	/* Amplitude tics */

	dticx = max/nticx;
	truedticx = truemax/nticx;

	
	for ( i = -nticx ; i <= nticx ; i++ ) {
		umove( (float)nt , i*dticx  / max );
		udraw( (1.0 + margint) * nt, i*dticx / max ); 
		sprintf( tval, "%.3g", i*truedticx );
		utext( (1.0 + 2*margint) * nt, i*dticx / max , ticsz, 0, tval);
	}


	/* DRAW N2 WIGGLE TRACES */
	for ( i = 0 ; i < nx ; i++ ) {
		if ( dashflag ) {
			dash = ( i % 6 ) * .05;
			gap = dash;
			if ( dash ) {
				setdash(dash,gap,dash,gap);
			}
		}
	 	setcol(6 - i % 6); 
		wgl1( data + nt*i, nt); 
	}
}