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
26 changes: 22 additions & 4 deletions Documentation/devicetree/bindings/input/touchscreen/st,salixp.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,33 @@
$id: http://devicetree.org/schemas/input/touchscreen/st,salixp.yaml#
$schema: http://devicetree.org/meta-schemas/core.yaml#

title: STMicroelectronics SALIXP SPI touch controller
title: STMicroelectronics SALIXP and ALIX SPI touch controllers

maintainers:
- David A. Buser <code@booze.dog>

description:
STMicroelectronics SALIXP touch controller on SPI. SALIXP is the FTS
part whose chip id is 36 40. The I2C FingerTip controller is
st,stmfts and is a different device.
part whose chip id is 36 40; ALIX has chip id 36 48. The I2C
FingerTip controller is st,stmfts and is a different device.

allOf:
- $ref: /schemas/spi/spi-peripheral-props.yaml#
- $ref: touchscreen.yaml#
- if:
properties:
compatible:
const: st,alix
then:
required:
- bus-request-gpios
- bus-ack-gpios

properties:
compatible:
const: st,salixp
enum:
- st,salixp
- st,alix

reg:
maxItems: 1
Expand All @@ -36,6 +46,14 @@ properties:
description: Active-low reset
maxItems: 1

bus-request-gpios:
description: Active-low AP bus request
maxItems: 1

bus-ack-gpios:
description: Active-low acknowledgment of AP bus ownership
maxItems: 1

spi-max-frequency: true

required:
Expand Down
72 changes: 72 additions & 0 deletions arch/arm64/boot/dts/exynos/google/gs101-bluejay-input.dtsi
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
// SPDX-License-Identifier: GPL-2.0-only
/*
* Bluejay ALIX touch wiring from Google's gs101-bluejay-touch.dtsi and
* gs101-common-touch.dtsi. The path stays disabled until a gated overlay.
*/

#include <dt-bindings/soc/samsung,exynos-usi.h>

&pinctrl_gpio_alive {
bluejay_touch_irq: bluejay-touch-irq-pins {
samsung,pins = "gpa9-0";
samsung,pin-pud = <GS101_PIN_PULL_NONE>;
};
};

&pinctrl_far_alive {
bluejay_touch_ack: bluejay-touch-ack-pins {
samsung,pins = "gpa8-6";
samsung,pin-pud = <GS101_PIN_PULL_DOWN>;
};
};

&pinctrl_peric1 {
bluejay_touch_reset: bluejay-touch-reset-pins {
samsung,pins = "gpp26-0";
samsung,pin-pud = <GS101_PIN_PULL_NONE>;
samsung,pin-con-pdn = <GS101_PIN_PDN_PREV>;
samsung,pin-pud-pdn = <GS101_PIN_PULL_NONE>;
};

bluejay_touch_request: bluejay-touch-request-pins {
samsung,pins = "gpp26-1";
samsung,pin-pud = <GS101_PIN_PULL_NONE>;
samsung,pin-con-pdn = <GS101_PIN_PDN_PREV>;
samsung,pin-pud-pdn = <GS101_PIN_PULL_NONE>;
};
};

&usi11 {
samsung,mode = <USI_MODE_SPI>;
status = "disabled";
};

&spi_11 {
pinctrl-0 = <&spi11_bus &spi11_cs>;
cs-gpios = <&gpp23 3 GPIO_ACTIVE_LOW>;
num-cs = <1>;
status = "disabled";

bluejay_touch: touchscreen@0 {
compatible = "st,alix";
reg = <0>;
spi-max-frequency = <10000000>;
interrupt-parent = <&gpa9>;
interrupts = <0 IRQ_TYPE_LEVEL_LOW>;
vdd-supply = <&{/firmware/power-management/pmic-1/regulators/ldo25m}>;
avdd-supply = <&{/firmware/power-management/pmic-1/regulators/ldo26m}>;
reset-gpios = <&gpp26 0 GPIO_ACTIVE_LOW>;
bus-request-gpios = <&gpp26 1 GPIO_ACTIVE_LOW>;
bus-ack-gpios = <&gpa8 6 GPIO_ACTIVE_LOW>;
touchscreen-size-x = <1080>;
touchscreen-size-y = <2400>;
pinctrl-names = "default";
pinctrl-0 = <&bluejay_touch_irq &bluejay_touch_reset
&bluejay_touch_request &bluejay_touch_ack>;
status = "disabled";

controller-data {
samsung,spi-feedback-delay = <1>;
};
};
};
1 change: 1 addition & 0 deletions arch/arm64/boot/dts/exynos/google/gs101-bluejay.dts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
/dts-v1/;

#include "gs101-pixel-common.dtsi"
#include "gs101-bluejay-input.dtsi"

