]>
Commit | Line | Data |
---|---|---|
2b6a321d AD |
1 | /* |
2 | * Copyright (c) 2011-2016 Synaptics Incorporated | |
3 | * Copyright (c) 2011 Unixphere | |
4 | * | |
5 | * This program is free software; you can redistribute it and/or modify it | |
6 | * under the terms of the GNU General Public License version 2 as published by | |
7 | * the Free Software Foundation. | |
8 | */ | |
9 | ||
10 | #ifndef _RMI_DRIVER_H | |
11 | #define _RMI_DRIVER_H | |
12 | ||
13 | #include <linux/ctype.h> | |
14 | #include <linux/hrtimer.h> | |
15 | #include <linux/ktime.h> | |
16 | #include <linux/input.h> | |
17 | #include "rmi_bus.h" | |
18 | ||
19 | #define RMI_DRIVER_VERSION "2.0" | |
20 | ||
21 | #define SYNAPTICS_INPUT_DEVICE_NAME "Synaptics RMI4 Touch Sensor" | |
22 | #define SYNAPTICS_VENDOR_ID 0x06cb | |
23 | ||
24 | #define GROUP(_attrs) { \ | |
25 | .attrs = _attrs, \ | |
26 | } | |
27 | ||
28 | #define PDT_PROPERTIES_LOCATION 0x00EF | |
29 | #define BSR_LOCATION 0x00FE | |
30 | ||
31 | #define RMI_PDT_PROPS_HAS_BSR 0x02 | |
32 | ||
33 | #define NAME_BUFFER_SIZE 256 | |
34 | ||
35 | #define RMI_PDT_ENTRY_SIZE 6 | |
36 | #define RMI_PDT_FUNCTION_VERSION_MASK 0x60 | |
37 | #define RMI_PDT_INT_SOURCE_COUNT_MASK 0x07 | |
38 | ||
39 | #define PDT_START_SCAN_LOCATION 0x00e9 | |
40 | #define PDT_END_SCAN_LOCATION 0x0005 | |
41 | #define RMI4_END_OF_PDT(id) ((id) == 0x00 || (id) == 0xff) | |
42 | ||
43 | struct pdt_entry { | |
44 | u16 page_start; | |
45 | u8 query_base_addr; | |
46 | u8 command_base_addr; | |
47 | u8 control_base_addr; | |
48 | u8 data_base_addr; | |
49 | u8 interrupt_source_count; | |
50 | u8 function_version; | |
51 | u8 function_number; | |
52 | }; | |
53 | ||
2b6a321d AD |
54 | #define RMI_REG_DESC_PRESENSE_BITS (32 * BITS_PER_BYTE) |
55 | #define RMI_REG_DESC_SUBPACKET_BITS (37 * BITS_PER_BYTE) | |
56 | ||
57 | /* describes a single packet register */ | |
58 | struct rmi_register_desc_item { | |
59 | u16 reg; | |
60 | unsigned long reg_size; | |
61 | u8 num_subpackets; | |
62 | unsigned long subpacket_map[BITS_TO_LONGS( | |
63 | RMI_REG_DESC_SUBPACKET_BITS)]; | |
64 | }; | |
65 | ||
66 | /* | |
67 | * describes the packet registers for a particular type | |
68 | * (ie query, control, data) | |
69 | */ | |
70 | struct rmi_register_descriptor { | |
71 | unsigned long struct_size; | |
72 | unsigned long presense_map[BITS_TO_LONGS(RMI_REG_DESC_PRESENSE_BITS)]; | |
73 | u8 num_registers; | |
74 | struct rmi_register_desc_item *registers; | |
75 | }; | |
76 | ||
77 | int rmi_read_register_desc(struct rmi_device *d, u16 addr, | |
78 | struct rmi_register_descriptor *rdesc); | |
79 | const struct rmi_register_desc_item *rmi_get_register_desc_item( | |
80 | struct rmi_register_descriptor *rdesc, u16 reg); | |
81 | ||
82 | /* | |
83 | * Calculate the total size of all of the registers described in the | |
84 | * descriptor. | |
85 | */ | |
86 | size_t rmi_register_desc_calc_size(struct rmi_register_descriptor *rdesc); | |
87 | int rmi_register_desc_calc_reg_offset( | |
88 | struct rmi_register_descriptor *rdesc, u16 reg); | |
89 | bool rmi_register_desc_has_subpacket(const struct rmi_register_desc_item *item, | |
90 | u8 subpacket); | |
91 | ||
92 | bool rmi_is_physical_driver(struct device_driver *); | |
93 | int rmi_register_physical_driver(void); | |
94 | void rmi_unregister_physical_driver(void); | |
29fd0ec2 | 95 | void rmi_free_function_list(struct rmi_device *rmi_dev); |
f32361b7 | 96 | struct rmi_function *rmi_find_function(struct rmi_device *rmi_dev, u8 number); |
29fd0ec2 ND |
97 | int rmi_enable_sensor(struct rmi_device *rmi_dev); |
98 | int rmi_scan_pdt(struct rmi_device *rmi_dev, void *ctx, | |
99 | int (*callback)(struct rmi_device *rmi_dev, void *ctx, | |
100 | const struct pdt_entry *entry)); | |
101 | int rmi_probe_interrupts(struct rmi_driver_data *data); | |
a64ea311 BT |
102 | void rmi_enable_irq(struct rmi_device *rmi_dev, bool clear_wake); |
103 | void rmi_disable_irq(struct rmi_device *rmi_dev, bool enable_wake); | |
29fd0ec2 ND |
104 | int rmi_init_functions(struct rmi_driver_data *data); |
105 | int rmi_initial_reset(struct rmi_device *rmi_dev, void *ctx, | |
106 | const struct pdt_entry *pdt); | |
2b6a321d | 107 | |
ce363f0d | 108 | const char *rmi_f01_get_product_ID(struct rmi_function *fn); |
2b6a321d | 109 | |
81dec809 BT |
110 | #ifdef CONFIG_RMI4_F03 |
111 | int rmi_f03_overwrite_button(struct rmi_function *fn, unsigned int button, | |
112 | int value); | |
113 | void rmi_f03_commit_buttons(struct rmi_function *fn); | |
114 | #else | |
115 | static inline int rmi_f03_overwrite_button(struct rmi_function *fn, | |
116 | unsigned int button, int value) | |
117 | { | |
118 | return 0; | |
119 | } | |
120 | static inline void rmi_f03_commit_buttons(struct rmi_function *fn) {} | |
121 | #endif | |
122 | ||
29fd0ec2 ND |
123 | #ifdef CONFIG_RMI4_F34 |
124 | int rmi_f34_create_sysfs(struct rmi_device *rmi_dev); | |
125 | void rmi_f34_remove_sysfs(struct rmi_device *rmi_dev); | |
126 | #else | |
127 | static inline int rmi_f34_create_sysfs(struct rmi_device *rmi_dev) | |
128 | { | |
129 | return 0; | |
130 | } | |
131 | ||
132 | static inline void rmi_f34_remove_sysfs(struct rmi_device *rmi_dev) | |
133 | { | |
134 | } | |
135 | #endif /* CONFIG_RMI_F34 */ | |
136 | ||
2b6a321d | 137 | extern struct rmi_function_handler rmi_f01_handler; |
c5e8848f | 138 | extern struct rmi_function_handler rmi_f03_handler; |
ff8f8370 | 139 | extern struct rmi_function_handler rmi_f11_handler; |
b43d2c1e | 140 | extern struct rmi_function_handler rmi_f12_handler; |
562b42d3 | 141 | extern struct rmi_function_handler rmi_f30_handler; |
29fd0ec2 | 142 | extern struct rmi_function_handler rmi_f34_handler; |
3a762dbd | 143 | extern struct rmi_function_handler rmi_f54_handler; |
6adba43f | 144 | extern struct rmi_function_handler rmi_f55_handler; |
2b6a321d | 145 | #endif |