blob: 70def61909fa8ff124a5509229b0ebbe7ec08837 [file] [log] [blame]
tracychui35151622020-04-29 16:24:36 +08001/* Himax Android Driver Sample Code for QCT platform
2*
3* Copyright (C) 2017 Himax Corporation.
4*
5* This software is licensed under the terms of the GNU General Public
6* License version 2, as published by the Free Software Foundation, and
7* may be copied, distributed, and modified under those terms.
8*
9* This program is distributed in the hope that it will be useful,
10* but WITHOUT ANY WARRANTY; without even the implied warranty of
11* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12* GNU General Public License for more details.
13*
14*/
15
16#ifndef HIMAX_PLATFORM_H
17#define HIMAX_PLATFORM_H
18
19#include <linux/delay.h>
20#include <linux/fs.h>
21#include <linux/gpio.h>
22#include <linux/types.h>
23#include <linux/i2c.h>
24#include <linux/interrupt.h>
25#if defined(CONFIG_HMX_DB)
26#include <linux/regulator/consumer.h>
27#endif
28
29#define QCT
30
31#if defined(CONFIG_TOUCHSCREEN_HIMAX_DEBUG)
32#define D(x...) printk("[HXTP] " x)
33#define I(x...) printk("[HXTP] " x)
34#define W(x...) printk("[HXTP][WARNING] " x)
35#define E(x...) printk("[HXTP][ERROR] " x)
36#define DIF(x...) \
37 if (debug_flag) \
38 printk("[HXTP][DEBUG] " x) \
39} while(0)
40#else
41#define D(x...)
42#define I(x...)
43#define W(x...)
44#define E(x...)
45#define DIF(x...)
46#endif
47
48#if defined(CONFIG_HMX_DB)
49/* Analog voltage @2.7 V */
50#define HX_VTG_MIN_UV 2700000
51#define HX_VTG_MAX_UV 3300000
52#define HX_ACTIVE_LOAD_UA 15000
53#define HX_LPM_LOAD_UA 10
54/* Digital voltage @1.8 V */
55#define HX_VTG_DIG_MIN_UV 1800000
56#define HX_VTG_DIG_MAX_UV 1800000
57#define HX_ACTIVE_LOAD_DIG_UA 10000
58#define HX_LPM_LOAD_DIG_UA 10
59
60#define HX_I2C_VTG_MIN_UV 1800000
61#define HX_I2C_VTG_MAX_UV 1800000
62#define HX_I2C_LOAD_UA 10000
63#define HX_I2C_LPM_LOAD_UA 10
64#endif
65
66#define HIMAX_common_NAME "himax_tp"
67#define HIMAX_I2C_ADDR 0x48
68#define INPUT_DEV_NAME "himax-touchscreen"
69
70struct himax_i2c_platform_data
71{
72 int abs_x_min;
73 int abs_x_max;
74 int abs_x_fuzz;
75 int abs_y_min;
76 int abs_y_max;
77 int abs_y_fuzz;
78 int abs_pressure_min;
79 int abs_pressure_max;
80 int abs_pressure_fuzz;
81 int abs_width_min;
82 int abs_width_max;
83 int screenWidth;
84 int screenHeight;
85 uint8_t fw_version;
86 uint8_t tw_id;
87 uint8_t powerOff3V3;
88 uint8_t cable_config[2];
89 uint8_t protocol_type;
90 int gpio_irq;
91 int gpio_reset;
92 int gpio_3v3_en;
93 int (*power)(int on);
94 void (*reset)(void);
95 struct himax_virtual_key *virtual_key;
96 struct kobject *vk_obj;
97 struct kobj_attribute *vk2Use;
98
99 int hx_config_size;
100#if defined(CONFIG_HMX_DB)
101 bool i2c_pull_up;
102 bool digital_pwr_regulator;
103 int reset_gpio;
104 u32 reset_gpio_flags;
105 int irq_gpio;
106 u32 irq_gpio_flags;
107
108 struct regulator *vcc_ana; //For Dragon Board
109 struct regulator *vcc_dig; //For Dragon Board
110 struct regulator *vcc_i2c; //For Dragon Board
111#endif
112};
113
114
115extern int irq_enable_count;
116extern int i2c_himax_read(struct i2c_client *client, uint8_t command, uint8_t *data, uint8_t length, uint8_t toRetry);
117extern int i2c_himax_write(struct i2c_client *client, uint8_t command, uint8_t *data, uint8_t length, uint8_t toRetry);
118extern int i2c_himax_write_command(struct i2c_client *client, uint8_t command, uint8_t toRetry);
119extern int i2c_himax_master_write(struct i2c_client *client, uint8_t *data, uint8_t length, uint8_t toRetry);
120extern void himax_int_enable(int irqnum, int enable);
121extern int himax_ts_register_interrupt(struct i2c_client *client);
122extern uint8_t himax_int_gpio_read(int pinnum);
123
124extern int himax_gpio_power_config(struct i2c_client *client,struct himax_i2c_platform_data *pdata);
125
126#if defined(CONFIG_FB)
127extern int fb_notifier_callback(struct notifier_block *self, unsigned long event, void *data);
128#endif
129
130#endif