Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ allOf:
properties:
compatible:
enum:
- goodix,gt9895
- goodix,gt9897
- goodix,gt9916

Expand Down
61 changes: 59 additions & 2 deletions arch/arm64/boot/dts/exynos/google/gs201-lynx.dts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
* Google Pixel 7a (lynx) - M1 bring-up board file.
*
* USB (NCM + ACM), the cluster watchdogs from gs201.dtsi, a
* simple-framebuffer on the buffer ABL leaves DPP0 scanning out, and UFS.
* The panel driver, touch and the GPU stay disabled.
* simple-framebuffer on the buffer ABL leaves DPP0 scanning out, UFS and
* the touchscreen. The panel driver and the GPU stay disabled.
*/

/dts-v1/;
Expand Down Expand Up @@ -94,6 +94,58 @@
};
};

&acpm_ipc {
/*
* Main PMIC, touch rails only. LDO25M is L25M_TSP_DVDD and LDO26M is
* L26M_TS_AVDD, with stock's ranges; nothing else on the stock board
* consumes them. Unlike on cheetah, the bootloader leaves both off.
* The sub-PMIC is not described.
*/
pmic-1 {
compatible = "samsung,s2mpg12-pmic";
interrupts = <GIC_SPI 72 IRQ_TYPE_LEVEL_HIGH>;
google,vgpio2ap-sysreg = <&sysreg_vgpio2ap>;
wakeup-source;

regulators {
ldo25m: ldo25m {
regulator-name = "vddio-ts";
regulator-min-microvolt = <1800000>;
regulator-max-microvolt = <1800000>;
};

ldo26m: ldo26m {
regulator-name = "avdd-ts";
regulator-min-microvolt = <3000000>;
regulator-max-microvolt = <3000000>;
};
};
};
};

/* Touchscreen: Goodix GT9895 (Berlin) on USI0 SPI, wired as on cheetah */
&spi_0 {
pinctrl-0 = <&spi0_bus &spi0_miso &spi0_cs_gpio>;
cs-gpios = <&gpp20 3 GPIO_ACTIVE_LOW>;
num-cs = <1>;
status = "okay";

touchscreen@0 {
compatible = "goodix,gt9895";
reg = <0>;
spi-max-frequency = <10000000>;
interrupt-parent = <&gpa7>;
interrupts = <0 IRQ_TYPE_EDGE_FALLING>;
reset-gpios = <&gpp23 2 GPIO_ACTIVE_LOW>;
pinctrl-0 = <&ts_irq &ts_reset>;
pinctrl-names = "default";
avdd-supply = <&ldo26m>;
vddio-supply = <&ldo25m>;
touchscreen-size-x = <1080>;
touchscreen-size-y = <2400>;
};
};

&usbdrd31_phy {
status = "okay";
};
Expand All @@ -110,3 +162,8 @@
&ufs_0_phy {
status = "okay";
};

&usi0 {
samsung,mode = <USI_MODE_SPI>;
status = "okay";
};
2 changes: 2 additions & 0 deletions drivers/input/touchscreen/goodix_berlin.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ struct goodix_berlin_ic_data {
int ic_info_addr;
ssize_t read_dummy_len;
ssize_t read_prefix_len;
/* Size of one contact record, 0 for the 8-byte default */
size_t touch_size;
};

struct device;
Expand Down
24 changes: 15 additions & 9 deletions drivers/input/touchscreen/goodix_berlin_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,11 @@ struct goodix_berlin_touch {
__le16 w;
};
#define GOODIX_BERLIN_TOUCH_SIZE sizeof(struct goodix_berlin_touch)
/*
* Some firmware appends pressure, both axes and an orientation to each
* record. The first GOODIX_BERLIN_TOUCH_SIZE bytes keep the layout above.
*/
#define GOODIX_BERLIN_TOUCH_SIZE_MAX 14

