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 54 int rmi_read_pdt_entry(struct rmi_device *rmi_dev, struct pdt_entry *entry, 55 u16 pdt_address); 56 57 #define RMI_REG_DESC_PRESENSE_BITS (32 * BITS_PER_BYTE) 58 #define RMI_REG_DESC_SUBPACKET_BITS (37 * BITS_PER_BYTE) 59 60 /* describes a single packet register */ 61 struct rmi_register_desc_item { 62 u16 reg; 63 unsigned long reg_size; 64 u8 num_subpackets; 65 unsigned long subpacket_map[BITS_TO_LONGS( 66 RMI_REG_DESC_SUBPACKET_BITS)]; 67 }; 68 69 /* 70 * describes the packet registers for a particular type 71 * (ie query, control, data) 72 */ 73 struct rmi_register_descriptor { 74 unsigned long struct_size; 75 unsigned long presense_map[BITS_TO_LONGS(RMI_REG_DESC_PRESENSE_BITS)]; 76 u8 num_registers; 77 struct rmi_register_desc_item *registers; 78 }; 79 80 int rmi_read_register_desc(struct rmi_device *d, u16 addr, 81 struct rmi_register_descriptor *rdesc); 82 const struct rmi_register_desc_item *rmi_get_register_desc_item( 83 struct rmi_register_descriptor *rdesc, u16 reg); 84 85 /* 86 * Calculate the total size of all of the registers described in the 87 * descriptor. 88 */ 89 size_t rmi_register_desc_calc_size(struct rmi_register_descriptor *rdesc); 90 int rmi_register_desc_calc_reg_offset( 91 struct rmi_register_descriptor *rdesc, u16 reg); 92 bool rmi_register_desc_has_subpacket(const struct rmi_register_desc_item *item, 93 u8 subpacket); 94 95 bool rmi_is_physical_driver(struct device_driver *); 96 int rmi_register_physical_driver(void); 97 void rmi_unregister_physical_driver(void); 98 99 char *rmi_f01_get_product_ID(struct rmi_function *fn); 100 101 extern struct rmi_function_handler rmi_f01_handler; 102 extern struct rmi_function_handler rmi_f11_handler; 103 extern struct rmi_function_handler rmi_f12_handler; 104 extern struct rmi_function_handler rmi_f30_handler; 105 #endif 106