aboutsummaryrefslogtreecommitdiff
path: root/drivers/gpio/tc35892.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/gpio/tc35892.c')
-rw-r--r--drivers/gpio/tc35892.c405
1 files changed, 178 insertions, 227 deletions
diff --git a/drivers/gpio/tc35892.c b/drivers/gpio/tc35892.c
index db77b07a0dd..633be5bf6c1 100644
--- a/drivers/gpio/tc35892.c
+++ b/drivers/gpio/tc35892.c
@@ -5,7 +5,7 @@
* Copyright (C) 2009 ST Ericsson.
*
* Author: Hanumath Prasad <hanumath.prasad@stericsson.com>
- * heavily based on stmpe2401 driver
+ *
*
* 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
@@ -25,9 +25,7 @@
#include <mach/tc35892.h>
static void tc35892_work(struct work_struct *_chip);
-
-/**
- * struct tc35892_chip - tc35892 gpio chip strcture
+/* struct tc35892_chip - tc35892 gpio chip strcture
* @gpio_chip: pointer to the gpio_chip library
* @client: pointer to the i2c_client structure
* @lock: internal sync primitive
@@ -76,7 +74,7 @@ static int tc35892_write_byte(struct tc35892_chip *chip,
* This funtion uses smbus byte read API to read a byte from the given offset.
**/
static int tc35892_read_byte(struct tc35892_chip *chip, unsigned char reg,
- unsigned char *val)
+ unsigned char *val)
{
int ret;
ret = i2c_smbus_read_byte_data(chip->client, reg);
@@ -99,10 +97,8 @@ static int tc35892_read_byte(struct tc35892_chip *chip, unsigned char reg,
static int tc35892_read(struct tc35892_chip *chip, unsigned char reg, unsigned char *buf, unsigned char nbytes)
{
int ret;
-
- ret = i2c_smbus_read_i2c_block_data(chip->client,reg,nbytes,buf);
-
- if (ret < nbytes){
+ ret = i2c_smbus_read_i2c_block_data(chip->client, reg, nbytes, buf);
+ if (ret < nbytes) {
printk(KERN_ERR "error in reading a byte, smbus byte read failed\n");
return ret;
}
@@ -117,13 +113,13 @@ static int tc35892_read(struct tc35892_chip *chip, unsigned char reg, unsigned c
* This funtion uses smbus block write API's to write n number of bytes to the tc35892
**/
static t_tc35892_error tc35892_write(struct tc35892_chip *chip,
- unsigned char *buf,unsigned char nbytes)
+ unsigned char *buf, unsigned char nbytes)
{
int ret;
/* Need to check the return value*/
- ret = i2c_smbus_write_i2c_block_data(chip->client, buf[0],nbytes-1,&buf[1]);
- if(ret < 0){
- printk("i2c smbus write block data failed\n");
+ ret = i2c_smbus_write_i2c_block_data(chip->client, buf[0], nbytes-1, &buf[1]);
+ if (ret < 0) {
+ printk(KERN_ERR"i2c smbus write block data failed\n");
return ret;
}
return 0;
@@ -162,25 +158,21 @@ static int tc35892_gpio_get_value(struct gpio_chip *gc, unsigned off)
unsigned char reg_val, offset, mask;
chip = container_of(gc, struct tc35892_chip, gpio_chip);
- if(off >= MAX_TC35892_GPIO)
+ if (off >= MAX_TC35892_GPIO)
/*number of pin exceeded*/
return TC35892_BAD_PARAMETER;
-
- if(off < 8)
- {
+ mutex_lock(&chip->lock);
+ if (off < 8) {
offset = GPIO_DATA0_Index;
mask = 1 << off;
- }
- else if(off < 16)
- {
+ } else if (off < 16) {
offset = GPIO_DATA1_Index;
mask = 1 << (off-8);
- }
- else
- {
+ } else {
offset = GPIO_DATA2_Index;
mask = 1 << (off-16);
}
+ mutex_unlock(&chip->lock);
ret = tc35892_read_byte(chip, offset, &reg_val);
if (ret < 0) {
printk(KERN_ERR "Error in tc35892_gpio_get_vaule\n");
@@ -192,7 +184,7 @@ static int tc35892_gpio_get_value(struct gpio_chip *gc, unsigned off)
* tc35892_gpio_set_value() - Set a GPIO value from the given offset
* @gc: pointer to the gpio_chip strcture
* @off: The write gpio offset
- * @val: value need to be written
+ * @val: value need to be written
*
* This funtion is called from the gpio library to set/unset a GPIO
* value. This funtion sets the GPIO DATA register to set a bit.
@@ -207,41 +199,35 @@ static void tc35892_gpio_set_value(struct gpio_chip *gc,
mutex_lock(&chip->lock);
offset = calculate_gpio_offset(off);
mask = 1 << (off % 8);
-
/*register selection depending on the pin number*/
- if((off/8) == 0){
+ if ((off/8) == 0) {
temp_buf[0] = GPIO_DATA0_Index;
- if(val == 0 ){
+ if (val == 0) {
temp_buf[1] = ~(1 << off);
temp_buf[2] = (1 << off);
- }else if(val == 1){
+ } else if (val == 1) {
temp_buf[1] = 1 << off;
temp_buf[2] = 1 << off;
}
-
- }
- else if((off/8) == 1) {
+ } else if ((off/8) == 1) {
temp_buf[0] = GPIO_DATA1_Index;
- if(val == 0 ){
+ if (val == 0) {
temp_buf[1] = ~(1 << (off-8));
temp_buf[2] = (1 << (off-8));
- }else if(val == 1){
+ } else if (val == 1) {
temp_buf[1] = 1 << (off-8);
temp_buf[2] = 1 << (off-8);
}
- }
-
- else {
+ } else {
temp_buf[0] = GPIO_DATA2_Index;
- if(val == 0 ){
+ if (val == 0) {
temp_buf[1] = ~(1 << (off-16));
temp_buf[2] = 1 << (off-16);
- }else if(val == 1){
+ } else if (val == 1) {
temp_buf[1] = 1 << (off-16);
temp_buf[2] = 1 << (off-16);
}
}
-
tc35892_write(chip, temp_buf, 3);
mutex_unlock(&chip->lock);
}
@@ -263,15 +249,18 @@ static int tc35892_gpio_direction_output(struct gpio_chip *gc,
unsigned char mask, temp;
chip = container_of(gc, struct tc35892_chip, gpio_chip);
- if(off >= MAX_TC35892_GPIO)
+ if (off >= MAX_TC35892_GPIO)
/*number of pin exceeded*/
return TC35892_BAD_PARAMETER;
offset = calculate_gpio_offset(off);
mask = 1 << (off % 8);
-
reg_val = tc35892_read_byte(chip, (GPIO_DIR0_Index + offset), &temp);
+ if (reg_val != TC35892_OK)
+ return TC35892_I2C_ERROR;
temp |= mask;
reg_val = tc35892_write_byte(chip, (GPIO_DIR0_Index + offset), temp);
+ if (reg_val != TC35892_OK)
+ return TC35892_I2C_ERROR;
return 0;
}
/**
@@ -286,19 +275,19 @@ static int tc35892_gpio_direction_input(struct gpio_chip *gc, unsigned off)
{
struct tc35892_chip *chip;
unsigned char reg_val, temp, offset, mask;
-
- if(off >= MAX_TC35892_GPIO)
+ if (off >= MAX_TC35892_GPIO)
/*number of pin exceeded*/
return TC35892_BAD_PARAMETER;
-
chip = container_of(gc, struct tc35892_chip, gpio_chip);
-
offset = calculate_gpio_offset(off);
mask = 1 << (off % 8);
reg_val = tc35892_read_byte(chip, (GPIO_DIR0_Index + offset), &temp);
+ if (reg_val != TC35892_OK)
+ return TC35892_I2C_ERROR;
temp &= ~mask;
-
- tc35892_write_byte(chip, (GPIO_DIR0_Index + offset), temp);
+ reg_val = tc35892_write_byte(chip, (GPIO_DIR0_Index + offset), temp);
+ if (reg_val != TC35892_OK)
+ return TC35892_I2C_ERROR;
return 0;
}
/**
@@ -341,143 +330,127 @@ static t_tc35892_error tc35892_bit_calc(unsigned char pin_index, unsigned char p
{
unsigned char mask;
mask = 1 << (pin_index % 8);
- if(pin_value == 0)
- {
- *reg_byte &=~ mask;
- }
- else if(pin_value == 1)
- {
- *reg_byte |= mask;
- }
- else
- {
+ if (pin_value == 0) {
+ *reg_byte &= ~mask;
+ } else if (pin_value == 1) {
+ *reg_byte |= mask;
+ } else {
return TC35892_BAD_PARAMETER;
}
return TC35892_OK;
}
/**
* tc35892_set_gpio_intr_conf()- configure tc35892 gpio interrupt configuration
- * @tc35892_id: index of the device (0-3)
* @pin_index: pin to be read (0-23)
* @edge_level_sensitive: interrupt is either edge sensitive(EDGE_SENSITIVE) or level sensitive(LEVEl_SENSITIVE)
* @edge_level_type: intr can be detected on FALLING/RISING edge or LOW/HIGH level or on BOTH EDGES
*
* This function configure tc35892 gpio intr_type for edge/level detection.
- * TC35892_FALLING_EDGE_OR_LOWLEVEL fallingedge/lowlevel detection
- * TC35892_RISING_EDGE_OR_HIGHLEVEl risingedge/highlevel detection
- * TC35892_BOTH_EDGE falling and rising edge detection
+ * TC35892_FALLING_EDGE_OR_LOWLEVEL fallingedge/lowlevel detection
+ * TC35892_RISING_EDGE_OR_HIGHLEVEl risingedge/highlevel detection
+ * TC35892_BOTH_EDGE falling and rising edge detection
* This function will set the interrupt sensitivity as edge or level sensitive. Depending on that
* it will configure the interrupt detection either on fallingedge/lowlevel or risingedge/highlevel.
**/
-t_tc35892_error tc35892_set_gpio_intr_conf (int pin_index,unsigned char edge_level_sensitive, unsigned char edge_level_type)
+t_tc35892_error tc35892_set_gpio_intr_conf (int pin_index, unsigned char edge_level_sensitive, unsigned char edge_level_type)
{
t_tc35892_error retval = TC35892_OK;
- unsigned char offset,tempbyte, off;
+ unsigned char offset, tempbyte, off;
unsigned char val_intr = 0, val_sense = 0;
unsigned char val_both_edge = 0;
pin_index = pin_index - EGPIO_PIN_0;
- if(pin_index < 0 || pin_index >= MAX_TC35892_GPIO)
+ if (pin_index < 0 || pin_index >= MAX_TC35892_GPIO)
/*number of pin exceeded*/
return TC35892_BAD_PARAMETER;
-
- switch(edge_level_sensitive)
- {
- case EDGE_SENSITIVE:
- val_sense = 0;
- break;
- case LEVEl_SENSITIVE:
- val_sense = 1;
- break;
- default :
- retval = TC35892_BAD_PARAMETER;
- break;
+ switch (edge_level_sensitive) {
+ case EDGE_SENSITIVE:
+ val_sense = 0;
+ break;
+ case LEVEl_SENSITIVE:
+ val_sense = 1;
+ break;
+ default:
+ retval = TC35892_BAD_PARAMETER;
+ break;
}
-
- switch(edge_level_type)
- {
- case TC35892_FALLING_EDGE_OR_LOWLEVEL:
- val_intr = 0;
- break;
- case TC35892_RISING_EDGE_OR_HIGHLEVEL:
- val_intr = 1;
- break;
- case TC35892_BOTH_EDGE:
- val_both_edge = 1;
- break;
- default :
- retval = TC35892_BAD_PARAMETER;
- break;
+ switch (edge_level_type) {
+ case TC35892_FALLING_EDGE_OR_LOWLEVEL:
+ val_intr = 0;
+ break;
+ case TC35892_RISING_EDGE_OR_HIGHLEVEL:
+ val_intr = 1;
+ break;
+ case TC35892_BOTH_EDGE:
+ val_both_edge = 1;
+ break;
+ default:
+ retval = TC35892_BAD_PARAMETER;
+ break;
}
-
off = calculate_gpio_offset(pin_index);
-
/*configuring the sync register to synchronize the interrupt signal*/
- if(retval == TC35892_OK)
- {
+ if (retval == TC35892_OK) {
offset = GPIO_SYNC0_Index + off;
retval = tc35892_read_byte(the_tc35892, offset, &tempbyte);
- if(retval != TC35892_OK)
- return TC35892_I2C_ERROR;
+ if (retval != TC35892_OK)
+ return TC35892_I2C_ERROR;
retval = tc35892_bit_calc(pin_index, 1, &tempbyte);
retval = tc35892_write_byte(the_tc35892, offset, tempbyte);
- if(retval != TC35892_OK)
- return TC35892_I2C_ERROR;
+ if (retval != TC35892_OK)
+ return TC35892_I2C_ERROR;
}
-
/*configuring the GPIO interrupt on both edges*/
- if(retval == TC35892_OK && val_both_edge)
- {
+ if (retval == TC35892_OK && val_both_edge) {
offset = GPIO_IBE0_Index + off;
retval = tc35892_read_byte(the_tc35892, offset, &tempbyte);
- if(retval != TC35892_OK)
- return TC35892_I2C_ERROR;
+ if (retval != TC35892_OK)
+ return TC35892_I2C_ERROR;
retval = tc35892_bit_calc(pin_index, val_both_edge, &tempbyte);
+ if (retval != TC35892_OK)
+ return TC35892_I2C_ERROR;
retval = tc35892_write_byte(the_tc35892, offset, tempbyte);
-
- tc35892_read_byte(the_tc35892, offset, &tempbyte);
-
- //printk("\n The value of the INTR CONF REISTER is = %x\n",tempbyte);
- if(retval != TC35892_OK)
- return TC35892_I2C_ERROR;
+ if (retval != TC35892_OK)
+ return TC35892_I2C_ERROR;
}
-
/*configure the GPIO on rising edge or falling edge*/
- if(retval == TC35892_OK && !val_both_edge)
- {
+ if (retval == TC35892_OK && !val_both_edge) {
offset = GPIO_IEV0_Index + off;
retval = tc35892_read_byte(the_tc35892, offset, &tempbyte);
- if(retval != TC35892_OK)
- return TC35892_I2C_ERROR;
+ if (retval != TC35892_OK)
+ return TC35892_I2C_ERROR;
retval = tc35892_bit_calc(pin_index, val_intr, &tempbyte);
+ if (retval != TC35892_OK)
+ return TC35892_I2C_ERROR;
retval = tc35892_write_byte(the_tc35892, offset, tempbyte);
- if(retval != TC35892_OK)
- return TC35892_I2C_ERROR;
+ if (retval != TC35892_OK)
+ return TC35892_I2C_ERROR;
}
-
/*configure the interrupt on edgesensitive or levelsensitive*/
- if(retval == TC35892_OK)
- {
+ if (retval == TC35892_OK) {
offset = GPIO_IS0_Index + off;
retval = tc35892_read_byte(the_tc35892, offset, &tempbyte);
- if(retval != TC35892_OK)
- return TC35892_I2C_ERROR;
+ if (retval != TC35892_OK)
+ return TC35892_I2C_ERROR;
retval = tc35892_bit_calc(pin_index, val_sense, &tempbyte);
+ if (retval != TC35892_OK)
+ return TC35892_I2C_ERROR;
retval = tc35892_write_byte(the_tc35892, offset, tempbyte);
- if(retval != TC35892_OK)
- return TC35892_I2C_ERROR;
+ if (retval != TC35892_OK)
+ return TC35892_I2C_ERROR;
}
/*clearing the interrupt*/
- if(retval == TC35892_OK)
- {
+ if (retval == TC35892_OK) {
offset = GPIO_IC0_Index + off;
retval = tc35892_read_byte(the_tc35892, offset, &tempbyte);
- if(retval != TC35892_OK)
- return TC35892_I2C_ERROR;
+ if (retval != TC35892_OK)
+ return TC35892_I2C_ERROR;
retval = tc35892_bit_calc(pin_index, 1, &tempbyte);
+ if (retval != TC35892_OK)
+ return TC35892_I2C_ERROR;
retval = tc35892_write_byte(the_tc35892, offset, tempbyte);
- if(retval != TC35892_OK)
- return TC35892_I2C_ERROR;
+ if (retval != TC35892_OK)
+ return TC35892_I2C_ERROR;
}
return retval;
}
@@ -490,65 +463,59 @@ EXPORT_SYMBOL(tc35892_set_gpio_intr_conf);
*
* This funtion will enable(ENABLE_INTERRUPT) or disable(DISABLE_INTERRUPT) the interrupt
**/
-t_tc35892_error tc35892_set_intr_enable(int pin_index,unsigned char intr_enable_disable)
+t_tc35892_error tc35892_set_intr_enable(int pin_index, unsigned char intr_enable_disable)
{
t_tc35892_error retval = TC35892_OK;
- unsigned char offset,tempbyte;
+ unsigned char offset, tempbyte;
unsigned char val_enable, off;
pin_index = pin_index - EGPIO_PIN_0;
- if(pin_index < 0 || pin_index >= MAX_TC35892_GPIO)
+ if (pin_index < 0 || pin_index >= MAX_TC35892_GPIO)
/*number of pin exceeded*/
return TC35892_BAD_PARAMETER;
- switch(intr_enable_disable)
- {
- case ENABLE_INTERRUPT:
- val_enable = 1;
- break;
- case DISABLE_INTERRUPT:
- val_enable = 0;
- break;
- default:
- retval = TC35892_BAD_PARAMETER;
- break;
-
+ switch (intr_enable_disable) {
+ case ENABLE_INTERRUPT:
+ val_enable = 1;
+ break;
+ case DISABLE_INTERRUPT:
+ val_enable = 0;
+ break;
+ default:
+ retval = TC35892_BAD_PARAMETER;
+ break;
}
-
off = calculate_gpio_offset(pin_index);
/* Enabling the interrupt */
- if(retval == TC35892_OK)
- {
+ if (retval == TC35892_OK) {
offset = GPIO_IE0_Index + off;
retval = tc35892_read_byte(the_tc35892, offset, &tempbyte);
- if(retval != TC35892_OK)
- return TC35892_I2C_ERROR;
-
- retval = tc35892_read_byte(the_tc35892, offset, &tempbyte);
+ if (retval != TC35892_OK)
+ return TC35892_I2C_ERROR;
retval = tc35892_bit_calc(pin_index, val_enable, &tempbyte);
+ if (retval != TC35892_OK)
+ return TC35892_I2C_ERROR;
retval = tc35892_write_byte(the_tc35892, offset, tempbyte);
- retval = tc35892_read_byte(the_tc35892, offset, &tempbyte);
- if(retval != TC35892_OK)
- return TC35892_I2C_ERROR;
+ if (retval != TC35892_OK)
+ return TC35892_I2C_ERROR;
}
return retval;
}
EXPORT_SYMBOL(tc35892_set_intr_enable);
-
/**
* tc35892_set_callback() - install a callback handler
* @irq: gpio number
* @handler: funtion pointer to the callback handler
- * @data: Arguement to the callback
+ * @data: Arguement to the callback
*
* This funtion install the callback handler for the client device
**/
int tc35892_set_callback(int irq, void *handler, void *data)
{
- mutex_lock(&the_tc35892->lock);
irq = irq - EGPIO_PIN_0;
- if(irq < 0 || irq >= MAX_TC35892_GPIO)
+ if (irq < 0 || irq >= MAX_TC35892_GPIO)
/*number of pin exceeded*/
return TC35892_BAD_PARAMETER;
+ mutex_lock(&the_tc35892->lock);
the_tc35892->handlers[irq] = handler;
the_tc35892->data[irq] = data;
/*if required, you can enable interrupt here
@@ -566,11 +533,11 @@ EXPORT_SYMBOL(tc35892_set_callback);
**/
int tc35892_remove_callback(int irq)
{
- mutex_lock(&the_tc35892->lock);
irq = irq - EGPIO_PIN_0;
- if(irq < 0 || irq >= MAX_TC35892_GPIO)
+ if (irq < 0 || irq >= MAX_TC35892_GPIO)
/*number of pin exceeded*/
return TC35892_BAD_PARAMETER;
+ mutex_lock(&the_tc35892->lock);
the_tc35892->handlers[irq] = NULL;
the_tc35892->data[irq] = NULL;
/*if required, you can disable interrupt here
@@ -592,7 +559,6 @@ EXPORT_SYMBOL(tc35892_remove_callback);
static irqreturn_t tc35892_intr_handler(int irq, void *_chip)
{
struct tc35892_chip *chip = _chip;
- //printk("\nInterrupt from %d\n", irq);
schedule_work(&chip->work);
return IRQ_HANDLED;
@@ -622,26 +588,24 @@ static void tc35892_work(struct work_struct *_chip)
bit = find_first_bit(&mask_intr_status, 8);
while (bit) {
handler = the_tc35892->handlers[bit + count];
- if (handler){
+ if (handler) {
handler(the_tc35892->data[bit+count]);
mask = 1 << ((bit + count) % 8);
tc35892_write_byte(chip, (GPIO_IC0_Index + i), mask);
tc35892_write_byte(chip, RSTINTCLR_index, 0x01);
return;
- //bit = find_next_bit(&mask_intr_status, 8, bit + 1);
- }
- else{
+ /*bit = find_next_bit(&mask_intr_status, 8, bit + 1);*/
+ } else {
mask = 1 << ((bit + count) % 8);
tc35892_write_byte(chip, (GPIO_IC0_Index + i), mask);
tc35892_write_byte(chip, RSTINTCLR_index, 0x01);
break;
}
- //bit = find_next_bit(&mask_intr_status, 8, bit + 1);
+ /*bit = find_next_bit(&mask_intr_status, 8, bit + 1);*/
}
count += 8;
}
}
-
/**
* tc35892_probe() - initialize the tc35892
* @client: pointer to the i2c client structure
@@ -652,12 +616,12 @@ static void tc35892_work(struct work_struct *_chip)
* and set up the i2c client information
**/
static int tc35892_probe(struct i2c_client *client,
- const struct i2c_device_id *id)
+ const struct i2c_device_id *id)
{
struct tc35892_platform_data *pdata = client->dev.platform_data;
struct tc35892_chip *chip;
unsigned char chip_id, version_id, clk_en;
- int ret,i;
+ int ret, i;
chip = kzalloc(sizeof(struct tc35892_chip), GFP_KERNEL);
if (chip == NULL)
@@ -685,63 +649,50 @@ static int tc35892_probe(struct i2c_client *client,
/*
* issue soft reset for all the modules
*/
- ret = tc35892_write_byte(chip,RSTCTRL_Index,0x0E);
- if(ret != TC35892_OK)
- {
- printk("couldn't do soft reset the tc35892 modules\n");
- return ret;
- }
- /*configure the EXTRSTN line as the hardware reset*/
-
- ret = tc35892_write_byte(chip,EXTRSTN_Index,0x1);
- if(ret != TC35892_OK)
- {
- printk("couldn't configure EXTRSTN line for hard reset \n");
- return ret;
- }
- ret = tc35892_read_byte(chip,MANFACTURE_Code_Index,&chip_id);
- if(ret != TC35892_OK)
- {
- printk("couldn't read the MANFACTURE ID of the GPIO EXPANDER \n");
- return ret;
- }
- ret = tc35892_read_byte(chip,VERSION_ID_Index,&version_id);
- if(ret != TC35892_OK)
- {
- printk("couldn't read the VERSION ID of the GPIO EXPANDER \n");
- return ret;
- }
-
- //ret = tc35892_write_byte(chip,CLKCFG_Index,0xB0);
- ret = tc35892_write_byte(chip,CLKEN_Index,0x40);
-
- if(ret != TC35892_OK)
- {
- printk("couldn't configure CLKEN register\n");
- return ret;
- }
- ret = tc35892_read(chip, CLKEN_Index, &clk_en, 1);
- if(ret != TC35892_OK)
- {
- printk("couldn't read CLKEN register\n");
- return ret;
- }
- printk(KERN_INFO
- "tc35892 gpio expander: chip id: %d, version id:%d \n", chip_id,
- version_id);
-
- ret = tc35892_write_byte( chip, RSTINTCLR_index, 0x01);
- if(ret != TC35892_OK)
- {
- printk("couldn't configure RSTINTCLR register\n");
- return ret;
- }
+ ret = tc35892_write_byte(chip, RSTCTRL_Index, 0x0E);
+ if (ret != TC35892_OK) {
+ printk(KERN_ERR"couldn't do soft reset the tc35892 modules\n");
+ return ret;
+ }
+ /*configure the EXTRSTN line as the hardware reset*/
- for(i=0; i < MAX_INT_EXP; i++)
+ ret = tc35892_write_byte(chip, EXTRSTN_Index, 0x1);
+ if (ret != TC35892_OK) {
+ printk(KERN_ERR"couldn't configure EXTRSTN line for hard reset \n");
+ return ret;
+ }
+ ret = tc35892_read_byte(chip, MANFACTURE_Code_Index, &chip_id);
+ if (ret != TC35892_OK) {
+ printk(KERN_ERR"couldn't read the MANFACTURE ID of the GPIO EXPANDER \n");
+ return ret;
+ }
+ ret = tc35892_read_byte(chip, VERSION_ID_Index, &version_id);
+ if (ret != TC35892_OK) {
+ printk(KERN_ERR"couldn't read the VERSION ID of the GPIO EXPANDER \n");
+ return ret;
+ }
+ ret = tc35892_write_byte(chip, CLKEN_Index, 0x40);
+ if (ret != TC35892_OK) {
+ printk(KERN_ERR"couldn't configure CLKEN register\n");
+ return ret;
+ }
+ ret = tc35892_read(chip, CLKEN_Index, &clk_en, 1);
+ if (ret != TC35892_OK) {
+ printk(KERN_ERR"couldn't read CLKEN register\n");
+ return ret;
+ }
+ printk(KERN_INFO
+ "tc35892 gpio expander: chip id: %d, version id:%d \n", chip_id,
+ version_id);
+ ret = tc35892_write_byte(chip, RSTINTCLR_index, 0x01);
+ if (ret != TC35892_OK) {
+ printk(KERN_ERR"couldn't configure RSTINTCLR register\n");
+ return ret;
+ }
+ for (i = 0; i < MAX_INT_EXP; i++)
the_tc35892->handlers[i] = NULL;
-
ret = request_irq(pdata->irq, tc35892_intr_handler,
- IRQF_TRIGGER_FALLING, "tc35892", chip);
+ (IRQF_TRIGGER_FALLING), "tc35892", chip);
if (ret) {
printk(KERN_ERR
"unable to request for the irq %d\n", GPIO_TO_IRQ(217));
@@ -779,9 +730,9 @@ MODULE_DEVICE_TABLE(i2c, tc35892_id);
static struct i2c_driver tc35892_driver = {
.driver = {
- .name = "tc35892",
- .owner = THIS_MODULE,
- },
+ .name = "tc35892",
+ .owner = THIS_MODULE,
+ },
.probe = tc35892_probe,
.remove = __exit_p(tc35892_remove),
.id_table = tc35892_id,