struct goodix_berlin_header {
u8 status;
Expand All @@ -157,7 +162,7 @@ struct goodix_berlin_header {
struct goodix_berlin_event {
struct goodix_berlin_header hdr;
/* The data below is u16/__le16 aligned */
u8 data[GOODIX_BERLIN_TOUCH_SIZE * GOODIX_BERLIN_MAX_TOUCH +
u8 data[GOODIX_BERLIN_TOUCH_SIZE_MAX * GOODIX_BERLIN_MAX_TOUCH +
GOODIX_BERLIN_CHECKSUM_SIZE];
};

Expand All @@ -176,6 +181,7 @@ struct goodix_berlin_core {
u32 touch_data_addr;

const struct goodix_berlin_ic_data *ic_data;
size_t touch_size;

struct goodix_berlin_event event;
};
Expand Down Expand Up @@ -416,14 +422,14 @@ static int goodix_berlin_get_ic_info(struct goodix_berlin_core *cd)
static int goodix_berlin_get_remaining_contacts(struct goodix_berlin_core *cd,
int n)
{
size_t offset = 2 * GOODIX_BERLIN_TOUCH_SIZE +
size_t offset = 2 * cd->touch_size +
GOODIX_BERLIN_CHECKSUM_SIZE;
u32 addr = cd->touch_data_addr + GOODIX_BERLIN_HEADER_SIZE + offset;
int error;

error = regmap_raw_read(cd->regmap, addr,
&cd->event.data[offset],
(n - 2) * GOODIX_BERLIN_TOUCH_SIZE);
(n - 2) * cd->touch_size);
if (error) {
dev_err_ratelimited(cd->dev, "failed to get touch data, %d\n",
error);
Expand All @@ -435,14 +441,12 @@ static int goodix_berlin_get_remaining_contacts(struct goodix_berlin_core *cd,

static void goodix_berlin_report_state(struct goodix_berlin_core *cd, int n)
{
struct goodix_berlin_touch *touch_data =
(struct goodix_berlin_touch *)cd->event.data;
struct goodix_berlin_touch *t;
int i;
u8 type, id;

for (i = 0; i < n; i++) {
t = &touch_data[i];
t = (struct goodix_berlin_touch *)&cd->event.data[i * cd->touch_size];

type = FIELD_GET(GOODIX_BERLIN_POINT_TYPE_MASK, t->status);
if (type == GOODIX_BERLIN_POINT_TYPE_STYLUS ||
Expand Down Expand Up @@ -491,7 +495,7 @@ static void goodix_berlin_touch_handler(struct goodix_berlin_core *cd)
}

if (touch_num) {
int len = touch_num * GOODIX_BERLIN_TOUCH_SIZE +
int len = touch_num * cd->touch_size +
GOODIX_BERLIN_CHECKSUM_SIZE;
if (!goodix_berlin_checksum_valid(cd->event.data, len)) {
dev_err(cd->dev, "touch data checksum error: %*ph\n",
Expand Down Expand Up @@ -524,7 +528,8 @@ static irqreturn_t goodix_berlin_irq(int irq, void *data)
* - GOODIX_BERLIN_HEADER_SIZE = 8 bytes
* - GOODIX_BERLIN_TOUCH_SIZE * 2 = 16 bytes
* - GOODIX_BERLIN_CHECKLSUM_SIZE = 2 bytes
* For a total of 26 bytes.
* For a total of 26 bytes. The layout below is for 8-byte records;
* with a larger touch_size the same reads cover touch_size per finger.
*
* If only a single finger is reported, we will read 8 bytes more than
* needed:
Expand Down Expand Up @@ -557,7 +562,7 @@ static irqreturn_t goodix_berlin_irq(int irq, void *data)
error = regmap_raw_read(cd->regmap, cd->touch_data_addr,
&cd->event,
GOODIX_BERLIN_HEADER_SIZE +
2 * GOODIX_BERLIN_TOUCH_SIZE +
2 * cd->touch_size +
GOODIX_BERLIN_CHECKSUM_SIZE);
if (error) {
dev_warn_ratelimited(cd->dev,
Expand Down Expand Up @@ -745,6 +750,7 @@ int goodix_berlin_probe(struct device *dev, int irq, const struct input_id *id,
cd->regmap = regmap;
cd->irq = irq;
cd->ic_data = ic_data;
cd->touch_size = ic_data->touch_size ?: GOODIX_BERLIN_TOUCH_SIZE;

cd->reset_gpio = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_HIGH);
if (IS_ERR(cd->reset_gpio))
Expand Down
10 changes: 10 additions & 0 deletions drivers/input/touchscreen/goodix_berlin_spi.c
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,14 @@ static int goodix_berlin_spi_probe(struct spi_device *spi)
return 0;
}

static const struct goodix_berlin_ic_data gt9895_data = {
.fw_version_info_addr = GOODIX_BERLIN_FW_VERSION_INFO_ADDR_D,
.ic_info_addr = GOODIX_BERLIN_IC_INFO_ADDR_D,
.read_dummy_len = GOODIX_BERLIN_SPI_READ_DUMMY_LEN_D,
.read_prefix_len = GOODIX_BERLIN_SPI_READ_PREFIX_LEN_D,
.touch_size = 14,
};

static const struct goodix_berlin_ic_data gt9897_data = {
.fw_version_info_addr = GOODIX_BERLIN_FW_VERSION_INFO_ADDR_A,
.ic_info_addr = GOODIX_BERLIN_IC_INFO_ADDR_A,
Expand All @@ -173,13 +181,15 @@ static const struct goodix_berlin_ic_data gt9916_data = {
};

static const struct spi_device_id goodix_berlin_spi_ids[] = {
{ .name = "gt9895", .driver_data = (long)&gt9895_data },
{ .name = "gt9897", .driver_data = (long)&gt9897_data },
{ .name = "gt9916", .driver_data = (long)&gt9916_data },
{ },
};
MODULE_DEVICE_TABLE(spi, goodix_berlin_spi_ids);

static const struct of_device_id goodix_berlin_spi_of_match[] = {
{ .compatible = "goodix,gt9895", .data = &gt9895_data },
{ .compatible = "goodix,gt9897", .data = &gt9897_data },
{ .compatible = "goodix,gt9916", .data = &gt9916_data },
{ }
Expand Down