From f0509b42dbbbd69dff4b75a46c0cb9ed06e94d16 Mon Sep 17 00:00:00 2001 From: Luca Weiss Date: Mon, 17 Feb 2025 15:40:04 +0100 Subject: [PATCH] Input: eswin_touch - Fix up downstream driver --- .../touchscreen/eswin_touch/eswin_eph861x.c | 38 +++++++---------- .../eswin_touch/eswin_eph861x_bootloader.c | 7 ++-- .../eswin_touch/eswin_eph861x_comms.c | 2 +- .../eswin_touch/eswin_eph861x_eswin.c | 42 +++++++------------ .../eswin_touch/eswin_eph861x_i2c.c | 1 - .../eswin_touch/eswin_eph861x_types.h | 4 +- 6 files changed, 36 insertions(+), 58 deletions(-) diff --git a/drivers/input/touchscreen/eswin_touch/eswin_eph861x.c b/drivers/input/touchscreen/eswin_touch/eswin_eph861x.c index 09eefc803fcb..b5f9b49d8ecd 100644 --- a/drivers/input/touchscreen/eswin_touch/eswin_eph861x.c +++ b/drivers/input/touchscreen/eswin_touch/eswin_eph861x.c @@ -34,7 +34,6 @@ #include #include #include -#include #include #include #include @@ -42,7 +41,7 @@ #include #include -#include +//#include #include "eswin_eph861x_project_config.h" #include "eswin_eph861x_types.h" #include "eswin_eph861x_comms.h" @@ -58,7 +57,7 @@ /* Touchscreen absolute values */ #define EPH_MAX_HEIGHT_WIDTH 255u -#if defined(CONFIG_DRM) +#if 0 static struct drm_panel *active_panel; static void eph_panel_notifier_callback(enum panel_event_notifier_tag tag, struct panel_event_notification *event, void *client_data); @@ -441,7 +440,7 @@ static int eph_acquire_irq(struct eph_data *ephdata) if (!ephdata->chg_irq) { - ephdata->chg_irq = gpio_to_irq(ephdata->ephplatform->gpio_chg_irq); + ephdata->chg_irq = gpiod_to_irq(ephdata->ephplatform->gpio_chg_irq); commsdevice_name = eph_comms_devicename_get(ephdata); @@ -461,7 +460,7 @@ static int eph_acquire_irq(struct eph_data *ephdata) } /* Presence of ephdata->chg_irq means IRQ initialised */ - dev_info(&ephdata->commsdevice->dev, "zxz gpio_to_irq %lu -> %d\n", ephdata->ephplatform->gpio_chg_irq, ephdata->chg_irq); + dev_info(&ephdata->commsdevice->dev, "zxz gpio_to_irq -> %d\n", ephdata->chg_irq); } else { @@ -501,12 +500,12 @@ static int eph_probe_regulators(struct eph_data *ephdata) dev_dbg(dev, "%s >\n", __func__); /* Must have reset GPIO to use regulator support */ - if (!gpio_is_valid(ephdata->ephplatform->gpio_reset)) + if (IS_ERR(ephdata->ephplatform->gpio_reset)) { ret_val = -EINVAL; goto fail; } - if (!gpio_is_valid(ephdata->ephplatform->gpio_chg_irq)) + if (IS_ERR(ephdata->ephplatform->gpio_chg_irq)) { ret_val = -EINVAL; goto fail; @@ -541,8 +540,6 @@ fail_release: fail: ephdata->reg_vdd = NULL; ephdata->reg_avdd = NULL; - gpio_free(ephdata->ephplatform->gpio_reset); - gpio_free(ephdata->ephplatform->gpio_chg_irq); return ret_val; } @@ -1561,12 +1558,12 @@ static void eph_input_close(struct input_dev *inputdev) } } -#if defined(CONFIG_DRM) //|| defined(CONFIG_BOARD_CLOUDRIPPER) +#if 0 static int eph_dev_enter_lp_mode(struct eph_data *ephdata); static int eph_dev_enter_normal_mode(struct eph_data *ephdata); #endif -#if defined(CONFIG_DRM) +#if 0 static void eph_panel_notifier_callback(enum panel_event_notifier_tag tag, struct panel_event_notification *notification, void *client_data) { @@ -1903,7 +1900,7 @@ ic_reset: return; } -#if defined(CONFIG_DRM) +#if 0 static int eph_check_dt(struct device_node *np) { int i; @@ -1988,7 +1985,7 @@ static int eph_probe(struct comms_device *commsdevice, const struct comms_device int device_info_read_retry = 0; struct device *dev = &commsdevice->dev; - struct device_node *node = commsdevice->dev.of_node; + //struct device_node *node = commsdevice->dev.of_node; dev_dbg(dev, "%s >>>\n", __func__); pr_err("eph_probe----11--100000ms--\n"); @@ -2005,7 +2002,7 @@ static int eph_probe(struct comms_device *commsdevice, const struct comms_device { return PTR_ERR(ephplatform); } -#if defined(CONFIG_DRM) +#if 0 ret_val = eph_check_dt(node); if (ret_val == -EPROBE_DEFER) { @@ -2028,6 +2025,7 @@ static int eph_probe(struct comms_device *commsdevice, const struct comms_device return -ENOMEM; } +#if 0 ephdata->bl = backlight_device_get_by_type(BACKLIGHT_RAW); if (ephdata->bl) { @@ -2038,6 +2036,7 @@ static int eph_probe(struct comms_device *commsdevice, const struct comms_device ret_val = -EPROBE_DEFER; goto err_free_mem; } +#endif INIT_WORK(&ephdata->force_baseline_work, eph_trigger_baseline_work); INIT_DELAYED_WORK(&ephdata->heartbeat_work, heartbeat_work_handler); @@ -2152,7 +2151,7 @@ static int eph_probe(struct comms_device *commsdevice, const struct comms_device goto err_free_irq; } -#if defined(CONFIG_DRM) +#if 0 eph_register_for_panel_events(node, ephdata); // ephdata->notifier.notifier_call = eph_notifier_callback; // ret_val = msm_drm_register_client(&ephdata->notifier); @@ -2186,8 +2185,6 @@ err_free_irq: free_irq(ephdata->chg_irq, ephdata); } - gpio_free(ephdata->ephplatform->gpio_reset); - gpio_free(ephdata->ephplatform->gpio_chg_irq); if(ephdata->reg_vdd) { regulator_put(ephdata->reg_vdd); @@ -2216,7 +2213,7 @@ static void eph_remove(struct comms_device *commsdevice) sysfs_remove_group(&commsdevice->dev.kobj, &eph_fw_attr_group); eph_sysfs_mem_access_remove(ephdata); -#if defined(CONFIG_DRM) +#if 0 if (ephdata->notifier_cookie) panel_event_notifier_unregister(ephdata->notifier_cookie); // #elif defined(CONFIG_BOARD_CLOUDRIPPER) @@ -2228,9 +2225,6 @@ static void eph_remove(struct comms_device *commsdevice) free_irq(ephdata->chg_irq, ephdata); } - gpio_free(ephdata->ephplatform->gpio_reset); - gpio_free(ephdata->ephplatform->gpio_chg_irq); - if(ephdata->reg_avdd) { regulator_put(ephdata->reg_avdd); @@ -2261,7 +2255,7 @@ static void eph_remove(struct comms_device *commsdevice) #endif } -#if defined(CONFIG_DRM) //|| defined(CONFIG_BOARD_CLOUDRIPPER) +#if 0 int eph_enable_report_event(struct device *dev, int enable) { int ret = 0; diff --git a/drivers/input/touchscreen/eswin_touch/eswin_eph861x_bootloader.c b/drivers/input/touchscreen/eswin_touch/eswin_eph861x_bootloader.c index 42009b3b407f..3b1ffbe13196 100644 --- a/drivers/input/touchscreen/eswin_touch/eswin_eph861x_bootloader.c +++ b/drivers/input/touchscreen/eswin_touch/eswin_eph861x_bootloader.c @@ -29,7 +29,6 @@ #include #include #include -#include #include "eswin_eph861x_project_config.h" #include "eswin_eph861x_tlv.h" @@ -256,9 +255,9 @@ int eph_chg_force_bootloader(struct eph_data *ephdata) msleep((EPH_POWERON_DELAY)); #else for (int i = 0; i < 10; i++) { - gpio_set_value(ephdata->ephplatform->gpio_reset, GPIO_RESET_YES_LOW); + gpiod_set_value(ephdata->ephplatform->gpio_reset, GPIO_RESET_YES_LOW); msleep(EPH_RESET_HOLD_TIME); - gpio_set_value(ephdata->ephplatform->gpio_reset, GPIO_RESET_NO_HIGH); + gpiod_set_value(ephdata->ephplatform->gpio_reset, GPIO_RESET_NO_HIGH); msleep((EPH_POWERON_DELAY)); } #endif @@ -272,7 +271,7 @@ int eph_chg_force_bootloader(struct eph_data *ephdata) int eph_bootloader_release_chg(struct eph_data *ephdata) { int ret_val; - ret_val = gpio_direction_input(ephdata->ephplatform->gpio_chg_irq); + ret_val = gpiod_direction_input(ephdata->ephplatform->gpio_chg_irq); return ret_val; } diff --git a/drivers/input/touchscreen/eswin_touch/eswin_eph861x_comms.c b/drivers/input/touchscreen/eswin_touch/eswin_eph861x_comms.c index 61485798bcdc..d781bfbad134 100644 --- a/drivers/input/touchscreen/eswin_touch/eswin_eph861x_comms.c +++ b/drivers/input/touchscreen/eswin_touch/eswin_eph861x_comms.c @@ -125,7 +125,7 @@ int eph_read_report(struct eph_data *ephdata, u8 *buf) u8 eph_read_chg(struct eph_data *ephdata) { - u8 ret_val = (u8)gpio_get_value(ephdata->ephplatform->gpio_chg_irq); + u8 ret_val = (u8)gpiod_get_value(ephdata->ephplatform->gpio_chg_irq); return ret_val; } diff --git a/drivers/input/touchscreen/eswin_touch/eswin_eph861x_eswin.c b/drivers/input/touchscreen/eswin_touch/eswin_eph861x_eswin.c index e71e285aa992..08d8e7d127b1 100644 --- a/drivers/input/touchscreen/eswin_touch/eswin_eph861x_eswin.c +++ b/drivers/input/touchscreen/eswin_touch/eswin_eph861x_eswin.c @@ -32,7 +32,6 @@ #include #include #include -#include #include "eswin_eph861x_project_config.h" #include "eswin_eph861x_tlv.h" @@ -170,8 +169,8 @@ const struct eph_platform_data *eph_platform_data_get_from_device_tree(struct co return (struct eph_platform_data *)ERR_PTR(-ENOMEM); } - ephplatform->gpio_reset = of_get_named_gpio_flags(devnode, "eswin,reset-gpio", 0, NULL); - ephplatform->gpio_chg_irq = of_get_named_gpio_flags(devnode, "eswin,irq-gpio", 0, NULL); + ephplatform->gpio_reset = devm_gpiod_get(&commsdevice->dev, "eswin,reset", GPIOD_ASIS); + ephplatform->gpio_chg_irq = devm_gpiod_get(&commsdevice->dev, "eswin,irq", GPIOD_ASIS); /* returns pointer to already allocated memory containing the string */ ret_val = of_property_read_string(devnode, "eswin,regulator_dvdd", &ephplatform->regulator_dvdd); @@ -280,34 +279,22 @@ int eph_gpio_setup(struct eph_data *ephdata) int ret_val; dev_dbg(&ephdata->commsdevice->dev, "%s >\n", __func__); - ret_val = gpio_request(ephdata->ephplatform->gpio_chg_irq, "irq-gpio"); + ret_val = gpiod_direction_input(ephdata->ephplatform->gpio_chg_irq); if (ret_val) { - dev_err(&ephdata->commsdevice->dev, "gpio_request %lu (%d)", ephdata->ephplatform->gpio_chg_irq, ret_val); + dev_err(&ephdata->commsdevice->dev, "gpio_direction_input (%d)", ret_val); return ret_val; } - ret_val = gpio_direction_input(ephdata->ephplatform->gpio_chg_irq); - if (ret_val) - { - dev_err(&ephdata->commsdevice->dev, "gpio_direction_input %lu (%d)", ephdata->ephplatform->gpio_chg_irq, ret_val); - return ret_val; - } - dev_dbg(&ephdata->commsdevice->dev, "gpio_chg_irq %lu IN %d\n", ephdata->ephplatform->gpio_chg_irq, (u8)gpio_get_value(ephdata->ephplatform->gpio_chg_irq)); + dev_dbg(&ephdata->commsdevice->dev, "gpio_chg_irq IN %d\n", (u8)gpiod_get_value(ephdata->ephplatform->gpio_chg_irq)); - ret_val = gpio_request(ephdata->ephplatform->gpio_reset, "reset-gpio"); - if (ret_val) - { - dev_err(&ephdata->commsdevice->dev, "gpio_request %lu (%d)", ephdata->ephplatform->gpio_reset, ret_val); - return ret_val; - } /* Initialise so that we are holding the device in reset until power has been applied */ - ret_val = gpio_direction_output(ephdata->ephplatform->gpio_reset, GPIO_RESET_YES_LOW); + ret_val = gpiod_direction_output(ephdata->ephplatform->gpio_reset, GPIO_RESET_YES_LOW); if (ret_val) { - dev_err(&ephdata->commsdevice->dev, "gpio_direction_output %lu (%d)", ephdata->ephplatform->gpio_reset, ret_val); + dev_err(&ephdata->commsdevice->dev, "gpio_direction_output (%d)", ret_val); return ret_val; } - dev_dbg(&ephdata->commsdevice->dev, "gpio_reset %lu OUT %d\n", ephdata->ephplatform->gpio_reset, GPIO_RESET_YES_LOW); + dev_dbg(&ephdata->commsdevice->dev, "gpio_reset OUT %d\n", GPIO_RESET_YES_LOW); dev_dbg(&ephdata->commsdevice->dev, "%s <\n", __func__); @@ -351,7 +338,7 @@ void eph_regulator_enable(struct eph_data *ephdata) return; } - gpio_set_value(ephdata->ephplatform->gpio_reset, GPIO_RESET_YES_LOW); + gpiod_set_value(ephdata->ephplatform->gpio_reset, GPIO_RESET_YES_LOW); ret_val = regulator_enable(ephdata->reg_vdd); if (ret_val) @@ -370,7 +357,7 @@ void eph_regulator_enable(struct eph_data *ephdata) /* According to power sequencing specification, RESET line must be kept * low until some time after regulators come up to voltage */ msleep(EPH_REGULATOR_DELAY); - gpio_set_value(ephdata->ephplatform->gpio_reset, GPIO_RESET_NO_HIGH); + gpiod_set_value(ephdata->ephplatform->gpio_reset, GPIO_RESET_NO_HIGH); //TODO this additional delay should not be needed /* Delay to prevent poor signals after power up. This will allow device time to "settle" before baseline */ msleep(EPH_POWERON_DELAY); @@ -404,7 +391,7 @@ void eph_recovery_device(struct eph_data *ephdata) int ret_val; disable_irq(ephdata->chg_irq); - gpio_set_value(ephdata->ephplatform->gpio_reset, GPIO_RESET_YES_LOW); + gpiod_set_value(ephdata->ephplatform->gpio_reset, GPIO_RESET_YES_LOW); if (ephdata->reg_vdd && regulator_is_enabled(ephdata->reg_vdd)) regulator_disable(ephdata->reg_vdd); if (ephdata->reg_avdd && regulator_is_enabled(ephdata->reg_avdd)) @@ -419,7 +406,7 @@ void eph_recovery_device(struct eph_data *ephdata) msleep(20); // ic spec at least 10ms - gpio_set_value(ephdata->ephplatform->gpio_reset, GPIO_RESET_NO_HIGH); + gpiod_set_value(ephdata->ephplatform->gpio_reset, GPIO_RESET_NO_HIGH); // wait ic stable, ic spec should no comms action before ic has // first data ready @@ -436,10 +423,9 @@ void eph_recovery_device(struct eph_data *ephdata) void eph_reset_device(struct eph_data *ephdata) { - dev_dbg(&ephdata->commsdevice->dev, "%s gpio is %ld >\n", __func__, ephdata->ephplatform->gpio_reset); - gpio_set_value(ephdata->ephplatform->gpio_reset, GPIO_RESET_YES_LOW); + gpiod_set_value(ephdata->ephplatform->gpio_reset, GPIO_RESET_YES_LOW); msleep(1); - gpio_set_value(ephdata->ephplatform->gpio_reset, GPIO_RESET_NO_HIGH); + gpiod_set_value(ephdata->ephplatform->gpio_reset, GPIO_RESET_NO_HIGH); msleep(EPH_POWERON_DELAY); return; diff --git a/drivers/input/touchscreen/eswin_touch/eswin_eph861x_i2c.c b/drivers/input/touchscreen/eswin_touch/eswin_eph861x_i2c.c index 55b81c308737..be4b9231ea81 100644 --- a/drivers/input/touchscreen/eswin_touch/eswin_eph861x_i2c.c +++ b/drivers/input/touchscreen/eswin_touch/eswin_eph861x_i2c.c @@ -35,7 +35,6 @@ #include #include #include -#include #include #include #include diff --git a/drivers/input/touchscreen/eswin_touch/eswin_eph861x_types.h b/drivers/input/touchscreen/eswin_touch/eswin_eph861x_types.h index 930a67c2217c..f7409ac454d5 100644 --- a/drivers/input/touchscreen/eswin_touch/eswin_eph861x_types.h +++ b/drivers/input/touchscreen/eswin_touch/eswin_eph861x_types.h @@ -130,8 +130,8 @@ enum eph_suspend_mode struct eph_platform_data { enum eph_suspend_mode suspend_mode; - unsigned long gpio_reset; - unsigned long gpio_chg_irq; + struct gpio_desc *gpio_reset; + struct gpio_desc *gpio_chg_irq; const char *regulator_dvdd; const char *regulator_avdd; const char *device_settings_name;