From 3c8a23c29d30eec7a20fbb3e47e5346d9ada687b Mon Sep 17 00:00:00 2001 From: Linus Walleij Date: Mon, 1 Jan 2018 22:49:29 -0800 Subject: Input: gpio_tilt - delete driver This driver was merged in 2011 as a tool for detecting the orientation of a screen. The device driver assumes board file setup using the platform data from . But no boards in the kernel tree defines this platform data. As I am faced with refactoring drivers to use GPIO descriptors and pass decriptor tables from boards, or use the device tree device drivers like these creates a serious problem: I cannot fix them and cannot test them, not even compile-test them with a system actually using it (no in-tree boardfile). I suggest to delete this driver and rewrite it using device tree if it is still in use on actively maintained systems. I can also offer to rewrite it out of the blue using device tree if someone promise to test it and help me iterate it. Signed-off-by: Linus Walleij Acked-by: Heiko Stuebner Patchwork-Id: 10133609 Signed-off-by: Dmitry Torokhov --- Documentation/gpio/drivers-on-gpio.txt | 5 -- Documentation/input/devices/gpio-tilt.rst | 103 ------------------------------ 2 files changed, 108 deletions(-) delete mode 100644 Documentation/input/devices/gpio-tilt.rst (limited to 'Documentation') diff --git a/Documentation/gpio/drivers-on-gpio.txt b/Documentation/gpio/drivers-on-gpio.txt index 9a78d385b92e..a2ccbab12eb7 100644 --- a/Documentation/gpio/drivers-on-gpio.txt +++ b/Documentation/gpio/drivers-on-gpio.txt @@ -28,11 +28,6 @@ hardware descriptions such as device tree or ACPI: - gpio-beeper: drivers/input/misc/gpio-beeper.c is used to provide a beep from an external speaker connected to a GPIO line. -- gpio-tilt-polled: drivers/input/misc/gpio_tilt_polled.c provides tilt - detection switches using GPIO, which is useful for your homebrewn pinball - machine if for nothing else. It can detect different tilt angles of the - monitored object. - - extcon-gpio: drivers/extcon/extcon-gpio.c is used when you need to read an external connector status, such as a headset line for an audio driver or an HDMI connector. It will provide a better userspace sysfs interface than GPIO. diff --git a/Documentation/input/devices/gpio-tilt.rst b/Documentation/input/devices/gpio-tilt.rst deleted file mode 100644 index fa6e64570aa7..000000000000 --- a/Documentation/input/devices/gpio-tilt.rst +++ /dev/null @@ -1,103 +0,0 @@ -Driver for tilt-switches connected via GPIOs -============================================ - -Generic driver to read data from tilt switches connected via gpios. -Orientation can be provided by one or more than one tilt switches, -i.e. each tilt switch providing one axis, and the number of axes -is also not limited. - - -Data structures ---------------- - -The array of struct gpio in the gpios field is used to list the gpios -that represent the current tilt state. - -The array of struct gpio_tilt_axis describes the axes that are reported -to the input system. The values set therein are used for the -input_set_abs_params calls needed to init the axes. - -The array of struct gpio_tilt_state maps gpio states to the corresponding -values to report. The gpio state is represented as a bitfield where the -bit-index corresponds to the index of the gpio in the struct gpio array. -In the same manner the values stored in the axes array correspond to -the elements of the gpio_tilt_axis-array. - - -Example -------- - -Example configuration for a single TS1003 tilt switch that rotates around -one axis in 4 steps and emits the current tilt via two GPIOs:: - - static int sg060_tilt_enable(struct device *dev) { - /* code to enable the sensors */ - }; - - static void sg060_tilt_disable(struct device *dev) { - /* code to disable the sensors */ - }; - - static struct gpio sg060_tilt_gpios[] = { - { SG060_TILT_GPIO_SENSOR1, GPIOF_IN, "tilt_sensor1" }, - { SG060_TILT_GPIO_SENSOR2, GPIOF_IN, "tilt_sensor2" }, - }; - - static struct gpio_tilt_state sg060_tilt_states[] = { - { - .gpios = (0 << 1) | (0 << 0), - .axes = (int[]) { - 0, - }, - }, { - .gpios = (0 << 1) | (1 << 0), - .axes = (int[]) { - 1, /* 90 degrees */ - }, - }, { - .gpios = (1 << 1) | (1 << 0), - .axes = (int[]) { - 2, /* 180 degrees */ - }, - }, { - .gpios = (1 << 1) | (0 << 0), - .axes = (int[]) { - 3, /* 270 degrees */ - }, - }, - }; - - static struct gpio_tilt_axis sg060_tilt_axes[] = { - { - .axis = ABS_RY, - .min = 0, - .max = 3, - .fuzz = 0, - .flat = 0, - }, - }; - - static struct gpio_tilt_platform_data sg060_tilt_pdata= { - .gpios = sg060_tilt_gpios, - .nr_gpios = ARRAY_SIZE(sg060_tilt_gpios), - - .axes = sg060_tilt_axes, - .nr_axes = ARRAY_SIZE(sg060_tilt_axes), - - .states = sg060_tilt_states, - .nr_states = ARRAY_SIZE(sg060_tilt_states), - - .debounce_interval = 100, - - .poll_interval = 1000, - .enable = sg060_tilt_enable, - .disable = sg060_tilt_disable, - }; - - static struct platform_device sg060_device_tilt = { - .name = "gpio-tilt-polled", - .id = -1, - .dev = { - .platform_data = &sg060_tilt_pdata, - }, - }; -- cgit v1.2.3 From eca3be9b95ac7cf9442654a54962859d74f8e38a Mon Sep 17 00:00:00 2001 From: Hans de Goede Date: Tue, 9 Jan 2018 11:34:15 -0800 Subject: Input: silead - add support for capactive home button found on some x86 tablets On some x86 tablets with a silead touchscreen the windows logo on the front is a capacitive home button. Touching this button results in a touch with bits 12-15 of the Y coordinates set, while normally only the lower 12 are used. Detect this and report a KEY_LEFTMETA press when this happens. Note for now we only respond to the Y coordinate bits 12-15 containing 0x01, on some tablets *without* a capacative button I've noticed these bits containing 0x04 when crossing the edges of the screen. Acked-by: Rob Herring Signed-off-by: Hans de Goede Signed-off-by: Dmitry Torokhov --- .../bindings/input/touchscreen/silead_gsl1680.txt | 2 + drivers/input/touchscreen/silead.c | 46 ++++++++++++++++------ 2 files changed, 37 insertions(+), 11 deletions(-) (limited to 'Documentation') diff --git a/Documentation/devicetree/bindings/input/touchscreen/silead_gsl1680.txt b/Documentation/devicetree/bindings/input/touchscreen/silead_gsl1680.txt index 6aa625e0cb8d..84752de12412 100644 --- a/Documentation/devicetree/bindings/input/touchscreen/silead_gsl1680.txt +++ b/Documentation/devicetree/bindings/input/touchscreen/silead_gsl1680.txt @@ -23,6 +23,8 @@ Optional properties: - touchscreen-inverted-y : See touchscreen.txt - touchscreen-swapped-x-y : See touchscreen.txt - silead,max-fingers : maximum number of fingers the touchscreen can detect +- silead,home-button : Boolean, set to true on devices which have a + capacitive home-button build into the touchscreen - vddio-supply : regulator phandle for controller VDDIO - avdd-supply : regulator phandle for controller AVDD diff --git a/drivers/input/touchscreen/silead.c b/drivers/input/touchscreen/silead.c index 0dbcf105f7db..646b1e768e6b 100644 --- a/drivers/input/touchscreen/silead.c +++ b/drivers/input/touchscreen/silead.c @@ -56,7 +56,7 @@ #define SILEAD_POINT_Y_MSB_OFF 0x01 #define SILEAD_POINT_X_OFF 0x02 #define SILEAD_POINT_X_MSB_OFF 0x03 -#define SILEAD_TOUCH_ID_MASK 0xF0 +#define SILEAD_EXTRA_DATA_MASK 0xF0 #define SILEAD_CMD_SLEEP_MIN 10000 #define SILEAD_CMD_SLEEP_MAX 20000 @@ -109,6 +109,9 @@ static int silead_ts_request_input_dev(struct silead_ts_data *data) INPUT_MT_DIRECT | INPUT_MT_DROP_UNUSED | INPUT_MT_TRACK); + if (device_property_read_bool(dev, "silead,home-button")) + input_set_capability(data->input, EV_KEY, KEY_LEFTMETA); + data->input->name = SILEAD_TS_NAME; data->input->phys = "input/ts"; data->input->id.bustype = BUS_I2C; @@ -139,7 +142,8 @@ static void silead_ts_read_data(struct i2c_client *client) struct input_dev *input = data->input; struct device *dev = &client->dev; u8 *bufp, buf[SILEAD_TS_DATA_LEN]; - int touch_nr, error, i; + int touch_nr, softbutton, error, i; + bool softbutton_pressed = false; error = i2c_smbus_read_i2c_block_data(client, SILEAD_REG_DATA, SILEAD_TS_DATA_LEN, buf); @@ -148,21 +152,40 @@ static void silead_ts_read_data(struct i2c_client *client) return; } - touch_nr = buf[0]; - if (touch_nr > data->max_fingers) { + if (buf[0] > data->max_fingers) { dev_warn(dev, "More touches reported then supported %d > %d\n", - touch_nr, data->max_fingers); - touch_nr = data->max_fingers; + buf[0], data->max_fingers); + buf[0] = data->max_fingers; } + touch_nr = 0; bufp = buf + SILEAD_POINT_DATA_LEN; - for (i = 0; i < touch_nr; i++, bufp += SILEAD_POINT_DATA_LEN) { - /* Bits 4-7 are the touch id */ - data->id[i] = (bufp[SILEAD_POINT_X_MSB_OFF] & - SILEAD_TOUCH_ID_MASK) >> 4; - touchscreen_set_mt_pos(&data->pos[i], &data->prop, + for (i = 0; i < buf[0]; i++, bufp += SILEAD_POINT_DATA_LEN) { + softbutton = (bufp[SILEAD_POINT_Y_MSB_OFF] & + SILEAD_EXTRA_DATA_MASK) >> 4; + + if (softbutton) { + /* + * For now only respond to softbutton == 0x01, some + * tablets *without* a capacative button send 0x04 + * when crossing the edges of the screen. + */ + if (softbutton == 0x01) + softbutton_pressed = true; + + continue; + } + + /* + * Bits 4-7 are the touch id, note not all models have + * hardware touch ids so atm we don't use these. + */ + data->id[touch_nr] = (bufp[SILEAD_POINT_X_MSB_OFF] & + SILEAD_EXTRA_DATA_MASK) >> 4; + touchscreen_set_mt_pos(&data->pos[touch_nr], &data->prop, get_unaligned_le16(&bufp[SILEAD_POINT_X_OFF]) & 0xfff, get_unaligned_le16(&bufp[SILEAD_POINT_Y_OFF]) & 0xfff); + touch_nr++; } input_mt_assign_slots(input, data->slots, data->pos, touch_nr, 0); @@ -178,6 +201,7 @@ static void silead_ts_read_data(struct i2c_client *client) } input_mt_sync_frame(input); + input_report_key(input, KEY_LEFTMETA, softbutton_pressed); input_sync(input); } -- cgit v1.2.3 From a3f061bc26e07fecc4e3c2ed12d5d6947d996036 Mon Sep 17 00:00:00 2001 From: Jean-François Têtu Date: Thu, 18 Jan 2018 15:58:18 -0800 Subject: Input: fix small typos in force feedback documentation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fix small typos in the Instructions and Uploading sections. Fix a typo in the start/stop effect example usage code. Signed-off-by: Jean-François Têtu Signed-off-by: Dmitry Torokhov --- Documentation/input/ff.rst | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'Documentation') diff --git a/Documentation/input/ff.rst b/Documentation/input/ff.rst index 26d461998e08..0c02e87ee86d 100644 --- a/Documentation/input/ff.rst +++ b/Documentation/input/ff.rst @@ -31,7 +31,7 @@ To enable force feedback, you have to: Before you start, let me WARN you that some devices shake violently during the initialisation phase. This happens for example with my "AVB Top Shot Pegasus". -To stop this annoying behaviour, move you joystick to its limits. Anyway, you +To stop this annoying behaviour, move your joystick to its limits. Anyway, you should keep a hand on your device, in order to avoid it to break down if something goes wrong. @@ -121,7 +121,7 @@ uploaded, but not played. The content of effect may be modified. In particular, its field "id" is set to the unique id assigned by the driver. This data is required for performing some operations (removing an effect, controlling the playback). -This if field must be set to -1 by the user in order to tell the driver to +The "id" field must be set to -1 by the user in order to tell the driver to allocate a new effect. Effects are file descriptor specific. @@ -178,7 +178,7 @@ Control of playing is done with write(). Below is an example: stop.code = effect.id; stop.value = 0; - write(fd, (const void*) &play, sizeof(stop)); + write(fd, (const void*) &stop, sizeof(stop)); Setting the gain ---------------- -- cgit v1.2.3 From a4d5569eb2169190f9c904cd1a155263735e87a9 Mon Sep 17 00:00:00 2001 From: Andy Shevchenko Date: Mon, 22 Jan 2018 09:27:22 -0800 Subject: Input: docs - use PROPERTY_ENTRY_U32() directly Instead of using PROPERTY_ENTRY_INTEGER() with explicitly supplied type, use PROPERTY_ENTRY_U32() dedicated macro. It will help modify internals of built-in device properties API. No functional change intended. Signed-off-by: Andy Shevchenko Signed-off-by: Dmitry Torokhov --- Documentation/input/devices/rotary-encoder.rst | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'Documentation') diff --git a/Documentation/input/devices/rotary-encoder.rst b/Documentation/input/devices/rotary-encoder.rst index b07b20a295ac..810ae02bdaa0 100644 --- a/Documentation/input/devices/rotary-encoder.rst +++ b/Documentation/input/devices/rotary-encoder.rst @@ -108,9 +108,9 @@ example below: }; static const struct property_entry rotary_encoder_properties[] __initconst = { - PROPERTY_ENTRY_INTEGER("rotary-encoder,steps-per-period", u32, 24), - PROPERTY_ENTRY_INTEGER("linux,axis", u32, ABS_X), - PROPERTY_ENTRY_INTEGER("rotary-encoder,relative_axis", u32, 0), + PROPERTY_ENTRY_U32("rotary-encoder,steps-per-period", 24), + PROPERTY_ENTRY_U32("linux,axis", ABS_X), + PROPERTY_ENTRY_U32("rotary-encoder,relative_axis", 0), { }, }; -- cgit v1.2.3 From 5b0d0033f3f3a3d09178ef0dcdd0d4e1a08666b8 Mon Sep 17 00:00:00 2001 From: Simon Shields Date: Mon, 22 Jan 2018 17:45:09 -0800 Subject: Input: mms114 - drop platform data and use generic APIs The MMS114 platform data has no in-tree users, so drop it. Switch to using the standard touchscreen properties via touchscreen_parse_properties(), and move the old DT parsing code to use device_property_*() APIs. Finally, use touchscreen_report_pos to report x/y coordinates and drop the custom x/y inversion code. Signed-off-by: Simon Shields Reviewed-by: Rob Herring Reviewed-by: Andi Shyti Tested-by: Andi Shyti Signed-off-by: Dmitry Torokhov --- .../bindings/input/touchscreen/mms114.txt | 29 ++-- drivers/input/touchscreen/mms114.c | 147 +++++++++------------ include/linux/platform_data/mms114.h | 24 ---- 3 files changed, 82 insertions(+), 118 deletions(-) delete mode 100644 include/linux/platform_data/mms114.h (limited to 'Documentation') diff --git a/Documentation/devicetree/bindings/input/touchscreen/mms114.txt b/Documentation/devicetree/bindings/input/touchscreen/mms114.txt index 89d4c56c5671..8f9f9f38eff4 100644 --- a/Documentation/devicetree/bindings/input/touchscreen/mms114.txt +++ b/Documentation/devicetree/bindings/input/touchscreen/mms114.txt @@ -4,14 +4,18 @@ Required properties: - compatible: must be "melfas,mms114" - reg: I2C address of the chip - interrupts: interrupt to which the chip is connected -- x-size: horizontal resolution of touchscreen -- y-size: vertical resolution of touchscreen +- touchscreen-size-x: See [1] +- touchscreen-size-y: See [1] Optional properties: -- contact-threshold: -- moving-threshold: -- x-invert: invert X axis -- y-invert: invert Y axis +- touchscreen-fuzz-x: See [1] +- touchscreen-fuzz-y: See [1] +- touchscreen-fuzz-pressure: See [1] +- touchscreen-inverted-x: See [1] +- touchscreen-inverted-y: See [1] +- touchscreen-swapped-x-y: See [1] + +[1]: Documentation/devicetree/bindings/input/touchscreen/touchscreen.txt Example: @@ -22,12 +26,13 @@ Example: compatible = "melfas,mms114"; reg = <0x48>; interrupts = <39 0>; - x-size = <720>; - y-size = <1280>; - contact-threshold = <10>; - moving-threshold = <10>; - x-invert; - y-invert; + touchscreen-size-x = <720>; + touchscreen-size-y = <1280>; + touchscreen-fuzz-x = <10>; + touchscreen-fuzz-y = <10>; + touchscreen-fuzz-pressure = <10>; + touchscreen-inverted-x; + touchscreen-inverted-y; }; /* ... */ diff --git a/drivers/input/touchscreen/mms114.c b/drivers/input/touchscreen/mms114.c index c3480db5d21e..69e4288bf8aa 100644 --- a/drivers/input/touchscreen/mms114.c +++ b/drivers/input/touchscreen/mms114.c @@ -12,8 +12,8 @@ #include #include #include +#include #include -#include #include #include @@ -55,7 +55,9 @@ struct mms114_data { struct input_dev *input_dev; struct regulator *core_reg; struct regulator *io_reg; - const struct mms114_platform_data *pdata; + struct touchscreen_properties props; + unsigned int contact_threshold; + unsigned int moving_threshold; /* Use cache data for mode control register(write only) */ u8 cache_mode_control; @@ -143,7 +145,6 @@ static int mms114_write_reg(struct mms114_data *data, unsigned int reg, static void mms114_process_mt(struct mms114_data *data, struct mms114_touch *touch) { - const struct mms114_platform_data *pdata = data->pdata; struct i2c_client *client = data->client; struct input_dev *input_dev = data->input_dev; unsigned int id; @@ -163,16 +164,6 @@ static void mms114_process_mt(struct mms114_data *data, struct mms114_touch *tou id = touch->id - 1; x = touch->x_lo | touch->x_hi << 8; y = touch->y_lo | touch->y_hi << 8; - if (x > pdata->x_size || y > pdata->y_size) { - dev_dbg(&client->dev, - "Wrong touch coordinates (%d, %d)\n", x, y); - return; - } - - if (pdata->x_invert) - x = pdata->x_size - x; - if (pdata->y_invert) - y = pdata->y_size - y; dev_dbg(&client->dev, "id: %d, type: %d, pressed: %d, x: %d, y: %d, width: %d, strength: %d\n", @@ -183,9 +174,8 @@ static void mms114_process_mt(struct mms114_data *data, struct mms114_touch *tou input_mt_report_slot_state(input_dev, MT_TOOL_FINGER, touch->pressed); if (touch->pressed) { + touchscreen_report_pos(input_dev, &data->props, x, y, true); input_report_abs(input_dev, ABS_MT_TOUCH_MAJOR, touch->width); - input_report_abs(input_dev, ABS_MT_POSITION_X, x); - input_report_abs(input_dev, ABS_MT_POSITION_Y, y); input_report_abs(input_dev, ABS_MT_PRESSURE, touch->strength); } } @@ -263,7 +253,7 @@ static int mms114_get_version(struct mms114_data *data) static int mms114_setup_regs(struct mms114_data *data) { - const struct mms114_platform_data *pdata = data->pdata; + const struct touchscreen_properties *props = &data->props; int val; int error; @@ -275,32 +265,32 @@ static int mms114_setup_regs(struct mms114_data *data) if (error < 0) return error; - val = (pdata->x_size >> 8) & 0xf; - val |= ((pdata->y_size >> 8) & 0xf) << 4; + val = (props->max_x >> 8) & 0xf; + val |= ((props->max_y >> 8) & 0xf) << 4; error = mms114_write_reg(data, MMS114_XY_RESOLUTION_H, val); if (error < 0) return error; - val = pdata->x_size & 0xff; + val = props->max_x & 0xff; error = mms114_write_reg(data, MMS114_X_RESOLUTION, val); if (error < 0) return error; - val = pdata->y_size & 0xff; + val = props->max_x & 0xff; error = mms114_write_reg(data, MMS114_Y_RESOLUTION, val); if (error < 0) return error; - if (pdata->contact_threshold) { + if (data->contact_threshold) { error = mms114_write_reg(data, MMS114_CONTACT_THRESHOLD, - pdata->contact_threshold); + data->contact_threshold); if (error < 0) return error; } - if (pdata->moving_threshold) { + if (data->moving_threshold) { error = mms114_write_reg(data, MMS114_MOVING_THRESHOLD, - pdata->moving_threshold); + data->moving_threshold); if (error < 0) return error; } @@ -335,9 +325,6 @@ static int mms114_start(struct mms114_data *data) return error; } - if (data->pdata->cfg_pin) - data->pdata->cfg_pin(true); - enable_irq(client->irq); return 0; @@ -350,9 +337,6 @@ static void mms114_stop(struct mms114_data *data) disable_irq(client->irq); - if (data->pdata->cfg_pin) - data->pdata->cfg_pin(false); - error = regulator_disable(data->io_reg); if (error) dev_warn(&client->dev, "Failed to disable vdd: %d\n", error); @@ -376,67 +360,43 @@ static void mms114_input_close(struct input_dev *dev) mms114_stop(data); } -#ifdef CONFIG_OF -static struct mms114_platform_data *mms114_parse_dt(struct device *dev) +static int mms114_parse_legacy_bindings(struct mms114_data *data) { - struct mms114_platform_data *pdata; - struct device_node *np = dev->of_node; - - if (!np) - return NULL; + struct device *dev = &data->client->dev; + struct touchscreen_properties *props = &data->props; - pdata = devm_kzalloc(dev, sizeof(*pdata), GFP_KERNEL); - if (!pdata) { - dev_err(dev, "failed to allocate platform data\n"); - return NULL; + if (device_property_read_u32(dev, "x-size", &props->max_x)) { + dev_dbg(dev, "failed to get legacy x-size property\n"); + return -EINVAL; } - if (of_property_read_u32(np, "x-size", &pdata->x_size)) { - dev_err(dev, "failed to get x-size property\n"); - return NULL; + if (device_property_read_u32(dev, "y-size", &props->max_y)) { + dev_dbg(dev, "failed to get legacy y-size property\n"); + return -EINVAL; } - if (of_property_read_u32(np, "y-size", &pdata->y_size)) { - dev_err(dev, "failed to get y-size property\n"); - return NULL; - } + device_property_read_u32(dev, "contact-threshold", + &data->contact_threshold); + device_property_read_u32(dev, "moving-threshold", + &data->moving_threshold); - of_property_read_u32(np, "contact-threshold", - &pdata->contact_threshold); - of_property_read_u32(np, "moving-threshold", - &pdata->moving_threshold); + if (device_property_read_bool(dev, "x-invert")) + props->invert_x = true; + if (device_property_read_bool(dev, "y-invert")) + props->invert_y = true; - if (of_find_property(np, "x-invert", NULL)) - pdata->x_invert = true; - if (of_find_property(np, "y-invert", NULL)) - pdata->y_invert = true; + props->swap_x_y = false; - return pdata; -} -#else -static inline struct mms114_platform_data *mms114_parse_dt(struct device *dev) -{ - return NULL; + return 0; } -#endif static int mms114_probe(struct i2c_client *client, const struct i2c_device_id *id) { - const struct mms114_platform_data *pdata; struct mms114_data *data; struct input_dev *input_dev; int error; - pdata = dev_get_platdata(&client->dev); - if (!pdata) - pdata = mms114_parse_dt(&client->dev); - - if (!pdata) { - dev_err(&client->dev, "Need platform data\n"); - return -EINVAL; - } - if (!i2c_check_functionality(client->adapter, I2C_FUNC_PROTOCOL_MANGLING)) { dev_err(&client->dev, @@ -454,7 +414,38 @@ static int mms114_probe(struct i2c_client *client, data->client = client; data->input_dev = input_dev; - data->pdata = pdata; + + input_set_capability(input_dev, EV_ABS, ABS_MT_POSITION_X); + input_set_capability(input_dev, EV_ABS, ABS_MT_POSITION_Y); + input_set_abs_params(input_dev, ABS_MT_PRESSURE, 0, 255, 0, 0); + input_set_abs_params(input_dev, ABS_MT_TOUCH_MAJOR, + 0, MMS114_MAX_AREA, 0, 0); + + touchscreen_parse_properties(input_dev, true, &data->props); + if (!data->props.max_x || !data->props.max_y) { + dev_dbg(&client->dev, + "missing X/Y size properties, trying legacy bindings\n"); + error = mms114_parse_legacy_bindings(data); + if (error) + return error; + + input_set_abs_params(input_dev, ABS_MT_POSITION_X, + 0, data->props.max_x, 0, 0); + input_set_abs_params(input_dev, ABS_MT_POSITION_Y, + 0, data->props.max_y, 0, 0); + } + + /* + * The firmware handles movement and pressure fuzz, so + * don't duplicate that in software. + */ + data->moving_threshold = input_abs_get_fuzz(input_dev, + ABS_MT_POSITION_X); + data->contact_threshold = input_abs_get_fuzz(input_dev, + ABS_MT_PRESSURE); + input_abs_set_fuzz(input_dev, ABS_MT_POSITION_X, 0); + input_abs_set_fuzz(input_dev, ABS_MT_POSITION_Y, 0); + input_abs_set_fuzz(input_dev, ABS_MT_PRESSURE, 0); input_dev->name = "MELFAS MMS114 Touchscreen"; input_dev->id.bustype = BUS_I2C; @@ -462,14 +453,6 @@ static int mms114_probe(struct i2c_client *client, input_dev->open = mms114_input_open; input_dev->close = mms114_input_close; - input_set_abs_params(input_dev, ABS_MT_TOUCH_MAJOR, - 0, MMS114_MAX_AREA, 0, 0); - input_set_abs_params(input_dev, ABS_MT_POSITION_X, - 0, data->pdata->x_size, 0, 0); - input_set_abs_params(input_dev, ABS_MT_POSITION_Y, - 0, data->pdata->y_size, 0, 0); - input_set_abs_params(input_dev, ABS_MT_PRESSURE, 0, 255, 0, 0); - error = input_mt_init_slots(input_dev, MMS114_MAX_TOUCH, INPUT_MT_DIRECT); if (error) diff --git a/include/linux/platform_data/mms114.h b/include/linux/platform_data/mms114.h deleted file mode 100644 index 5722ebfb2738..000000000000 --- a/include/linux/platform_data/mms114.h +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Copyright (C) 2012 Samsung Electronics Co.Ltd - * Author: Joonyoung Shim - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 as - * published by the Free Software Foundationr - */ - -#ifndef __LINUX_MMS114_H -#define __LINUX_MMS114_H - -struct mms114_platform_data { - unsigned int x_size; - unsigned int y_size; - unsigned int contact_threshold; - unsigned int moving_threshold; - bool x_invert; - bool y_invert; - - void (*cfg_pin)(bool); -}; - -#endif /* __LINUX_MMS114_H */ -- cgit v1.2.3 From 72b0c0cf9720cd139829610cfcd9ac294451a9f8 Mon Sep 17 00:00:00 2001 From: Simon Shields Date: Tue, 23 Jan 2018 12:02:39 -0800 Subject: Input: mms114 - add support for mms152 MMS152 has no configuration registers, but the packet format used in interrupts is identical to mms114. Signed-off-by: Simon Shields Reviewed-by: Andi Shyti Tested-by: Andi Shyti Signed-off-by: Dmitry Torokhov --- .../bindings/input/touchscreen/mms114.txt | 6 +- drivers/input/touchscreen/mms114.c | 92 +++++++++++++++++----- 2 files changed, 77 insertions(+), 21 deletions(-) (limited to 'Documentation') diff --git a/Documentation/devicetree/bindings/input/touchscreen/mms114.txt b/Documentation/devicetree/bindings/input/touchscreen/mms114.txt index 8f9f9f38eff4..2cd954051d29 100644 --- a/Documentation/devicetree/bindings/input/touchscreen/mms114.txt +++ b/Documentation/devicetree/bindings/input/touchscreen/mms114.txt @@ -1,7 +1,9 @@ -* MELFAS MMS114 touchscreen controller +* MELFAS MMS114/MMS152 touchscreen controller Required properties: -- compatible: must be "melfas,mms114" +- compatible: should be one of: + - "melfas,mms114" + - "melfas,mms152" - reg: I2C address of the chip - interrupts: interrupt to which the chip is connected - touchscreen-size-x: See [1] diff --git a/drivers/input/touchscreen/mms114.c b/drivers/input/touchscreen/mms114.c index 69e4288bf8aa..c54f4afe1103 100644 --- a/drivers/input/touchscreen/mms114.c +++ b/drivers/input/touchscreen/mms114.c @@ -10,6 +10,7 @@ #include #include #include +#include #include #include #include @@ -33,6 +34,9 @@ #define MMS114_INFOMATION 0x10 #define MMS114_TSP_REV 0xF0 +#define MMS152_FW_REV 0xE1 +#define MMS152_COMPAT_GROUP 0xF2 + /* Minimum delay time is 50us between stop and start signal of i2c */ #define MMS114_I2C_DELAY 50 @@ -50,12 +54,18 @@ #define MMS114_TYPE_TOUCHSCREEN 1 #define MMS114_TYPE_TOUCHKEY 2 +enum mms_type { + TYPE_MMS114 = 114, + TYPE_MMS152 = 152, +}; + struct mms114_data { struct i2c_client *client; struct input_dev *input_dev; struct regulator *core_reg; struct regulator *io_reg; struct touchscreen_properties props; + enum mms_type type; unsigned int contact_threshold; unsigned int moving_threshold; @@ -239,14 +249,33 @@ static int mms114_get_version(struct mms114_data *data) { struct device *dev = &data->client->dev; u8 buf[6]; + int group; int error; - error = __mms114_read_reg(data, MMS114_TSP_REV, 6, buf); - if (error < 0) - return error; + switch (data->type) { + case TYPE_MMS152: + error = __mms114_read_reg(data, MMS152_FW_REV, 3, buf); + if (error) + return error; + + group = i2c_smbus_read_byte_data(data->client, + MMS152_COMPAT_GROUP); + if (group < 0) + return group; + + dev_info(dev, "TSP FW Rev: bootloader 0x%x / core 0x%x / config 0x%x, Compat group: %c\n", + buf[0], buf[1], buf[2], group); + break; + + case TYPE_MMS114: + error = __mms114_read_reg(data, MMS114_TSP_REV, 6, buf); + if (error) + return error; - dev_info(dev, "TSP Rev: 0x%x, HW Rev: 0x%x, Firmware Ver: 0x%x\n", - buf[0], buf[1], buf[3]); + dev_info(dev, "TSP Rev: 0x%x, HW Rev: 0x%x, Firmware Ver: 0x%x\n", + buf[0], buf[1], buf[3]); + break; + } return 0; } @@ -261,6 +290,10 @@ static int mms114_setup_regs(struct mms114_data *data) if (error < 0) return error; + /* MMS152 has no configuration or power on registers */ + if (data->type == TYPE_MMS152) + return 0; + error = mms114_set_active(data, true); if (error < 0) return error; @@ -395,6 +428,7 @@ static int mms114_probe(struct i2c_client *client, { struct mms114_data *data; struct input_dev *input_dev; + const void *match_data; int error; if (!i2c_check_functionality(client->adapter, @@ -415,6 +449,13 @@ static int mms114_probe(struct i2c_client *client, data->client = client; data->input_dev = input_dev; + /* FIXME: switch to device_get_match_data() when available */ + match_data = of_device_get_match_data(&client->dev); + if (!match_data) + return -EINVAL; + + data->type = (enum mms_type)match_data; + input_set_capability(input_dev, EV_ABS, ABS_MT_POSITION_X); input_set_capability(input_dev, EV_ABS, ABS_MT_POSITION_Y); input_set_abs_params(input_dev, ABS_MT_PRESSURE, 0, 255, 0, 0); @@ -435,19 +476,26 @@ static int mms114_probe(struct i2c_client *client, 0, data->props.max_y, 0, 0); } - /* - * The firmware handles movement and pressure fuzz, so - * don't duplicate that in software. - */ - data->moving_threshold = input_abs_get_fuzz(input_dev, - ABS_MT_POSITION_X); - data->contact_threshold = input_abs_get_fuzz(input_dev, - ABS_MT_PRESSURE); - input_abs_set_fuzz(input_dev, ABS_MT_POSITION_X, 0); - input_abs_set_fuzz(input_dev, ABS_MT_POSITION_Y, 0); - input_abs_set_fuzz(input_dev, ABS_MT_PRESSURE, 0); - - input_dev->name = "MELFAS MMS114 Touchscreen"; + if (data->type == TYPE_MMS114) { + /* + * The firmware handles movement and pressure fuzz, so + * don't duplicate that in software. + */ + data->moving_threshold = input_abs_get_fuzz(input_dev, + ABS_MT_POSITION_X); + data->contact_threshold = input_abs_get_fuzz(input_dev, + ABS_MT_PRESSURE); + input_abs_set_fuzz(input_dev, ABS_MT_POSITION_X, 0); + input_abs_set_fuzz(input_dev, ABS_MT_POSITION_Y, 0); + input_abs_set_fuzz(input_dev, ABS_MT_PRESSURE, 0); + } + + input_dev->name = devm_kasprintf(&client->dev, GFP_KERNEL, + "MELFAS MMS%d Touchscreen", + data->type); + if (!input_dev->name) + return -ENOMEM; + input_dev->id.bustype = BUS_I2C; input_dev->dev.parent = &client->dev; input_dev->open = mms114_input_open; @@ -549,7 +597,13 @@ MODULE_DEVICE_TABLE(i2c, mms114_id); #ifdef CONFIG_OF static const struct of_device_id mms114_dt_match[] = { - { .compatible = "melfas,mms114" }, + { + .compatible = "melfas,mms114", + .data = (void *)TYPE_MMS114, + }, { + .compatible = "melfas,mms152", + .data = (void *)TYPE_MMS152, + }, { } }; MODULE_DEVICE_TABLE(of, mms114_dt_match); -- cgit v1.2.3