Input: synaptics-rmi4 - add support for Synaptics RMI4 devices
[deliverable/linux.git] / include / linux / rmi.h
CommitLineData
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_H
11#define _RMI_H
12#include <linux/kernel.h>
13#include <linux/device.h>
14#include <linux/interrupt.h>
15#include <linux/input.h>
16#include <linux/list.h>
17#include <linux/module.h>
18#include <linux/types.h>
19
20#define NAME_BUFFER_SIZE 256
21
22/**
23 * struct rmi_f01_power - override default power management settings.
24 *
25 */
26enum rmi_f01_nosleep {
27 RMI_F01_NOSLEEP_DEFAULT = 0,
28 RMI_F01_NOSLEEP_OFF = 1,
29 RMI_F01_NOSLEEP_ON = 2
30};
31
32/**
33 * struct rmi_f01_power_management -When non-zero, these values will be written
34 * to the touch sensor to override the default firmware settigns. For a
35 * detailed explanation of what each field does, see the corresponding
36 * documention in the RMI4 specification.
37 *
38 * @nosleep - specifies whether the device is permitted to sleep or doze (that
39 * is, enter a temporary low power state) when no fingers are touching the
40 * sensor.
41 * @wakeup_threshold - controls the capacitance threshold at which the touch
42 * sensor will decide to wake up from that low power state.
43 * @doze_holdoff - controls how long the touch sensor waits after the last
44 * finger lifts before entering the doze state, in units of 100ms.
45 * @doze_interval - controls the interval between checks for finger presence
46 * when the touch sensor is in doze mode, in units of 10ms.
47 */
48struct rmi_f01_power_management {
49 enum rmi_f01_nosleep nosleep;
50 u8 wakeup_threshold;
51 u8 doze_holdoff;
52 u8 doze_interval;
53};
54
55/**
56 * struct rmi_device_platform_data - system specific configuration info.
57 *
58 * @reset_delay_ms - after issuing a reset command to the touch sensor, the
59 * driver waits a few milliseconds to give the firmware a chance to
60 * to re-initialize. You can override the default wait period here.
61 */
62struct rmi_device_platform_data {
63 int reset_delay_ms;
64
65 /* function handler pdata */
66 struct rmi_f01_power_management power_management;
67};
68
69/**
70 * struct rmi_function_descriptor - RMI function base addresses
71 *
72 * @query_base_addr: The RMI Query base address
73 * @command_base_addr: The RMI Command base address
74 * @control_base_addr: The RMI Control base address
75 * @data_base_addr: The RMI Data base address
76 * @interrupt_source_count: The number of irqs this RMI function needs
77 * @function_number: The RMI function number
78 *
79 * This struct is used when iterating the Page Description Table. The addresses
80 * are 16-bit values to include the current page address.
81 *
82 */
83struct rmi_function_descriptor {
84 u16 query_base_addr;
85 u16 command_base_addr;
86 u16 control_base_addr;
87 u16 data_base_addr;
88 u8 interrupt_source_count;
89 u8 function_number;
90 u8 function_version;
91};
92
93struct rmi_device;
94
95/**
96 * struct rmi_transport_dev - represent an RMI transport device
97 *
98 * @dev: Pointer to the communication device, e.g. i2c or spi
99 * @rmi_dev: Pointer to the RMI device
100 * @proto_name: name of the transport protocol (SPI, i2c, etc)
101 * @ops: pointer to transport operations implementation
102 *
103 * The RMI transport device implements the glue between different communication
104 * buses such as I2C and SPI.
105 *
106 */
107struct rmi_transport_dev {
108 struct device *dev;
109 struct rmi_device *rmi_dev;
110
111 const char *proto_name;
112 const struct rmi_transport_ops *ops;
113
114 struct rmi_device_platform_data pdata;
115
116 struct input_dev *input;
117
118 void *attn_data;
119 int attn_size;
120};
121
122/**
123 * struct rmi_transport_ops - defines transport protocol operations.
124 *
125 * @write_block: Writing a block of data to the specified address
126 * @read_block: Read a block of data from the specified address.
127 */
128struct rmi_transport_ops {
129 int (*write_block)(struct rmi_transport_dev *xport, u16 addr,
130 const void *buf, size_t len);
131 int (*read_block)(struct rmi_transport_dev *xport, u16 addr,
132 void *buf, size_t len);
133 int (*reset)(struct rmi_transport_dev *xport, u16 reset_addr);
134};
135
136/**
137 * struct rmi_driver - driver for an RMI4 sensor on the RMI bus.
138 *
139 * @driver: Device driver model driver
140 * @reset_handler: Called when a reset is detected.
141 * @clear_irq_bits: Clear the specified bits in the current interrupt mask.
142 * @set_irq_bist: Set the specified bits in the current interrupt mask.
143 * @store_productid: Callback for cache product id from function 01
144 * @data: Private data pointer
145 *
146 */
147struct rmi_driver {
148 struct device_driver driver;
149
150 int (*reset_handler)(struct rmi_device *rmi_dev);
151 int (*clear_irq_bits)(struct rmi_device *rmi_dev, unsigned long *mask);
152 int (*set_irq_bits)(struct rmi_device *rmi_dev, unsigned long *mask);
153 int (*store_productid)(struct rmi_device *rmi_dev);
154 int (*set_input_params)(struct rmi_device *rmi_dev,
155 struct input_dev *input);
156 void *data;
157};
158
159/**
160 * struct rmi_device - represents an RMI4 sensor device on the RMI bus.
161 *
162 * @dev: The device created for the RMI bus
163 * @number: Unique number for the device on the bus.
164 * @driver: Pointer to associated driver
165 * @xport: Pointer to the transport interface
166 *
167 */
168struct rmi_device {
169 struct device dev;
170 int number;
171
172 struct rmi_driver *driver;
173 struct rmi_transport_dev *xport;
174
175};
176
177struct rmi_driver_data {
178 struct list_head function_list;
179
180 struct rmi_device *rmi_dev;
181
182 struct rmi_function *f01_container;
183 bool f01_bootloader_mode;
184
185 u32 attn_count;
186 int num_of_irq_regs;
187 int irq_count;
188 unsigned long *irq_status;
189 unsigned long *fn_irq_bits;
190 unsigned long *current_irq_mask;
191 unsigned long *new_irq_mask;
192 struct mutex irq_mutex;
193 struct input_dev *input;
194
195 u8 pdt_props;
196 u8 bsr;
197
198 bool enabled;
199
200 void *data;
201};
202
203int rmi_register_transport_device(struct rmi_transport_dev *xport);
204void rmi_unregister_transport_device(struct rmi_transport_dev *xport);
205int rmi_process_interrupt_requests(struct rmi_device *rmi_dev);
206
207int rmi_driver_suspend(struct rmi_device *rmi_dev);
208int rmi_driver_resume(struct rmi_device *rmi_dev);
209#endif
This page took 0.034272 seconds and 5 git commands to generate.