rk29 aigo 1. add it7260 touch 2.modified backlight 3. gpio key

This commit is contained in:
hxy 2010-12-30 19:24:07 +08:00
parent c77dd468c7
commit d0f38270ea
10 changed files with 3043 additions and 69 deletions

File diff suppressed because it is too large Load Diff

View File

@ -3,4 +3,4 @@ obj-$(CONFIG_CPU_FREQ) += cpufreq.o
obj-$(CONFIG_RK29_VPU) += vpu.o vpu_mem.o
obj-$(CONFIG_MACH_RK29SDK) += board-rk29sdk.o board-rk29sdk-key.o board-rk29sdk-rfkill.o
obj-$(CONFIG_MACH_RK29WINACCORD) += board-rk29-winaccord.o board-rk29sdk-key.o
obj-$(CONFIG_MACH_RK29_AIGO) += board-rk29-aigo.o board-rk29sdk-key.o
obj-$(CONFIG_MACH_RK29_AIGO) += board-rk29-aigo.o board-rk29aigo-key.o board-rk29sdk-rfkill.o

View File

@ -54,28 +54,33 @@
/* Set memory size of pmem */
#ifdef CONFIG_MACH_RK29SDK_MEM_SIZE_M
#define SDRAM_SIZE (CONFIG_MACH_RK29SDK_MEM_SIZE_M * SZ_1M)
#ifdef CONFIG_RK29_MEM_SIZE_M
#define SDRAM_SIZE (CONFIG_RK29_MEM_SIZE_M * SZ_1M)
#else
#define SDRAM_SIZE SZ_512M
#endif
#define PMEM_GPU_SIZE SZ_64M
#define PMEM_UI_SIZE SZ_32M
#define PMEM_VPU_SIZE SZ_32M
#define PMEM_CAM_SIZE SZ_16M
#define PMEM_VPU_SIZE SZ_64M
#define PMEM_CAM_SIZE 0x00c00000
#ifdef CONFIG_VIDEO_RK29_WORK_IPP
#define MEM_CAMIPP_SIZE SZ_4M
#else
#define MEM_CAMIPP_SIZE 0
#endif
#define MEM_FB_SIZE (3*SZ_2M)
#define PMEM_GPU_BASE ((u32)RK29_SDRAM_PHYS + SDRAM_SIZE - PMEM_GPU_SIZE)
#define PMEM_UI_BASE (PMEM_GPU_BASE - PMEM_UI_SIZE)
#define PMEM_VPU_BASE (PMEM_UI_BASE - PMEM_VPU_SIZE)
#define PMEM_CAM_BASE (PMEM_VPU_BASE - PMEM_CAM_SIZE)
#define MEM_FB_BASE (PMEM_CAM_BASE - MEM_FB_SIZE)
#define MEM_CAMIPP_BASE (PMEM_CAM_BASE - MEM_CAMIPP_SIZE)
#define MEM_FB_BASE (MEM_CAMIPP_BASE - MEM_FB_SIZE)
#define LINUX_SIZE (MEM_FB_BASE - RK29_SDRAM_PHYS)
extern struct sys_timer rk29_timer;
#define NAND_CS_MAX_NUM 1 /*form 0 to 8, it is 0 when no nand flash */
int rk29_nand_io_init(void)
{
#if (NAND_CS_MAX_NUM == 2)
@ -313,8 +318,8 @@ static struct android_pmem_platform_data android_pmem_cam_pdata = {
.name = "pmem_cam",
.start = PMEM_CAM_BASE,
.size = PMEM_CAM_SIZE,
.no_allocator = 0,
.cached = 1,
.no_allocator = 1,
.cached = 0,
};
static struct platform_device android_pmem_cam_device = {
@ -362,9 +367,9 @@ int p1003_init_platform_hw(void)
}
gpio_pull_updown(TOUCH_INT_PIN, 1);
gpio_direction_output(TOUCH_RESET_PIN, 0);
mdelay(500);
msleep(500);
gpio_set_value(TOUCH_RESET_PIN,GPIO_LOW);
mdelay(500);
msleep(500);
gpio_set_value(TOUCH_RESET_PIN,GPIO_HIGH);
return 0;
@ -378,6 +383,82 @@ struct p1003_platform_data p1003_info = {
};
#endif
/*MMA8452 gsensor*/
#if defined (CONFIG_GS_MMA8452)
#define MMA8452_INT_PIN RK29_PIN0_PA3
int mma8452_init_platform_hw(void)
{
if(gpio_request(MMA8452_INT_PIN,NULL) != 0){
gpio_free(MMA8452_INT_PIN);
printk("mma8452_init_platform_hw gpio_request error\n");
return -EIO;
}
gpio_pull_updown(MMA8452_INT_PIN, 1);
return 0;
}
struct mma8452_platform_data mma8452_info = {
.model= 8452,
.swap_xy = 0,
.init_platform_hw= mma8452_init_platform_hw,
};
#endif
/*it7260 touch*/
#if defined (CONFIG_TOUCHSCREEN_IT7260)
#define TOUCH_PWR_PIN RK29_PIN6_PD1
#define TOUCH_RESET_PIN RK29_PIN6_PC3
#define TOUCH_INT_PIN RK29_PIN0_PA2
int it7260_init_platform_hw(void)
{
if(gpio_request(TOUCH_RESET_PIN,NULL) != 0){
gpio_free(TOUCH_RESET_PIN);
printk("it7260_init_platform_hw gpio_request error\n");
return -EIO;
}
if(gpio_request(TOUCH_INT_PIN,NULL) != 0){
gpio_free(TOUCH_INT_PIN);
printk("it7260_init_platform_hw gpio_request error\n");
return -EIO;
}
gpio_direction_output(TOUCH_PWR_PIN, 0);
gpio_set_value(TOUCH_PWR_PIN,GPIO_LOW);
msleep(100);
gpio_direction_output(TOUCH_INT_PIN, 0);
gpio_set_value(TOUCH_INT_PIN,GPIO_LOW);
msleep(100); //msleep(3000);
gpio_set_value(TOUCH_PWR_PIN,GPIO_HIGH);
msleep(100);
gpio_direction_output(TOUCH_RESET_PIN, 0);
mdelay(100);
gpio_set_value(TOUCH_RESET_PIN,GPIO_LOW);
mdelay(100);
gpio_set_value(TOUCH_RESET_PIN,GPIO_HIGH);
gpio_direction_output(TOUCH_INT_PIN, 1);
gpio_pull_updown(TOUCH_INT_PIN, 0);
return 0;
}
struct it7260_platform_data it7260_info = {
.init_platform_hw=NULL, //it7260_init_platform_hw,
};
#endif
/*****************************************************************************************
* i2c devices
@ -491,6 +572,31 @@ static struct i2c_board_info __initdata board_i2c0_devices[] = {
///.irq = RK2818_PIN_PA4,
},
#endif
#if defined (CONFIG_GS_MMA8452)
{
.type = "gs_mma8452",
.addr = 0x1c,
.flags = 0,
.irq = MMA8452_INT_PIN,
.platform_data = &mma8452_info,
},
#endif
#if defined (CONFIG_SENSORS_AK8973)
{
.type = "ak8973",
.addr = 0x1d,
.flags = 0,
.irq = RK29_PIN0_PA4,
},
#endif
#if defined (CONFIG_SENSORS_AK8975)
{
.type = "ak8975",
.addr = 0x1d,
.flags = 0,
.irq = RK29_PIN0_PA4,
},
#endif
};
#endif
@ -503,22 +609,15 @@ static struct i2c_board_info __initdata board_i2c1_devices[] = {
.flags = 0,
},
#endif
#if defined (CONFIG_SENSORS_AK8973)
{
.type = "ak8973",
.addr = 0x1c,
.flags = 0,
.irq = RK29_PIN4_PA1,
},
#endif
#if defined (CONFIG_SENSORS_AK8975)
{
.type = "ak8975",
.addr = 0x1c,
.flags = 0,
.irq = RK29_PIN4_PA1,
},
#if defined (CONFIG_ANX7150)
{
.type = "anx7150",
.addr = 0x39, //0x39, 0x3d
.flags = 0,
.irq = RK29_PIN1_PD7,
},
#endif
};
#endif
@ -533,6 +632,15 @@ static struct i2c_board_info __initdata board_i2c2_devices[] = {
.platform_data = &p1003_info,
},
#endif
#if defined (CONFIG_TOUCHSCREEN_IT7260)
{
.type = "it7260_touch",
.addr = 0x46,
.flags = 0,
.irq = RK29_PIN0_PA2,
.platform_data = &it7260_info,
},
#endif
};
#endif
@ -581,7 +689,14 @@ struct rk29camera_platform_data rk29_camera_platform_data = {
.gpio_flag = (SENSOR_POWERACTIVE_LEVEL_1|SENSOR_RESETACTIVE_LEVEL_1),
.dev_name = SENSOR_NAME_1,
}
}
},
#ifdef CONFIG_VIDEO_RK29_WORK_IPP
.meminfo = {
.name = "camera_ipp_mem",
.start = MEM_CAMIPP_BASE,
.size = MEM_CAMIPP_SIZE,
}
#endif
};
static int rk29_sensor_io_init(void)
@ -691,7 +806,7 @@ static int rk29_sensor_power(struct device *dev, int on)
}
return 0;
}
#if (SENSOR_IIC_ADDR_0 != 0x00)
static struct i2c_board_info rk29_i2c_cam_info_0[] = {
{
I2C_BOARD_INFO(SENSOR_NAME_0, SENSOR_IIC_ADDR_0>>1)
@ -715,7 +830,7 @@ struct platform_device rk29_soc_camera_pdrv_0 = {
.platform_data = &rk29_iclink_0,
},
};
#endif
static struct i2c_board_info rk29_i2c_cam_info_1[] = {
{
I2C_BOARD_INFO(SENSOR_NAME_1, SENSOR_IIC_ADDR_1>>1)
@ -741,7 +856,32 @@ struct platform_device rk29_soc_camera_pdrv_1 = {
};
extern struct platform_device rk29_device_camera;
static u64 rockchip_device_camera_dmamask = 0xffffffffUL;
struct resource rk29_camera_resource[] = {
[0] = {
.start = RK29_VIP_PHYS,
.end = RK29_VIP_PHYS + RK29_VIP_SIZE - 1,
.flags = IORESOURCE_MEM,
},
[1] = {
.start = IRQ_VIP,
.end = IRQ_VIP,
.flags = IORESOURCE_IRQ,
}
};
/*platform_device : */
struct platform_device rk29_device_camera = {
.name = RK29_CAM_DRV_NAME,
.id = RK29_CAM_PLATFORM_DEV_ID, /* This is used to put cameras on this interface */
.num_resources = ARRAY_SIZE(rk29_camera_resource),
.resource = rk29_camera_resource,
.dev = {
.dma_mask = &rockchip_device_camera_dmamask,
.coherent_dma_mask = 0xffffffffUL,
.platform_data = &rk29_camera_platform_data,
}
};
#endif
/*****************************************************************************************
* backlight devices
@ -827,7 +967,7 @@ static struct regulator_consumer_supply pwm_consumers[] = {
static struct regulator_init_data rk29_pwm_regulator_data = {
.constraints = {
.name = "PWM2",
.min_uV = 1200000,
.min_uV = 950000,
.max_uV = 1400000,
.apply_uV = 1,
.valid_ops_mask = REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_VOLTAGE,
@ -1048,6 +1188,14 @@ static struct platform_device rk29sdk_wifi_device = {
};
#endif
/* bluetooth rfkill device */
static struct platform_device rk29sdk_rfkill = {
.name = "rk29sdk_rfkill",
.id = -1,
};
#ifdef CONFIG_VIVANTE
static struct resource resources_gpu[] = {
[0] = {
@ -1086,13 +1234,6 @@ static struct platform_device rk29_device_keys = {
},
};
#endif
/********************usb*********************/
struct usb_mass_storage_platform_data mass_storage_pdata = {
.nluns = 1,
.vendor = "RockChip",
.product = "rk9 sdk",
.release = 0x0100,
};
static void __init rk29_board_iomux_init(void)
{
@ -1158,6 +1299,13 @@ static struct platform_device *devices[] __initdata = {
#ifdef CONFIG_UART1_RK29
&rk29_device_uart1,
#endif
#ifdef CONFIG_UART0_RK29
&rk29_device_uart0,
#endif
#ifdef CONFIG_UART2_RK29
&rk29_device_uart2,
#endif
#ifdef CONFIG_RK29_PWM_REGULATOR
&rk29_device_pwm_regulator,
#endif
@ -1207,6 +1355,11 @@ static struct platform_device *devices[] __initdata = {
#ifdef CONFIG_WIFI_CONTROL_FUNC
&rk29sdk_wifi_device,
#endif
#ifdef CONFIG_BT
&rk29sdk_rfkill,
#endif
#ifdef CONFIG_MTD_NAND_RK29
&rk29_device_nand,
#endif
@ -1225,19 +1378,30 @@ static struct platform_device *devices[] __initdata = {
#endif
#ifdef CONFIG_VIDEO_RK29
&rk29_device_camera, /* ddl@rock-chips.com : camera support */
#if (SENSOR_IIC_ADDR_0 != 0x00)
&rk29_soc_camera_pdrv_0,
#endif
&rk29_soc_camera_pdrv_1,
&android_pmem_cam_device,
#endif
&android_pmem_device,
&rk29_vpu_mem_device,
#ifdef CONFIG_DWC_OTG
&rk29_device_dwc_otg,
#ifdef CONFIG_USB20_OTG
&rk29_device_usb20_otg,
#endif
#ifdef CONFIG_USB20_HOST
&rk29_device_usb20_host,
#endif
#ifdef CONFIG_USB11_HOST
&rk29_device_usb11_host,
#endif
#ifdef CONFIG_USB_ANDROID
&android_usb_device,
&usb_mass_storage_device,
#endif
#ifdef CONFIG_RK29_IPP
&rk29_device_ipp,
#endif
};
/*****************************************************************************************
@ -1258,53 +1422,47 @@ static int rk29_rmii_io_init(void)
int err;
//set dm9161 rmii
rk29_mux_api_set(GPIO2D3_I2S0SDI_MIICOL_NAME, GPIO2H_GPIO2D3);
err = gpio_request(RK29_PIN2_PD3, "rmii");
if (err) {
gpio_free(RK29_PIN2_PD3);
printk("-------request RK29_PIN2_PD3 fail--------\n");
return -1;
}
gpio_direction_output(RK29_PIN2_PD3, GPIO_HIGH);
gpio_set_value(RK29_PIN2_PD3, GPIO_HIGH);
//rmii power on
err = gpio_request(RK29_PIN6_PB0, "rmii_power_en");
err = gpio_request(RK29_PIN6_PB0, "phy_power_en");
if (err) {
gpio_free(RK29_PIN6_PB0);
gpio_free(RK29_PIN2_PD3);
printk("-------request RK29_PIN6_PB0 fail--------\n");
return -1;
}
gpio_direction_output(RK29_PIN6_PB0, GPIO_HIGH);
gpio_set_value(RK29_PIN6_PB0, GPIO_HIGH);
}
//phy power down
gpio_direction_output(RK29_PIN6_PB0, GPIO_LOW);
gpio_set_value(RK29_PIN6_PB0, GPIO_LOW);
return 0;
}
static int rk29_rmii_io_deinit(void)
{
//phy power down
gpio_direction_output(RK29_PIN6_PB0, GPIO_LOW);
gpio_set_value(RK29_PIN6_PB0, GPIO_LOW);
//free
gpio_free(RK29_PIN6_PB0);
return 0;
}
static int rk29_rmii_power_control(int enable)
{
if (enable) {
//set dm9161 as rmii
gpio_direction_output(RK29_PIN2_PD3, GPIO_HIGH);
gpio_set_value(RK29_PIN2_PD3, GPIO_HIGH);
//enable rmii power
//enable phy power
gpio_direction_output(RK29_PIN6_PB0, GPIO_HIGH);
gpio_set_value(RK29_PIN6_PB0, GPIO_HIGH);
}
else {
gpio_direction_output(RK29_PIN6_PB0, GPIO_LOW);
gpio_set_value(RK29_PIN6_PB0, GPIO_LOW);
}
return 0;
}
struct rk29_vmac_platform_data rk29_vmac_pdata = {
.vmac_register_set = rk29_vmac_register_set,
.rmii_io_init = rk29_rmii_io_init,
.rmii_io_deinit = rk29_rmii_io_deinit,
.rmii_power_control = rk29_rmii_power_control,
};
@ -1518,8 +1676,8 @@ static void __init machine_rk29_board_init(void)
{
rk29_board_iomux_init();
gpio_request(POWER_ON_PIN,"poweronpin");
gpio_set_value(POWER_ON_PIN, 1);
gpio_direction_output(POWER_ON_PIN, 1);
gpio_set_value(POWER_ON_PIN, GPIO_HIGH);
gpio_direction_output(POWER_ON_PIN, GPIO_HIGH);
#ifdef CONFIG_WIFI_CONTROL_FUNC
rk29sdk_wifi_bt_gpio_control_init();
@ -1544,6 +1702,11 @@ static void __init machine_rk29_board_init(void)
#endif
spi_register_board_info(board_spi_devices, ARRAY_SIZE(board_spi_devices));
#ifdef CONFIG_TOUCHSCREEN_IT7260
// must before lcd, so place here
it7260_init_platform_hw();
#endif
}
static void __init machine_rk29_fixup(struct machine_desc *desc, struct tag *tags,

View File

@ -0,0 +1,53 @@
#include <mach/key.h>
#include <mach/gpio.h>
#define EV_ENCALL KEY_F4
#define EV_MENU KEY_F1
#define PRESS_LEV_LOW 1
#define PRESS_LEV_HIGH 0
static struct rk29_keys_button key_button[] = {
{
.desc = "menu",
.code = EV_MENU,
.gpio = RK29_PIN6_PA0,
.active_low = PRESS_LEV_LOW,
},
{
.desc = "vol+",
.code = KEY_VOLUMEUP,
.gpio = RK29_PIN6_PA1,
.active_low = PRESS_LEV_LOW,
},
{
.desc = "vol-",
.code = KEY_VOLUMEDOWN,
.gpio = RK29_PIN6_PA2,
.active_low = PRESS_LEV_LOW,
},
{
.desc = "home",
.code = KEY_HOME,
.gpio = RK29_PIN6_PA3,
.active_low = PRESS_LEV_LOW,
},
{
.desc = "esc",
.code = KEY_BACK,
.gpio = RK29_PIN6_PA5,
.active_low = PRESS_LEV_LOW,
},
{
.desc = "play",
.code = KEY_POWER,
.gpio = RK29_PIN6_PA7,
.active_low = PRESS_LEV_LOW,
},
};
struct rk29_keys_platform_data rk29_keys_pdata = {
.buttons = key_button,
.nbuttons = ARRAY_SIZE(key_button),
.chn = -1, //chn: 0-7, if do not use ADC,set 'chn' -1
};

View File

@ -141,6 +141,15 @@ struct mma8452_platform_data {
int (*mma8452_platform_wakeup)(void);
void (*exit_platform_hw)(void);
};
/*it7260 touch */
struct it7260_platform_data {
int (*get_pendown_state)(void);
int (*init_platform_hw)(void);
int (*it7260_platform_sleep)(void);
int (*it7260_platform_wakeup)(void);
void (*exit_platform_hw)(void);
};
void __init rk29_map_common_io(void);
void __init rk29_clock_init(void);

View File

@ -604,5 +604,14 @@ config HANNSTAR_P1003
help
RK29 hannstar touch debug
config TOUCHSCREEN_IT7260
tristate "IT7260 based touchscreens: IT7260 Interface"
depends on I2C2_RK29
help
Say Y here if you have a touchscreen interface using the
it7260 controller, and your board-specific initialization
code includes that in its table of I2C devices.
If unsure, say N (but it's safe to say "Y").
endif

View File

@ -50,3 +50,4 @@ obj-$(CONFIG_TOUCHSCREEN_XPT2046_320X480_CBN_SPI) += xpt2046_cbn_ts.o calibrati
obj-$(CONFIG_TOUCHSCREEN_IT7250) += ctp_it7250.o
obj-$(CONFIG_RK28_I2C_TS_NTP070) += ntp070.o
obj-$(CONFIG_HANNSTAR_P1003) += hannstar_p1003.o
obj-$(CONFIG_TOUCHSCREEN_IT7260) += it7260_ts.o

View File

@ -0,0 +1,778 @@
/****************************************************************************************
* driver/input/touchscreen/i2cpca955x.c
*Copyright :ROCKCHIP Inc
*Author : sfm
*Date : 2010.2.5
*This driver use for rk28 chip extern touchscreen. Use i2c IF ,the chip is pca955x
*description£º
********************************************************************************************/
#include <linux/module.h>
#include <linux/delay.h>
#include <linux/earlysuspend.h>
#include <linux/hrtimer.h>
#include <linux/i2c.h>
#include <linux/input.h>
#include <linux/interrupt.h>
#include <linux/io.h>
#include <linux/platform_device.h>
#include <linux/async.h>
#include <linux/workqueue.h>
#include <mach/gpio.h>
#include <linux/irq.h>
#include <mach/board.h>
#ifdef CONFIG_ANDROID_POWER
#include <linux/android_power.h>
#endif
#define IT7260_DEBUG 0
#if IT7260_DEBUG
#define it7250_debug(msg...) printk(msg)
#else
#define it7250_debug(msg...)
#endif
/******************************************
DEBUG
*** ***************************************/
#define IT7260_IIC_SPEED 200*1000
#define IT7260_MAX_X 800//1024//1020//800
#define IT7260_MAX_Y 600//768//600//480
#define Mulitouch_Mode 1
#define Singltouch_Mode 0
struct touch_event{
short x;
short y;
};
struct MultiTouch_event{
short x1;
short y1;
short x2;
short y2;
char p1_press;
char p2_press;
};
#define TS_POLL_DELAY (10*1000000) /* ns delay before the first sample */
#define TS_POLL_PERIOD (15*1000000) /* ns delay between samples */
struct it7260_dev{
struct i2c_client *client;
struct input_dev *input;
spinlock_t lock;
char phys[32];
int irq;
#if Singltouch_Mode
struct touch_event point;
#else
struct MultiTouch_event point;
char P_state;
char p_DelayTime;
#endif
struct delayed_work work;
struct workqueue_struct *wq;
bool pendown;
bool status;
bool pass;
struct timer_list timer;//hrtimer timer;
int has_relative_report;
};
#define COMMAND_BUFFER_INDEX 0x20
#define QUERY_BUFFER_INDEX 0x80
#define COMMAND_RESPONSE_BUFFER_INDEX 0xA0
#define POINT_BUFFER_INDEX 0xE0
#define QUERY_SUCCESS 0x00
#define QUERY_BUSY 0x01
#define QUERY_ERROR 0x02
#define QUERY_POINT 0x80
static char cal_status = 0;
/*read the it7260 register ,used i2c bus*/
static int it7260_read_regs(struct i2c_client *client, u8 reg, u8 buf[], unsigned len)
{
int ret;
ret = i2c_master_reg8_recv(client, reg, buf, len, IT7260_IIC_SPEED);
return ret;
}
/* set the it7260 registe,used i2c bus*/
static int it7260_set_regs(struct i2c_client *client, u8 reg, u8 const buf[], unsigned short len)
{
int ret;
ret = i2c_master_reg8_send(client, reg, buf, (int)len, IT7260_IIC_SPEED);
return ret;
}
void ReadQueryBuffer(struct i2c_client *client,u8 pucData[])
{
it7260_read_regs(client,QUERY_BUFFER_INDEX,pucData,1);
}
bool ReadCommandResponseBuffer(struct i2c_client *client,u8 pucData[], unsigned int unDataLength)
{
return it7260_read_regs(client,COMMAND_RESPONSE_BUFFER_INDEX,pucData,unDataLength);
}
bool ReadPointBuffer(struct i2c_client *client,u8 pucData[])
{
return it7260_read_regs(client,POINT_BUFFER_INDEX,pucData,14);
}
int WriteCommandBuffer(struct i2c_client *client,u8 pucData[], unsigned int unDataLength)
{
return it7260_set_regs(client,COMMAND_BUFFER_INDEX,pucData,unDataLength);
}
/*
sleep
*/
static void it7260_chip_sleep(void)
{
/*
u8 pucPoint1[12] ={0x12,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};
u8 pucPoint2[12] ={0x11,0x01,0x01};
int aaa;
aaa = WriteCommandBuffer(ts_dev->client,pucPoint1, 10);
if(aaa <0)
{
printk("set mode err\n");
}
aaa = WriteCommandBuffer(ts_dev->client,pucPoint2, 3);
*/
}
/*
wake up
*/
static void it7260_chip_wakeup(void)
{
}
struct it7260_dev *g_dev;
#if 1
void ite_ts_test()
{
u8 ucWriteLength, ucReadLength;
u8 pucData[128];
u8 ucQuery;
ucWriteLength = 1;
ucReadLength = 0x0A;
pucData[0] = 0x00;
// Query
do
{
ReadQueryBuffer(g_dev->client,&ucQuery);
if(ucQuery == 0)
break;
}while(ucQuery & QUERY_BUSY);
//IdentifyCapSensor
WriteCommandBuffer(g_dev->client,pucData, ucWriteLength);
it7260_read_regs(g_dev->client,COMMAND_RESPONSE_BUFFER_INDEX,pucData,10);
printk("[%c][%c][%c][%c][%c][%c][%c]\n",pucData[1],pucData[2],pucData[3],pucData[4],pucData[5],pucData[6],pucData[7]);
//
ucWriteLength = 2;
pucData[0] = 0x01;
pucData[1] = 0x04;
WriteCommandBuffer(g_dev->client,pucData, ucWriteLength);
it7260_read_regs(g_dev->client,COMMAND_RESPONSE_BUFFER_INDEX,pucData,2);
printk("[%x][%x]\n",pucData[0],pucData[1]);
ucWriteLength = 4;
pucData[0] = 0x02;
pucData[1] = 0x04;
pucData[2] = 0x01;
pucData[3] = 0x00;
WriteCommandBuffer(g_dev->client,pucData, ucWriteLength);
ucWriteLength = 2;
pucData[0] = 0x01;
pucData[1] = 0x04;
WriteCommandBuffer(g_dev->client,pucData, ucWriteLength);
it7260_read_regs(g_dev->client,COMMAND_RESPONSE_BUFFER_INDEX,pucData,2);
printk("[%x][%x]\n",pucData[0],pucData[1]);
// printk("[%x][%x][%x][%x][%x][%x][%x][%x][%x][%x][%x][%x][%x][%x]\n",pucData[0],pucData[1],pucData[2],pucData[3],pucData[4],pucData[5],pucData[6],
// pucData[7],pucData[8],pucData[9],pucData[10],pucData[11],pucData[12],pucData[13]);
/* if(pucData[1] != 'I'
|| pucData[2] != 'T'
|| pucData[3] != 'E'
|| pucData[4] != '7'
|| pucData[5] != '2'
|| pucData[6] != '6'
|| pucData[7] != '0')
{
// firmware signature is not match
return false;
}*/
return ;
}
#endif
static int set_mode(struct it7260_dev *ts_dev)
{
u8 pucPoint[12] ={0x13,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};
int ret;
printk("start to calibration......\n");
ret = WriteCommandBuffer(ts_dev->client,pucPoint, 12);
if(ret <0)
{
printk("set mode err\n");
cal_status = 0;
}
else
{
printk("it7260 set mode ok\n");
cal_status = 1;
}
return ret;
}
static int set_sleep_mode(struct it7260_dev *ts_dev)
{
u8 pucPoint[3] ={0x04,0x00,0x02};
u8 pucPoint1[2] ={0x11,0x01};
int aaa;
aaa = WriteCommandBuffer(ts_dev->client,pucPoint1, 2);
//aaa = WriteCommandBuffer(ts_dev->client,pucPoint, 3);
if(aaa <0)
{
printk("set mode err\n");
}
}
static int set_active_mode(struct it7260_dev *ts_dev)
{
u8 pucPoint[12] ={0x04,0x00,0x00};
int aaa;
aaa = WriteCommandBuffer(ts_dev->client,pucPoint, 3);
if(aaa <0)
{
printk("set mode err\n");
}
}
static int read_point(struct it7260_dev *ts_dev )
{
u8 pucPoint[20];
u8 ucQuery =0;
u8 readbuf[2];
u8 i;
int xraw, yraw, xtmp, ytmp;
char pressure_point,z,w;
int finger2_pressed=0;
ReadQueryBuffer(ts_dev->client,&ucQuery);
it7250_debug("ucQuery = 0x%x\n",ucQuery);
if(ucQuery == 0 )
{
it7250_debug("ucQuery == 0 return \n");
return 0;
}
if(ucQuery == 2)
{
ReadCommandResponseBuffer(ts_dev->client,readbuf, 2);
it7250_debug(" read buf [0] = 0x0%x , buf [1] = 0x0%x\n",readbuf[0],readbuf[1]);
it7260_read_regs(ts_dev->client,POINT_BUFFER_INDEX,pucPoint,14);
return 0;
}
else
{
if(ucQuery & 0x80)
{
it7260_read_regs(ts_dev->client,POINT_BUFFER_INDEX,pucPoint,14);
if(pucPoint[0] & 0xF0)
{
it7250_debug("a\n");
return 0;
}
else {
if(pucPoint[1] & 0x01)
{
it7250_debug("b\n");
return 0;
}
}
if(((pucPoint[0] & 0x07)==0)/*|| GPIOGetPinLevel(it7260_IRQ_PIN)*/)
{
//sisdbg("=Read_Point pull= [%d][%d]\n",pucPoint[0] & 0x07,GPIOGetPinLevel(it7260_IRQ_PIN));
#if Singltouch_Mode
ts_dev->status = 0;
ts_dev->pass = 1;
input_report_key(ts_dev->input, BTN_TOUCH, 0);
//input_report_abs(ts_dev->input, ABS_PRESSURE, 0);
input_sync(ts_dev->input);
return;
#else
ts_dev->pass = 1;
input_report_abs(ts_dev->input, ABS_MT_TOUCH_MAJOR, 0);
input_report_abs(ts_dev->input, ABS_MT_WIDTH_MAJOR, 15);
input_report_abs(ts_dev->input, ABS_MT_POSITION_X, ts_dev->point.x1);
input_report_abs(ts_dev->input, ABS_MT_POSITION_Y, ts_dev->point.y1);
input_report_key(ts_dev->input, BTN_TOUCH, 0);
input_mt_sync(ts_dev->input);
it7250_debug("TP up\n");
if(ts_dev->has_relative_report ==2)
{
ts_dev->has_relative_report = 0;
input_report_abs(ts_dev->input, ABS_MT_TOUCH_MAJOR, 0);
input_report_abs(ts_dev->input, ABS_MT_WIDTH_MAJOR, 15);
input_report_abs(ts_dev->input, ABS_MT_POSITION_X, ts_dev->point.x2);
input_report_abs(ts_dev->input, ABS_MT_POSITION_Y, ts_dev->point.y2);
input_report_key(ts_dev->input, BTN_2, 0);
it7250_debug("TP up\n");
input_mt_sync(ts_dev->input);
}
input_sync(ts_dev->input);
return 0;
#endif
}
else
{
if(pucPoint[0] & 0x01)
{
xraw = ((pucPoint[3] & 0x0F) << 8) + pucPoint[2];
yraw = ((pucPoint[3] & 0xF0) << 4) + pucPoint[4];
pressure_point=pucPoint[5]&0x0f;
xtmp = xraw;
ytmp = yraw;
#if Mulitouch_Mode
ts_dev->point.x1 = xtmp;
ts_dev->point.y1 = ytmp;
ts_dev->has_relative_report = 1;
#endif
if(pressure_point==4)
{
z=10;
w=15;
}
else
{
z=10;
w=15;
}
it7250_debug("=Read_Point1 x=%d y=%d p=%d=\n",xtmp,ytmp,pressure_point);
#if Singltouch_Mode
if(ts_dev->pass == 1)
{
ts_dev->pass = 0;
return 0;
}///
if(ts_dev->status == 0)
{
ts_dev->status = 1;
input_report_abs(ts_dev->input, ABS_X, xtmp);
input_report_abs(ts_dev->input, ABS_Y, ytmp);
input_report_key(ts_dev->input, BTN_TOUCH, 1);
}else{
input_report_abs(ts_dev->input, ABS_X, xtmp);
input_report_abs(ts_dev->input, ABS_Y, ytmp);
}
input_report_abs(ts_dev->input, ABS_PRESSURE, 1);
ts_dev->pendown = 1;
input_sync(ts_dev->input);
#else
if(ts_dev->pass == 1)
{
ts_dev->pass = 0;
return 0;
}///
input_report_abs(ts_dev->input, ABS_MT_TOUCH_MAJOR, z);
input_report_abs(ts_dev->input, ABS_MT_WIDTH_MAJOR, w);
input_report_abs(ts_dev->input, ABS_MT_POSITION_X, xtmp);
input_report_abs(ts_dev->input, ABS_MT_POSITION_Y, ytmp);
input_report_key(ts_dev->input, BTN_TOUCH, 1);
ts_dev->pendown = 1;
it7250_debug("TP down\n");
input_mt_sync(ts_dev->input);
#endif
}
#if Mulitouch_Mode
if(pucPoint[0] & 0x02)
{
xraw = ((pucPoint[7] & 0x0F) << 8) + pucPoint[6];
yraw = ((pucPoint[7] & 0xF0) << 4) + pucPoint[8];
pressure_point=pucPoint[9]&0x0f;
xtmp = xraw;
ytmp = yraw;
ts_dev->point.x2 = xtmp;
ts_dev->point.y2 = ytmp;
ts_dev->has_relative_report = 2;
it7250_debug("=Read_Point2 x=%d y=%d p=%d=\n",xtmp,ytmp,pressure_point);
if(pressure_point==4)
{
z=10;
w=15;
}
else
{
z=10;
w=15;
}
#if Singltouch_Mode
if(ts_dev->pass == 1)
{
ts_dev->pass = 0;
return 0;
}
input_report_abs(ts_dev->input, ABS_X, xtmp);
input_report_abs(ts_dev->input, ABS_Y, ytmp);
input_report_key(ts_dev->input, BTN_TOUCH, 1);
ts_dev->pendown = 1;
input_sync(ts_dev->input);
#else
if(ts_dev->pass == 1)
{
ts_dev->pass = 0;
return 0;
}
input_report_abs(ts_dev->input, ABS_MT_TOUCH_MAJOR, z);
input_report_abs(ts_dev->input, ABS_MT_WIDTH_MAJOR, w);
input_report_abs(ts_dev->input, ABS_MT_POSITION_X, xtmp);
input_report_abs(ts_dev->input, ABS_MT_POSITION_Y, ytmp);
input_report_key(ts_dev->input, BTN_2, 1);
ts_dev->pendown = 1;
it7250_debug("TP down\n");
input_mt_sync(ts_dev->input);
#endif
}
#endif
}
input_sync(ts_dev->input);
}
}
return 0;
}
static void it7260_dostimer(unsigned long data)
{
struct it7260_dev *ts_dev = (struct it7260_dev *)data;
read_point(ts_dev);
}
static void it7260_work(struct work_struct *work)
{
struct it7260_dev *ts_dev =
container_of(to_delayed_work(work), struct it7260_dev, work);
read_point(ts_dev);
out:
if (ts_dev->pendown){
queue_delayed_work(ts_dev->wq, &ts_dev->work, msecs_to_jiffies(10));
ts_dev->pendown = 0;
}
else{
enable_irq(ts_dev->irq);
}
}
static irqreturn_t it7260_irq_hander(int irq, void *handle)
{
struct it7260_dev *ts_dev = handle;
if (1/*!ts_dev->get_pendown || likely(ts_dev->get_pendown_state())*/) {
disable_irq_nosync(ts_dev->irq);
queue_delayed_work(ts_dev->wq, &ts_dev->work, 0);
}
return IRQ_HANDLED;
}
static int it7260_detach_client(struct i2c_client *client)
{
printk("************>%s.....%s.....\n",__FILE__,__FUNCTION__);
return 0;
}
static void it7260_shutdown(struct i2c_client *client)
{
printk("************>%s.....%s.....\n",__FILE__,__FUNCTION__);
}
#ifdef CONFIG_ANDROID_POWER
static void suspend(android_early_suspend_t *h)
{
printk("************>%s.....%s.....\n",__FILE__,__FUNCTION__);
}
static void resume(android_early_suspend_t *h)
{
printk("************>%s.....%s.....\n",__FILE__,__FUNCTION__);
}
static android_early_suspend_t ts_early_suspend;
#endif
ssize_t tp_cal_show(struct kobject *kobj, struct kobj_attribute *attr,
const char *buf, size_t count)
{
if(cal_status)
return sprintf(buf,"successful");
else
return sprintf(buf,"fail");
}
ssize_t tp_cal_store(struct kobject *kobj, struct kobj_attribute *attr,
const char *buf, size_t count)
{
if( !strncmp(buf,"tp_cal" , strlen("tp_cal")) )
{
set_mode(g_dev);
}
return count;
}
struct kobj_attribute tp_cal_attrs =
{
.attr = {
.name = "tp_calibration",
.mode = 0777},
.show = tp_cal_show,
.store = tp_cal_store,
};
struct attribute *tp_attrs[] =
{
&tp_cal_attrs.attr,
NULL
};
static struct kobj_type tp_kset_ktype = {
.sysfs_ops = &kobj_sysfs_ops,
.default_attrs = &tp_attrs[0],
};
static int tp_cal_add_attr(struct it7260_dev *ts_dev)
{
int result;
struct input_dev *input;
struct kobject *parentkobject;
struct kobject * me = kmalloc(sizeof(struct kobject) , GFP_KERNEL );
if( !me )
return -ENOMEM;
memset(me ,0,sizeof(struct kobject));
kobject_init( me , &tp_kset_ktype );
parentkobject = &ts_dev->input->dev.kobj ;
result = kobject_add( me , parentkobject->parent->parent->parent, "%s", "tp_calibration" );
return result;
}
static void it7260_remove(struct i2c_client * client)
{
}
static int it7260_probe(struct i2c_client *client ,const struct i2c_device_id *id)
{
struct it7260_dev *ts_dev;
struct input_dev *input;
struct it7260_platform_data *pdata = pdata = client->dev.platform_data;
int i, ret=0;
if (!pdata) {
dev_err(&client->dev, "platform data is required!\n");
return -EINVAL;
}
if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C))
return -EIO;
ts_dev=kzalloc(sizeof(struct it7260_dev), GFP_KERNEL);
if(!ts_dev)
{
printk("it7260 failed to allocate memory!!\n");
goto nomem;
}
input = input_allocate_device();
if(!input)
{
printk("it7260 allocate input device failed!!!\n");
goto fail1;
}
ts_dev->client = client;
ts_dev->status = 0;
ts_dev->pendown = 0;
ts_dev->pass = 0;
ts_dev->input = input;
ts_dev->irq = client->irq;
ts_dev->has_relative_report = 0;
snprintf(ts_dev->phys, sizeof(ts_dev->phys),
"%s/input0", dev_name(&client->dev));
input->name = "it7260 touchscreen";
input->phys = ts_dev->phys;
input->id.bustype = BUS_I2C;
ts_dev->wq = create_rt_workqueue("it7260_wq");
INIT_DELAYED_WORK(&ts_dev->work, it7260_work);
#if Singltouch_Mode
input->evbit[0] = BIT_MASK(EV_ABS)|BIT_MASK(EV_KEY)|BIT_MASK(EV_SYN);
input->keybit[BIT_WORD(BTN_TOUCH)] = BIT_MASK(BTN_TOUCH);
input_set_abs_params(input, ABS_X, 0, IT7260_MAX_X, 0, 0);
input_set_abs_params(input, ABS_Y, 35, IT7260_MAX_Y , 0, 0);
#else
input->evbit[0] = BIT_MASK(EV_ABS)|BIT_MASK(EV_KEY)|BIT_MASK(EV_SYN);
input->keybit[BIT_WORD(BTN_TOUCH)] = BIT_MASK(BTN_TOUCH);
input->keybit[BIT_WORD(BTN_2)] = BIT_MASK(BTN_2); //jaocbchen for dual
input_set_abs_params(input, ABS_X, 0, IT7260_MAX_X, 0, 0);
input_set_abs_params(input, ABS_Y, 0, IT7260_MAX_Y, 0, 0);
input_set_abs_params(input, ABS_PRESSURE, 0, 255, 0, 0);
input_set_abs_params(input, ABS_TOOL_WIDTH, 0, 15, 0, 0);
input_set_abs_params(input, ABS_HAT0X, 0, IT7260_MAX_X, 0, 0);
input_set_abs_params(input, ABS_HAT0Y, 0, IT7260_MAX_Y, 0, 0);
input_set_abs_params(input, ABS_MT_POSITION_X,0, IT7260_MAX_X, 0, 0);
input_set_abs_params(input, ABS_MT_POSITION_Y, 0, IT7260_MAX_Y, 0, 0);
input_set_abs_params(input, ABS_MT_TOUCH_MAJOR, 0, 255, 0, 0);
input_set_abs_params(input, ABS_MT_WIDTH_MAJOR, 0, 15, 0, 0);
for (i = 0; i < (BITS_TO_LONGS(ABS_CNT)); i++)
printk("%s::input->absbit[%d] = 0x%x \n",__FUNCTION__,i,input->absbit[i]);
#endif
if (pdata->init_platform_hw)
pdata->init_platform_hw();
if (!ts_dev->irq) {
dev_dbg(&ts_dev->client->dev, "no IRQ?\n");
return -ENODEV;
}else{
ts_dev->irq = gpio_to_irq(ts_dev->irq);
}
printk("client->dev.driver->name %s\n",client->dev.driver->name);
ret = request_irq(ts_dev->irq, it7260_irq_hander, IRQF_TRIGGER_LOW,
client->dev.driver->name, ts_dev);
if (ret < 0) {
dev_err(&client->dev, "irq %d busy?\n", ts_dev->irq);
goto fail3;
}
ret = input_register_device(input);
if(ret<0)
{
printk("it7260 register input device failed!!!!\n");
goto fail2;
}
#ifdef CONFIG_ANDROID_POWER
ts_early_suspend.suspend = suspend;
ts_early_suspend.resume = resume;
android_register_early_suspend(&ts_early_suspend);
#endif
g_dev = ts_dev;
// ite_ts_test();
set_mode(ts_dev);
printk("it7260 register input device ok!!!!\n");
return 0;
fail3:
free_irq(ts_dev->irq,ts_dev);
fail2:
input_unregister_device(input);
input = NULL;
fail1:
input_free_device(input);
nomem:
kfree(ts_dev);
return ret;
}
static struct i2c_device_id it7260_idtable[] = {
{ "it7260_touch", 0 },
{ }
};
MODULE_DEVICE_TABLE(i2c, it7260_idtable);
static struct i2c_driver it7260_driver = {
.driver = {
.owner = THIS_MODULE,
.name = "it7260_touch"
},
.id_table = it7260_idtable,
.probe = it7260_probe,
.remove = __devexit_p(it7260_remove),
};
static int __init it7260_init(void)
{
return i2c_add_driver(&it7260_driver);
}
static void __exit it7260_exit(void)
{
i2c_del_driver(&it7260_driver);
}
module_init(it7260_init);
module_exit(it7260_exit);
MODULE_DESCRIPTION ("it7260 touchscreen driver");
MODULE_AUTHOR("llx<llx@rockchip.com>");
MODULE_LICENSE("GPL");

View File

@ -67,8 +67,11 @@ static s32 rk29_bl_update_status(struct backlight_device *bl)
div_total = read_pwm_reg(id, PWM_REG_LRC);
if (ref) {
#if defined(CONFIG_MACH_RK29_AIGO)
divh = div_total*(BL_STEP - bl->props.brightness)/BL_STEP;
#else
divh = div_total*(bl->props.brightness)/BL_STEP;
#endif
DBG(">>>%s-->%d bl->props.brightness == %d, div_total == %d , divh == %d\n",__FUNCTION__,__LINE__,bl->props.brightness, div_total, divh);
} else {
DBG(">>>%s-->%d bl->props.brightness == %d\n",__FUNCTION__,__LINE__,bl->props.brightness);

View File

@ -13,7 +13,7 @@
#if defined(CONFIG_MACH_RK29SDK)
#define OUT_FACE OUT_D888_P666
#elif defined(CONFIG_MACH_RK29_AIGO)
#define OUT_FACE OUT_P888
#define OUT_FACE OUT_D888_P666 //OUT_P888
#endif
#define OUT_CLK 65000000
#define LCDC_ACLK 312000000 //29 lcdc axi DMA ƵÂÊ
@ -36,7 +36,7 @@
#if defined(CONFIG_MACH_RK29SDK)
#define SWAP_RB 0
#elif defined(CONFIG_MACH_RK29_AIGO)
#define SWAP_RB 1
#define SWAP_RB 0 // 1
#endif
void set_lcd_info(struct rk29fb_screen *screen, struct rk29lcd_info *lcd_info )