1 /* SPDX-License-Identifier: GPL-2.0-only */
3 * Copyright (c) 2011-2016 Synaptics Incorporated
4 * Copyright (c) 2011 Unixphere
10 #include <linux/ctype.h>
11 #include <linux/hrtimer.h>
12 #include <linux/ktime.h>
13 #include <linux/input.h>
16 #define SYNAPTICS_INPUT_DEVICE_NAME "Synaptics RMI4 Touch Sensor"
17 #define SYNAPTICS_VENDOR_ID 0x06cb
19 #define GROUP(_attrs) { \
23 #define PDT_PROPERTIES_LOCATION 0x00EF
24 #define BSR_LOCATION 0x00FE
26 #define RMI_PDT_PROPS_HAS_BSR 0x02
28 #define NAME_BUFFER_SIZE 256
30 #define RMI_PDT_ENTRY_SIZE 6
31 #define RMI_PDT_FUNCTION_VERSION_MASK 0x60
32 #define RMI_PDT_INT_SOURCE_COUNT_MASK 0x07
34 #define PDT_START_SCAN_LOCATION 0x00e9
35 #define PDT_END_SCAN_LOCATION 0x0005
36 #define RMI4_END_OF_PDT(id) ((id) == 0x00 || (id) == 0xff)
44 u8 interrupt_source_count
;
49 #define RMI_REG_DESC_PRESENSE_BITS (32 * BITS_PER_BYTE)
50 #define RMI_REG_DESC_SUBPACKET_BITS (37 * BITS_PER_BYTE)
52 /* describes a single packet register */
53 struct rmi_register_desc_item
{
55 unsigned long reg_size
;
57 unsigned long subpacket_map
[BITS_TO_LONGS(
58 RMI_REG_DESC_SUBPACKET_BITS
)];
62 * describes the packet registers for a particular type
63 * (ie query, control, data)
65 struct rmi_register_descriptor
{
66 unsigned long struct_size
;
67 unsigned long presense_map
[BITS_TO_LONGS(RMI_REG_DESC_PRESENSE_BITS
)];
69 struct rmi_register_desc_item
*registers
;
72 int rmi_read_register_desc(struct rmi_device
*d
, u16 addr
,
73 struct rmi_register_descriptor
*rdesc
);
74 const struct rmi_register_desc_item
*rmi_get_register_desc_item(
75 struct rmi_register_descriptor
*rdesc
, u16 reg
);
78 * Calculate the total size of all of the registers described in the
81 size_t rmi_register_desc_calc_size(struct rmi_register_descriptor
*rdesc
);
82 int rmi_register_desc_calc_reg_offset(
83 struct rmi_register_descriptor
*rdesc
, u16 reg
);
84 bool rmi_register_desc_has_subpacket(const struct rmi_register_desc_item
*item
,
87 bool rmi_is_physical_driver(struct device_driver
*);
88 int rmi_register_physical_driver(void);
89 void rmi_unregister_physical_driver(void);
90 void rmi_free_function_list(struct rmi_device
*rmi_dev
);
91 struct rmi_function
*rmi_find_function(struct rmi_device
*rmi_dev
, u8 number
);
92 int rmi_enable_sensor(struct rmi_device
*rmi_dev
);
93 int rmi_scan_pdt(struct rmi_device
*rmi_dev
, void *ctx
,
94 int (*callback
)(struct rmi_device
*rmi_dev
, void *ctx
,
95 const struct pdt_entry
*entry
));
96 int rmi_probe_interrupts(struct rmi_driver_data
*data
);
97 void rmi_enable_irq(struct rmi_device
*rmi_dev
, bool clear_wake
);
98 void rmi_disable_irq(struct rmi_device
*rmi_dev
, bool enable_wake
);
99 int rmi_init_functions(struct rmi_driver_data
*data
);
100 int rmi_initial_reset(struct rmi_device
*rmi_dev
, void *ctx
,
101 const struct pdt_entry
*pdt
);
103 const char *rmi_f01_get_product_ID(struct rmi_function
*fn
);
105 #ifdef CONFIG_RMI4_F03
106 int rmi_f03_overwrite_button(struct rmi_function
*fn
, unsigned int button
,
108 void rmi_f03_commit_buttons(struct rmi_function
*fn
);
110 static inline int rmi_f03_overwrite_button(struct rmi_function
*fn
,
111 unsigned int button
, int value
)
115 static inline void rmi_f03_commit_buttons(struct rmi_function
*fn
) {}
118 #ifdef CONFIG_RMI4_F34
119 int rmi_f34_create_sysfs(struct rmi_device
*rmi_dev
);
120 void rmi_f34_remove_sysfs(struct rmi_device
*rmi_dev
);
122 static inline int rmi_f34_create_sysfs(struct rmi_device
*rmi_dev
)
127 static inline void rmi_f34_remove_sysfs(struct rmi_device
*rmi_dev
)
130 #endif /* CONFIG_RMI_F34 */
132 extern struct rmi_function_handler rmi_f01_handler
;
133 extern struct rmi_function_handler rmi_f03_handler
;
134 extern struct rmi_function_handler rmi_f11_handler
;
135 extern struct rmi_function_handler rmi_f12_handler
;
136 extern struct rmi_function_handler rmi_f30_handler
;
137 extern struct rmi_function_handler rmi_f34_handler
;
138 extern struct rmi_function_handler rmi_f3a_handler
;
139 extern struct rmi_function_handler rmi_f54_handler
;
140 extern struct rmi_function_handler rmi_f55_handler
;