porting tp ct36x to linux3.10

This commit is contained in:
yxj
2014-03-06 09:34:09 +08:00
parent 7aefc71b17
commit 58f19df659
9 changed files with 2265 additions and 48 deletions

View File

@@ -117,6 +117,17 @@
dvdd18-gpio = <&gpio3 GPIO_D4 GPIO_ACTIVE_HIGH>;
reset-gpio = <&gpio0 GPIO_B4 GPIO_ACTIVE_LOW>;
};
ts@01 {
compatible = "ct,ct36x";
reg = <0x01>;
ct-model = <363>;
touch-gpio = <&gpio1 GPIO_B7 IRQ_TYPE_LEVEL_LOW>;
reset-gpio = <&gpio0 GPIO_B6 GPIO_ACTIVE_HIGH>;
max-x = <2048>;
max-y = <1536>;
orientation=<1 0 0 1>;
};
};
&i2c3 {
@@ -136,6 +147,43 @@
&lcdc1 {
status = "okay";
};
&adc {
status = "okay";
key {
compatible = "rockchip,key";
io-channels = <&adc 1>;
vol-up-key {
linux,code = <115>;
label = "volume up";
rockchip,adc_value = <1>;
};
vol-down-key {
linux,code = <114>;
label = "volume down";
rockchip,adc_value = <145>;
};
power-key {
gpios = <&gpio0 GPIO_A4 GPIO_ACTIVE_LOW>;
linux,code = <116>;
label = "power";
gpio-key,wakeup;
};
home-key {
linux,code = <102>;
label = "home";
rockchip,adc_value = <355>;
};
};
};
&pwm3 {
status = "okay";
};

View File

@@ -98,7 +98,6 @@ CONFIG_IPV6_MIP6=y
CONFIG_IPV6_MULTIPLE_TABLES=y
CONFIG_IPV6_SUBTREES=y
CONFIG_NETFILTER=y
CONFIG_NETFILTER_NETLINK_LOG=y
CONFIG_NF_CONNTRACK=y
CONFIG_NF_CONNTRACK_SECMARK=y
CONFIG_NF_CONNTRACK_EVENTS=y
@@ -200,11 +199,6 @@ CONFIG_BT_BNEP=y
CONFIG_BT_BNEP_MC_FILTER=y
CONFIG_BT_BNEP_PROTO_FILTER=y
CONFIG_BT_HIDP=y
CONFIG_WIRELESS=y
CONFIG_WIRELESS_EXT=y
CONFIG_WEXT_CORE=y
CONFIG_WEXT_PROC=y
CONFIG_WEXT_PRIV=y
CONFIG_CFG80211=y
CONFIG_NL80211_TESTMODE=y
CONFIG_CFG80211_WEXT=y
@@ -277,11 +271,6 @@ CONFIG_USB_HSO=y
CONFIG_USB_NET_INT51X1=y
CONFIG_USB_IPHETH=y
CONFIG_USB_SIERRA_NET=y
CONFIG_WLAN=y
# CONFIG_RKWIFI=y
CONFIG_RK903=y
CONFIG_RKWIFI_26M=y
CONFIG_WIFI_CONTROL_FUNC=y
# CONFIG_INPUT_MOUSEDEV is not set
CONFIG_INPUT_EVDEV=y
CONFIG_INPUT_KEYRESET=y
@@ -300,6 +289,8 @@ CONFIG_TABLET_USB_KBTAB=y
CONFIG_TABLET_USB_WACOM=y
CONFIG_INPUT_TOUCHSCREEN=y
CONFIG_TOUCHSCREEN_GT8XX=y
CONFIG_CT36X_TS=y
CONFIG_CT363_TS=y
CONFIG_INPUT_MISC=y
CONFIG_INPUT_KEYCHORD=y
CONFIG_INPUT_UINPUT=y
@@ -337,6 +328,10 @@ CONFIG_FB_ROCKCHIP=y
CONFIG_LCDC_RK3188=y
CONFIG_LCDC0_RK3188=y
CONFIG_LCDC1_RK3188=y
CONFIG_RK_TRSM=y
CONFIG_DP_ANX6345=y
CONFIG_RK32_DP=y
CONFIG_ROCKCHIP_RGA=y
CONFIG_LOGO=y
# CONFIG_LOGO_LINUX_MONO is not set
# CONFIG_LOGO_LINUX_VGA16 is not set
@@ -413,7 +408,6 @@ CONFIG_HID_WIIMOTE=y
CONFIG_HID_ZEROPLUS=y
CONFIG_HID_ZYDACRON=y
CONFIG_USB_HIDDEV=y
CONFIG_USB=y
CONFIG_USB_ANNOUNCE_NEW_DEVICES=y
CONFIG_USB_ACM=y
CONFIG_USB_PRINTER=y
@@ -430,22 +424,21 @@ CONFIG_USB_STORAGE_ONETOUCH=y
CONFIG_USB_STORAGE_KARMA=y
CONFIG_USB_STORAGE_CYPRESS_ATACB=y
CONFIG_USB_STORAGE_ENE_UB6250=y
CONFIG_USB20_HOST=y
CONFIG_USB20_OTG=y
CONFIG_DWC_OTG_310=y
CONFIG_USB_TRANCEVIBRATOR=y
CONFIG_USB_OTG_WAKELOCK=y
CONFIG_USB_GADGET=y
CONFIG_USB_GADGET_DEBUG_FILES=y
CONFIG_USB_GADGET_VBUS_DRAW=500
CONFIG_USB_G_ANDROID=y
CONFIG_DWC_OTG_310=y
CONFIG_USB20_HOST=y
CONFIG_USB20_OTG=y
CONFIG_MMC=y
CONFIG_MMC_CLKGATE=y
CONFIG_MMC_PARANOID_SD_INIT=y
CONFIG_MMC_BLOCK_MINORS=32
# CONFIG_MMC_BLOCK_BOUNCE is not set
CONFIG_MMC_DW=y
CONFIG_MMC_DW_PLTFM=y
CONFIG_MMC_DW_ROCKCHIP=y
CONFIG_LEDS_GPIO=y
CONFIG_LEDS_TRIGGERS=y
@@ -508,6 +501,4 @@ CONFIG_LSM_MMAP_MIN_ADDR=4096
CONFIG_SECURITY_SELINUX=y
CONFIG_CRYPTO_NULL=y
CONFIG_CRYPTO_TWOFISH=y
CONFIG_ROCKCHIP_RGA=y
# CONFIG_ROCKCHIP_RGA2=y
# CONFIG_CRYPTO_ANSI_CPRNG is not set

View File

@@ -19,6 +19,21 @@ config TOUCHSCREEN_GT8XX
code includes that in its table of IIC devices.
If unsure, say N.
config CT36X_TS
tristate "CT36X touchscreens support"
choice
prompt "ct36x chip select"
depends on CT36X_TS
default CT365_TS
config CT365_TS
bool "ct365"
config CT363_TS
bool "ct363"
config CT361_TS
bool "ct360"
endchoice
config TOUCHSCREEN_88PM860X
tristate "Marvell 88PM860x touchscreen"
depends on MFD_88PM860X

View File

@@ -5,7 +5,7 @@
# Each configuration option enables a list of files.
wm97xx-ts-y := wm97xx-core.o
obj-y += ct36x/
obj-$(CONFIG_TOUCHSCREEN_GT8XX) += rk29_i2c_goodix.o
obj-$(CONFIG_TOUCHSCREEN_88PM860X) += 88pm860x-ts.o
obj-$(CONFIG_TOUCHSCREEN_AD7877) += ad7877.o
@@ -24,7 +24,7 @@ obj-$(CONFIG_TOUCHSCREEN_CYTTSP_SPI) += cyttsp_spi.o
obj-$(CONFIG_TOUCHSCREEN_DA9034) += da9034-ts.o
obj-$(CONFIG_TOUCHSCREEN_DA9052) += da9052_tsi.o
obj-$(CONFIG_TOUCHSCREEN_DYNAPRO) += dynapro.o
obj-$(CONFIG_TOUCHSCREEN_EDT_FT5X06) += edt-ft5x06.o
obj-$(CONFIG_TOUCHSCREEN_EDT_FT5X06) += ft5506_wgj.o
obj-$(CONFIG_TOUCHSCREEN_HAMPSHIRE) += hampshire.o
obj-$(CONFIG_TOUCHSCREEN_GUNZE) += gunze.o
obj-$(CONFIG_TOUCHSCREEN_EETI) += eeti_ts.o

View File

@@ -8,7 +8,7 @@
#define CT36X_CHIP_FLASH_SOURCE_SIZE 8
static unsigned char binary_data[] = {
#include "LX20JS06_A1_CT363_V03_5198_121015.dat"
#include "wgj97112tsm01_CT363_01_V01_EA50_140224.dat"
};
int ct36x_chip_set_idle(struct ct36x_data *ts)

View File

@@ -25,7 +25,7 @@ struct ct363_priv{
static int ct363_init_hw(struct ct36x_data *ts)
{
int ret = 0;
/*
ret = gpio_request(ts->rst_io.gpio, "ct363_rst");
if(ret < 0){
dev_err(ts->dev, "Failed to request rst gpio\n");
@@ -37,10 +37,10 @@ static int ct363_init_hw(struct ct36x_data *ts)
gpio_free(ts->rst_io.gpio);
dev_err(ts->dev, "Failed to request irq gpio\n");
return ret;
}
}*/
gpio_direction_input(ts->irq_io.gpio);
gpio_pull_updown(ts->irq_io.gpio, 1);
//gpio_pull_updown(ts->irq_io.gpio, 1);
//gpio_set_value(ts->irq_io.gpio,1);
gpio_direction_output(ts->rst_io.gpio, ts->rst_io.active_low);
return 0;
@@ -204,7 +204,7 @@ static void ct363_report(struct ct36x_data *ts)
if( (ct363->x > ts->x_max) || (ct363->y > ts->y_max) || (ct363->x < 0) || (ct363->y < 0) ){
continue ;
}
ct363->x=2048-ct363->x;
input_mt_slot(ts->input, ct363->pts[i].id - 1);
input_mt_report_slot_state(ts->input, MT_TOOL_FINGER, true);
input_report_abs(ts->input, ABS_MT_TOUCH_MAJOR, 1);

View File

@@ -1,7 +1,7 @@
#ifndef __CT36X_PRIV__
#define __CT36X_PRIV__
#include <linux/earlysuspend.h>
//#include <linux/earlysuspend.h>
#include <linux/device.h>
#include <linux/kernel.h>
#include <linux/module.h>
@@ -20,8 +20,8 @@
#include <linux/ct36x.h>
#include <mach/board.h>
#include <mach/gpio.h>
//#include <mach/board.h>
//#include <mach/gpio.h>
//#if 1
//#define ct36x_dbg(ts, format, arg...) \
// dev_printk(KERN_INFO , ts->dev , format , ## arg)
@@ -77,6 +77,42 @@ struct ct36x_data{
void *priv;
};
int i2c_master_normal_send(const struct i2c_client *client, const char *buf, int count, int scl_rate)
{
int ret;
struct i2c_adapter *adap=client->adapter;
struct i2c_msg msg;
msg.addr = client->addr;
msg.flags = client->flags;
msg.len = count;
msg.buf = (char *)buf;
msg.scl_rate = scl_rate;
//msg.udelay = client->udelay;
ret = i2c_transfer(adap, &msg, 1);
return (ret == 1) ? count : ret;
}
static int i2c_master_normal_recv(const struct i2c_client *client, char *buf, int count, int scl_rate)
{
struct i2c_adapter *adap=client->adapter;
struct i2c_msg msg;
int ret;
msg.addr = client->addr;
msg.flags = client->flags | I2C_M_RD;
msg.len = count;
msg.buf = (char *)buf;
msg.scl_rate = scl_rate;
//msg.udelay = client->udelay;
ret = i2c_transfer(adap, &msg, 1);
return (ret == 1) ? count : ret;
}
EXPORT_SYMBOL(i2c_master_normal_recv);
static inline int ct36x_read(struct ct36x_data *ts, char *buf, int len)
{
return i2c_master_normal_recv(ts->client, buf, len, CT36X_I2C_RATE);

View File

@@ -1,4 +1,5 @@
#include "ct36x_priv.h"
#include <linux/of_gpio.h>
#include "core.c"
#include "ct360.c"
@@ -141,43 +142,106 @@ static int ct36x_ts_probe(struct i2c_client *client, const struct i2c_device_id
{
int ret = 0, i;
struct ct36x_data *ts = NULL;
struct ct36x_platform_data *pdata = client->dev.platform_data;
/*struct ct36x_platform_data *pdata = client->dev.platform_data;
if(!pdata){
dev_err(&client->dev, "no platform data\n");
return -EINVAL;
};
};*/
struct device_node *np = client->dev.of_node;
enum of_gpio_flags rst_flags;
unsigned long irq_flags;
u32 val;
if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) {
dev_err(&client->dev, "I2C-Adapter doesn't support I2C_FUNC_I2C\n");
return -ENODEV;
}
ts = devm_kzalloc(&client->dev, sizeof(struct ct36x_data), GFP_KERNEL);
if (ts == NULL) {
dev_err(&client->dev, "alloc for struct rk_ts_data fail\n");
return -ENOMEM;
}
if (!np) {
dev_err(&client->dev, "no device tree\n");
return -EINVAL;
}
/*
ts = kzalloc(sizeof(struct ct36x_data), GFP_KERNEL);
if(!ts){
dev_err(&client->dev, "No memory for ct36x");
return -ENOMEM;
}*/
if (of_property_read_u32(np, "max-x", &val)) {
dev_err(&client->dev, "no max-x defined\n");
return -EINVAL;
}
ts->model = pdata->model;
ts->x_max = pdata->x_max;
ts->y_max = pdata->y_max;
ts->rst_io = pdata->rst_io;
ts->irq_io = pdata->irq_io;
ts->x_max = val;
if (of_property_read_u32(np, "max-y", &val)) {
dev_err(&client->dev, "no max-y defined\n");
return -EINVAL;
}
ts->y_max = val;
printk("the ts->x_max is %d,ts->y_max is %d\n",ts->x_max,ts->y_max);
if (of_property_read_u32(np, "ct-model", &val)) {
dev_err(&client->dev, "no ct-model defined\n");
return -EINVAL;
}
ts->model = val;//pdata->model;
//ts->x_max = pdata->x_max;
//ts->y_max = pdata->y_max;
//ts->rst_io = pdata->rst_io;
//ts->irq_io = pdata->irq_io;
ts->irq_io.gpio = of_get_named_gpio_flags(np, "touch-gpio", 0, &irq_flags);
ts->rst_io.gpio = of_get_named_gpio_flags(np, "reset-gpio", 0, &rst_flags);
printk("the irq_flags is %d,rst_flags is %d\n",irq_flags,rst_flags);
int orientation[4];
ret = of_property_read_u32_array(np, "orientation",orientation,4);
if (ret < 0)
return ret;
for(i = 0; i < 4; i++)
ts->orientation[i] = pdata->orientation[i];
ts->orientation[i] = orientation[i];
ts->client = client;
ts->dev = &client->dev;
i2c_set_clientdata(client, ts);
ret = ct36x_set_ops(ts, pdata->model);
ret = ct36x_set_ops(ts, ts->model);
if(ret < 0){
dev_err(ts->dev, "Failed to set ct36x ops\n");
goto err_ct36x_set_ops;
}
if (gpio_is_valid(ts->rst_io.gpio)) {
ts->rst_io.active_low = (rst_flags & OF_GPIO_ACTIVE_LOW) ? 0 : 1;
printk("the ts->rst_io.active_low is %d ========\n",ts->rst_io.active_low);
ret = devm_gpio_request_one(&client->dev, ts->rst_io.gpio, (rst_flags & OF_GPIO_ACTIVE_LOW) ? GPIOF_OUT_INIT_HIGH : GPIOF_OUT_INIT_LOW, "ct363 reset pin");
if (ret != 0) {
dev_err(&client->dev, "ct363 gpio_request error\n");
return -EIO;
}
msleep(100);
} else {
dev_info(&client->dev, "reset pin invalid\n");
}
if (gpio_is_valid(ts->irq_io.gpio)) {
ts->irq_io.active_low = (irq_flags & OF_GPIO_ACTIVE_LOW) ? 0 : 1;
ret = devm_gpio_request_one(&client->dev, ts->irq_io.gpio, (irq_flags & OF_GPIO_ACTIVE_LOW) ? GPIOF_OUT_INIT_HIGH : GPIOF_OUT_INIT_LOW, "ct363 irq pin");
if (ret != 0) {
dev_err(&client->dev, "ct363 gpio_request error\n");
return -EIO;
}
}
if(ts->ops->init){
ret = ts->ops->init(ts);
if(ret < 0){
@@ -186,7 +250,7 @@ static int ct36x_ts_probe(struct i2c_client *client, const struct i2c_device_id
}
}
ts->input = input_allocate_device();
ts->input = devm_input_allocate_device(&ts->client->dev);
if(!ts->input){
ret = -ENODEV;
dev_err(ts->dev, "Failed to allocate input device\n");
@@ -197,9 +261,9 @@ static int ct36x_ts_probe(struct i2c_client *client, const struct i2c_device_id
ts->input->dev.parent = &client->dev;
set_bit(EV_ABS, ts->input->evbit);
set_bit(INPUT_PROP_DIRECT, ts->input->propbit);
input_mt_init_slots(ts->input, ts->point_num);
input_set_abs_params(ts->input, ABS_MT_POSITION_X, 0, pdata->x_max, 0, 0);
input_set_abs_params(ts->input, ABS_MT_POSITION_Y, 0, pdata->y_max, 0, 0);
input_mt_init_slots(ts->input, ts->point_num,0);
input_set_abs_params(ts->input, ABS_MT_POSITION_X, 0, ts->x_max, 0, 0);
input_set_abs_params(ts->input, ABS_MT_POSITION_Y, 0, ts->y_max, 0, 0);
input_set_abs_params(ts->input, ABS_MT_TOUCH_MAJOR, 0, 255, 0, 0);
input_set_abs_params(ts->input, ABS_MT_WIDTH_MAJOR, 0, 255, 0, 0);
@@ -216,16 +280,25 @@ static int ct36x_ts_probe(struct i2c_client *client, const struct i2c_device_id
register_early_suspend(&ts->early_suspend);
#endif
ts->irq = gpio_to_irq(ts->irq_io.gpio);
ret = request_threaded_irq(ts->irq, NULL, ct36x_irq_handler, IRQF_TRIGGER_FALLING|IRQF_ONESHOT, CT36X_NAME, ts);
if (ts->irq)
{
ret = devm_request_threaded_irq(&client->dev, ts->irq, NULL, ct36x_irq_handler, irq_flags | IRQF_ONESHOT, client->name, ts);
if (ret != 0) {
printk(KERN_ALERT "Cannot allocate ts INT!ERRNO:%d\n", ret);
goto err_request_threaded_irq;
}
}
/* ret = request_threaded_irq(ts->irq, NULL, ct36x_irq_handler, IRQF_TRIGGER_FALLING|IRQF_ONESHOT, CT36X_NAME, ts);
if(ret < 0){
dev_err(ts->dev, "Failed to request threaded irq\n");
goto err_request_threaded_irq;
}
*/
dev_info(ts->dev, "CT363 Successfully initialized\n");
return 0;
err_request_threaded_irq:
unregister_early_suspend(&ts->early_suspend);
//unregister_early_suspend(&ts->early_suspend);
input_unregister_device(ts->input);
err_input_register_devcie:
input_free_device(ts->input);
@@ -246,7 +319,7 @@ static int ct36x_ts_remove(struct i2c_client *client)
free_irq(ts->irq, ts);
if(ts->ops->deinit)
ts->ops->deinit(ts);
unregister_early_suspend(&ts->early_suspend);
//unregister_early_suspend(&ts->early_suspend);
input_unregister_device(ts->input);
input_free_device(ts->input);
i2c_set_clientdata(client, NULL);
@@ -259,6 +332,11 @@ static const struct i2c_device_id ct36x_ts_id[] = {
{ CT36X_NAME, 0 },
{ }
};
static struct of_device_id ct36x_ts_dt_ids[] = {
{ .compatible = "ct,ct36x" },
{ }
};
static struct i2c_driver ct36x_ts_driver = {
.probe = ct36x_ts_probe,
.remove = ct36x_ts_remove,
@@ -266,6 +344,7 @@ static struct i2c_driver ct36x_ts_driver = {
.driver = {
.owner = THIS_MODULE,
.name = CT36X_NAME,
.of_match_table = of_match_ptr(ct36x_ts_dt_ids),
},
};

File diff suppressed because it is too large Load Diff