Commit latest Qisda version and Bookeen's modification

This commit is contained in:
mlt
2010-04-23 11:27:04 +00:00
committed by Godzil
parent 2c907884d1
commit f2fd2aec61
75 changed files with 182708 additions and 51781 deletions

View File

@@ -917,6 +917,11 @@ static int s3c24xx_i2c_resume(struct platform_device *dev)
//AUDIO [i2c] SDA setting
s3c2410_gpio_cfgpin(S3C2410_GPE15, S3C2410_GPE15_IICSDA);
/*kit.add 2010/01/11*/
//s3c2410_gpio_cfgpin(S3C2410_GPE15, S3C2410_GPE15_IICSDA);
//s3c2410_gpio_cfgpin(S3C2410_GPE14, S3C2410_GPE14_IICSCL);
/*kit.end*/
printk("[HIKO DEBUG]s3c24xx_i2c_resume");
//HIKO: for RT5624 audio power management process {
//#endif //0
@@ -941,6 +946,14 @@ static int s3c24xx_i2c_suspend(struct platform_device *dev)
//AUDIO [i2c] SDA setting
s3c2410_gpio_cfgpin(S3C2410_GPE15, S3C2410_GPE15_INP);
/*kit.add 2010/01/11*/
//s3c2410_gpio_cfgpin(S3C2410_GPE14, S3C2410_GPE14_OUTP);
//s3c2410_gpio_setpin(S3C2410_GPE14, 0);
//s3c2410_gpio_cfgpin(S3C2410_GPE15, S3C2410_GPE15_OUTP);
//s3c2410_gpio_setpin(S3C2410_GPE15, 0);
/*kit.end*/
printk("[HIKO DEBUG]s3c24xx_i2c_suspend");
@@ -956,7 +969,7 @@ static int s3c24xx_i2c_suspend(struct platform_device *dev)
static struct platform_driver s3c2410_i2c_driver = {
.probe = s3c24xx_i2c_probe,
.remove = s3c24xx_i2c_remove,
.suspend = s3c24xx_i2c_suspend, //Asaku
.suspend = s3c24xx_i2c_suspend, //Asaku
.resume = s3c24xx_i2c_resume,
.driver = {
.owner = THIS_MODULE,
@@ -967,7 +980,7 @@ static struct platform_driver s3c2410_i2c_driver = {
static struct platform_driver s3c2440_i2c_driver = {
.probe = s3c24xx_i2c_probe,
.remove = s3c24xx_i2c_remove,
.suspend = s3c24xx_i2c_suspend, //Asaku
.suspend = s3c24xx_i2c_suspend, //Asaku
.resume = s3c24xx_i2c_resume,
.driver = {
.owner = THIS_MODULE,

View File

@@ -131,4 +131,12 @@ config QISDA_IIC
help
tony.yc.huang@qisda.com
#Qisda Tony 090406, add Auo touch i2c driver ]
#BENQ Aaron 091210, add power-saving of AUO touch i2c driver for plato
config TOUCH_PM
tristate "Power Saving Setting of Touch for Plato use"
default n
help
aaron.lan@benq.com
endmenu

View File

@@ -52,6 +52,48 @@
#define QISDA_IIC_ID 0xB8
#define DELAY_TIME_IIC_READ 8//1//8
//Aaron, add for the feature of buffered touch data
#define USE_BUFFERED_TOUCH_DATA
#ifdef USE_BUFFERED_TOUCH_DATA
//Aaron, prevent from read wrong data in touch panel of old firmware version
static int IsBufferedDataFwVersion;
#endif
#ifdef CONFIG_TOUCH_PM
//Aaron
#define AXIS_DATA(axis) \
printk(KERN_INFO"AA: show_%s():", #axis); \
if (axis < 0) \
return snprintf(buf, PAGE_SIZE, "%s\n", "read data error"); \
else { \
axis = axis; \
return snprintf(buf, PAGE_SIZE, "0x%x(%d)\n", axis, axis); \
}
#define COORD_DATA_BLOCK_NUM 8
#define X1_LSB 0x00
#define X1_MSB 0x01
#define Y1_LSB 0x02
#define Y1_MSB 0x03
#define X2_LSB 0x04
#define X2_MSB 0x05
#define Y2_LSB 0x06
#define Y2_MSB 0x07
#define X_SENSITIVITY 0x6F
#define Y_SENSITIVITY 0x70
#define INT_SETTING 0x71
#define INT_WIDTH 0x72
#define POWERMODE 0x73
#define CALIBRATION 0x78
#endif
static struct i2c_driver qisda_iic_driver;
static unsigned short normal_i2c[] = { QISDA_IIC_ID>>1 , I2C_CLIENT_END };
I2C_CLIENT_INSMOD_1(qisda_iic);
@@ -105,6 +147,308 @@ static struct i2c_driver qisda_iic_driver = {
#define NEW_TCOM_BOARD
//Tony 090615 end
#ifdef CONFIG_TOUCH_PM
//Aaron
static ssize_t show_x1(struct device *device, struct device_attribute *attr,
char *buf)
{
#if 1
int x1;
// int x1_lsb, x1_msb;
struct qisda_iic_data *data = dev_get_drvdata(device);
x1 = i2c_smbus_read_word_data(&data->client, X1_LSB);
AXIS_DATA(x1); /* Macro */
// x1_lsb = i2c_smbus_read_byte_data(&data->client, X1_LSB);
// x1_msb = i2c_smbus_read_byte_data(&data->client, X1_MSB);
// printk(KERN_INFO"AA: show_x1():");
// if (x1_lsb < 0 || x1_msb < 0)
// return snprintf(buf, PAGE_SIZE, "%s\n", "read data error");
// else {
// x1 = (x1_lsb & 0xff) | (x1_msb << 8);
// return snprintf(buf, PAGE_SIZE, "0x%x(%d)\n", x1, x1);
// }
#else
struct qisda_iic_data *data = dev_get_drvdata(device);
u8 coordinate[COORD_DATA_BLOCK_NUM] = {0};
int ret = 0;
int x1, y1, x2, y2;
ret = i2c_smbus_read_i2c_block_data(&data->client, X1_LSB, COORD_DATA_BLOCK_NUM, coordinate);
if (ret != COORD_DATA_BLOCK_NUM)
return snprintf(buf, PAGE_SIZE, "%s\n", "read data error(number not match)");
x1 = *(coordinate ) | (*(coordinate + 1) << 8);
y1 = *(coordinate + 2) | (*(coordinate + 3) << 8);
x2 = *(coordinate + 4) | (*(coordinate + 5) << 8);
y2 = *(coordinate + 6) | (*(coordinate + 7) << 8);
return snprintf(buf, PAGE_SIZE, "(%d,%d)(%d,%d)\n", x1, y1, x2, y2);
#endif
}
static DEVICE_ATTR(x1, S_IRUGO, show_x1, NULL);
static ssize_t show_y1(struct device *device, struct device_attribute *attr,
char *buf)
{
int y1;
struct qisda_iic_data *data = dev_get_drvdata(device);
y1 = i2c_smbus_read_word_data(&data->client, Y1_LSB);
AXIS_DATA(y1); /* Macro */
/* printk(KERN_ERR"AA: show_y1(): y1_lsb=0x%x, y1_msb=0x%x \n", y1_lsb, y1_msb);
if (y1_lsb < 0 || y1_msb < 0)
return snprintf(buf, PAGE_SIZE, "%s\n", "read x1 error");
else {
y1 = (y1_lsb & 0xff) | ((y1_msb & 0x3) << 8);
return snprintf(buf, PAGE_SIZE, "0x%x(%d)\n", x1, x1);
}
*/
//return snprintf(buf, PAGE_SIZE, "0x%x\n", );
}
static DEVICE_ATTR(y1, S_IRUGO, show_y1, NULL);
static ssize_t show_x2(struct device *device, struct device_attribute *attr,
char *buf)
{
int x2;
struct qisda_iic_data *data = dev_get_drvdata(device);
#if 0
x2 = i2c_smbus_read_word_data(&data->client, X2_LSB);
#else
x2 = i2c_smbus_read_word_data(&data->client, 0xC0);
#endif
AXIS_DATA(x2); /* Macro */
}
static DEVICE_ATTR(x2, S_IRUGO, show_x2, NULL);
static ssize_t show_y2(struct device *device, struct device_attribute *attr,
char *buf)
{
int y2;
struct qisda_iic_data *data = dev_get_drvdata(device);
#if 0
y2 = i2c_smbus_read_word_data(&data->client, Y2_LSB);
#else
y2 = i2c_smbus_read_byte_data(&data->client, 0x77);
#endif
AXIS_DATA(y2); /* Macro */
}
static DEVICE_ATTR(y2, S_IRUGO, show_y2, NULL);
static ssize_t show_x_sensitivity(struct device *device, struct device_attribute *attr,
char *buf)
{
struct qisda_iic_data *data = dev_get_drvdata(device);
int value;
value = i2c_smbus_read_byte_data(&data->client, X_SENSITIVITY);
if (value < 0 || value > 255)
return snprintf(buf, PAGE_SIZE, "0x%x(error data)\n", value);
else
return snprintf(buf, PAGE_SIZE, "0x%x\n", value);
}
static ssize_t store_x_sensitivity(struct device *device,
struct device_attribute *attr,
const char *buf, size_t count)
{
struct qisda_iic_data *data = dev_get_drvdata(device);
int value = 0;
sscanf(buf, "%x", &value);
/* check whether data is correct */
if (value < 0 || value > 255)
return -EINVAL;
if (i2c_smbus_write_byte_data(&data->client, X_SENSITIVITY, value) < 0)
return -EIO;
return count;
}
static DEVICE_ATTR(x_sensitivity, S_IWUSR | S_IRUGO, show_x_sensitivity, store_x_sensitivity);
static ssize_t show_y_sensitivity(struct device *device, struct device_attribute *attr,
char *buf)
{
struct qisda_iic_data *data = dev_get_drvdata(device);
int value;
value = i2c_smbus_read_byte_data(&data->client, Y_SENSITIVITY);
if (value < 0 || value > 255)
return snprintf(buf, PAGE_SIZE, "0x%x(error)\n", value);
else
return snprintf(buf, PAGE_SIZE, "0x%x\n", value);
}
static ssize_t store_y_sensitivity(struct device *device,
struct device_attribute *attr,
const char *buf, size_t count)
{
struct qisda_iic_data *data = dev_get_drvdata(device);
int value = 0;
sscanf(buf, "%x", &value);
/* check whether data is correct */
if (value < 0 || value > 255)
return -EINVAL;
if (i2c_smbus_write_byte_data(&data->client, Y_SENSITIVITY, value) < 0)
return -EIO;
return count;
}
static DEVICE_ATTR(y_sensitivity, S_IWUSR | S_IRUGO, show_y_sensitivity, store_y_sensitivity);
static ssize_t show_int_setting(struct device *device, struct device_attribute *attr,
char *buf)
{
struct qisda_iic_data *data = dev_get_drvdata(device);
return snprintf(buf, PAGE_SIZE, "0x%x\n", i2c_smbus_read_byte_data(&data->client, INT_SETTING));
}
static ssize_t store_int_setting(struct device *device,
struct device_attribute *attr,
const char *buf, size_t count)
{
struct qisda_iic_data *data = dev_get_drvdata(device);
int setting_data = 0;
sscanf(buf, "%x", &setting_data);
/* check whether data is correct */
if (setting_data < 0 || setting_data > 0xf)
return -EINVAL;
if (i2c_smbus_write_byte_data(&data->client, INT_SETTING, setting_data) < 0)
return -EIO;
return count;
}
static DEVICE_ATTR(int_setting, S_IWUSR | S_IRUGO, show_int_setting, store_int_setting);
static ssize_t show_int_width(struct device *device, struct device_attribute *attr,
char *buf)
{
struct qisda_iic_data *data = dev_get_drvdata(device);
int value;
value = i2c_smbus_read_byte_data(&data->client, INT_WIDTH);
if (value < 0 || value > 255)
return snprintf(buf, PAGE_SIZE, "0x%x(error)\n", value);
else
return snprintf(buf, PAGE_SIZE, "0x%x\n", value);
}
static ssize_t store_int_width(struct device *device,
struct device_attribute *attr,
const char *buf, size_t count)
{
struct qisda_iic_data *data = dev_get_drvdata(device);
int value = 0;
sscanf(buf, "%x", &value);
/* check whether data is correct */
if (value < 0 || value > 255)
return -EINVAL;
if (i2c_smbus_write_byte_data(&data->client, INT_WIDTH, value) < 0)
return -EIO;
return count;
}
static DEVICE_ATTR(int_width, S_IWUSR | S_IRUGO, show_int_width, store_int_width);
static ssize_t show_powermode(struct device *device, struct device_attribute *attr,
char *buf)
{
struct qisda_iic_data *data = dev_get_drvdata(device);
int value;
value = i2c_smbus_read_byte_data(&data->client, POWERMODE);
if (value < 0 || value & 0x08)
return snprintf(buf, PAGE_SIZE, "0x%x(error)\n", value);
else
return snprintf(buf, PAGE_SIZE, "0x%x\n", value);
}
static ssize_t store_powermode(struct device *device,
struct device_attribute *attr,
const char *buf, size_t count)
{
struct qisda_iic_data *data = dev_get_drvdata(device);
int value = 0;
sscanf(buf, "%x", &value);
/* check whether data is correct */
if ((value < 0) || (value > (0xff -0x08)) || (value & 0x08))
return -EINVAL;
if (i2c_smbus_write_byte_data(&data->client, POWERMODE, value) < 0)
return -EIO;
return count;
}
static DEVICE_ATTR(powermode, S_IWUSR | S_IRUGO, show_powermode, store_powermode);
//TODO: add for calibration register.
static ssize_t show_calibration(struct device *device, struct device_attribute *attr,
char *buf)
{
struct qisda_iic_data *data = dev_get_drvdata(device);
int value;
value = i2c_smbus_read_byte_data(&data->client, CALIBRATION);
if (value < 0)
return snprintf(buf, PAGE_SIZE, "0x%x(error)\n", value);
else
return snprintf(buf, PAGE_SIZE, "0x%x\n", value);
}
static ssize_t store_calibration(struct device *device,
struct device_attribute *attr,
const char *buf, size_t count)
{
struct qisda_iic_data *data = dev_get_drvdata(device);
int value = 0;
//int value2 = -1;
sscanf(buf, "%x", &value);
/* check whether data is correct */
if ((value < 0) || (value & (0xff - 0x03)))
return -EINVAL;
if (i2c_smbus_write_byte_data(&data->client, CALIBRATION, value) < 0)
return -EIO;
return count;
}
static DEVICE_ATTR(calibration, S_IWUSR | S_IRUGO, show_calibration, store_calibration);
static struct attribute *multitouch_attributes[] = {
&dev_attr_x1.attr,
&dev_attr_y1.attr,
&dev_attr_x2.attr,
&dev_attr_y2.attr,
&dev_attr_x_sensitivity.attr,
&dev_attr_y_sensitivity.attr,
&dev_attr_int_setting.attr,
&dev_attr_int_width.attr,
&dev_attr_powermode.attr,
&dev_attr_calibration.attr,
NULL
};
static const struct attribute_group multitouch_group = {
.attrs = multitouch_attributes,
};
#endif
unsigned char qisda_iic_read(struct i2c_client *client, unsigned char subaddr)
{
int ret;
@@ -140,6 +484,35 @@ writel(readl(g_pGPIOReg_GPFCON+0x04) & (0x0<<0), g_pGPIOReg_GPFCON+0x04);
return buf[0];
}
/*kit.add 2009/12/02*/
unsigned char i2c_buf1[1];
unsigned char i2c_buf2[4];
int qisda_iic_read_pos(struct i2c_client *client, unsigned char subaddr)
{
int ret;
int i;
struct i2c_msg msg[] =
{
{client->addr, 0, 1, i2c_buf1},
{client->addr, I2C_M_RD, 4, i2c_buf2},
};
for(i=0; i<4; i++)
i2c_buf2[i] = 0;
i2c_buf1[0] = subaddr;
i2c_buf2[0] = subaddr;
ret = i2c_transfer(client->adapter, msg, 2) == 1 ? 0 : -EIO;
/*if (ret == -EIO) {
printk(" I2C read Error, subaddr: 0x%x \n", subaddr);
return 0;
}*/
return 0;
}
/*kit.end*/
static int qisda_iic_write(struct i2c_client *client, unsigned char subaddr, unsigned char val)
{
unsigned char buf[2];
@@ -190,6 +563,17 @@ static int qisda_iic_detect(struct i2c_adapter *adapter, int address, int kind)
//Then it will callback to the command
if ((err = s3c_ts_iic_port_init(new_client))) goto exit_kfree;;
#ifdef CONFIG_TOUCH_PM
/* Aaron: create sysfs group */
if (sysfs_create_group(&new_client->dev.kobj, &multitouch_group) < 0) {
printk(KERN_ERR "qisda_iic_detect: Unable to create sysfs group\n");
//goto err_sysfs_create_group_failed;
}
//Aaron: powermode with allow_sleep
if(qisda_iic_write(new_client, 0x73, 0x54) < 0)
printk(KERN_ERR "qisda_iic_detect: fail to set powermode with allow_sleep\n");
#endif
return err;
exit_kfree:
@@ -240,33 +624,55 @@ writel(readl(g_pGPIOReg_GPFCON+0x08) | (0x2<<0), g_pGPIOReg_GPFCON+0x08);
if(qisda_iic_write(client, 0x71, 0xA) < 0) return -EIO;
udelay(DELAY_TIME_IIC_READ);
u8return= qisda_iic_read(client, 0x71);
printk(KERN_INFO "qisda_iic_command INIT =0x%x\n",u8return);
//printk(KERN_INFO "qisda_iic_command INIT =0x%x\n",u8return);
qisda_iic_write(client, 0x6F, 0x22);
qisda_iic_write(client, 0x70, 0x22);
#ifdef USE_BUFFERED_TOUCH_DATA
//Aaron: add for buffered data
/* enable buffered data, because default is disabled (0x0) */
if(qisda_iic_write(client, 0xBE, 0x01) < 0) return -EIO;
udelay(DELAY_TIME_IIC_READ);
u8return= qisda_iic_read(client, 0xBE);
//printk(KERN_INFO "qisda_iic_command: points interval =0x%x\n",u8return);
u8return= qisda_iic_read(client, 0x77); //read firmware version of touch panel
//printk(KERN_INFO "qisda_iic_command: firmware version =0x%x\n",u8return);
if (u8return < 0x13)
IsBufferedDataFwVersion = 0;
else
IsBufferedDataFwVersion = 1;
#endif
#else // old
printk(KERN_INFO "qisda_iic_command INIT 1111\n");
//printk(KERN_INFO "qisda_iic_command INIT 1111\n");
mdelay(6000);
qisda_iic_write(client, 0x78, 0x3);
printk(KERN_INFO "qisda_iic_command INIT 2222\n");
//printk(KERN_INFO "qisda_iic_command INIT 2222\n");
qisda_iic_write(client, 0x71,INT_MODE_ENABLE | INT_MODE_TOUCH_INDICATE);
udelay(DELAY_TIME_IIC_READ);
u8return= qisda_iic_read(client, 0x71);
printk(KERN_INFO "qisda_iic_command INIT =0x%x\n",u8return);
//printk(KERN_INFO "qisda_iic_command INIT =0x%x\n",u8return);
#endif
break;
case QISDA_IIC_READ_POSITION:
pos = arg;
#ifdef NEW_TCOM_BOARD
u8x0= qisda_iic_read(client, 0x00);
/*kit.mod 2009/12/02*/
/*u8x0= qisda_iic_read(client, 0x00);
udelay(DELAY_TIME_IIC_READ);
u8x1= qisda_iic_read(client, 0x01);
udelay(DELAY_TIME_IIC_READ);
u8y0= qisda_iic_read(client, 0x02);
udelay(DELAY_TIME_IIC_READ);
u8y1= qisda_iic_read(client, 0x03);
udelay(DELAY_TIME_IIC_READ);
udelay(DELAY_TIME_IIC_READ);*/
qisda_iic_read_pos(client, 0x00);
u8x0 = i2c_buf2[0];
u8x1 = i2c_buf2[1];
u8y0 = i2c_buf2[2];
u8y1 = i2c_buf2[3];
/*kit.end*/
#else
u8x0= qisda_iic_read(client, 0x54);
udelay(DELAY_TIME_IIC_READ);
@@ -304,7 +710,62 @@ writel(readl(g_pGPIOReg_GPFCON+0x08) | (0x2<<0), g_pGPIOReg_GPFCON+0x08);
#endif
//printk("X: %d, Y: %d\n", pos[0], pos[1]);
break;
#ifdef USE_BUFFERED_TOUCH_DATA
/* Aaron,20091224, add for buffered data read */
case QISDA_IIC_READ_BUFFERED_POSITION:
{
int coordinate[2] = {0}; /*[0]=x, [1]=y*/
int *data = (int *)arg;
int index, len, i, j, offset, *point_data;
/* prevent from using the panel of old firmware version */
if (!IsBufferedDataFwVersion) {
printk("qisda_iic_command():buffered data(Not supported firmware version)\n");
break;
}
index = data[0];
len = data[1];
point_data = data + (2 + index * len * 2); /* each point is made of two coordinate data*/
offset = len * index * 4;
/* read buffered data for each check length */
for (i = 0; i < len; i++) {
/* read coordinates for x & y (two words), as one point data */
for (j = 0; j < 2; j++) {
coordinate[j] = i2c_smbus_read_word_data(client, (0xC0 + offset + j*2));
if (coordinate[j] < 0) {
printk("qisda_iic_command():read word data error(%d),i=%d,j=%d\n", coordinate[j], i, j);
break;
}
}
offset += 4; /* there are 4 bytes in each point data*/
//Aaron: //TODO: maybe should change from "<" to "<="
/* if either of x/y is zero, we think they are both zero. */
//TODO: need to feedback the status of no more read?????????
if (coordinate[0] <= 0 || coordinate[1] <= 0)
break;
#ifdef ROTATE_NAGATIVE_90
#if defined(AUO_EPAPER_6_INCH)
point_data[i*2] = 600 - coordinate[1];
#elif defined(AUO_EPAPER_9_INCH)
point_data[i*2] = 768 - coordinate[1];
#else
/* error: shall not go into this configuration */
point_data[i*2] = coordinate[1];
#endif
point_data[i*2 + 1] = coordinate[0];
#else
point_data[i*2] = coordinate[0];
point_data[i*2 + 1] = coordinate[1];
#endif
//printk("qisda_iic_command():buffered data(%d,%d)\n", point_data[i*2],point_data[i*2 + 1]);
}
}
break;
#endif //#ifdef USE_BUFFERED_TOUCH_DATA
case QISDA_IIC_CALIBRATION:
if(qisda_iic_write(client, 0x78, 0x3) < 0){
printk("CALIBRATION ERROR!");
@@ -312,25 +773,43 @@ writel(readl(g_pGPIOReg_GPFCON+0x08) | (0x2<<0), g_pGPIOReg_GPFCON+0x08);
}
msleep(300);
break;
#ifdef CONFIG_TOUCH_PM
case QISDA_IIC_ACTIVE_MODE:
printk("ACTIVE MODE\n");
//printk("ACTIVE MODE\n");
qisda_iic_write(client, 0x73, 0x54);
msleep(5);
break;
case QISDA_IIC_SLEEP_MODE:
//printk("SLEEP MODE\n");
qisda_iic_write(client, 0x73, 0x55);
msleep(5);
break;
case QISDA_IIC_DEEPSLEEP_MODE:
//printk("ALSO SLEEP MODE\n");
qisda_iic_write(client, 0x73, 0x55);
msleep(5);
break;
#else
case QISDA_IIC_ACTIVE_MODE:
//printk("ACTIVE MODE\n");
qisda_iic_write(client, 0x73, 0x50);
msleep(5);
break;
case QISDA_IIC_SLEEP_MODE:
printk("SLEEP MODE\n");
//printk("SLEEP MODE\n");
qisda_iic_write(client, 0x73, 0x51);
msleep(5);
break;
case QISDA_IIC_DEEPSLEEP_MODE:
printk("DEEP SLEEP MODE\n");
//printk("DEEP SLEEP MODE\n");
qisda_iic_write(client, 0x73, 0x52);
msleep(5);
break;
#endif
default:
break;