/ {
model = "Bluejay";
Expand Down
81 changes: 70 additions & 11 deletions drivers/input/touchscreen/salixp.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,16 @@
* SALIXP is the FTS part whose hardware id is 36 40. Google's GPL FTM5
* driver (kernel/google-modules/touch/fts_touch), Copyright (C) 2016
* STMicroelectronics, calls that id SALIXP. Chip id 36 48 is ALIX and is
* not this part. This driver sends four things: a hardware-register
* read (opcode 0xfb), a framebuffer read (opcode 0xa7), a FIFO read
* (opcode 0x87), and one scan command (0xa0 0x00 0xff). It also
* toggles the reset GPIO once, after the system-info read. It never
* sends opcode 0xfa, a flash or config write, a system or load
* command, or the setScanMode preamble. It does not request the
* interrupt. Attention is level low. After reset is released the line
* a separately matched part. ALIX negotiates AP bus ownership before reset,
* supply enable or SPI traffic. Device core pinctrl and SPI-controller setup
* precede the peripheral probe. Both variants assert reset before enabling
* vdd then avdd, and release reset before checking identity.
* This driver sends four things: a hardware-register read (opcode 0xfb), a
* framebuffer read (opcode 0xa7), a FIFO read (opcode 0x87), and one scan
* command (0xa0 0x00 0xff). It also toggles the reset GPIO once, after the
* system-info read. It never sends opcode 0xfa, a flash or config write, a
* system or load command, or the setScanMode preamble. It does not request
* the interrupt. Attention is level low. After reset is released the line
* falls and stays low, so a level interrupt would storm before any
* firmware handshake.
*
Expand Down Expand Up @@ -113,10 +116,13 @@

struct salixp_info {
u8 id[2];
const char *name;
bool bus_handshake;
};

struct salixp {
struct spi_device *spi;
const struct salixp_info *info;
struct gpio_desc *reset;
struct input_dev *input;
struct touchscreen_properties prop;
Expand All @@ -138,8 +144,49 @@ struct salixp {

static const struct salixp_info salixp_info = {
.id = { 0x36, 0x40 },
.name = "SALIXP Touchscreen",
};

static const struct salixp_info alix_info = {
.id = { 0x36, 0x48 },
.name = "ALIX Touchscreen",
.bus_handshake = true,
};

/*
* Google's touch_bus_negotiator uses physical zero for AP ownership on
* both GPIOs and a 500 ms request timeout. Both descriptors are active low,
* so an asserted request/ack is physical zero. Poll the acknowledgment here;
* the bring-up driver never starts AoC or requests its interrupt.
*/
static int alix_request_bus(struct device *dev)
{
struct gpio_desc *request, *ack;
ktime_t deadline;
int value;

ack = devm_gpiod_get(dev, "bus-ack", GPIOD_IN);
if (IS_ERR(ack))
return dev_err_probe(dev, PTR_ERR(ack), "getting bus ack\n");
request = devm_gpiod_get(dev, "bus-request", GPIOD_OUT_HIGH);
if (IS_ERR(request))
return dev_err_probe(dev, PTR_ERR(request), "requesting AP bus\n");

deadline = ktime_add_ms(ktime_get(), 500);
do {
value = gpiod_get_value_cansleep(ack);
if (value < 0)
return value;
if (value) {
dev_info(dev, "ALIX AP bus acknowledged\n");
return 0;
}
usleep_range(1000, 2000);
} while (ktime_before(ktime_get(), deadline));

return dev_err_probe(dev, -ETIMEDOUT, "AP bus not acknowledged\n");
}

static void salixp_assert_reset(void *data)
{
struct salixp *ts = data;
Expand Down Expand Up @@ -617,16 +664,19 @@ static int salixp_suspend(struct device *dev)
{
struct salixp *ts = spi_get_drvdata(to_spi_device(dev));

disable_delayed_work_sync(&ts->poll_work);
if (ts->input)
disable_delayed_work_sync(&ts->poll_work);
return 0;
}

static int salixp_resume(struct device *dev)
{
struct salixp *ts = spi_get_drvdata(to_spi_device(dev));

enable_delayed_work(&ts->poll_work);
queue_delayed_work(system_freezable_wq, &ts->poll_work, 0);
if (ts->input) {
enable_delayed_work(&ts->poll_work);
queue_delayed_work(system_freezable_wq, &ts->poll_work, 0);
}
return 0;
}

Expand All @@ -648,7 +698,7 @@ static int salixp_register_input(struct salixp *ts)
if (!input)
return -ENOMEM;

input->name = "SALIXP Touchscreen";
input->name = ts->info->name;
input->id.bustype = BUS_SPI;

/*
Expand Down Expand Up @@ -690,8 +740,15 @@ static int salixp_probe(struct spi_device *spi)
return -ENOMEM;

ts->spi = spi;
ts->info = info;
spi_set_drvdata(spi, ts);

if (info->bus_handshake) {
ret = alix_request_bus(dev);
if (ret)
return ret;
}

/*
* Assert reset before either rail. Cover rails are S2MPG12 LDO25M
* (1.8 V) and LDO26M (3.3 V). The board leaves them off, with no
Expand Down Expand Up @@ -765,12 +822,14 @@ static int salixp_probe(struct spi_device *spi)

static const struct of_device_id salixp_of_match[] = {
{ .compatible = "st,salixp", .data = &salixp_info },
{ .compatible = "st,alix", .data = &alix_info },
{ }
};
MODULE_DEVICE_TABLE(of, salixp_of_match);

static const struct spi_device_id salixp_id[] = {
{ "salixp", 0 },
{ "alix", 0 },
{ }
};
MODULE_DEVICE_TABLE(spi, salixp_id);
Expand Down