[RFC PATCH 13/17] input: RMI4 F21 Force sensing

2012-08-17 Thread Christopher Heiny
Signed-off-by: Christopher Heiny 

Cc: Dmitry Torokhov 
Cc: Linus Walleij 
Cc: Naveen Kumar Gaddipati 
Cc: Joeri de Gram 

Acked-by: Jean Delvare 

---

 drivers/input/rmi4/rmi_f21.c |  832 ++
 1 files changed, 832 insertions(+), 0 deletions(-)

diff --git a/drivers/input/rmi4/rmi_f21.c b/drivers/input/rmi4/rmi_f21.c
new file mode 100644
index 000..2e37c75
--- /dev/null
+++ b/drivers/input/rmi4/rmi_f21.c
@@ -0,0 +1,832 @@
+/*
+ * Copyright (c) 2012-2012 Synaptics Incorporated
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#define FUNCTION_DATA rmi_fn_21_data
+#define FNUM 21
+
+
+#include 
+#include 
+#include 
+#include "rmi_driver.h"
+
+union f21_2df_query {
+   struct {
+   /* Query 0 */
+   u8 max_force_sensor_count:3;
+   u8 f21_2df_query0_b3__6:4;
+   u8 has_high_resolution:1;
+   } __attribute__((__packed__));
+   struct {
+   u8 regs[1];
+   u16 address;
+   } __attribute__((__packed__));
+};
+
+union f21_2df_control_0__3 {
+   struct {
+   /* Control 0 */
+   u8 reporting_mode:3;
+   u8 no_rezero:1;
+   u8 ctl0_reserved:4;
+
+   /* Control 1 */
+   u8 force_click_threshold:8;
+
+   /* Control 2 */
+   u8 int_en_force_0:1;
+   u8 int_en_force_1:1;
+   u8 int_en_force_2:1;
+   u8 int_en_force_3:1;
+   u8 int_en_force_4:1;
+   u8 int_en_force_5:1;
+   u8 int_en_force_6:1;
+   u8 int_en_click:1;
+
+   /* Control 3 */
+   u8 force_interrupt_threshold:8;
+   } __attribute__((__packed__));
+   struct {
+   u8 regs[4];
+   u16 address;
+   } __attribute__((__packed__));
+};
+
+struct f21_2df_control_4n {
+   /*Control 4.* */
+   u8 one_newton_linear_calibration:7;
+   u8 use_cfg_cal:1;
+} __attribute__((__packed__));
+
+struct f21_2df_control_4 {
+   struct f21_2df_control_4n *regs;
+   u16 address;
+   u8 length;
+} __attribute__((__packed__));
+
+struct f21_2df_control_5n {
+   /* Control 5 */
+   u8 one_newton_nonlinear_calibration;
+};
+
+struct f21_2df_control_5 {
+   struct f21_2df_control_5n *regs;
+   u16 address;
+   u8 length;
+};
+
+struct f21_2df_control_6n {
+   /*Control 6.* */
+   u8 x_location;
+};
+
+struct f21_2df_control_6 {
+   struct f21_2df_control_6n *regs;
+   u16 address;
+   u8 length;
+};
+
+struct f21_2df_control_7n {
+   /*Control 7.* */
+   u8 y_location;
+};
+
+struct f21_2df_control_7 {
+   struct f21_2df_control_7n *regs;
+   u16 address;
+   u8 length;
+};
+
+struct f21_2df_control_8n {
+   /*Control 8.* */
+   u8 transmitter_force_sensor;
+};
+
+struct f21_2df_control_8 {
+   struct f21_2df_control_8n *regs;
+   u16 address;
+   u8 length;
+};
+
+struct f21_2df_control_9n {
+   /*Control 9.* */
+   u8 receiver_force_sensor;
+};
+
+struct f21_2df_control_9 {
+   struct f21_2df_control_9n *regs;
+   u16 address;
+   u8 length;
+};
+
+
+#define RMI_F21_NUM_CTRL_REGS 8
+struct f21_2df_control {
+   /* Control 0-3 */
+   union f21_2df_control_0__3 *reg_0__3;
+
+   /* Control 4 */
+   struct f21_2df_control_4 *reg_4;
+
+   /* Control 5 */
+   struct f21_2df_control_5 *reg_5;
+
+   /* Control 6 */
+   struct f21_2df_control_6 *reg_6;
+
+   /* Control 7 */
+   struct f21_2df_control_7 *reg_7;
+
+   /* Control 8 */
+   struct f21_2df_control_8 *reg_8;
+
+   /* Control 9 */
+   struct f21_2df_control_9 *reg_9;
+};
+
+union f21_2df_data_2 {
+   struct {
+   /* Data 2 */
+   u8 force_click:1;
+   u8 f21_2df_control0_b2__7:7;
+   } __attribute__((__packed__));
+   struct {
+   u8 regs[1];
+   u16 address;
+   } __attribute__((__packed__));
+};
+
+struct f21_2df_data {
+   /* Data 0 */
+   struct {
+   u8 *force_hi_lo;
+   u16 

[RFC PATCH 13/17] input: RMI4 F21 Force sensing

2012-08-17 Thread Christopher Heiny
Signed-off-by: Christopher Heiny che...@synaptics.com

Cc: Dmitry Torokhov dmitry.torok...@gmail.com
Cc: Linus Walleij linus.wall...@stericsson.com
Cc: Naveen Kumar Gaddipati naveen.gaddip...@stericsson.com
Cc: Joeri de Gram j.de.g...@gmail.com

Acked-by: Jean Delvare kh...@linux-fr.org

---

 drivers/input/rmi4/rmi_f21.c |  832 ++
 1 files changed, 832 insertions(+), 0 deletions(-)

diff --git a/drivers/input/rmi4/rmi_f21.c b/drivers/input/rmi4/rmi_f21.c
new file mode 100644
index 000..2e37c75
--- /dev/null
+++ b/drivers/input/rmi4/rmi_f21.c
@@ -0,0 +1,832 @@
+/*
+ * Copyright (c) 2012-2012 Synaptics Incorporated
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#define FUNCTION_DATA rmi_fn_21_data
+#define FNUM 21
+
+
+#include linux/kernel.h
+#include linux/rmi.h
+#include linux/slab.h
+#include rmi_driver.h
+
+union f21_2df_query {
+   struct {
+   /* Query 0 */
+   u8 max_force_sensor_count:3;
+   u8 f21_2df_query0_b3__6:4;
+   u8 has_high_resolution:1;
+   } __attribute__((__packed__));
+   struct {
+   u8 regs[1];
+   u16 address;
+   } __attribute__((__packed__));
+};
+
+union f21_2df_control_0__3 {
+   struct {
+   /* Control 0 */
+   u8 reporting_mode:3;
+   u8 no_rezero:1;
+   u8 ctl0_reserved:4;
+
+   /* Control 1 */
+   u8 force_click_threshold:8;
+
+   /* Control 2 */
+   u8 int_en_force_0:1;
+   u8 int_en_force_1:1;
+   u8 int_en_force_2:1;
+   u8 int_en_force_3:1;
+   u8 int_en_force_4:1;
+   u8 int_en_force_5:1;
+   u8 int_en_force_6:1;
+   u8 int_en_click:1;
+
+   /* Control 3 */
+   u8 force_interrupt_threshold:8;
+   } __attribute__((__packed__));
+   struct {
+   u8 regs[4];
+   u16 address;
+   } __attribute__((__packed__));
+};
+
+struct f21_2df_control_4n {
+   /*Control 4.* */
+   u8 one_newton_linear_calibration:7;
+   u8 use_cfg_cal:1;
+} __attribute__((__packed__));
+
+struct f21_2df_control_4 {
+   struct f21_2df_control_4n *regs;
+   u16 address;
+   u8 length;
+} __attribute__((__packed__));
+
+struct f21_2df_control_5n {
+   /* Control 5 */
+   u8 one_newton_nonlinear_calibration;
+};
+
+struct f21_2df_control_5 {
+   struct f21_2df_control_5n *regs;
+   u16 address;
+   u8 length;
+};
+
+struct f21_2df_control_6n {
+   /*Control 6.* */
+   u8 x_location;
+};
+
+struct f21_2df_control_6 {
+   struct f21_2df_control_6n *regs;
+   u16 address;
+   u8 length;
+};
+
+struct f21_2df_control_7n {
+   /*Control 7.* */
+   u8 y_location;
+};
+
+struct f21_2df_control_7 {
+   struct f21_2df_control_7n *regs;
+   u16 address;
+   u8 length;
+};
+
+struct f21_2df_control_8n {
+   /*Control 8.* */
+   u8 transmitter_force_sensor;
+};
+
+struct f21_2df_control_8 {
+   struct f21_2df_control_8n *regs;
+   u16 address;
+   u8 length;
+};
+
+struct f21_2df_control_9n {
+   /*Control 9.* */
+   u8 receiver_force_sensor;
+};
+
+struct f21_2df_control_9 {
+   struct f21_2df_control_9n *regs;
+   u16 address;
+   u8 length;
+};
+
+
+#define RMI_F21_NUM_CTRL_REGS 8
+struct f21_2df_control {
+   /* Control 0-3 */
+   union f21_2df_control_0__3 *reg_0__3;
+
+   /* Control 4 */
+   struct f21_2df_control_4 *reg_4;
+
+   /* Control 5 */
+   struct f21_2df_control_5 *reg_5;
+
+   /* Control 6 */
+   struct f21_2df_control_6 *reg_6;
+
+   /* Control 7 */
+   struct f21_2df_control_7 *reg_7;
+
+   /* Control 8 */
+   struct f21_2df_control_8 *reg_8;
+
+   /* Control 9 */
+   struct f21_2df_control_9 *reg_9;
+};
+
+union f21_2df_data_2 {
+   struct {
+   /* Data 2 */
+   u8 force_click:1;
+   u8 f21_2df_control0_b2__7:7;
+   } __attribute__((__packed__));
+   struct {
+   u8 regs[1];
+