917 lines
26 KiB
Diff
917 lines
26 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Geminux Contributors <dev@geminux.local>
|
|
Date: Sun, 22 Nov 2026 13:42:00 +0200
|
|
Subject: [PATCH] geminux: support Gemini PDA Solomon SSD2092 display and touch
|
|
|
|
Add Solomon Systech SSD2092 panel timings (SYNC_PULSE_VDO_MODE, 1004 Mbit/s,
|
|
no DCS BTA reads), snapshot loader DSI configuration when DSI_START is already
|
|
running, and support the Solomon SSD2092 I2C touchscreen controller at 0x53.
|
|
---
|
|
diff --git a/drivers/gpu/drm/panel/panel-novatek-nt36672e.c b/drivers/gpu/drm/panel/panel-novatek-nt36672e.c
|
|
--- a/drivers/gpu/drm/panel/panel-novatek-nt36672e.c
|
|
+++ b/drivers/gpu/drm/panel/panel-novatek-nt36672e.c
|
|
@@ -38,6 +38,7 @@
|
|
const char *panel_name;
|
|
void (*init_sequence)(struct mipi_dsi_multi_context *ctx);
|
|
bool can_adopt;
|
|
+ bool no_dcs_read;
|
|
unsigned int power_on_delay_ms;
|
|
unsigned int reset_high_delay_ms;
|
|
unsigned int reset_low_delay_ms;
|
|
@@ -56,6 +57,7 @@
|
|
const struct panel_desc *desc;
|
|
enum drm_panel_orientation orientation;
|
|
bool adopted;
|
|
+ bool awake;
|
|
};
|
|
|
|
/*
|
|
@@ -788,6 +790,45 @@
|
|
* survives this module: on the loader's first frame it is awake, and nothing is
|
|
* sent.
|
|
*/
|
|
+static bool gemini_prop_has_ssd2092(const void *prop, int len)
|
|
+{
|
|
+ int i;
|
|
+
|
|
+ if (!prop || len < 7)
|
|
+ return false;
|
|
+ for (i = 0; i <= len - 7; i++) {
|
|
+ if (memcmp((const u8 *)prop + i, "ssd2092", 7) == 0)
|
|
+ return true;
|
|
+ }
|
|
+ return false;
|
|
+}
|
|
+
|
|
+static bool gemini_panel_is_ssd2092(void)
|
|
+{
|
|
+ struct device_node *chosen;
|
|
+ const void *prop;
|
|
+ int len = 0;
|
|
+ bool found = false;
|
|
+
|
|
+ chosen = of_find_node_by_path("/chosen");
|
|
+ if (!chosen)
|
|
+ return false;
|
|
+
|
|
+ prop = of_get_property(chosen, "atag,videolfb-lcmname", &len);
|
|
+ if (gemini_prop_has_ssd2092(prop, len)) {
|
|
+ found = true;
|
|
+ goto out_put;
|
|
+ }
|
|
+
|
|
+ prop = of_get_property(chosen, "atag,videolfb", &len);
|
|
+ if (gemini_prop_has_ssd2092(prop, len))
|
|
+ found = true;
|
|
+
|
|
+out_put:
|
|
+ of_node_put(chosen);
|
|
+ return found;
|
|
+}
|
|
+
|
|
static int nt36672e_adopted_wake(struct nt36672e_panel *ctx)
|
|
{
|
|
struct mipi_dsi_device *dsi = ctx->dsi;
|
|
@@ -795,6 +836,19 @@
|
|
u8 mode = 0;
|
|
int ret;
|
|
|
|
+ if (ctx->desc->no_dcs_read) {
|
|
+ if (ctx->awake)
|
|
+ return 0;
|
|
+ dsi->mode_flags |= MIPI_DSI_MODE_LPM;
|
|
+ mipi_dsi_dcs_exit_sleep_mode_multi(&mctx);
|
|
+ mipi_dsi_msleep(&mctx, ctx->desc->exit_sleep_delay_ms);
|
|
+ mipi_dsi_dcs_set_display_on_multi(&mctx);
|
|
+ mipi_dsi_msleep(&mctx, ctx->desc->display_on_delay_ms);
|
|
+ if (!mctx.accum_err)
|
|
+ ctx->awake = true;
|
|
+ return mctx.accum_err;
|
|
+ }
|
|
+
|
|
ret = mipi_dsi_dcs_get_power_mode(dsi, &mode);
|
|
dev_dbg(&dsi->dev, "power mode read %d: 0x%02x\n", ret, mode);
|
|
/* Sleep out and display on; the running panel reads 0x9c. */
|
|
@@ -812,10 +866,12 @@
|
|
{
|
|
struct mipi_dsi_multi_context mctx = { .dsi = ctx->dsi };
|
|
|
|
+ ctx->dsi->mode_flags |= MIPI_DSI_MODE_LPM;
|
|
mipi_dsi_dcs_set_display_off_multi(&mctx);
|
|
mipi_dsi_msleep(&mctx, ctx->desc->display_off_delay_ms);
|
|
mipi_dsi_dcs_enter_sleep_mode_multi(&mctx);
|
|
mipi_dsi_msleep(&mctx, ctx->desc->sleep_in_delay_ms);
|
|
+ ctx->awake = false;
|
|
return mctx.accum_err;
|
|
}
|
|
|
|
@@ -946,6 +1002,44 @@
|
|
.display_on_delay_ms = 10,
|
|
};
|
|
|
|
+static const struct drm_display_mode gemini_ssd2092_1080x2160_60hz = {
|
|
+ .name = "1080x2160",
|
|
+ /* 1004 Mbit/s (502 MHz PLL) on four lanes at 24 bpp. */
|
|
+ .clock = 167334,
|
|
+ .hdisplay = 1080,
|
|
+ .hsync_start = 1080 + 26,
|
|
+ .hsync_end = 1080 + 26 + 4,
|
|
+ .htotal = 1080 + 26 + 4 + 20,
|
|
+ .vdisplay = 2160,
|
|
+ .vsync_start = 2160 + 76,
|
|
+ .vsync_end = 2160 + 76 + 1,
|
|
+ .vtotal = 2160 + 76 + 1 + 43,
|
|
+ .flags = 0,
|
|
+};
|
|
+
|
|
+static const struct panel_desc gemini_ssd2092_panel_desc = {
|
|
+ .supply_names = gemini_regulator_names,
|
|
+ .num_supplies = ARRAY_SIZE(gemini_regulator_names),
|
|
+ .display_mode = &gemini_ssd2092_1080x2160_60hz,
|
|
+ .width_mm = 68,
|
|
+ .height_mm = 136,
|
|
+ .mode_flags = MIPI_DSI_MODE_VIDEO | MIPI_DSI_MODE_VIDEO_SYNC_PULSE |
|
|
+ MIPI_DSI_MODE_LPM,
|
|
+ .format = MIPI_DSI_FMT_RGB888,
|
|
+ .lanes = 4,
|
|
+ .panel_name = "Gemini SSD2092 1080x2160 panel",
|
|
+ .can_adopt = true,
|
|
+ .no_dcs_read = true,
|
|
+ .power_on_delay_ms = 20,
|
|
+ .reset_high_delay_ms = 10,
|
|
+ .reset_low_delay_ms = 10,
|
|
+ .reset_final_high_delay_ms = 20,
|
|
+ .display_off_delay_ms = 50,
|
|
+ .sleep_in_delay_ms = 120,
|
|
+ .exit_sleep_delay_ms = 120,
|
|
+ .display_on_delay_ms = 20,
|
|
+};
|
|
+
|
|
static int nt36672e_panel_get_modes(struct drm_panel *panel, struct drm_connector *connector)
|
|
{
|
|
struct nt36672e_panel *ctx = to_nt36672e_panel(panel);
|
|
@@ -1005,11 +1099,17 @@
|
|
return -ENODEV;
|
|
}
|
|
|
|
+ if (ctx->desc == &gemini_panel_desc && gemini_panel_is_ssd2092()) {
|
|
+ ctx->desc = &gemini_ssd2092_panel_desc;
|
|
+ dev_info(dev, "detected Solomon SSD2092 panel from /chosen/atag,videolfb\n");
|
|
+ }
|
|
+
|
|
if (!ctx->desc->supply_names ||
|
|
ctx->desc->num_supplies > ARRAY_SIZE(ctx->supplies))
|
|
return -EINVAL;
|
|
|
|
ctx->adopted = adopt && ctx->desc->can_adopt;
|
|
+ ctx->awake = ctx->adopted;
|
|
if (!ctx->adopted) {
|
|
for (i = 0; i < ctx->desc->num_supplies; i++) {
|
|
ctx->supplies[i].supply = ctx->desc->supply_names[i];
|
|
|
|
diff --git a/drivers/gpu/drm/mediatek/mtk_dsi.c b/drivers/gpu/drm/mediatek/mtk_dsi.c
|
|
--- a/drivers/gpu/drm/mediatek/mtk_dsi.c
|
|
+++ b/drivers/gpu/drm/mediatek/mtk_dsi.c
|
|
@@ -228,6 +228,14 @@
|
|
u32 irq_data;
|
|
wait_queue_head_t irq_wait_queue;
|
|
const struct mtk_dsi_driver_data *driver_data;
|
|
+ bool loader_saved;
|
|
+ u32 loader_vact;
|
|
+ u32 loader_txrx;
|
|
+ u32 loader_hsa_wc;
|
|
+ u32 loader_hbp_wc;
|
|
+ u32 loader_hfp_wc;
|
|
+ u32 loader_hstx_ckl_wc;
|
|
+ u32 loader_timcon[4];
|
|
};
|
|
|
|
static inline struct mtk_dsi *bridge_to_dsi(struct drm_bridge *b)
|
|
@@ -288,8 +296,13 @@
|
|
FIELD_PREP(CLK_HS_POST, timing->clk_hs_post) |
|
|
FIELD_PREP(CLK_HS_EXIT, timing->clk_hs_exit);
|
|
|
|
- if (dsi->driver_data->fixed_timcon &&
|
|
- abs((s64)dsi->data_rate - dsi->driver_data->fixed_timcon_rate) < HZ_PER_MHZ) {
|
|
+ if (dsi->loader_saved && dsi->vm.vactive == dsi->loader_vact) {
|
|
+ timcon0 = dsi->loader_timcon[0];
|
|
+ timcon1 = dsi->loader_timcon[1];
|
|
+ timcon2 = dsi->loader_timcon[2];
|
|
+ timcon3 = dsi->loader_timcon[3];
|
|
+ } else if (dsi->driver_data->fixed_timcon &&
|
|
+ abs((s64)dsi->data_rate - dsi->driver_data->fixed_timcon_rate) < HZ_PER_MHZ) {
|
|
timcon0 = dsi->driver_data->fixed_timcon[0];
|
|
timcon1 = dsi->driver_data->fixed_timcon[1];
|
|
timcon2 = dsi->driver_data->fixed_timcon[2];
|
|
@@ -402,6 +415,10 @@
|
|
if (dsi->mode_flags & MIPI_DSI_MODE_NO_EOT_PACKET)
|
|
regval |= DIS_EOT;
|
|
|
|
+ if (dsi->loader_saved && dsi->vm.vactive == dsi->loader_vact)
|
|
+ regval = (regval & ~(DIS_EOT | HSTX_CKLP_EN | MAX_RTN_SIZE)) |
|
|
+ (dsi->loader_txrx & (DIS_EOT | HSTX_CKLP_EN | MAX_RTN_SIZE));
|
|
+
|
|
writel(regval, dsi->regs + DSI_TXRX_CTRL);
|
|
}
|
|
|
|
@@ -441,6 +458,8 @@
|
|
writel(vact_nl, dsi->regs + DSI_VACT_NL);
|
|
if (!dsi->driver_data->loader_porch_wc)
|
|
writel(ps_wc, dsi->regs + DSI_HSTX_CKL_WC);
|
|
+ else if (dsi->loader_saved && dsi->vm.vactive == dsi->loader_vact)
|
|
+ writel(dsi->loader_hstx_ckl_wc, dsi->regs + DSI_HSTX_CKL_WC);
|
|
}
|
|
writel(ps_val, dsi->regs + DSI_PSCTRL);
|
|
}
|
|
@@ -587,6 +606,23 @@
|
|
{
|
|
struct videomode *vm = &dsi->vm;
|
|
|
|
+ if (dsi->loader_saved && vm->vactive == dsi->loader_vact) {
|
|
+ writel(dsi->loader_hsa_wc, dsi->regs + DSI_HSA_WC);
|
|
+ writel(dsi->loader_hbp_wc, dsi->regs + DSI_HBP_WC);
|
|
+ writel(dsi->loader_hfp_wc, dsi->regs + DSI_HFP_WC);
|
|
+ return;
|
|
+ }
|
|
+
|
|
+ if (dsi->mode_flags & MIPI_DSI_MODE_VIDEO_SYNC_PULSE) {
|
|
+ writel(ALIGN(max_t(int, vm->hsync_len * 3 - 10, 4), 4),
|
|
+ dsi->regs + DSI_HSA_WC);
|
|
+ writel(ALIGN(max_t(int, vm->hback_porch * 3 - 10, 4), 4),
|
|
+ dsi->regs + DSI_HBP_WC);
|
|
+ writel(ALIGN(max_t(int, vm->hfront_porch * 3 - 12, 4), 4),
|
|
+ dsi->regs + DSI_HFP_WC);
|
|
+ return;
|
|
+ }
|
|
+
|
|
writel(ALIGN(vm->hsync_len * 3 - 4, 4), dsi->regs + DSI_HSA_WC);
|
|
writel(ALIGN((vm->hback_porch + vm->hsync_len) * 3 - 10, 4),
|
|
dsi->regs + DSI_HBP_WC);
|
|
@@ -760,6 +796,28 @@
|
|
goto err_disable_engine_clk;
|
|
}
|
|
|
|
+ if (!dsi->loader_saved && (readl(dsi->regs + DSI_START) & 1)) {
|
|
+ dsi->loader_vact = readl(dsi->regs + DSI_VACT_NL) & VACT_NL;
|
|
+ dsi->loader_txrx = readl(dsi->regs + DSI_TXRX_CTRL);
|
|
+ dsi->loader_hsa_wc = readl(dsi->regs + DSI_HSA_WC);
|
|
+ dsi->loader_hbp_wc = readl(dsi->regs + DSI_HBP_WC);
|
|
+ dsi->loader_hfp_wc = readl(dsi->regs + DSI_HFP_WC);
|
|
+ dsi->loader_hstx_ckl_wc = readl(dsi->regs + DSI_HSTX_CKL_WC);
|
|
+ dsi->loader_timcon[0] = readl(dsi->regs + DSI_PHY_TIMECON0);
|
|
+ dsi->loader_timcon[1] = readl(dsi->regs + DSI_PHY_TIMECON1);
|
|
+ dsi->loader_timcon[2] = readl(dsi->regs + DSI_PHY_TIMECON2);
|
|
+ dsi->loader_timcon[3] = readl(dsi->regs + DSI_PHY_TIMECON3);
|
|
+ dsi->loader_saved = true;
|
|
+ dev_info(dev,
|
|
+ "captured loader DSI state mode=%#x txrx=%#x vact=%u wc=%u/%u/%u ckl=%#x timcon=%#x/%#x/%#x/%#x\n",
|
|
+ readl(dsi->regs + DSI_MODE_CTRL), dsi->loader_txrx,
|
|
+ dsi->loader_vact, dsi->loader_hsa_wc,
|
|
+ dsi->loader_hbp_wc, dsi->loader_hfp_wc,
|
|
+ dsi->loader_hstx_ckl_wc, dsi->loader_timcon[0],
|
|
+ dsi->loader_timcon[1], dsi->loader_timcon[2],
|
|
+ dsi->loader_timcon[3]);
|
|
+ }
|
|
+
|
|
mtk_dsi_enable(dsi);
|
|
|
|
if (dsi->driver_data->has_shadow_ctl)
|
|
|
|
diff --git a/drivers/input/touchscreen/novatek-nt36xxx.c b/drivers/input/touchscreen/novatek-nt36xxx.c
|
|
--- a/drivers/input/touchscreen/novatek-nt36xxx.c
|
|
+++ b/drivers/input/touchscreen/novatek-nt36xxx.c
|
|
@@ -10,17 +10,31 @@
|
|
|
|
#include <linux/delay.h>
|
|
#include <linux/gpio/consumer.h>
|
|
+#include <linux/gpio/driver.h>
|
|
+#include <linux/gpio/machine.h>
|
|
#include <linux/i2c.h>
|
|
#include <linux/input.h>
|
|
#include <linux/input/mt.h>
|
|
#include <linux/input/touchscreen.h>
|
|
#include <linux/interrupt.h>
|
|
+#include <linux/irq.h>
|
|
+#include <linux/irqdomain.h>
|
|
+#include <linux/mfd/mt6351/registers.h>
|
|
+#include <linux/mfd/mt6397/core.h>
|
|
#include <linux/module.h>
|
|
+#include <linux/of.h>
|
|
+#include <linux/of_irq.h>
|
|
+#include <linux/of_platform.h>
|
|
+#include <linux/platform_device.h>
|
|
+#include <linux/regmap.h>
|
|
#include <linux/regulator/consumer.h>
|
|
|
|
#include <linux/unaligned.h>
|
|
|
|
#define NVT36XXX_HW_ADDR 0x62
|
|
+#define SSD2092_I2C_ADDR 0x53
|
|
+#define SSD2092_X_MAX 1080
|
|
+#define SSD2092_Y_MAX 2160
|
|
#define NVT36XXX_FW_ADDR 0x01
|
|
#define NVT36XXX_XDATA_CMD 0xff
|
|
#define NVT36XXX_TRIM_CMD 0x4e
|
|
@@ -39,17 +53,29 @@
|
|
#define NVT36XXX_RESET_RETRIES 5
|
|
#define NVT36XXX_RESET_STATE_INIT 0xa0
|
|
|
|
+struct ssd2092_slot {
|
|
+ bool down;
|
|
+ u16 x;
|
|
+ u16 y;
|
|
+ u8 w;
|
|
+};
|
|
+
|
|
struct nvt36xxx_data {
|
|
struct i2c_client *client;
|
|
+ struct i2c_client *ssl;
|
|
struct input_dev *input;
|
|
struct touchscreen_properties prop;
|
|
struct gpio_desc *reset_gpio;
|
|
+ struct regulator *vcc_reg;
|
|
struct regulator_bulk_data supplies[2];
|
|
u8 event[NVT36XXX_EVENT_DATA_LEN];
|
|
+ struct ssd2092_slot slots[NVT36XXX_MAX_TOUCHES];
|
|
u32 raw_x_max;
|
|
u32 raw_y_max;
|
|
+ u32 orig_irq_type;
|
|
u8 fw_version;
|
|
u16 pid;
|
|
+ bool is_ssd2092;
|
|
};
|
|
|
|
static int nvt36xxx_write(struct nvt36xxx_data *data, u16 target,
|
|
@@ -297,6 +323,496 @@ static void nvt36xxx_disable_regulators(
|
|
regulator_bulk_disable(ARRAY_SIZE(data->supplies), data->supplies);
|
|
}
|
|
|
|
+static bool gemini_touch_prop_has_ssd2092(const void *prop, int len)
|
|
+{
|
|
+ int i;
|
|
+
|
|
+ if (!prop || len < 7)
|
|
+ return false;
|
|
+ for (i = 0; i <= len - 7; i++) {
|
|
+ if (memcmp((const u8 *)prop + i, "ssd2092", 7) == 0)
|
|
+ return true;
|
|
+ }
|
|
+ return false;
|
|
+}
|
|
+
|
|
+static bool gemini_touch_is_ssd2092(void)
|
|
+{
|
|
+ struct device_node *chosen;
|
|
+ const void *prop;
|
|
+ int len = 0;
|
|
+ bool found = false;
|
|
+
|
|
+ chosen = of_find_node_by_path("/chosen");
|
|
+ if (!chosen)
|
|
+ return false;
|
|
+
|
|
+ prop = of_get_property(chosen, "atag,videolfb-lcmname", &len);
|
|
+ if (gemini_touch_prop_has_ssd2092(prop, len)) {
|
|
+ found = true;
|
|
+ goto out_put;
|
|
+ }
|
|
+
|
|
+ prop = of_get_property(chosen, "atag,videolfb", &len);
|
|
+ if (gemini_touch_prop_has_ssd2092(prop, len))
|
|
+ found = true;
|
|
+
|
|
+out_put:
|
|
+ of_node_put(chosen);
|
|
+ return found;
|
|
+}
|
|
+
|
|
+static void ssd2092_disable_vcc(void *arg)
|
|
+{
|
|
+ regulator_disable(arg);
|
|
+}
|
|
+
|
|
+static void ssd2092_free_own_gpio(void *arg)
|
|
+{
|
|
+ gpiochip_free_own_desc(arg);
|
|
+}
|
|
+
|
|
+static int ssd2092_enable_pmic_vldo28(void)
|
|
+{
|
|
+ struct device_node *np;
|
|
+ struct platform_device *pdev;
|
|
+ struct mt6397_chip *mt6351;
|
|
+ int ret = -ENODEV;
|
|
+
|
|
+ np = of_find_node_by_path("/pwrap@1000d000/pmic");
|
|
+ if (!np)
|
|
+ return -ENODEV;
|
|
+ pdev = of_find_device_by_node(np);
|
|
+ of_node_put(np);
|
|
+ if (!pdev)
|
|
+ return -EPROBE_DEFER;
|
|
+ mt6351 = platform_get_drvdata(pdev);
|
|
+ if (mt6351 && mt6351->regmap)
|
|
+ ret = regmap_update_bits(mt6351->regmap,
|
|
+ MT6351_LDO_VLDO28_CON0,
|
|
+ BIT(1), BIT(1));
|
|
+ put_device(&pdev->dev);
|
|
+ return ret;
|
|
+}
|
|
+
|
|
+static int ssd2092_setup_power_and_reset(struct nvt36xxx_data *data)
|
|
+{
|
|
+ struct device *dev = &data->client->dev;
|
|
+ struct regulator *vcc;
|
|
+ int ret;
|
|
+
|
|
+ vcc = devm_regulator_get_optional(dev, "vcc");
|
|
+ if (IS_ERR(vcc)) {
|
|
+ if (PTR_ERR(vcc) == -EPROBE_DEFER)
|
|
+ return -EPROBE_DEFER;
|
|
+ if (PTR_ERR(vcc) != -ENODEV)
|
|
+ return PTR_ERR(vcc);
|
|
+ } else if (vcc) {
|
|
+ ret = regulator_enable(vcc);
|
|
+ if (ret)
|
|
+ return ret;
|
|
+ data->vcc_reg = vcc;
|
|
+ ret = devm_add_action_or_reset(dev, ssd2092_disable_vcc, vcc);
|
|
+ if (ret)
|
|
+ return ret;
|
|
+ }
|
|
+
|
|
+ if (!data->vcc_reg) {
|
|
+ ret = ssd2092_enable_pmic_vldo28();
|
|
+ if (ret == -EPROBE_DEFER)
|
|
+ return ret;
|
|
+ if (ret)
|
|
+ dev_warn(dev, "failed to enable VLDO28 fallback: %d\n", ret);
|
|
+ }
|
|
+ msleep(10);
|
|
+
|
|
+ data->reset_gpio = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_LOW);
|
|
+ if (IS_ERR(data->reset_gpio))
|
|
+ return PTR_ERR(data->reset_gpio);
|
|
+
|
|
+ if (!data->reset_gpio) {
|
|
+ struct gpio_device *gdev = NULL;
|
|
+ struct device_node *pio_np;
|
|
+
|
|
+ pio_np = of_find_node_by_path("/pinctrl@10005000");
|
|
+ if (!pio_np)
|
|
+ pio_np = of_find_compatible_node(NULL, NULL,
|
|
+ "mediatek,mt6797-pinctrl");
|
|
+ if (pio_np) {
|
|
+ gdev = gpio_device_find_by_fwnode(of_fwnode_handle(pio_np));
|
|
+ of_node_put(pio_np);
|
|
+ }
|
|
+ if (!gdev)
|
|
+ gdev = gpio_device_find_by_label("10005000.pinctrl");
|
|
+ if (!gdev) {
|
|
+ dev_warn(dev, "no pinctrl gpio_device found for GPIO68 fallback\n");
|
|
+ } else {
|
|
+ struct gpio_chip *gc = gpio_device_get_chip(gdev);
|
|
+ struct gpio_desc *desc;
|
|
+
|
|
+ desc = gpiochip_request_own_desc(gc, 68, "ssd2092-rst",
|
|
+ GPIO_ACTIVE_LOW,
|
|
+ GPIOD_OUT_LOW);
|
|
+ gpio_device_put(gdev);
|
|
+ if (IS_ERR(desc)) {
|
|
+ dev_warn(dev, "failed to claim GPIO68 fallback: %ld\n",
|
|
+ PTR_ERR(desc));
|
|
+ } else {
|
|
+ data->reset_gpio = desc;
|
|
+ dev_info(dev, "claimed GPIO68 reset fallback for SSD2092\n");
|
|
+ ret = devm_add_action_or_reset(dev,
|
|
+ ssd2092_free_own_gpio,
|
|
+ desc);
|
|
+ if (ret)
|
|
+ return ret;
|
|
+ }
|
|
+ }
|
|
+ }
|
|
+
|
|
+ return 0;
|
|
+}
|
|
+
|
|
+static void ssd2092_reset_pulse(struct nvt36xxx_data *data)
|
|
+{
|
|
+ if (!data->reset_gpio)
|
|
+ return;
|
|
+ /* Logical 0 = physical HIGH, logical 1 = physical LOW (GPIO_ACTIVE_LOW). */
|
|
+ msleep(10);
|
|
+ gpiod_set_value_cansleep(data->reset_gpio, 0);
|
|
+ msleep(10);
|
|
+ gpiod_set_value_cansleep(data->reset_gpio, 1);
|
|
+ msleep(20);
|
|
+ gpiod_set_value_cansleep(data->reset_gpio, 0);
|
|
+ msleep(150);
|
|
+}
|
|
+
|
|
+static int ssd2092_read(struct i2c_client *ssl, u16 reg, void *buf, u16 len)
|
|
+{
|
|
+ u8 cmd[2] = { reg & 0xff, reg >> 8 };
|
|
+ int ret;
|
|
+
|
|
+ ret = i2c_master_send(ssl, cmd, sizeof(cmd));
|
|
+ if (ret != sizeof(cmd))
|
|
+ return ret < 0 ? ret : -EIO;
|
|
+ usleep_range(200, 300);
|
|
+
|
|
+ ret = i2c_master_recv(ssl, buf, len);
|
|
+ if (ret != len)
|
|
+ return ret < 0 ? ret : -EIO;
|
|
+ usleep_range(50, 100);
|
|
+ return 0;
|
|
+}
|
|
+
|
|
+static int ssd2092_write_u16(struct i2c_client *ssl, u16 reg, u16 val)
|
|
+{
|
|
+ u8 pkt[4] = { reg & 0xff, reg >> 8, val & 0xff, val >> 8 };
|
|
+ int ret;
|
|
+
|
|
+ ret = i2c_master_send(ssl, pkt, sizeof(pkt));
|
|
+ if (ret != sizeof(pkt))
|
|
+ return ret < 0 ? ret : -EIO;
|
|
+ usleep_range(200, 300);
|
|
+ return 0;
|
|
+}
|
|
+
|
|
+static int ssd2092_boot_seeprom(struct nvt36xxx_data *data)
|
|
+{
|
|
+ static const u8 status_cmd[4] = { 0x00, 0x00, 0x00, 0x00 };
|
|
+ static const u8 trim_e003[6] = { 0x04, 0x00, 0x03, 0xe0, 0x07, 0x00 };
|
|
+ static const u8 trim_e000[6] = { 0x04, 0x00, 0x00, 0xe0, 0x48, 0x00 };
|
|
+ struct device *dev = &data->client->dev;
|
|
+ u8 status[2] = { 0 };
|
|
+ int ret;
|
|
+
|
|
+ if (i2c_master_send(data->ssl, status_cmd, sizeof(status_cmd)) == sizeof(status_cmd)) {
|
|
+ usleep_range(200, 300);
|
|
+ i2c_master_recv(data->ssl, status, sizeof(status));
|
|
+ usleep_range(200, 300);
|
|
+ }
|
|
+
|
|
+ ret = i2c_master_send(data->ssl, trim_e003, sizeof(trim_e003));
|
|
+ if (ret != sizeof(trim_e003))
|
|
+ return ret < 0 ? ret : -EIO;
|
|
+ usleep_range(200, 300);
|
|
+
|
|
+ ret = i2c_master_send(data->ssl, trim_e000, sizeof(trim_e000));
|
|
+ if (ret != sizeof(trim_e000))
|
|
+ return ret < 0 ? ret : -EIO;
|
|
+ usleep_range(200, 300);
|
|
+
|
|
+ ret = ssd2092_write_u16(data->ssl, 0x0001, 0x0000);
|
|
+ if (ret)
|
|
+ return ret;
|
|
+ ret = ssd2092_write_u16(data->ssl, 0x0002, 0x0000);
|
|
+ if (ret)
|
|
+ return ret;
|
|
+
|
|
+ msleep(150);
|
|
+ dev_dbg(dev, "SSD2092 SEEPROM boot sequence sent (rom_status=%#06x)\n",
|
|
+ get_unaligned_le16(status));
|
|
+ return 0;
|
|
+}
|
|
+
|
|
+static int ssd2092_hw_init(struct nvt36xxx_data *data)
|
|
+{
|
|
+ struct device *dev = &data->client->dev;
|
|
+ u8 buf[2];
|
|
+ u8 hdr[4];
|
|
+ u16 fw_disp = 0, fw_touch = 0, x_nodes = 0, y_nodes = 0;
|
|
+ int ret = -EIO;
|
|
+ int i;
|
|
+
|
|
+ for (i = 0; i < 6; i++) {
|
|
+ ret = ssd2092_write_u16(data->ssl, 0x0050, 0x0000);
|
|
+ if (!ret)
|
|
+ break;
|
|
+ msleep(25);
|
|
+ }
|
|
+ if (ret)
|
|
+ return ret;
|
|
+
|
|
+ if (!ssd2092_read(data->ssl, 0x0055, buf, sizeof(buf)))
|
|
+ fw_disp = get_unaligned_le16(buf);
|
|
+ if (!ssd2092_read(data->ssl, 0x0054, buf, sizeof(buf)))
|
|
+ fw_touch = get_unaligned_le16(buf);
|
|
+ if (!ssd2092_read(data->ssl, 0x0056, buf, sizeof(buf)))
|
|
+ x_nodes = get_unaligned_le16(buf);
|
|
+ if (!ssd2092_read(data->ssl, 0x0057, buf, sizeof(buf)))
|
|
+ y_nodes = get_unaligned_le16(buf);
|
|
+
|
|
+ data->raw_x_max = SSD2092_X_MAX;
|
|
+ data->raw_y_max = SSD2092_Y_MAX;
|
|
+ dev_info(dev, "SSD2092 FW touch=%#06x disp=%#06x nodes=%ux%u\n",
|
|
+ fw_touch, fw_disp, x_nodes, y_nodes);
|
|
+
|
|
+ ret = ssd2092_write_u16(data->ssl, 0x016e, 0x0078);
|
|
+ if (ret)
|
|
+ dev_warn(dev, "SSD2092 reg 0x016e write failed: %d\n", ret);
|
|
+ ret = ssd2092_write_u16(data->ssl, 0x0102, 0x0a8c);
|
|
+ if (ret)
|
|
+ dev_warn(dev, "SSD2092 reg 0x0102 write failed: %d\n", ret);
|
|
+ ret = ssd2092_write_u16(data->ssl, 0x0103, 0x0032);
|
|
+ if (ret)
|
|
+ dev_warn(dev, "SSD2092 reg 0x0103 write failed: %d\n", ret);
|
|
+
|
|
+ for (i = 0; i < 6; i++) {
|
|
+ memset(hdr, 0, sizeof(hdr));
|
|
+ if (!ssd2092_read(data->ssl, 0x0af0, hdr, sizeof(hdr))) {
|
|
+ if (hdr[1] & 0x40)
|
|
+ ssd2092_read(data->ssl, 0x0af8, buf, sizeof(buf));
|
|
+ }
|
|
+ ret = ssd2092_write_u16(data->ssl, 0x0043, 0x0001);
|
|
+ if (hdr[0] == 0 && hdr[1] == 0)
|
|
+ break;
|
|
+ msleep(5);
|
|
+ }
|
|
+
|
|
+ return ret;
|
|
+}
|
|
+
|
|
+static void ssd2092_report_slots(struct nvt36xxx_data *data)
|
|
+{
|
|
+ unsigned int s, active = 0;
|
|
+
|
|
+ for (s = 0; s < NVT36XXX_MAX_TOUCHES; s++) {
|
|
+ struct ssd2092_slot *slot = &data->slots[s];
|
|
+
|
|
+ input_mt_slot(data->input, s);
|
|
+ input_mt_report_slot_state(data->input, MT_TOOL_FINGER,
|
|
+ slot->down);
|
|
+ if (slot->down) {
|
|
+ touchscreen_report_pos(data->input, &data->prop,
|
|
+ slot->x, slot->y, true);
|
|
+ input_report_abs(data->input, ABS_MT_TOUCH_MAJOR,
|
|
+ slot->w);
|
|
+ input_report_abs(data->input, ABS_MT_PRESSURE,
|
|
+ slot->w);
|
|
+ active++;
|
|
+ }
|
|
+ }
|
|
+ input_mt_sync_frame(data->input);
|
|
+ input_report_key(data->input, BTN_TOUCH, active != 0);
|
|
+ input_sync(data->input);
|
|
+}
|
|
+
|
|
+static irqreturn_t ssd2092_irq(int irq, void *arg)
|
|
+{
|
|
+ struct nvt36xxx_data *data = arg;
|
|
+ struct device *dev = &data->client->dev;
|
|
+ u8 hdr[4] = { 0 };
|
|
+ u8 pkt[64];
|
|
+ unsigned int len, i;
|
|
+ int ret;
|
|
+
|
|
+ ret = ssd2092_read(data->ssl, 0x0af0, hdr, sizeof(hdr));
|
|
+ if (!ret && get_unaligned_le16(hdr) == 0x0af0)
|
|
+ ret = ssd2092_read(data->ssl, 0x00f0, hdr, sizeof(hdr));
|
|
+ if (ret) {
|
|
+ dev_err_ratelimited(dev, "SSD2092 header read failed: %d\n", ret);
|
|
+ ssd2092_write_u16(data->ssl, 0x0043, 0x0001);
|
|
+ msleep(10);
|
|
+ return IRQ_HANDLED;
|
|
+ }
|
|
+
|
|
+ if (hdr[1] & 0x40) {
|
|
+ u8 aux[2] = { 0 };
|
|
+ u16 aux_val;
|
|
+
|
|
+ ssd2092_read(data->ssl, 0x0af8, aux, sizeof(aux));
|
|
+ aux_val = get_unaligned_le16(aux);
|
|
+ memset(data->slots, 0, sizeof(data->slots));
|
|
+ ssd2092_report_slots(data);
|
|
+ if (aux_val == 0x0001 || (aux_val & 0x0fff) == 0x0af8 ||
|
|
+ (aux_val & 0x00f0) == 0x00f0)
|
|
+ ssd2092_boot_seeprom(data);
|
|
+ ssd2092_hw_init(data);
|
|
+ return IRQ_HANDLED;
|
|
+ }
|
|
+
|
|
+ if (hdr[1] & 0x80) {
|
|
+ memset(data->slots, 0, sizeof(data->slots));
|
|
+ ssd2092_report_slots(data);
|
|
+ ssd2092_hw_init(data);
|
|
+ return IRQ_HANDLED;
|
|
+ }
|
|
+
|
|
+ len = min_t(unsigned int, hdr[0], 60);
|
|
+ if (len >= 6 && (hdr[1] & 0x3f)) {
|
|
+ ret = ssd2092_read(data->ssl, 0x0af1, pkt, len + 2);
|
|
+ if (ret) {
|
|
+ dev_err_ratelimited(dev, "SSD2092 packet read failed: %d\n", ret);
|
|
+ goto out_ack;
|
|
+ }
|
|
+ for (i = 0; i < len / 6; i++) {
|
|
+ const u8 *p = &pkt[i * 6];
|
|
+ unsigned int slot = p[0];
|
|
+ unsigned int x_raw = p[1] | ((p[3] & 0xf0) << 4);
|
|
+ unsigned int y_raw = p[2] | ((p[3] & 0x0f) << 8);
|
|
+ u8 w = p[4];
|
|
+
|
|
+ if (slot == 0xf6) {
|
|
+ if (get_unaligned_le16(&p[1]) & BIT(9))
|
|
+ memset(data->slots, 0, sizeof(data->slots));
|
|
+ continue;
|
|
+ }
|
|
+ if (slot >= NVT36XXX_MAX_TOUCHES)
|
|
+ continue;
|
|
+ if (w == 0) {
|
|
+ data->slots[slot].down = false;
|
|
+ } else if (x_raw <= SSD2092_X_MAX && y_raw <= SSD2092_Y_MAX) {
|
|
+ data->slots[slot].down = true;
|
|
+ data->slots[slot].x = min_t(unsigned int, x_raw,
|
|
+ SSD2092_X_MAX - 1);
|
|
+ data->slots[slot].y = min_t(unsigned int, y_raw,
|
|
+ SSD2092_Y_MAX - 1);
|
|
+ data->slots[slot].w = w;
|
|
+ }
|
|
+ }
|
|
+ ssd2092_report_slots(data);
|
|
+ }
|
|
+
|
|
+out_ack:
|
|
+ ssd2092_write_u16(data->ssl, 0x0043, 0x0001);
|
|
+ return IRQ_HANDLED;
|
|
+}
|
|
+
|
|
+static void ssd2092_restore_irq_type(void *arg)
|
|
+{
|
|
+ struct nvt36xxx_data *data = arg;
|
|
+
|
|
+ if (data->client->irq > 0 && data->orig_irq_type)
|
|
+ irq_set_irq_type(data->client->irq, data->orig_irq_type);
|
|
+}
|
|
+
|
|
+static int ssd2092_probe(struct i2c_client *client, struct nvt36xxx_data *data)
|
|
+{
|
|
+ struct device *dev = &client->dev;
|
|
+ struct input_dev *input;
|
|
+ u32 dt_trig = IRQ_TYPE_EDGE_RISING;
|
|
+ int ret;
|
|
+
|
|
+ of_property_read_u32_index(dev->of_node, "interrupts", 1, &dt_trig);
|
|
+ if (client->irq <= 0) {
|
|
+ struct device_node *parent = of_irq_find_parent(dev->of_node);
|
|
+ struct irq_domain *dom = parent ? irq_find_host(parent) : NULL;
|
|
+ u32 hwirq = 8;
|
|
+
|
|
+ of_property_read_u32_index(dev->of_node, "interrupts", 0, &hwirq);
|
|
+ if (dom)
|
|
+ client->irq = irq_find_mapping(dom, hwirq);
|
|
+ of_node_put(parent);
|
|
+ }
|
|
+ if (client->irq <= 0)
|
|
+ return -EINVAL;
|
|
+ data->orig_irq_type = dt_trig;
|
|
+
|
|
+ data->is_ssd2092 = true;
|
|
+ ret = ssd2092_setup_power_and_reset(data);
|
|
+ if (ret)
|
|
+ return ret;
|
|
+
|
|
+ data->ssl = devm_i2c_new_dummy_device(dev, client->adapter,
|
|
+ SSD2092_I2C_ADDR);
|
|
+ if (IS_ERR(data->ssl))
|
|
+ return dev_err_probe(dev, PTR_ERR(data->ssl),
|
|
+ "failed to register SSD2092 client\n");
|
|
+
|
|
+ ssd2092_reset_pulse(data);
|
|
+
|
|
+ ret = ssd2092_boot_seeprom(data);
|
|
+ if (ret)
|
|
+ return dev_err_probe(dev, ret,
|
|
+ "Solomon SSD2092 SEEPROM boot at %#02x failed\n",
|
|
+ SSD2092_I2C_ADDR);
|
|
+
|
|
+ ret = ssd2092_hw_init(data);
|
|
+ if (ret)
|
|
+ return dev_err_probe(dev, ret,
|
|
+ "Solomon SSD2092 init at %#02x failed\n",
|
|
+ SSD2092_I2C_ADDR);
|
|
+
|
|
+ dev_info(dev, "Solomon SSD2092 touchscreen at %#02x, %ux%u\n",
|
|
+ SSD2092_I2C_ADDR, data->raw_x_max, data->raw_y_max);
|
|
+
|
|
+ input = devm_input_allocate_device(dev);
|
|
+ if (!input)
|
|
+ return -ENOMEM;
|
|
+
|
|
+ input->name = "Solomon SSD2092 touchscreen";
|
|
+ input->id.bustype = BUS_I2C;
|
|
+ input_set_abs_params(input, ABS_MT_POSITION_X, 0,
|
|
+ data->raw_x_max - 1, 0, 0);
|
|
+ input_set_abs_params(input, ABS_MT_POSITION_Y, 0,
|
|
+ data->raw_y_max - 1, 0, 0);
|
|
+ input_set_abs_params(input, ABS_MT_TOUCH_MAJOR, 0,
|
|
+ NVT36XXX_MAX_WIDTH, 0, 0);
|
|
+ input_set_abs_params(input, ABS_MT_PRESSURE, 0,
|
|
+ NVT36XXX_MAX_WIDTH, 0, 0);
|
|
+ touchscreen_parse_properties(input, true, &data->prop);
|
|
+ ret = input_mt_init_slots(input, NVT36XXX_MAX_TOUCHES,
|
|
+ INPUT_MT_DIRECT);
|
|
+ if (ret)
|
|
+ return ret;
|
|
+
|
|
+ data->input = input;
|
|
+ input_set_drvdata(input, data);
|
|
+ ret = input_register_device(input);
|
|
+ if (ret)
|
|
+ return ret;
|
|
+
|
|
+ ret = devm_add_action_or_reset(dev, ssd2092_restore_irq_type, data);
|
|
+ if (ret)
|
|
+ return ret;
|
|
+
|
|
+ ret = devm_request_threaded_irq(dev, client->irq, NULL, ssd2092_irq,
|
|
+ IRQF_TRIGGER_LOW | IRQF_ONESHOT,
|
|
+ "ssd2092-ts", data);
|
|
+ if (ret)
|
|
+ return dev_err_probe(dev, ret, "failed to request SSD2092 IRQ\n");
|
|
+
|
|
+ return 0;
|
|
+}
|
|
+
|
|
static int nvt36xxx_probe(struct i2c_client *client)
|
|
{
|
|
struct device *dev = &client->dev;
|
|
@@ -304,7 +820,7 @@ static int nvt36xxx_probe(struct i2c_cli
|
|
struct input_dev *input;
|
|
int ret;
|
|
|
|
- if (client->addr != NVT36XXX_HW_ADDR || !client->irq)
|
|
+ if (client->addr != NVT36XXX_HW_ADDR)
|
|
return -EINVAL;
|
|
|
|
data = devm_kzalloc(dev, sizeof(*data), GFP_KERNEL);
|
|
@@ -313,6 +829,12 @@ static int nvt36xxx_probe(struct i2c_cli
|
|
|
|
data->client = client;
|
|
i2c_set_clientdata(client, data);
|
|
+
|
|
+ if (gemini_touch_is_ssd2092())
|
|
+ return ssd2092_probe(client, data);
|
|
+
|
|
+ if (!client->irq)
|
|
+ return -EINVAL;
|
|
data->supplies[0].supply = "vcc";
|
|
data->supplies[1].supply = "iovcc";
|
|
ret = devm_regulator_bulk_get(dev, ARRAY_SIZE(data->supplies),
|
|
@@ -393,6 +915,12 @@ static int nvt36xxx_suspend(struct devic
|
|
disable_irq(data->client->irq);
|
|
|
|
/* A finger down at suspend would otherwise stay down until it lifts */
|
|
+ if (data->is_ssd2092) {
|
|
+ memset(data->slots, 0, sizeof(data->slots));
|
|
+ ssd2092_report_slots(data);
|
|
+ return 0;
|
|
+ }
|
|
+
|
|
input_mt_sync_frame(data->input);
|
|
input_report_key(data->input, BTN_TOUCH, 0);
|
|
input_sync(data->input);
|
|
@@ -404,6 +932,19 @@ static int nvt36xxx_resume(struct device
|
|
{
|
|
struct nvt36xxx_data *data = dev_get_drvdata(dev);
|
|
|
|
+ if (data->is_ssd2092) {
|
|
+ int ret;
|
|
+
|
|
+ if (!data->vcc_reg)
|
|
+ ssd2092_enable_pmic_vldo28();
|
|
+ ssd2092_reset_pulse(data);
|
|
+ ret = ssd2092_boot_seeprom(data);
|
|
+ if (!ret)
|
|
+ ret = ssd2092_hw_init(data);
|
|
+ if (ret)
|
|
+ dev_warn(dev, "SSD2092 resume init failed: %d\n", ret);
|
|
+ }
|
|
+
|
|
enable_irq(data->client->irq);
|
|
|
|
return 0;
|
|
|
|
diff --git a/drivers/power/supply/bq25890_charger.c b/drivers/power/supply/bq25890_charger.c
|
|
--- a/drivers/power/supply/bq25890_charger.c
|
|
+++ b/drivers/power/supply/bq25890_charger.c
|
|
@@ -1384,11 +1384,8 @@
|
|
usb = power_supply_get_by_name(bq->guard_usb_type);
|
|
if (!usb)
|
|
return false;
|
|
- if (!power_supply_get_property(usb, POWER_SUPPLY_PROP_ONLINE, &val) && val.intval &&
|
|
- !power_supply_get_property(usb, POWER_SUPPLY_PROP_USB_TYPE, &val))
|
|
- wall = val.intval == POWER_SUPPLY_USB_TYPE_DCP ||
|
|
- val.intval == POWER_SUPPLY_USB_TYPE_CDP ||
|
|
- val.intval == POWER_SUPPLY_USB_TYPE_APPLE_BRICK_ID;
|
|
+ if (!power_supply_get_property(usb, POWER_SUPPLY_PROP_ONLINE, &val) && val.intval)
|
|
+ wall = true;
|
|
power_supply_put(usb);
|
|
|
|
if (!wall || temp >= BQ25890_GUARD_WALL_HOT)
|
|
--
|
|
2.55.0
|