Exemplo n.º 1
0
int ths8200_test(struct i2c_client *client, u8 reg, u8 value)
{
    int err;
    err |= ths8200_write(client, reg, value);
    if (err < 0) {
        dev_err(&client->dev, "%s: Write Error...\n", __func__);
	return -EINVAL;
    }
}
Exemplo n.º 2
0
int ths8200_disable(struct i2c_client *client)
{
    int err = 0;

    //attempt graceful powerdown: set chip_pwdn bit (enter PD mode)
    err |= ths8200_write(client, 0x03, 0x04);
    if (err < 0) {
        dev_err(&client->dev, "%s: Unable to place THS8200 into power down state...\n", __func__);
	return -EINVAL;
    }

    mdelay(1);
    return 0;
}
Exemplo n.º 3
0
int ths8200_enable(struct i2c_client *client)
{
    //ths8200_enable should only be used following ths8200_disable if THS has been initialized
    int err = 0;

    //clear chip_pwdn bit (exit PD mode)
    err |= ths8200_write(client, 0x03, 0x01);
    if (err < 0) {
        dev_err(&client->dev, "%s: Unable to communicate with THS8200...\n", __func__);
	return -EINVAL;
    }

    mdelay(1);
    return 0;
}
Exemplo n.º 4
0
int ths8200_init(struct i2c_client *client)
{
    u8 c;
    int i;
    int err = 0;

    //issue THS reset:  set reset low, (duration > 200ns)
    //disable pwm
    twl4030_i2c_read_u8(TWL4030_MODULE_INTBR, &c, 0x0d);
    c &= ~(0x30);
    twl4030_i2c_write_u8 (TWL4030_MODULE_INTBR, c, 0x0d);
    //set GPIO7 as output - pg 506
    twl4030_i2c_read_u8(TWL4030_MODULE_GPIO, &c, 0x03);
    c |= (0x80);
    twl4030_i2c_write_u8 (TWL4030_MODULE_GPIO, c, 0x03);
    //ensure reest line is high
    twl4030_i2c_read_u8(TWL4030_MODULE_GPIO, &c, 0x06);
    c |= (0x80);
    twl4030_i2c_write_u8 (TWL4030_MODULE_GPIO, c, 0x06);
    mdelay(1);
    //pull reset line low (min duration 200ns)
    c &= ~(0x80);
    twl4030_i2c_write_u8 (TWL4030_MODULE_GPIO, c, 0x06);
    mdelay(1);
    //set reset line high again
    c |= (0x80);
    twl4030_i2c_write_u8 (TWL4030_MODULE_GPIO, c, 0x06);
    mdelay(1);

    //execute init sequence
    for (i = 0; i < (sizeof(ths8200_init_seq)/2); i++)
        {
	    err |= ths8200_write(client,
	        ths8200_init_seq[i][0],
		ths8200_init_seq[i][1]);	     
	}
		
        if (err < 0) {
	        dev_err(&client->dev, "%s: Error during THS8200 init\n", __func__);
		return -EINVAL;
        }

    return 0;
}
Exemplo n.º 5
0
int ths8200_init(struct i2c_client *client)
{
    int i;
    int err = 0;

    //execute init sequence
    for (i = 0; i < (sizeof(ths8200_init_seq)/2); i++)
        {
	    err |= ths8200_write(client,
	        ths8200_init_seq[i][0],
		ths8200_init_seq[i][1]);	     
	}
		
        if (err < 0) {
	        dev_err(&client->dev, "%s: Error during THS8200 init\n", __func__);
		return -EINVAL;
        }

    return 0;
}