diff options
Diffstat (limited to 'drivers/input/touchscreen/rmi4/rmi_f01.c')
| -rw-r--r-- | drivers/input/touchscreen/rmi4/rmi_f01.c | 775 |
1 files changed, 775 insertions, 0 deletions
diff --git a/drivers/input/touchscreen/rmi4/rmi_f01.c b/drivers/input/touchscreen/rmi4/rmi_f01.c new file mode 100644 index 00000000000..ef9adb0586b --- /dev/null +++ b/drivers/input/touchscreen/rmi4/rmi_f01.c | |||
| @@ -0,0 +1,775 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (c) 2011 Synaptics Incorporated | ||
| 3 | * Copyright (c) 2011 Unixphere | ||
| 4 | * | ||
| 5 | * This program is free software; you can redistribute it and/or modify | ||
| 6 | * it under the terms of the GNU General Public License as published by | ||
| 7 | * the Free Software Foundation; either version 2 of the License, or | ||
| 8 | * (at your option) any later version. | ||
| 9 | * | ||
| 10 | * This program is distributed in the hope that it will be useful, | ||
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 13 | * GNU General Public License for more details. | ||
| 14 | * | ||
| 15 | * You should have received a copy of the GNU General Public License | ||
| 16 | * along with this program; if not, write to the Free Software | ||
| 17 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
| 18 | */ | ||
| 19 | |||
| 20 | #define DEBUG | ||
| 21 | |||
| 22 | #include <linux/kernel.h> | ||
| 23 | #include <linux/rmi.h> | ||
| 24 | #include <linux/slab.h> | ||
| 25 | #include "rmi_driver.h" | ||
| 26 | |||
| 27 | /* control register bits */ | ||
| 28 | #define RMI_SLEEP_MODE_NORMAL (0x00) | ||
| 29 | #define RMI_SLEEP_MODE_SENSOR_SLEEP (0x01) | ||
| 30 | #define RMI_SLEEP_MODE_RESERVED0 (0x02) | ||
| 31 | #define RMI_SLEEP_MODE_RESERVED1 (0x03) | ||
| 32 | |||
| 33 | #define RMI_IS_VALID_SLEEPMODE(mode) \ | ||
| 34 | (mode >= RMI_SLEEP_MODE_NORMAL && mode <= RMI_SLEEP_MODE_RESERVED1) | ||
| 35 | |||
| 36 | union f01_device_commands { | ||
| 37 | struct { | ||
| 38 | u8 reset:1; | ||
| 39 | u8 reserved:1; | ||
| 40 | }; | ||
| 41 | u8 reg; | ||
| 42 | }; | ||
| 43 | |||
| 44 | union f01_device_control { | ||
| 45 | struct { | ||
| 46 | u8 sleep_mode:2; | ||
| 47 | u8 nosleep:1; | ||
| 48 | u8 reserved:2; | ||
| 49 | u8 charger_input:1; | ||
| 50 | u8 report_rate:1; | ||
| 51 | u8 configured:1; | ||
| 52 | }; | ||
| 53 | u8 reg; | ||
| 54 | }; | ||
| 55 | |||
| 56 | union f01_device_status { | ||
| 57 | struct { | ||
| 58 | u8 status_code:4; | ||
| 59 | u8 reserved:2; | ||
| 60 | u8 flash_prog:1; | ||
| 61 | u8 unconfigured:1; | ||
| 62 | }; | ||
| 63 | u8 reg; | ||
| 64 | }; | ||
| 65 | |||
| 66 | union f01_basic_queries { | ||
| 67 | struct { | ||
| 68 | u8 manufacturer_id:8; | ||
| 69 | |||
| 70 | u8 custom_map:1; | ||
| 71 | u8 non_compliant:1; | ||
| 72 | u8 q1_bit_2:1; | ||
| 73 | u8 has_sensor_id:1; | ||
| 74 | u8 has_charger_input:1; | ||
| 75 | u8 has_adjustable_doze:1; | ||
| 76 | u8 has_adjustable_doze_holdoff:1; | ||
| 77 | u8 q1_bit_7:1; | ||
| 78 | |||
| 79 | u8 productinfo_1:7; | ||
| 80 | u8 q2_bit_7:1; | ||
| 81 | u8 productinfo_2:7; | ||
| 82 | u8 q3_bit_7:1; | ||
| 83 | |||
| 84 | u8 year:5; | ||
| 85 | u8 month:4; | ||
| 86 | u8 day:5; | ||
| 87 | u8 cp1:1; | ||
| 88 | u8 cp2:1; | ||
| 89 | u8 wafer_id1_lsb:8; | ||
| 90 | u8 wafer_id1_msb:8; | ||
| 91 | u8 wafer_id2_lsb:8; | ||
| 92 | u8 wafer_id2_msb:8; | ||
| 93 | u8 wafer_id3_lsb:8; | ||
| 94 | }; | ||
| 95 | u8 regs[11]; | ||
| 96 | }; | ||
| 97 | |||
| 98 | struct f01_data { | ||
| 99 | union f01_device_control device_control; | ||
| 100 | union f01_basic_queries basic_queries; | ||
| 101 | union f01_device_status device_status; | ||
| 102 | u8 product_id[RMI_PRODUCT_ID_LENGTH+1]; | ||
| 103 | |||
| 104 | #ifdef CONFIG_PM | ||
| 105 | bool suspended; | ||
| 106 | bool old_nosleep; | ||
| 107 | #endif | ||
| 108 | }; | ||
| 109 | |||
| 110 | |||
| 111 | static ssize_t rmi_fn_01_productinfo_show(struct device *dev, | ||
| 112 | struct device_attribute *attr, | ||
| 113 | char *buf); | ||
| 114 | |||
| 115 | static ssize_t rmi_fn_01_productid_show(struct device *dev, | ||
| 116 | struct device_attribute *attr, | ||
| 117 | char *buf); | ||
| 118 | |||
| 119 | static ssize_t rmi_fn_01_manufacturer_show(struct device *dev, | ||
| 120 | struct device_attribute *attr, | ||
| 121 | char *buf); | ||
| 122 | |||
| 123 | static ssize_t rmi_fn_01_datecode_show(struct device *dev, | ||
| 124 | struct device_attribute *attr, | ||
| 125 | char *buf); | ||
| 126 | |||
| 127 | static ssize_t rmi_fn_01_reportrate_show(struct device *dev, | ||
| 128 | struct device_attribute *attr, | ||
| 129 | char *buf); | ||
| 130 | |||
| 131 | static ssize_t rmi_fn_01_reportrate_store(struct device *dev, | ||
| 132 | struct device_attribute *attr, | ||
| 133 | const char *buf, size_t count); | ||
| 134 | |||
| 135 | static ssize_t rmi_fn_01_reset_store(struct device *dev, | ||
| 136 | struct device_attribute *attr, | ||
| 137 | const char *buf, size_t count); | ||
| 138 | |||
| 139 | static ssize_t rmi_fn_01_sleepmode_show(struct device *dev, | ||
| 140 | struct device_attribute *attr, | ||
| 141 | char *buf); | ||
| 142 | |||
| 143 | static ssize_t rmi_fn_01_sleepmode_store(struct device *dev, | ||
| 144 | struct device_attribute *attr, | ||
| 145 | const char *buf, size_t count); | ||
| 146 | |||
| 147 | static ssize_t rmi_fn_01_nosleep_show(struct device *dev, | ||
| 148 | struct device_attribute *attr, | ||
| 149 | char *buf); | ||
| 150 | |||
| 151 | static ssize_t rmi_fn_01_nosleep_store(struct device *dev, | ||
| 152 | struct device_attribute *attr, | ||
| 153 | const char *buf, size_t count); | ||
| 154 | |||
| 155 | static ssize_t rmi_fn_01_chargerinput_show(struct device *dev, | ||
| 156 | struct device_attribute *attr, | ||
| 157 | char *buf); | ||
| 158 | |||
| 159 | static ssize_t rmi_fn_01_chargerinput_store(struct device *dev, | ||
| 160 | struct device_attribute *attr, | ||
| 161 | const char *buf, size_t count); | ||
| 162 | |||
| 163 | static ssize_t rmi_fn_01_configured_show(struct device *dev, | ||
| 164 | struct device_attribute *attr, | ||
| 165 | char *buf); | ||
| 166 | |||
| 167 | static ssize_t rmi_fn_01_unconfigured_show(struct device *dev, | ||
| 168 | struct device_attribute *attr, | ||
| 169 | char *buf); | ||
| 170 | |||
| 171 | static ssize_t rmi_fn_01_flashprog_show(struct device *dev, | ||
| 172 | struct device_attribute *attr, | ||
| 173 | char *buf); | ||
| 174 | |||
| 175 | static ssize_t rmi_fn_01_statuscode_show(struct device *dev, | ||
| 176 | struct device_attribute *attr, | ||
| 177 | char *buf); | ||
| 178 | |||
| 179 | static struct device_attribute fn_01_attrs[] = { | ||
| 180 | __ATTR(productinfo, RMI_RO_ATTR, | ||
| 181 | rmi_fn_01_productinfo_show, rmi_store_error), | ||
| 182 | __ATTR(productid, RMI_RO_ATTR, | ||
| 183 | rmi_fn_01_productid_show, rmi_store_error), | ||
| 184 | __ATTR(manufacturer, RMI_RO_ATTR, | ||
| 185 | rmi_fn_01_manufacturer_show, rmi_store_error), | ||
| 186 | __ATTR(datecode, RMI_RO_ATTR, | ||
| 187 | rmi_fn_01_datecode_show, rmi_store_error), | ||
| 188 | |||
| 189 | /* control register access */ | ||
| 190 | __ATTR(sleepmode, RMI_RW_ATTR, | ||
| 191 | rmi_fn_01_sleepmode_show, rmi_fn_01_sleepmode_store), | ||
| 192 | __ATTR(nosleep, RMI_RW_ATTR, | ||
| 193 | rmi_fn_01_nosleep_show, rmi_fn_01_nosleep_store), | ||
| 194 | __ATTR(chargerinput, RMI_RW_ATTR, | ||
| 195 | rmi_fn_01_chargerinput_show, rmi_fn_01_chargerinput_store), | ||
| 196 | __ATTR(reportrate, RMI_RW_ATTR, | ||
| 197 | rmi_fn_01_reportrate_show, rmi_fn_01_reportrate_store), | ||
| 198 | /* We make report rate RO, since the driver uses that to look for | ||
| 199 | * resets. We don't want someone faking us out by changing that | ||
| 200 | * bit. | ||
| 201 | */ | ||
| 202 | __ATTR(configured, RMI_RO_ATTR, | ||
| 203 | rmi_fn_01_configured_show, rmi_store_error), | ||
| 204 | |||
| 205 | /* Command register access. */ | ||
| 206 | __ATTR(reset, RMI_WO_ATTR, | ||
| 207 | |||
