[PATCH 2/2] drm/panel: Add support for E Ink VB3300-KCA

2021-04-19 Thread Alistair Francis
Add support for the 10.3" E Ink panel described at:
https://www.eink.com/product.html?type=productdetail=7

Signed-off-by: Alistair Francis 
---
 drivers/gpu/drm/panel/panel-simple.c | 29 
 1 file changed, 29 insertions(+)

diff --git a/drivers/gpu/drm/panel/panel-simple.c 
b/drivers/gpu/drm/panel/panel-simple.c
index 4e2dad314c79..f1f6fd2517f6 100644
--- a/drivers/gpu/drm/panel/panel-simple.c
+++ b/drivers/gpu/drm/panel/panel-simple.c
@@ -1964,6 +1964,32 @@ static const struct panel_desc edt_etm0700g0bdh6 = {
.bus_flags = DRM_BUS_FLAG_DE_HIGH | DRM_BUS_FLAG_PIXDATA_DRIVE_POSEDGE,
 };
 
+static const struct display_timing eink_vb3300_kca_timing = {
+   .pixelclock = { 4000, 4000, 4000 },
+   .hactive = { 334, 334, 334 },
+   .hfront_porch = { 1, 1, 1 },
+   .hback_porch = { 1, 1, 1 },
+   .hsync_len = { 1, 1, 1 },
+   .vactive = { 1405, 1405, 1405 },
+   .vfront_porch = { 1, 1, 1 },
+   .vback_porch = { 1, 1, 1 },
+   .vsync_len = { 1, 1, 1 },
+   .flags = DISPLAY_FLAGS_HSYNC_LOW | DISPLAY_FLAGS_VSYNC_LOW |
+DISPLAY_FLAGS_DE_HIGH | DISPLAY_FLAGS_PIXDATA_POSEDGE,
+};
+
+static const struct panel_desc eink_vb3300_kca = {
+   .modes = _etm0700g0dh6_mode,
+   .num_modes = 1,
+   .bpc = 6,
+   .size = {
+   .width = 157,
+   .height = 209,
+   },
+   .bus_format = MEDIA_BUS_FMT_RGB888_1X24,
+   .bus_flags = DRM_BUS_FLAG_DE_HIGH | DRM_BUS_FLAG_PIXDATA_DRIVE_POSEDGE,
+};
+
 static const struct display_timing evervision_vgg804821_timing = {
.pixelclock = { 2760, 3330, 5000 },
.hactive = { 800, 800, 800 },
@@ -4232,6 +4258,9 @@ static const struct of_device_id platform_of_match[] = {
}, {
.compatible = "edt,etm0700g0dh6",
.data = _etm0700g0dh6,
+   }, {
+   .compatible = "eink,vb3300-kca",
+   .data = _vb3300_kca,
}, {
.compatible = "edt,etm0700g0bdh6",
.data = _etm0700g0bdh6,
-- 
2.31.1



[PATCH 1/2] dt-bindings: Add E Ink to vendor bindings

2021-04-19 Thread Alistair Francis
Add the E Ink Corporation to the vendor bindings.

Signed-off-by: Alistair Francis 
---
 Documentation/devicetree/bindings/vendor-prefixes.yaml | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/Documentation/devicetree/bindings/vendor-prefixes.yaml 
b/Documentation/devicetree/bindings/vendor-prefixes.yaml
index 996f4de2fff5..6c9323dc9b78 100644
--- a/Documentation/devicetree/bindings/vendor-prefixes.yaml
+++ b/Documentation/devicetree/bindings/vendor-prefixes.yaml
@@ -329,6 +329,8 @@ patternProperties:
 description: eGalax_eMPIA Technology Inc
   "^einfochips,.*":
 description: Einfochips
+  "^eink,.*":
+description: E Ink Corporation
   "^elan,.*":
 description: Elan Microelectronic Corp.
   "^element14,.*":
-- 
2.31.1



[PATCH v5 5/5] ARM: dts: imx7d: remarkable2: Enable silergy,sy7636a

2021-04-19 Thread Alistair Francis
Enable the silergy,sy7636a and silergy,sy7636a-regulator on the
reMarkable2.

Signed-off-by: Alistair Francis 
---
 arch/arm/boot/dts/imx7d-remarkable2.dts | 61 +
 1 file changed, 61 insertions(+)

diff --git a/arch/arm/boot/dts/imx7d-remarkable2.dts 
b/arch/arm/boot/dts/imx7d-remarkable2.dts
index ea1dd41023f9..bdfc658d89db 100644
--- a/arch/arm/boot/dts/imx7d-remarkable2.dts
+++ b/arch/arm/boot/dts/imx7d-remarkable2.dts
@@ -22,6 +22,27 @@ memory@8000 {
reg = <0x8000 0x4000>;
};
 
+   thermal-zones {
+   epd-thermal {
+   thermal-sensors = <_pmic>;
+   polling-delay-passive = <3>;
+   polling-delay = <3>;
+   trips {
+   trip0 {
+   temperature = <49000>;
+   hysteresis = <2000>;
+   type = "passive";
+   };
+
+   trip1 {
+   temperature = <5>;
+   hysteresis = <2000>;
+   type = "critical";
+   };
+   };
+   };
+   };
+
reg_brcm: regulator-brcm {
compatible = "regulator-fixed";
regulator-name = "brcm_reg";
@@ -86,6 +107,32 @@ wacom_digitizer: digitizer@9 {
};
 };
 
+ {
+   clock-frequency = <10>;
+   pinctrl-names = "default", "sleep";
+   pinctrl-0 = <_i2c4>;
+   pinctrl-1 = <_i2c4>;
+   status = "okay";
+
+   epd_pmic: sy7636a@62 {
+   compatible = "silergy,sy7636a";
+   reg = <0x62>;
+   status = "okay";
+   pinctrl-names = "default";
+   pinctrl-0 = <_epdpmic>;
+   #thermal-sensor-cells = <0>;
+
+   epd-pwr-good-gpios = < 21 GPIO_ACTIVE_HIGH>;
+   regulators {
+   compatible = "silergy,sy7636a-regulator";
+   reg_epdpmic: vcom {
+   regulator-name = "vcom";
+   regulator-boot-on;
+   };
+   };
+   };
+};
+
 _pwrkey {
status = "okay";
 };
@@ -179,6 +226,13 @@ MX7D_PAD_SAI1_TX_BCLK__GPIO6_IO13  0x14
>;
};
 
+   pinctrl_epdpmic: epdpmicgrp {
+   fsl,pins = <
+   MX7D_PAD_SAI2_RX_DATA__GPIO6_IO21 0x0074
+   MX7D_PAD_ENET1_RGMII_TXC__GPIO7_IO11 0x0014
+   >;
+   };
+
pinctrl_i2c1: i2c1grp {
fsl,pins = <
MX7D_PAD_I2C1_SDA__I2C1_SDA 0x407f
@@ -186,6 +240,13 @@ MX7D_PAD_I2C1_SCL__I2C1_SCL0x407f
>;
};
 
+   pinctrl_i2c4: i2c4grp {
+   fsl,pins = <
+   MX7D_PAD_I2C4_SDA__I2C4_SDA 0x407f
+   MX7D_PAD_I2C4_SCL__I2C4_SCL 0x407f
+   >;
+   };
+
pinctrl_uart1: uart1grp {
fsl,pins = <
MX7D_PAD_UART1_TX_DATA__UART1_DCE_TX0x79
-- 
2.31.1



[PATCH v5 4/5] ARM: imx_v6_v7_defconfig: Enable silergy,sy7636a

2021-04-19 Thread Alistair Francis
Enable the silergy,sy7636a and silergy,sy7636a-regulator for the
reMarkable2.

Signed-off-by: Alistair Francis 
---
 arch/arm/configs/imx_v6_v7_defconfig | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/arch/arm/configs/imx_v6_v7_defconfig 
b/arch/arm/configs/imx_v6_v7_defconfig
index cd80e85d37cf..bafd1d7b4ad5 100644
--- a/arch/arm/configs/imx_v6_v7_defconfig
+++ b/arch/arm/configs/imx_v6_v7_defconfig
@@ -245,6 +245,7 @@ CONFIG_MFD_MC13XXX_I2C=y
 CONFIG_MFD_RN5T618=y
 CONFIG_MFD_STMPE=y
 CONFIG_REGULATOR=y
+CONFIG_MFD_SY7636A=y
 CONFIG_REGULATOR_FIXED_VOLTAGE=y
 CONFIG_REGULATOR_ANATOP=y
 CONFIG_REGULATOR_DA9052=y
@@ -255,6 +256,7 @@ CONFIG_REGULATOR_MC13783=y
 CONFIG_REGULATOR_MC13892=y
 CONFIG_REGULATOR_PFUZE100=y
 CONFIG_REGULATOR_RN5T618=y
+CONFIG_REGULATOR_SY7636A=y
 CONFIG_RC_CORE=y
 CONFIG_RC_DEVICES=y
 CONFIG_IR_GPIO_CIR=y
-- 
2.31.1



[PATCH v5 3/5] regulator: sy7636a: Initial commit

2021-04-19 Thread Alistair Francis
Initial support for the Silergy SY7636A-regulator Power Management chip.

Signed-off-by: Alistair Francis 
---
v5:
 - Simplify the implementation

 drivers/regulator/Kconfig |   6 ++
 drivers/regulator/Makefile|   1 +
 drivers/regulator/sy7636a-regulator.c | 127 ++
 include/linux/mfd/sy7636a.h   |   1 +
 4 files changed, 135 insertions(+)
 create mode 100644 drivers/regulator/sy7636a-regulator.c

diff --git a/drivers/regulator/Kconfig b/drivers/regulator/Kconfig
index 77c43134bc9e..6d501ce921a8 100644
--- a/drivers/regulator/Kconfig
+++ b/drivers/regulator/Kconfig
@@ -1130,6 +1130,12 @@ config REGULATOR_STW481X_VMMC
  This driver supports the internal VMMC regulator in the STw481x
  PMIC chips.
 
+config REGULATOR_SY7636A
+   tristate "Silergy SY7636A voltage regulator"
+   depends on MFD_SY7636A
+   help
+ This driver supports Silergy SY3686A voltage regulator.
+
 config REGULATOR_SY8106A
tristate "Silergy SY8106A regulator"
depends on I2C && (OF || COMPILE_TEST)
diff --git a/drivers/regulator/Makefile b/drivers/regulator/Makefile
index 44d2f8bf4b74..5a981036a9f0 100644
--- a/drivers/regulator/Makefile
+++ b/drivers/regulator/Makefile
@@ -134,6 +134,7 @@ obj-$(CONFIG_REGULATOR_STM32_VREFBUF) += stm32-vrefbuf.o
 obj-$(CONFIG_REGULATOR_STM32_PWR) += stm32-pwr.o
 obj-$(CONFIG_REGULATOR_STPMIC1) += stpmic1_regulator.o
 obj-$(CONFIG_REGULATOR_STW481X_VMMC) += stw481x-vmmc.o
+obj-$(CONFIG_REGULATOR_SY7636A) += sy7636a-regulator.o
 obj-$(CONFIG_REGULATOR_SY8106A) += sy8106a-regulator.o
 obj-$(CONFIG_REGULATOR_SY8824X) += sy8824x.o
 obj-$(CONFIG_REGULATOR_SY8827N) += sy8827n.o
diff --git a/drivers/regulator/sy7636a-regulator.c 
b/drivers/regulator/sy7636a-regulator.c
new file mode 100644
index ..c384c2b6ac46
--- /dev/null
+++ b/drivers/regulator/sy7636a-regulator.c
@@ -0,0 +1,127 @@
+// SPDX-License-Identifier: GPL-2.0+
+//
+// Functions to access SY3686A power management chip voltages
+//
+// Copyright (C) 2019 reMarkable AS - http://www.remarkable.com/
+//
+// Authors: Lars Ivar Miljeteig 
+//  Alistair Francis 
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#define SY7636A_POLL_ENABLED_TIME 500
+
+static int sy7636a_get_vcom_voltage_op(struct regulator_dev *rdev)
+{
+   int ret;
+   unsigned int val, val_h;
+
+   ret = regmap_read(rdev->regmap, SY7636A_REG_VCOM_ADJUST_CTRL_L, );
+   if (ret)
+   return ret;
+
+   ret = regmap_read(rdev->regmap, SY7636A_REG_VCOM_ADJUST_CTRL_H, _h);
+   if (ret)
+   return ret;
+
+   val |= (val_h << VCOM_ADJUST_CTRL_SHIFT);
+
+   return (val & VCOM_ADJUST_CTRL_MASK) * VCOM_ADJUST_CTRL_SCAL;
+}
+
+static int sy7636a_get_status(struct regulator_dev *rdev)
+{
+   struct sy7636a *sy7636a = dev_get_drvdata(rdev->dev.parent);
+   int ret = 0;
+
+   ret = gpiod_get_value_cansleep(sy7636a->pgood_gpio);
+   if (ret < 0)
+   dev_err(>dev, "Failed to read pgood gpio: %d\n", ret);
+
+   return ret;
+}
+
+static const struct regulator_ops sy7636a_vcom_volt_ops = {
+   .get_voltage = sy7636a_get_vcom_voltage_op,
+   .enable = regulator_enable_regmap,
+   .disable = regulator_disable_regmap,
+   .is_enabled = regulator_is_enabled_regmap,
+   .get_status = sy7636a_get_status,
+};
+
+struct regulator_desc desc = {
+   .name = "vcom",
+   .id = 0,
+   .ops = _vcom_volt_ops,
+   .type = REGULATOR_VOLTAGE,
+   .owner = THIS_MODULE,
+   .enable_reg = SY7636A_REG_OPERATION_MODE_CRL,
+   .enable_mask = SY7636A_OPERATION_MODE_CRL_ONOFF,
+   .poll_enabled_time  = SY7636A_POLL_ENABLED_TIME,
+   .regulators_node = of_match_ptr("regulators"),
+   .of_match = of_match_ptr("vcom"),
+};
+
+static int sy7636a_regulator_probe(struct platform_device *pdev)
+{
+   struct sy7636a *sy7636a = dev_get_drvdata(pdev->dev.parent);
+   struct regulator_config config = { };
+   struct regulator_dev *rdev;
+   struct gpio_desc *gdp;
+   int ret;
+
+   if (!sy7636a)
+   return -EPROBE_DEFER;
+
+   platform_set_drvdata(pdev, sy7636a);
+
+   gdp = devm_gpiod_get(sy7636a->dev, "epd-pwr-good", GPIOD_IN);
+   if (IS_ERR(gdp)) {
+   dev_err(sy7636a->dev, "Power good GPIO fault %ld\n", 
PTR_ERR(gdp));
+   return PTR_ERR(gdp);
+   }
+
+   sy7636a->pgood_gpio = gdp;
+
+   ret = regmap_write(sy7636a->regmap, SY7636A_REG_POWER_ON_DELAY_TIME, 
0x0);
+   if (ret) {
+   dev_err(sy7636a->dev, "Failed to initialize regulator: %d\n", 
ret);
+   return ret;
+   }
+
+   config.dev = >dev;
+   config.dev->of_node = sy7636a->dev->of_node;
+   config.driver_data = sy7636a;
+

[PATCH v5 2/5] mfd: sy7636a: Initial commit

2021-04-19 Thread Alistair Francis
Initial support for the Silergy SY7636A Power Management chip.

Signed-off-by: Alistair Francis 
---
v5:
 - Don't use regmap-irq

 drivers/mfd/Kconfig |  9 
 drivers/mfd/Makefile|  1 +
 drivers/mfd/sy7636a.c   | 82 +
 include/linux/mfd/sy7636a.h | 46 +
 4 files changed, 138 insertions(+)
 create mode 100644 drivers/mfd/sy7636a.c
 create mode 100644 include/linux/mfd/sy7636a.h

diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig
index b74efa469e90..9516ba932b5e 100644
--- a/drivers/mfd/Kconfig
+++ b/drivers/mfd/Kconfig
@@ -1351,6 +1351,15 @@ config MFD_SYSCON
  Select this option to enable accessing system control registers
  via regmap.
 
+config MFD_SY7636A
+   tristate "Silergy SY7636A Power Management chip"
+   select MFD_CORE
+   select REGMAP_I2C
+   depends on I2C
+   help
+ Select this option to enable support for the Silergy SY7636A
+ Power Management chip.
+
 config MFD_DAVINCI_VOICECODEC
tristate
select MFD_CORE
diff --git a/drivers/mfd/Makefile b/drivers/mfd/Makefile
index 834f5463af28..5bfa0d6e5dc5 100644
--- a/drivers/mfd/Makefile
+++ b/drivers/mfd/Makefile
@@ -265,6 +265,7 @@ obj-$(CONFIG_MFD_STMFX) += stmfx.o
 obj-$(CONFIG_MFD_KHADAS_MCU)   += khadas-mcu.o
 obj-$(CONFIG_MFD_ACER_A500_EC) += acer-ec-a500.o
 
+obj-$(CONFIG_MFD_SY7636A)  += sy7636a.o
 obj-$(CONFIG_SGI_MFD_IOC3) += ioc3.o
 obj-$(CONFIG_MFD_SIMPLE_MFD_I2C)   += simple-mfd-i2c.o
 obj-$(CONFIG_MFD_INTEL_M10_BMC)   += intel-m10-bmc.o
diff --git a/drivers/mfd/sy7636a.c b/drivers/mfd/sy7636a.c
new file mode 100644
index ..e08f29ea63f8
--- /dev/null
+++ b/drivers/mfd/sy7636a.c
@@ -0,0 +1,82 @@
+// SPDX-License-Identifier: GPL-2.0+
+//
+// MFD parent driver for SY7636A chip
+//
+// Copyright (C) 2021 reMarkable AS - http://www.remarkable.com/
+//
+// Authors: Lars Ivar Miljeteig 
+//  Alistair Francis 
+//
+// Based on the lp87565 driver by Keerthy 
+
+#include 
+#include 
+#include 
+#include 
+
+#include 
+
+static const struct regmap_config sy7636a_regmap_config = {
+   .reg_bits = 8,
+   .val_bits = 8,
+};
+
+static const struct mfd_cell sy7636a_cells[] = {
+   { .name = "sy7636a-regulator", },
+   { .name = "sy7636a-temperature", },
+   { .name = "sy7636a-thermal", },
+};
+
+static const struct of_device_id of_sy7636a_match_table[] = {
+   { .compatible = "silergy,sy7636a", },
+   {}
+};
+MODULE_DEVICE_TABLE(of, of_sy7636a_match_table);
+
+static int sy7636a_probe(struct i2c_client *client,
+const struct i2c_device_id *ids)
+{
+   struct sy7636a *sy7636a;
+   int ret;
+
+   sy7636a = devm_kzalloc(>dev, sizeof(*sy7636a), GFP_KERNEL);
+   if (!sy7636a)
+   return -ENOMEM;
+
+   sy7636a->dev = >dev;
+
+   sy7636a->regmap = devm_regmap_init_i2c(client, _regmap_config);
+   if (IS_ERR(sy7636a->regmap)) {
+   ret = PTR_ERR(sy7636a->regmap);
+   dev_err(sy7636a->dev,
+   "Failed to initialize register map: %d\n", ret);
+   return ret;
+   }
+
+   i2c_set_clientdata(client, sy7636a);
+
+   ret = devm_mfd_add_devices(sy7636a->dev, PLATFORM_DEVID_AUTO,
+   sy7636a_cells, 
ARRAY_SIZE(sy7636a_cells),
+   NULL, 0, NULL);
+   return 0;
+}
+
+static const struct i2c_device_id sy7636a_id_table[] = {
+   { "sy7636a", 0 },
+   { },
+};
+MODULE_DEVICE_TABLE(i2c, sy7636a_id_table);
+
+static struct i2c_driver sy7636a_driver = {
+   .driver = {
+   .name   = "sy7636a",
+   .of_match_table = of_sy7636a_match_table,
+   },
+   .probe = sy7636a_probe,
+   .id_table = sy7636a_id_table,
+};
+module_i2c_driver(sy7636a_driver);
+
+MODULE_AUTHOR("Lars Ivar Miljeteig ");
+MODULE_DESCRIPTION("Silergy SY7636A Multi-Function Device Driver");
+MODULE_LICENSE("GPL v2");
diff --git a/include/linux/mfd/sy7636a.h b/include/linux/mfd/sy7636a.h
new file mode 100644
index ..43b0db0f8e6d
--- /dev/null
+++ b/include/linux/mfd/sy7636a.h
@@ -0,0 +1,46 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+/*
+ * Functions to access SY3686A power management chip.
+ *
+ * Copyright (C) 2021 reMarkable AS - http://www.remarkable.com/
+ */
+
+#ifndef __MFD_SY7636A_H
+#define __MFD_SY7636A_H
+
+#include 
+#include 
+#include 
+#include 
+
+#define SY7636A_REG_OPERATION_MODE_CRL 0x00
+#define SY7636A_OPERATION_MODE_CRL_VCOMCTL BIT(6)
+#define SY7636A_OPERATION_MODE_CRL_ONOFF   BIT(7)
+#define SY7636A_REG_VCOM_ADJUST_CTRL_L 0x01
+#define SY7636A_REG_VCOM_ADJUST_CTRL_H 0x02
+#define SY7636A_REG_VCOM_ADJUST_CTRL_MASK  0x01ff
+#define SY

[PATCH v5 1/5] dt-bindings: mfd: Initial commit of silergy,sy7636a.yaml

2021-04-19 Thread Alistair Francis
Initial support for the Silergy SY7636A Power Management chip
and regulator.

Signed-off-by: Alistair Francis 
---
v5:
 - Improve the documentation

 .../bindings/mfd/silergy,sy7636a.yaml | 70 +++
 1 file changed, 70 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/mfd/silergy,sy7636a.yaml

diff --git a/Documentation/devicetree/bindings/mfd/silergy,sy7636a.yaml 
b/Documentation/devicetree/bindings/mfd/silergy,sy7636a.yaml
new file mode 100644
index ..83050c36acaf
--- /dev/null
+++ b/Documentation/devicetree/bindings/mfd/silergy,sy7636a.yaml
@@ -0,0 +1,70 @@
+# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/mfd/silergy,sy7636a.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: silergy sy7636a PMIC
+
+maintainers:
+  - Alistair Francis 
+
+properties:
+  compatible:
+const: silergy,sy7636a
+
+  reg:
+maxItems: 1
+
+  '#thermal-sensor-cells':
+const: 0
+
+  epd-pwr-good-gpios:
+description:
+  Specifying the power good GPIOs. As defined in bindings/gpio.txt.
+maxItems: 1
+
+  regulators:
+type: object
+
+properties:
+  compatible:
+const: silergy,sy7636a-regulator
+  $ref: /schemas/regulator/regulator.yaml#
+
+  regulator-name:
+const: "vcom"
+
+  additionalProperties: false
+
+required:
+  - compatible
+  - reg
+  - '#thermal-sensor-cells'
+
+additionalProperties: false
+
+examples:
+  - |
+i2c {
+  #address-cells = <1>;
+  #size-cells = <0>;
+
+  pmic@62 {
+compatible = "silergy,sy7636a";
+reg = <0x62>;
+status = "okay";
+pinctrl-names = "default";
+pinctrl-0 = <_epdpmic>;
+#thermal-sensor-cells = <0>;
+
+regulators {
+  compatible = "silergy,sy7636a-regulator";
+  reg_epdpmic: vcom {
+regulator-name = "vcom";
+regulator-boot-on;
+  };
+};
+  };
+};
+...
-- 
2.31.1



[PATCH] ARM: imx7d-remarkable2.dts: Add WiFi support

2021-04-19 Thread Alistair Francis
Signed-off-by: Alistair Francis 
---
 arch/arm/boot/dts/imx7d-remarkable2.dts | 91 +
 1 file changed, 91 insertions(+)

diff --git a/arch/arm/boot/dts/imx7d-remarkable2.dts 
b/arch/arm/boot/dts/imx7d-remarkable2.dts
index 8cbae656395c..c3dda2b92fe6 100644
--- a/arch/arm/boot/dts/imx7d-remarkable2.dts
+++ b/arch/arm/boot/dts/imx7d-remarkable2.dts
@@ -21,6 +21,27 @@ memory@8000 {
device_type = "memory";
reg = <0x8000 0x4000>;
};
+
+   reg_brcm: regulator-brcm {
+   compatible = "regulator-fixed";
+   regulator-name = "brcm_reg";
+   regulator-min-microvolt = <330>;
+   regulator-max-microvolt = <330>;
+   pinctrl-names = "default";
+   pinctrl-0 = <_brcm_reg>;
+   gpio = < 13 GPIO_ACTIVE_HIGH>;
+   enable-active-high;
+   startup-delay-us = <150>;
+   };
+
+   wifi_pwrseq: wifi_pwrseq {
+   compatible = "mmc-pwrseq-simple";
+   pinctrl-names = "default";
+   pinctrl-0 = <_wifi>;
+   reset-gpios = < 9 GPIO_ACTIVE_LOW>;
+   clocks = < IMX7D_CLKO2_ROOT_DIV>;
+   clock-names = "ext_clock";
+   };
 };
 
  {
@@ -56,6 +77,27 @@  {
status = "okay";
 };
 
+ {
+   #address-cells = <1>;
+   #size-cells = <0>;
+   pinctrl-names = "default", "state_100mhz", "sleep";
+   pinctrl-0 = <_usdhc2>;
+   pinctrl-1 = <_usdhc2_100mhz>;
+   pinctrl-2 = <_usdhc2>;
+   mmc-pwrseq = <_pwrseq>;
+   vmmc-supply = <_brcm>;
+   bus-width = <4>;
+   non-removable;
+   keep-power-in-suspend;
+   cap-power-off-card;
+   status = "okay";
+
+   brcmf: bcrmf@1 {
+   reg = <1>;
+   compatible = "brcm,bcm4329-fmac";
+   };
+};
+
  {
pinctrl-names = "default", "state_100mhz", "state_200mhz", "sleep";
pinctrl-0 = <_usdhc3>;
@@ -76,6 +118,13 @@  {
 };
 
  {
+   pinctrl_brcm_reg: brcmreggrp {
+   fsl,pins = <
+   /* WIFI_PWR_EN */
+   MX7D_PAD_SAI1_TX_BCLK__GPIO6_IO13   0x14
+   >;
+   };
+
pinctrl_uart1: uart1grp {
fsl,pins = <
MX7D_PAD_UART1_TX_DATA__UART1_DCE_TX0x79
@@ -90,6 +139,39 @@ MX7D_PAD_EPDC_DATA08__UART6_DCE_RX  0x79
>;
};
 
+   pinctrl_usdhc2: usdhc2grp {
+   fsl,pins = <
+   MX7D_PAD_SD2_CMD__SD2_CMD   0x59
+   MX7D_PAD_SD2_CLK__SD2_CLK   0x19
+   MX7D_PAD_SD2_DATA0__SD2_DATA0   0x59
+   MX7D_PAD_SD2_DATA1__SD2_DATA1   0x59
+   MX7D_PAD_SD2_DATA2__SD2_DATA2   0x59
+   MX7D_PAD_SD2_DATA3__SD2_DATA3   0x59
+   >;
+   };
+
+   pinctrl_usdhc2_100mhz: usdhc2grp_100mhz {
+   fsl,pins = <
+   MX7D_PAD_SD2_CMD__SD2_CMD   0x5a
+   MX7D_PAD_SD2_CLK__SD2_CLK   0x1a
+   MX7D_PAD_SD2_DATA0__SD2_DATA0   0x5a
+   MX7D_PAD_SD2_DATA1__SD2_DATA1   0x5a
+   MX7D_PAD_SD2_DATA2__SD2_DATA2   0x5a
+   MX7D_PAD_SD2_DATA3__SD2_DATA3   0x5a
+   >;
+   };
+
+   pinctrl_usdhc2_200mhz: usdhc2grp_200mhz {
+   fsl,pins = <
+   MX7D_PAD_SD2_CMD__SD2_CMD   0x5b
+   MX7D_PAD_SD2_CLK__SD2_CLK   0x1b
+   MX7D_PAD_SD2_DATA0__SD2_DATA0   0x5b
+   MX7D_PAD_SD2_DATA1__SD2_DATA1   0x5b
+   MX7D_PAD_SD2_DATA2__SD2_DATA2   0x5b
+   MX7D_PAD_SD2_DATA3__SD2_DATA3   0x5b
+   >;
+   };
+
pinctrl_usdhc3: usdhc3grp {
fsl,pins = <
MX7D_PAD_SD3_CMD__SD3_CMD   0x59
@@ -143,4 +225,13 @@ pinctrl_wdog: wdoggrp {
MX7D_PAD_ENET1_COL__WDOG1_WDOG_ANY  0x74
>;
};
+
+   pinctrl_wifi: wifigrp {
+   fsl,pins = <
+   /* WiFi Reg On */
+   MX7D_PAD_SD2_CD_B__GPIO5_IO90x0014
+   /* WiFi Sleep 32k */
+   MX7D_PAD_SD1_WP__CCM_CLKO2  0x0014
+   >;
+   };
 };
-- 
2.31.1



[PATCH v5 9/9] ARM: dts: imx7d: remarkable2: add wacom digitizer device

2021-04-19 Thread Alistair Francis
Enable the wacom_i2c touchscreen for the reMarkable2.

Signed-off-by: Alistair Francis 
---
 arch/arm/boot/dts/imx7d-remarkable2.dts | 61 +
 1 file changed, 61 insertions(+)

diff --git a/arch/arm/boot/dts/imx7d-remarkable2.dts 
b/arch/arm/boot/dts/imx7d-remarkable2.dts
index c3dda2b92fe6..ea1dd41023f9 100644
--- a/arch/arm/boot/dts/imx7d-remarkable2.dts
+++ b/arch/arm/boot/dts/imx7d-remarkable2.dts
@@ -34,6 +34,19 @@ reg_brcm: regulator-brcm {
startup-delay-us = <150>;
};
 
+   reg_digitizer: regulator-digitizer {
+   compatible = "regulator-fixed";
+   regulator-name = "VDD_3V3_DIGITIZER";
+   regulator-min-microvolt = <330>;
+   regulator-max-microvolt = <330>;
+   pinctrl-names = "default", "sleep";
+   pinctrl-0 = <_digitizer_reg>;
+   pinctrl-1 = <_digitizer_reg>;
+   gpio = < 6 GPIO_ACTIVE_HIGH>;
+   enable-active-high;
+   startup-delay-us = <10>; /* 100 ms */
+   };
+
wifi_pwrseq: wifi_pwrseq {
compatible = "mmc-pwrseq-simple";
pinctrl-names = "default";
@@ -51,6 +64,28 @@  {
assigned-clock-rates = <0>, <32768>;
 };
 
+ {
+   clock-frequency = <40>;
+   pinctrl-names = "default";
+   pinctrl-0 = <_i2c1>;
+   status = "okay";
+
+   wacom_digitizer: digitizer@9 {
+   compatible = "wacom,i2c-30";
+   reg = <0x09>;
+   pinctrl-names = "default";
+   pinctrl-0 = <_wacom>;
+   interrupt-parent = <>;
+   interrupts = <1 IRQ_TYPE_EDGE_FALLING>;
+   flip-tilt-x;
+   flip-tilt-y;
+   flip-pos-x;
+   flip-pos-y;
+   flip-distance;
+   vdd-supply = <_digitizer>;
+   };
+};
+
 _pwrkey {
status = "okay";
 };
@@ -117,6 +152,25 @@  {
fsl,ext-reset-output;
 };
 
+_lpsr {
+   pinctrl_digitizer_reg: digitizerreggrp {
+   fsl,pins = <
+   /* DIGITIZER_PWR_EN */
+   MX7D_PAD_LPSR_GPIO1_IO06__GPIO1_IO6 0x14
+   >;
+   };
+
+   pinctrl_wacom: wacomgrp {
+   fsl,pins = <
+   /*MX7D_PAD_LPSR_GPIO1_IO05__GPIO1_IO5   0x0014 /* 
FWE */
+   MX7D_PAD_LPSR_GPIO1_IO04__GPIO1_IO4 0x0074 /* 
PDCTB */
+   MX7D_PAD_LPSR_GPIO1_IO01__GPIO1_IO1 0x0034 /* 
WACOM INT */
+   /*MX7D_PAD_LPSR_GPIO1_IO06__GPIO1_IO6   0x0014 /* 
WACOM PWR ENABLE */
+   /*MX7D_PAD_LPSR_GPIO1_IO00__GPIO1_IO0   0x0074 /* 
WACOM RESET */
+   >;
+   };
+};
+
  {
pinctrl_brcm_reg: brcmreggrp {
fsl,pins = <
@@ -125,6 +179,13 @@ MX7D_PAD_SAI1_TX_BCLK__GPIO6_IO13  0x14
>;
};
 
+   pinctrl_i2c1: i2c1grp {
+   fsl,pins = <
+   MX7D_PAD_I2C1_SDA__I2C1_SDA 0x407f
+   MX7D_PAD_I2C1_SCL__I2C1_SCL 0x407f
+   >;
+   };
+
pinctrl_uart1: uart1grp {
fsl,pins = <
MX7D_PAD_UART1_TX_DATA__UART1_DCE_TX0x79
-- 
2.31.1



[PATCH v5 8/9] ARM: imx_v6_v7_defconfig: Enable Wacom I2C

2021-04-19 Thread Alistair Francis
Enable the Wacom I2C in the imx defconfig as it is used by the
reMarkable2 tablet.

Signed-off-by: Alistair Francis 
---
 arch/arm/configs/imx_v6_v7_defconfig | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/arm/configs/imx_v6_v7_defconfig 
b/arch/arm/configs/imx_v6_v7_defconfig
index 70928cc48939..cd80e85d37cf 100644
--- a/arch/arm/configs/imx_v6_v7_defconfig
+++ b/arch/arm/configs/imx_v6_v7_defconfig
@@ -174,6 +174,7 @@ CONFIG_TOUCHSCREEN_DA9052=y
 CONFIG_TOUCHSCREEN_EGALAX=y
 CONFIG_TOUCHSCREEN_GOODIX=y
 CONFIG_TOUCHSCREEN_ILI210X=y
+CONFIG_TOUCHSCREEN_WACOM_I2C=y
 CONFIG_TOUCHSCREEN_MAX11801=y
 CONFIG_TOUCHSCREEN_IMX6UL_TSC=y
 CONFIG_TOUCHSCREEN_EDT_FT5X06=y
-- 
2.31.1



[PATCH v5 5/9] Input: wacom_i2c - Add support for distance and tilt x/y

2021-04-19 Thread Alistair Francis
This is based on the out of tree rM2 driver.

Signed-off-by: Alistair Francis 
---
v5:
 - Check the firmware version

 drivers/input/touchscreen/wacom_i2c.c | 34 +--
 1 file changed, 32 insertions(+), 2 deletions(-)

diff --git a/drivers/input/touchscreen/wacom_i2c.c 
b/drivers/input/touchscreen/wacom_i2c.c
index 28290724b3da..e0a69e63204d 100644
--- a/drivers/input/touchscreen/wacom_i2c.c
+++ b/drivers/input/touchscreen/wacom_i2c.c
@@ -22,12 +22,18 @@
 #define WACOM_CMD_QUERY3   0x02
 #define WACOM_CMD_THROW0   0x05
 #define WACOM_CMD_THROW1   0x00
-#define WACOM_QUERY_SIZE   19
+#define WACOM_QUERY_SIZE   22
+
+#define WACOM_DISTANCE_TILT_VERSION0x30
 
 struct wacom_features {
int x_max;
int y_max;
int pressure_max;
+   int distance_max;
+   int distance_physical_max;
+   int tilt_x_max;
+   int tilt_y_max;
char fw_version;
 };
 
@@ -79,6 +85,17 @@ static int wacom_query_device(struct i2c_client *client,
features->y_max = get_unaligned_le16([5]);
features->pressure_max = get_unaligned_le16([11]);
features->fw_version = get_unaligned_le16([13]);
+   if (features->fw_version >= WACOM_DISTANCE_TILT_VERSION) {
+   features->distance_max = data[15];
+   features->distance_physical_max = data[16];
+   features->tilt_x_max = get_unaligned_le16([17]);
+   features->tilt_y_max = get_unaligned_le16([19]);
+   } else {
+   features->distance_max = -1;
+   features->distance_physical_max = -1;
+   features->tilt_x_max = -1;
+   features->tilt_y_max = -1;
+   }
 
dev_dbg(>dev,
"x_max:%d, y_max:%d, pressure:%d, fw:%d\n",
@@ -95,6 +112,7 @@ static irqreturn_t wacom_i2c_irq(int irq, void *dev_id)
u8 *data = wac_i2c->data;
unsigned int x, y, pressure;
unsigned char tsw, f1, f2, ers;
+   short tilt_x, tilt_y, distance;
int error;
 
error = i2c_master_recv(wac_i2c->client,
@@ -109,6 +127,11 @@ static irqreturn_t wacom_i2c_irq(int irq, void *dev_id)
x = le16_to_cpup((__le16 *)[4]);
y = le16_to_cpup((__le16 *)[6]);
pressure = le16_to_cpup((__le16 *)[8]);
+   distance = data[10];
+
+   /* Signed */
+   tilt_x = le16_to_cpup((__le16 *)[11]);
+   tilt_y = le16_to_cpup((__le16 *)[13]);
 
if (!wac_i2c->prox)
wac_i2c->tool = (data[3] & 0x0c) ?
@@ -123,6 +146,9 @@ static irqreturn_t wacom_i2c_irq(int irq, void *dev_id)
input_report_key(input, BTN_STYLUS, f1);
input_report_key(input, BTN_STYLUS2, f2);
input_report_abs(input, ABS_PRESSURE, pressure);
+   input_report_abs(input, ABS_DISTANCE, distance);
+   input_report_abs(input, ABS_TILT_X, tilt_x);
+   input_report_abs(input, ABS_TILT_Y, tilt_y);
input_sync(input);
 
 out:
@@ -195,7 +221,11 @@ static int wacom_i2c_probe(struct i2c_client *client,
input_set_abs_params(input, ABS_Y, 0, features.y_max, 0, 0);
input_set_abs_params(input, ABS_PRESSURE,
 0, features.pressure_max, 0, 0);
-
+   input_set_abs_params(input, ABS_DISTANCE, 0, features.distance_max, 0, 
0);
+   input_set_abs_params(input, ABS_TILT_X, -features.tilt_x_max,
+features.tilt_x_max, 0, 0);
+   input_set_abs_params(input, ABS_TILT_Y, -features.tilt_y_max,
+features.tilt_y_max, 0, 0);
input_set_drvdata(input, wac_i2c);
 
error = request_threaded_irq(client->irq, NULL, wacom_i2c_irq,
-- 
2.31.1



[PATCH v5 6/9] Input: wacom_i2c - Clean up the query device fields

2021-04-19 Thread Alistair Francis
Improve the query device fields to be more verbose.

Signed-off-by: Alistair Francis 
---
 drivers/input/touchscreen/wacom_i2c.c | 64 ++-
 1 file changed, 44 insertions(+), 20 deletions(-)

diff --git a/drivers/input/touchscreen/wacom_i2c.c 
b/drivers/input/touchscreen/wacom_i2c.c
index e0a69e63204d..26881149d509 100644
--- a/drivers/input/touchscreen/wacom_i2c.c
+++ b/drivers/input/touchscreen/wacom_i2c.c
@@ -13,15 +13,32 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 
-#define WACOM_CMD_QUERY0   0x04
-#define WACOM_CMD_QUERY1   0x00
-#define WACOM_CMD_QUERY2   0x33
-#define WACOM_CMD_QUERY3   0x02
-#define WACOM_CMD_THROW0   0x05
-#define WACOM_CMD_THROW1   0x00
+// Registers
+#define WACOM_COMMAND_LSB   0x04
+#define WACOM_COMMAND_MSB   0x00
+
+#define WACOM_DATA_LSB  0x05
+#define WACOM_DATA_MSB  0x00
+
+// Report types
+#define REPORT_FEATURE  0x30
+
+// Requests / operations
+#define OPCODE_GET_REPORT   0x02
+
+// Power settings
+#define POWER_ON0x00
+#define POWER_SLEEP 0x01
+
+// Input report ids
+#define WACOM_PEN_DATA_REPORT   2
+#define WACOM_SHINONOME_REPORT  26
+
+#define WACOM_QUERY_REPORT 3
 #define WACOM_QUERY_SIZE   22
 
 #define WACOM_DISTANCE_TILT_VERSION0x30
@@ -50,27 +67,30 @@ static int wacom_query_device(struct i2c_client *client,
  struct wacom_features *features)
 {
int ret;
-   u8 cmd1[] = { WACOM_CMD_QUERY0, WACOM_CMD_QUERY1,
-   WACOM_CMD_QUERY2, WACOM_CMD_QUERY3 };
-   u8 cmd2[] = { WACOM_CMD_THROW0, WACOM_CMD_THROW1 };
u8 data[WACOM_QUERY_SIZE];
+
+   u8 get_query_data_cmd[] = {
+   WACOM_COMMAND_LSB,
+   WACOM_COMMAND_MSB,
+   REPORT_FEATURE | WACOM_QUERY_REPORT,
+   OPCODE_GET_REPORT,
+   WACOM_DATA_LSB,
+   WACOM_DATA_MSB,
+   };
+
struct i2c_msg msgs[] = {
+   // Request reading of feature ReportID: 3 (Pen Query Data)
{
.addr = client->addr,
.flags = 0,
-   .len = sizeof(cmd1),
-   .buf = cmd1,
-   },
-   {
-   .addr = client->addr,
-   .flags = 0,
-   .len = sizeof(cmd2),
-   .buf = cmd2,
+   .len = sizeof(get_query_data_cmd),
+   .buf = get_query_data_cmd,
},
+   // Read 21 bytes
{
.addr = client->addr,
.flags = I2C_M_RD,
-   .len = sizeof(data),
+   .len = WACOM_QUERY_SIZE - 1,
.buf = data,
},
};
@@ -98,9 +118,13 @@ static int wacom_query_device(struct i2c_client *client,
}
 
dev_dbg(>dev,
-   "x_max:%d, y_max:%d, pressure:%d, fw:%d\n",
+   "x_max:%d, y_max:%d, pressure:%d, fw:%d, "
+   "distance: %d, phys distance: %d, "
+   "tilt_x_max: %d, tilt_y_max: %d\n",
features->x_max, features->y_max,
-   features->pressure_max, features->fw_version);
+   features->pressure_max, features->fw_version,
+   features->distance_max, features->distance_physical_max,
+   features->tilt_x_max, features->tilt_y_max);
 
return 0;
 }
-- 
2.31.1



[PATCH v5 7/9] Input: wacom_i2c - Add support for vdd regulator

2021-04-19 Thread Alistair Francis
Add support for a VDD regulator. This allows the kernel to prove the
Wacom-I2C device on the rM2.

Signed-off-by: Alistair Francis 
---
 drivers/input/touchscreen/wacom_i2c.c | 18 ++
 1 file changed, 18 insertions(+)

diff --git a/drivers/input/touchscreen/wacom_i2c.c 
b/drivers/input/touchscreen/wacom_i2c.c
index 26881149d509..a5963d9e1194 100644
--- a/drivers/input/touchscreen/wacom_i2c.c
+++ b/drivers/input/touchscreen/wacom_i2c.c
@@ -13,6 +13,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -58,6 +59,7 @@ struct wacom_i2c {
struct i2c_client *client;
struct input_dev *input;
struct touchscreen_properties props;
+   struct regulator *vdd;
u8 data[WACOM_QUERY_SIZE];
bool prox;
int tool;
@@ -221,6 +223,20 @@ static int wacom_i2c_probe(struct i2c_client *client,
goto err_free_mem;
}
 
+   wac_i2c->vdd = regulator_get(>dev, "vdd");
+   if (IS_ERR(wac_i2c->vdd)) {
+   error = PTR_ERR(wac_i2c->vdd);
+   kfree(wac_i2c);
+   return error;
+   }
+
+   error = regulator_enable(wac_i2c->vdd);
+   if (error) {
+   regulator_put(wac_i2c->vdd);
+   kfree(wac_i2c);
+   return error;
+   }
+
wac_i2c->client = client;
wac_i2c->input = input;
 
@@ -277,6 +293,8 @@ static int wacom_i2c_probe(struct i2c_client *client,
 err_free_irq:
free_irq(client->irq, wac_i2c);
 err_free_mem:
+   regulator_disable(wac_i2c->vdd);
+   regulator_put(wac_i2c->vdd);
input_free_device(input);
kfree(wac_i2c);
 
-- 
2.31.1



[PATCH v5 3/9] Input: wacom_i2c - Add device tree support to wacom_i2c

2021-04-19 Thread Alistair Francis
Allow the wacom-i2c device to be exposed via device tree.

Signed-off-by: Alistair Francis 
---
 drivers/input/touchscreen/wacom_i2c.c | 8 
 1 file changed, 8 insertions(+)

diff --git a/drivers/input/touchscreen/wacom_i2c.c 
b/drivers/input/touchscreen/wacom_i2c.c
index 1afc6bde2891..dd3fc54d3825 100644
--- a/drivers/input/touchscreen/wacom_i2c.c
+++ b/drivers/input/touchscreen/wacom_i2c.c
@@ -12,6 +12,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 
 #define WACOM_CMD_QUERY0   0x04
@@ -262,10 +263,17 @@ static const struct i2c_device_id wacom_i2c_id[] = {
 };
 MODULE_DEVICE_TABLE(i2c, wacom_i2c_id);
 
+static const struct of_device_id wacom_i2c_of_match_table[] = {
+   { .compatible = "wacom,i2c-30" },
+   {}
+};
+MODULE_DEVICE_TABLE(of, wacom_i2c_of_match_table);
+
 static struct i2c_driver wacom_i2c_driver = {
.driver = {
.name   = "wacom_i2c",
.pm = _i2c_pm,
+   .of_match_table = wacom_i2c_of_match_table,
},
 
.probe  = wacom_i2c_probe,
-- 
2.31.1



[PATCH v5 4/9] Input: wacom_i2c - Add touchscren properties

2021-04-19 Thread Alistair Francis
Connect touchscreen properties to the wacom_i2c.

Signed-off-by: Alistair Francis 
---
 drivers/input/touchscreen/wacom_i2c.c | 7 +--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/input/touchscreen/wacom_i2c.c 
b/drivers/input/touchscreen/wacom_i2c.c
index dd3fc54d3825..28290724b3da 100644
--- a/drivers/input/touchscreen/wacom_i2c.c
+++ b/drivers/input/touchscreen/wacom_i2c.c
@@ -11,6 +11,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -33,6 +34,7 @@ struct wacom_features {
 struct wacom_i2c {
struct i2c_client *client;
struct input_dev *input;
+   struct touchscreen_properties props;
u8 data[WACOM_QUERY_SIZE];
bool prox;
int tool;
@@ -114,12 +116,12 @@ static irqreturn_t wacom_i2c_irq(int irq, void *dev_id)
 
wac_i2c->prox = data[3] & 0x20;
 
+   touchscreen_report_pos(input, _i2c->props, features.x_max,
+  features.y_max, true);
input_report_key(input, BTN_TOUCH, tsw || ers);
input_report_key(input, wac_i2c->tool, wac_i2c->prox);
input_report_key(input, BTN_STYLUS, f1);
input_report_key(input, BTN_STYLUS2, f2);
-   input_report_abs(input, ABS_X, x);
-   input_report_abs(input, ABS_Y, y);
input_report_abs(input, ABS_PRESSURE, pressure);
input_sync(input);
 
@@ -188,6 +190,7 @@ static int wacom_i2c_probe(struct i2c_client *client,
__set_bit(BTN_STYLUS2, input->keybit);
__set_bit(BTN_TOUCH, input->keybit);
 
+   touchscreen_parse_properties(input, true, _i2c->props);
input_set_abs_params(input, ABS_X, 0, features.x_max, 0, 0);
input_set_abs_params(input, ABS_Y, 0, features.y_max, 0, 0);
input_set_abs_params(input, ABS_PRESSURE,
-- 
2.31.1



[PATCH v5 1/9] dt-bindings: Add Wacom to vendor bindings

2021-04-19 Thread Alistair Francis
Signed-off-by: Alistair Francis 
---
 Documentation/devicetree/bindings/vendor-prefixes.yaml | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/Documentation/devicetree/bindings/vendor-prefixes.yaml 
b/Documentation/devicetree/bindings/vendor-prefixes.yaml
index a8e1e8d2ef20..996f4de2fff5 100644
--- a/Documentation/devicetree/bindings/vendor-prefixes.yaml
+++ b/Documentation/devicetree/bindings/vendor-prefixes.yaml
@@ -1216,6 +1216,8 @@ patternProperties:
 description: Vision Optical Technology Co., Ltd.
   "^vxt,.*":
 description: VXT Ltd
+  "^wacom,.*":
+description: Wacom Co., Ltd
   "^wand,.*":
 description: Wandbord (Technexion)
   "^waveshare,.*":
-- 
2.31.1



[PATCH v5 2/9] dt-bindings: touchscreen: Initial commit of wacom,generic

2021-04-19 Thread Alistair Francis
Signed-off-by: Alistair Francis 
---
 .../input/touchscreen/wacom,generic.yaml  | 48 +++
 1 file changed, 48 insertions(+)
 create mode 100644 
Documentation/devicetree/bindings/input/touchscreen/wacom,generic.yaml

diff --git 
a/Documentation/devicetree/bindings/input/touchscreen/wacom,generic.yaml 
b/Documentation/devicetree/bindings/input/touchscreen/wacom,generic.yaml
new file mode 100644
index ..19bbfc55ed76
--- /dev/null
+++ b/Documentation/devicetree/bindings/input/touchscreen/wacom,generic.yaml
@@ -0,0 +1,48 @@
+# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/input/touchscreen/wacom,generic.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Wacom I2C Controller
+
+maintainers:
+  - Alistair Francis 
+
+allOf:
+  - $ref: touchscreen.yaml#
+
+properties:
+  compatible:
+const: wacom,generic
+
+  reg:
+maxItems: 1
+
+  interrupts:
+maxItems: 1
+
+  vdd-supply:
+maxItems: 1
+
+required:
+  - compatible
+  - reg
+  - interrupts
+
+additionalProperties: false
+
+examples:
+  - |
+#include "dt-bindings/interrupt-controller/irq.h"
+i2c {
+#address-cells = <1>;
+#size-cells = <0>;
+digitiser@9 {
+compatible = "wacom,generic";
+reg = <0x9>;
+interrupt-parent = <>;
+interrupts = <9 IRQ_TYPE_LEVEL_LOW>;
+vdd-supply = <_touch>;
+};
+};
-- 
2.31.1



Re: [PATCH v4 04/10] Input: wacom_i2c - Add touchscren properties

2021-03-29 Thread Alistair Francis
 On Mon, Mar 29, 2021 at 3:08 PM Dmitry Torokhov
 wrote:
>
> On Thu, Mar 25, 2021 at 09:52:24PM -0400, Alistair Francis wrote:
> > Connect touchscreen properties to the wacom_i2c.
> >
> > Signed-off-by: Alistair Francis 
> > ---
> > v4:
> >  - Add touchscreen_report_pos() as well
> >
> >  drivers/input/touchscreen/wacom_i2c.c | 5 +
> >  1 file changed, 5 insertions(+)
> >
> > diff --git a/drivers/input/touchscreen/wacom_i2c.c 
> > b/drivers/input/touchscreen/wacom_i2c.c
> > index eada68770671..ee1829dd35f4 100644
> > --- a/drivers/input/touchscreen/wacom_i2c.c
> > +++ b/drivers/input/touchscreen/wacom_i2c.c
> > @@ -11,6 +11,7 @@
> >  #include 
> >  #include 
> >  #include 
> > +#include 
> >  #include 
> >  #include 
> >  #include 
> > @@ -33,6 +34,7 @@ struct wacom_features {
> >  struct wacom_i2c {
> >   struct i2c_client *client;
> >   struct input_dev *input;
> > + struct touchscreen_properties props;
> >   u8 data[WACOM_QUERY_SIZE];
> >   bool prox;
> >   int tool;
> > @@ -188,6 +190,9 @@ static int wacom_i2c_probe(struct i2c_client *client,
> >   __set_bit(BTN_STYLUS2, input->keybit);
> >   __set_bit(BTN_TOUCH, input->keybit);
> >
> > + touchscreen_parse_properties(input, true, _i2c->props);
> > + touchscreen_report_pos(input, _i2c->props, features.x_max,
> > +features.y_max, true);
>
> ??? This goes into wacom_i2c_irq() where it previously used
> input_report_abs() for X and Y so that transformations (swap, mirrot)
> requested via device properties are applied to the coordinates.

Ah sorry. I misunderstood what touchscreen_report_pos() does (and
didn't read it).

Looking at the actual code it seems that I need to remove

input_report_abs(input, ABS_Y, y);
input_report_abs(input, ABS_X, x);

from wacom_i2c_irq() and add touchscreen_report_pos() to wacom_i2c_irq() instead

I'll do that in the next version.

Alistair

>
> Thanks.
>
> --
> Dmitry


[PATCH v4 4/5] ARM: imx_v6_v7_defconfig: Enable silergy,sy7636a

2021-03-25 Thread Alistair Francis
Enable the silergy,sy7636a and silergy,sy7636a-regulator for the
reMarkable2.

Signed-off-by: Alistair Francis 
---
v3:
 - Change patch title
v2:
 - N/A

 arch/arm/configs/imx_v6_v7_defconfig | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/arch/arm/configs/imx_v6_v7_defconfig 
b/arch/arm/configs/imx_v6_v7_defconfig
index cd80e85d37cf..bafd1d7b4ad5 100644
--- a/arch/arm/configs/imx_v6_v7_defconfig
+++ b/arch/arm/configs/imx_v6_v7_defconfig
@@ -245,6 +245,7 @@ CONFIG_MFD_MC13XXX_I2C=y
 CONFIG_MFD_RN5T618=y
 CONFIG_MFD_STMPE=y
 CONFIG_REGULATOR=y
+CONFIG_MFD_SY7636A=y
 CONFIG_REGULATOR_FIXED_VOLTAGE=y
 CONFIG_REGULATOR_ANATOP=y
 CONFIG_REGULATOR_DA9052=y
@@ -255,6 +256,7 @@ CONFIG_REGULATOR_MC13783=y
 CONFIG_REGULATOR_MC13892=y
 CONFIG_REGULATOR_PFUZE100=y
 CONFIG_REGULATOR_RN5T618=y
+CONFIG_REGULATOR_SY7636A=y
 CONFIG_RC_CORE=y
 CONFIG_RC_DEVICES=y
 CONFIG_IR_GPIO_CIR=y
-- 
2.31.0



[PATCH v4 5/5] ARM: dts: imx7d: remarkable2: Enable silergy,sy7636a

2021-03-25 Thread Alistair Francis
Enable the silergy,sy7636a and silergy,sy7636a-regulator on the
reMarkable2.

Signed-off-by: Alistair Francis 
---
v3:
 - Change patch title
v2:
 - N/A

 arch/arm/boot/dts/imx7d-remarkable2.dts | 61 +
 1 file changed, 61 insertions(+)

diff --git a/arch/arm/boot/dts/imx7d-remarkable2.dts 
b/arch/arm/boot/dts/imx7d-remarkable2.dts
index 791ad55281cc..37834bc7fc72 100644
--- a/arch/arm/boot/dts/imx7d-remarkable2.dts
+++ b/arch/arm/boot/dts/imx7d-remarkable2.dts
@@ -22,6 +22,27 @@ memory@8000 {
reg = <0x8000 0x4000>;
};
 
+   thermal-zones {
+   epd-thermal {
+   thermal-sensors = <_pmic>;
+   polling-delay-passive = <3>;
+   polling-delay = <3>;
+   trips {
+   trip0 {
+   temperature = <49000>;
+   hysteresis = <2000>;
+   type = "passive";
+   };
+
+   trip1 {
+   temperature = <5>;
+   hysteresis = <2000>;
+   type = "critical";
+   };
+   };
+   };
+   };
+
reg_brcm: regulator-brcm {
compatible = "regulator-fixed";
regulator-name = "brcm_reg";
@@ -86,6 +107,32 @@ wacom_digitizer: digitizer@9 {
};
 };
 
+ {
+   clock-frequency = <10>;
+   pinctrl-names = "default", "sleep";
+   pinctrl-0 = <_i2c4>;
+   pinctrl-1 = <_i2c4>;
+   status = "okay";
+
+   epd_pmic: sy7636a@62 {
+   compatible = "silergy,sy7636a";
+   reg = <0x62>;
+   status = "okay";
+   pinctrl-names = "default";
+   pinctrl-0 = <_epdpmic>;
+   #thermal-sensor-cells = <0>;
+
+   epd-pwr-good-gpios = < 21 GPIO_ACTIVE_HIGH>;
+   regulators {
+   compatible = "silergy,sy7636a-regulator";
+   reg_epdpmic: vcom {
+   regulator-name = "vcom";
+   regulator-boot-on;
+   };
+   };
+   };
+};
+
 _pwrkey {
status = "okay";
 };
@@ -179,6 +226,13 @@ MX7D_PAD_SAI1_TX_BCLK__GPIO6_IO13  0x14
>;
};
 
+   pinctrl_epdpmic: epdpmicgrp {
+   fsl,pins = <
+   MX7D_PAD_SAI2_RX_DATA__GPIO6_IO21 0x0074
+   MX7D_PAD_ENET1_RGMII_TXC__GPIO7_IO11 0x0014
+   >;
+   };
+
pinctrl_i2c1: i2c1grp {
fsl,pins = <
MX7D_PAD_I2C1_SDA__I2C1_SDA 0x407f
@@ -186,6 +240,13 @@ MX7D_PAD_I2C1_SCL__I2C1_SCL0x407f
>;
};
 
+   pinctrl_i2c4: i2c4grp {
+   fsl,pins = <
+   MX7D_PAD_I2C4_SDA__I2C4_SDA 0x407f
+   MX7D_PAD_I2C4_SCL__I2C4_SCL 0x407f
+   >;
+   };
+
pinctrl_uart1: uart1grp {
fsl,pins = <
MX7D_PAD_UART1_TX_DATA__UART1_DCE_TX0x79
-- 
2.31.0



[PATCH v4 3/5] regulator: sy7636a: Initial commit

2021-03-25 Thread Alistair Francis
Initial support for the Silergy SY7636A-regulator Power Management chip.

Signed-off-by: Alistair Francis 
---
v3:
 - Move sysfs power from mfd to regulaator
 - Add ABI documentation
v2:
 - N/A
 .../testing/sysfs-driver-sy7636a-regulator|  21 ++
 drivers/regulator/Kconfig |   6 +
 drivers/regulator/Makefile|   1 +
 drivers/regulator/sy7636a-regulator.c | 354 ++
 include/linux/mfd/sy7636a.h   |   1 +
 5 files changed, 383 insertions(+)
 create mode 100644 Documentation/ABI/testing/sysfs-driver-sy7636a-regulator
 create mode 100644 drivers/regulator/sy7636a-regulator.c

diff --git a/Documentation/ABI/testing/sysfs-driver-sy7636a-regulator 
b/Documentation/ABI/testing/sysfs-driver-sy7636a-regulator
new file mode 100644
index ..ab534a8ea21a
--- /dev/null
+++ b/Documentation/ABI/testing/sysfs-driver-sy7636a-regulator
@@ -0,0 +1,21 @@
+What:  /sys/bus/regulator/drivers/sy7636a-regulator/state
+Date:  April 2021
+KernelVersion: 5.12
+Contact:   alist...@alistair23.me
+Description:
+   This file allows you to see the current power rail state.
+
+What:  /sys/bus/regulator/drivers/sy7636a-regulator/power_good
+Date:  April 2021
+KernelVersion: 5.12
+Contact:   alist...@alistair23.me
+Description:
+   This file allows you to see the current state of the regulator
+   as either ON or OFF.
+
+What:  /sys/bus/regulator/drivers/sy7636a-regulator/vcom
+Date:  April 2021
+KernelVersion: 5.12
+Contact:   alist...@alistair23.me
+Description:
+   This file allows you to see and set the current voltage in mV.
diff --git a/drivers/regulator/Kconfig b/drivers/regulator/Kconfig
index 77c43134bc9e..6d501ce921a8 100644
--- a/drivers/regulator/Kconfig
+++ b/drivers/regulator/Kconfig
@@ -1130,6 +1130,12 @@ config REGULATOR_STW481X_VMMC
  This driver supports the internal VMMC regulator in the STw481x
  PMIC chips.
 
+config REGULATOR_SY7636A
+   tristate "Silergy SY7636A voltage regulator"
+   depends on MFD_SY7636A
+   help
+ This driver supports Silergy SY3686A voltage regulator.
+
 config REGULATOR_SY8106A
tristate "Silergy SY8106A regulator"
depends on I2C && (OF || COMPILE_TEST)
diff --git a/drivers/regulator/Makefile b/drivers/regulator/Makefile
index 44d2f8bf4b74..5a981036a9f0 100644
--- a/drivers/regulator/Makefile
+++ b/drivers/regulator/Makefile
@@ -134,6 +134,7 @@ obj-$(CONFIG_REGULATOR_STM32_VREFBUF) += stm32-vrefbuf.o
 obj-$(CONFIG_REGULATOR_STM32_PWR) += stm32-pwr.o
 obj-$(CONFIG_REGULATOR_STPMIC1) += stpmic1_regulator.o
 obj-$(CONFIG_REGULATOR_STW481X_VMMC) += stw481x-vmmc.o
+obj-$(CONFIG_REGULATOR_SY7636A) += sy7636a-regulator.o
 obj-$(CONFIG_REGULATOR_SY8106A) += sy8106a-regulator.o
 obj-$(CONFIG_REGULATOR_SY8824X) += sy8824x.o
 obj-$(CONFIG_REGULATOR_SY8827N) += sy8827n.o
diff --git a/drivers/regulator/sy7636a-regulator.c 
b/drivers/regulator/sy7636a-regulator.c
new file mode 100644
index ..0ec6f852cb3d
--- /dev/null
+++ b/drivers/regulator/sy7636a-regulator.c
@@ -0,0 +1,354 @@
+// SPDX-License-Identifier: GPL-2.0+
+//
+// Functions to access SY3686A power management chip voltages
+//
+// Copyright (C) 2019 reMarkable AS - http://www.remarkable.com/
+//
+// Authors: Lars Ivar Miljeteig 
+//  Alistair Francis 
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+static const char * const states[] = {
+   "no fault event",
+   "UVP at VP rail",
+   "UVP at VN rail",
+   "UVP at VPOS rail",
+   "UVP at VNEG rail",
+   "UVP at VDDH rail",
+   "UVP at VEE rail",
+   "SCP at VP rail",
+   "SCP at VN rail",
+   "SCP at VPOS rail",
+   "SCP at VNEG rail",
+   "SCP at VDDH rail",
+   "SCP at VEE rail",
+   "SCP at V COM rail",
+   "UVLO",
+   "Thermal shutdown",
+};
+
+static int sy7636a_get_vcom_voltage_mv(struct regmap *regmap)
+{
+   int ret;
+   unsigned int val, val_h;
+
+   ret = regmap_read(regmap, SY7636A_REG_VCOM_ADJUST_CTRL_L, );
+   if (ret)
+   return ret;
+
+   ret = regmap_read(regmap, SY7636A_REG_VCOM_ADJUST_CTRL_H, _h);
+   if (ret)
+   return ret;
+
+   val |= (val_h << VCOM_ADJUST_CTRL_SHIFT);
+
+   return (val & VCOM_ADJUST_CTRL_MASK) * VCOM_ADJUST_CTRL_SCAL;
+}
+
+static int sy7636a_set_vcom_voltage_mv(struct regmap *regmap, unsigned int 
vcom)
+{
+   int ret;
+   unsigned int val;
+
+   if (vcom < VCOM_MIN || vcom > VCOM_MAX)
+   return -EINVAL;
+
+   val = (unsigned int)(vcom / VCOM_ADJUST_CTRL_SCAL) & 
VCOM_ADJUST_CTRL_MASK;
+
+   ret = regmap_write(

[PATCH v4 1/5] dt-bindings: mfd: Initial commit of silergy,sy7636a.yaml

2021-03-25 Thread Alistair Francis
Initial support for the Silergy SY7636A Power Management chip
and regulator.

Signed-off-by: Alistair Francis 
---
v3:
 - No change
v2:
 - N/A

 .../bindings/mfd/silergy,sy7636a.yaml | 63 +++
 1 file changed, 63 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/mfd/silergy,sy7636a.yaml

diff --git a/Documentation/devicetree/bindings/mfd/silergy,sy7636a.yaml 
b/Documentation/devicetree/bindings/mfd/silergy,sy7636a.yaml
new file mode 100644
index ..f260a8eae226
--- /dev/null
+++ b/Documentation/devicetree/bindings/mfd/silergy,sy7636a.yaml
@@ -0,0 +1,63 @@
+# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/mfd/silergy,sy7636a.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: silergy sy7636a PMIC
+
+maintainers:
+  - Alistair Francis 
+
+properties:
+  compatible:
+const: silergy,sy7636a
+
+  reg:
+maxItems: 1
+
+  '#thermal-sensor-cells':
+const: 0
+
+  regulators:
+type: object
+$ref: /schemas/regulator/regulator.yaml#
+
+properties:
+  compatible:
+const: silergy,sy7636a-regulator
+
+  regulator-name:
+pattern: "vcom"
+
+required:
+  - compatible
+  - reg
+  - '#thermal-sensor-cells'
+
+additionalProperties: false
+
+examples:
+  - |
+i2c {
+  #address-cells = <1>;
+  #size-cells = <0>;
+
+  sy7636a@62 {
+compatible = "silergy,sy7636a";
+reg = <0x62>;
+status = "okay";
+pinctrl-names = "default";
+pinctrl-0 = <_epdpmic>;
+#thermal-sensor-cells = <0>;
+
+regulators {
+  compatible = "silergy,sy7636a-regulator";
+  reg_epdpmic: vcom {
+regulator-name = "vcom";
+regulator-boot-on;
+  };
+};
+  };
+};
+...
-- 
2.31.0



[PATCH v4 2/5] mfd: sy7636a: Initial commit

2021-03-25 Thread Alistair Francis
Initial support for the Silergy SY7636A Power Management chip.

Signed-off-by: Alistair Francis 
---
v3:
 - Update copyright year
 - Move power parts to regulator
 - Change Kconfig depends to be tristate
v2:
 - Address comments from review

 drivers/mfd/Kconfig | 10 +
 drivers/mfd/Makefile|  1 +
 drivers/mfd/sy7636a.c   | 82 +
 include/linux/mfd/sy7636a.h | 46 +
 4 files changed, 139 insertions(+)
 create mode 100644 drivers/mfd/sy7636a.c
 create mode 100644 include/linux/mfd/sy7636a.h

diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig
index b74efa469e90..ac09b40e1724 100644
--- a/drivers/mfd/Kconfig
+++ b/drivers/mfd/Kconfig
@@ -1351,6 +1351,16 @@ config MFD_SYSCON
  Select this option to enable accessing system control registers
  via regmap.
 
+config MFD_SY7636A
+   tristate "Silergy SY7636A Power Management chip"
+   select MFD_CORE
+   select REGMAP_I2C
+   select REGMAP_IRQ
+   depends on I2C
+   help
+ Select this option to enable support for the Silergy SY7636A
+ Power Management chip.
+
 config MFD_DAVINCI_VOICECODEC
tristate
select MFD_CORE
diff --git a/drivers/mfd/Makefile b/drivers/mfd/Makefile
index 834f5463af28..5bfa0d6e5dc5 100644
--- a/drivers/mfd/Makefile
+++ b/drivers/mfd/Makefile
@@ -265,6 +265,7 @@ obj-$(CONFIG_MFD_STMFX) += stmfx.o
 obj-$(CONFIG_MFD_KHADAS_MCU)   += khadas-mcu.o
 obj-$(CONFIG_MFD_ACER_A500_EC) += acer-ec-a500.o
 
+obj-$(CONFIG_MFD_SY7636A)  += sy7636a.o
 obj-$(CONFIG_SGI_MFD_IOC3) += ioc3.o
 obj-$(CONFIG_MFD_SIMPLE_MFD_I2C)   += simple-mfd-i2c.o
 obj-$(CONFIG_MFD_INTEL_M10_BMC)   += intel-m10-bmc.o
diff --git a/drivers/mfd/sy7636a.c b/drivers/mfd/sy7636a.c
new file mode 100644
index ..e08f29ea63f8
--- /dev/null
+++ b/drivers/mfd/sy7636a.c
@@ -0,0 +1,82 @@
+// SPDX-License-Identifier: GPL-2.0+
+//
+// MFD parent driver for SY7636A chip
+//
+// Copyright (C) 2021 reMarkable AS - http://www.remarkable.com/
+//
+// Authors: Lars Ivar Miljeteig 
+//  Alistair Francis 
+//
+// Based on the lp87565 driver by Keerthy 
+
+#include 
+#include 
+#include 
+#include 
+
+#include 
+
+static const struct regmap_config sy7636a_regmap_config = {
+   .reg_bits = 8,
+   .val_bits = 8,
+};
+
+static const struct mfd_cell sy7636a_cells[] = {
+   { .name = "sy7636a-regulator", },
+   { .name = "sy7636a-temperature", },
+   { .name = "sy7636a-thermal", },
+};
+
+static const struct of_device_id of_sy7636a_match_table[] = {
+   { .compatible = "silergy,sy7636a", },
+   {}
+};
+MODULE_DEVICE_TABLE(of, of_sy7636a_match_table);
+
+static int sy7636a_probe(struct i2c_client *client,
+const struct i2c_device_id *ids)
+{
+   struct sy7636a *sy7636a;
+   int ret;
+
+   sy7636a = devm_kzalloc(>dev, sizeof(*sy7636a), GFP_KERNEL);
+   if (!sy7636a)
+   return -ENOMEM;
+
+   sy7636a->dev = >dev;
+
+   sy7636a->regmap = devm_regmap_init_i2c(client, _regmap_config);
+   if (IS_ERR(sy7636a->regmap)) {
+   ret = PTR_ERR(sy7636a->regmap);
+   dev_err(sy7636a->dev,
+   "Failed to initialize register map: %d\n", ret);
+   return ret;
+   }
+
+   i2c_set_clientdata(client, sy7636a);
+
+   ret = devm_mfd_add_devices(sy7636a->dev, PLATFORM_DEVID_AUTO,
+   sy7636a_cells, 
ARRAY_SIZE(sy7636a_cells),
+   NULL, 0, NULL);
+   return 0;
+}
+
+static const struct i2c_device_id sy7636a_id_table[] = {
+   { "sy7636a", 0 },
+   { },
+};
+MODULE_DEVICE_TABLE(i2c, sy7636a_id_table);
+
+static struct i2c_driver sy7636a_driver = {
+   .driver = {
+   .name   = "sy7636a",
+   .of_match_table = of_sy7636a_match_table,
+   },
+   .probe = sy7636a_probe,
+   .id_table = sy7636a_id_table,
+};
+module_i2c_driver(sy7636a_driver);
+
+MODULE_AUTHOR("Lars Ivar Miljeteig ");
+MODULE_DESCRIPTION("Silergy SY7636A Multi-Function Device Driver");
+MODULE_LICENSE("GPL v2");
diff --git a/include/linux/mfd/sy7636a.h b/include/linux/mfd/sy7636a.h
new file mode 100644
index ..a5ec5d911b3a
--- /dev/null
+++ b/include/linux/mfd/sy7636a.h
@@ -0,0 +1,46 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+/*
+ * Functions to access SY3686A power management chip.
+ *
+ * Copyright (C) 2021 reMarkable AS - http://www.remarkable.com/
+ */
+
+#ifndef __MFD_SY7636A_H
+#define __MFD_SY7636A_H
+
+#include 
+#include 
+#include 
+#include 
+
+#define SY7636A_REG_OPERATION_MODE_CRL 0x00
+#define SY7636A_OPERATION_MODE_CRL_VCOMCTL BIT(6)
+#define SY7636A_OPERATION_MODE_CRL_ONOFF   BIT(7)
+#define SY7636A_REG_VCOM_ADJUST_CT

[PATCH v4 07/10] Input: wacom_i2c - Add support for reset control

2021-03-25 Thread Alistair Francis
From: Alistair Francis 

Signed-off-by: Alistair Francis 
---
v4:
 - Initial commit

 drivers/input/touchscreen/wacom_i2c.c | 11 +++
 1 file changed, 11 insertions(+)

diff --git a/drivers/input/touchscreen/wacom_i2c.c 
b/drivers/input/touchscreen/wacom_i2c.c
index 84c7ccb737bd..28004b1180c9 100644
--- a/drivers/input/touchscreen/wacom_i2c.c
+++ b/drivers/input/touchscreen/wacom_i2c.c
@@ -55,6 +55,7 @@ struct wacom_features {
 struct wacom_i2c {
struct i2c_client *client;
struct input_dev *input;
+   struct reset_control *rstc;
struct touchscreen_properties props;
u8 data[WACOM_QUERY_SIZE];
bool prox;
@@ -175,6 +176,8 @@ static int wacom_i2c_open(struct input_dev *dev)
struct wacom_i2c *wac_i2c = input_get_drvdata(dev);
struct i2c_client *client = wac_i2c->client;
 
+   reset_control_reset(wac_i2c->rstc);
+
enable_irq(client->irq);
 
return 0;
@@ -193,6 +196,7 @@ static int wacom_i2c_probe(struct i2c_client *client,
 {
struct wacom_i2c *wac_i2c;
struct input_dev *input;
+   struct reset_control *rstc;
struct wacom_features features = { 0 };
int error;
 
@@ -201,6 +205,12 @@ static int wacom_i2c_probe(struct i2c_client *client,
return -EIO;
}
 
+   rstc = devm_reset_control_get_optional_exclusive(>dev, NULL);
+   if (IS_ERR(rstc)) {
+   dev_err(>dev, "Failed to get reset control before 
init\n");
+   return PTR_ERR(rstc);
+   }
+
error = wacom_query_device(client, );
if (error)
return error;
@@ -214,6 +224,7 @@ static int wacom_i2c_probe(struct i2c_client *client,
 
wac_i2c->client = client;
wac_i2c->input = input;
+   wac_i2c->rstc = rstc;
 
input->name = "Wacom I2C Digitizer";
input->id.bustype = BUS_I2C;
-- 
2.31.0



[PATCH v4 08/10] Input: wacom_i2c - Add support for vdd regulator

2021-03-25 Thread Alistair Francis
Add support for a VDD regulator. This allows the kernel to prove the
Wacom-I2C device on the rM2.

Signed-off-by: Alistair Francis 
---
v4:
 - Don't double allocate wac_i2c

 drivers/input/touchscreen/wacom_i2c.c | 18 ++
 1 file changed, 18 insertions(+)

diff --git a/drivers/input/touchscreen/wacom_i2c.c 
b/drivers/input/touchscreen/wacom_i2c.c
index 28004b1180c9..c78195b6b3b1 100644
--- a/drivers/input/touchscreen/wacom_i2c.c
+++ b/drivers/input/touchscreen/wacom_i2c.c
@@ -13,6 +13,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -57,6 +58,7 @@ struct wacom_i2c {
struct input_dev *input;
struct reset_control *rstc;
struct touchscreen_properties props;
+   struct regulator *vdd;
u8 data[WACOM_QUERY_SIZE];
bool prox;
int tool;
@@ -222,6 +224,20 @@ static int wacom_i2c_probe(struct i2c_client *client,
goto err_free_mem;
}
 
+   wac_i2c->vdd = regulator_get(>dev, "vdd");
+   if (IS_ERR(wac_i2c->vdd)) {
+   error = PTR_ERR(wac_i2c->vdd);
+   kfree(wac_i2c);
+   return error;
+   }
+
+   error = regulator_enable(wac_i2c->vdd);
+   if (error) {
+   regulator_put(wac_i2c->vdd);
+   kfree(wac_i2c);
+   return error;
+   }
+
wac_i2c->client = client;
wac_i2c->input = input;
wac_i2c->rstc = rstc;
@@ -281,6 +297,8 @@ static int wacom_i2c_probe(struct i2c_client *client,
 err_free_irq:
free_irq(client->irq, wac_i2c);
 err_free_mem:
+   regulator_disable(wac_i2c->vdd);
+   regulator_put(wac_i2c->vdd);
input_free_device(input);
kfree(wac_i2c);
 
-- 
2.31.0



[PATCH v4 09/10] ARM: imx_v6_v7_defconfig: Enable Wacom I2C

2021-03-25 Thread Alistair Francis
Enable the Wacom I2C in the imx defconfig as it is used by the
reMarkable2 tablet.

Signed-off-by: Alistair Francis 
---
 arch/arm/configs/imx_v6_v7_defconfig | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/arm/configs/imx_v6_v7_defconfig 
b/arch/arm/configs/imx_v6_v7_defconfig
index 70928cc48939..cd80e85d37cf 100644
--- a/arch/arm/configs/imx_v6_v7_defconfig
+++ b/arch/arm/configs/imx_v6_v7_defconfig
@@ -174,6 +174,7 @@ CONFIG_TOUCHSCREEN_DA9052=y
 CONFIG_TOUCHSCREEN_EGALAX=y
 CONFIG_TOUCHSCREEN_GOODIX=y
 CONFIG_TOUCHSCREEN_ILI210X=y
+CONFIG_TOUCHSCREEN_WACOM_I2C=y
 CONFIG_TOUCHSCREEN_MAX11801=y
 CONFIG_TOUCHSCREEN_IMX6UL_TSC=y
 CONFIG_TOUCHSCREEN_EDT_FT5X06=y
-- 
2.31.0



[PATCH v4 05/10] Input: wacom_i2c - Add support for distance and tilt x/y

2021-03-25 Thread Alistair Francis
This is based on the out of tree rM2 driver.

Signed-off-by: Alistair Francis 
---
 drivers/input/touchscreen/wacom_i2c.c | 25 +++--
 1 file changed, 23 insertions(+), 2 deletions(-)

diff --git a/drivers/input/touchscreen/wacom_i2c.c 
b/drivers/input/touchscreen/wacom_i2c.c
index ee1829dd35f4..3b4bc514dc3f 100644
--- a/drivers/input/touchscreen/wacom_i2c.c
+++ b/drivers/input/touchscreen/wacom_i2c.c
@@ -22,12 +22,16 @@
 #define WACOM_CMD_QUERY3   0x02
 #define WACOM_CMD_THROW0   0x05
 #define WACOM_CMD_THROW1   0x00
-#define WACOM_QUERY_SIZE   19
+#define WACOM_QUERY_SIZE   22
 
 struct wacom_features {
int x_max;
int y_max;
int pressure_max;
+   int distance_max;
+   int distance_physical_max;
+   int tilt_x_max;
+   int tilt_y_max;
char fw_version;
 };
 
@@ -79,6 +83,10 @@ static int wacom_query_device(struct i2c_client *client,
features->y_max = get_unaligned_le16([5]);
features->pressure_max = get_unaligned_le16([11]);
features->fw_version = get_unaligned_le16([13]);
+   features->distance_max = data[15];
+   features->distance_physical_max = data[16];
+   features->tilt_x_max = get_unaligned_le16([17]);
+   features->tilt_y_max = get_unaligned_le16([19]);
 
dev_dbg(>dev,
"x_max:%d, y_max:%d, pressure:%d, fw:%d\n",
@@ -95,6 +103,7 @@ static irqreturn_t wacom_i2c_irq(int irq, void *dev_id)
u8 *data = wac_i2c->data;
unsigned int x, y, pressure;
unsigned char tsw, f1, f2, ers;
+   short tilt_x, tilt_y, distance;
int error;
 
error = i2c_master_recv(wac_i2c->client,
@@ -109,6 +118,11 @@ static irqreturn_t wacom_i2c_irq(int irq, void *dev_id)
x = le16_to_cpup((__le16 *)[4]);
y = le16_to_cpup((__le16 *)[6]);
pressure = le16_to_cpup((__le16 *)[8]);
+   distance = data[10];
+
+   /* Signed */
+   tilt_x = le16_to_cpup((__le16 *)[11]);
+   tilt_y = le16_to_cpup((__le16 *)[13]);
 
if (!wac_i2c->prox)
wac_i2c->tool = (data[3] & 0x0c) ?
@@ -123,6 +137,9 @@ static irqreturn_t wacom_i2c_irq(int irq, void *dev_id)
input_report_abs(input, ABS_X, x);
input_report_abs(input, ABS_Y, y);
input_report_abs(input, ABS_PRESSURE, pressure);
+   input_report_abs(input, ABS_DISTANCE, distance);
+   input_report_abs(input, ABS_TILT_X, tilt_x);
+   input_report_abs(input, ABS_TILT_Y, tilt_y);
input_sync(input);
 
 out:
@@ -197,7 +214,11 @@ static int wacom_i2c_probe(struct i2c_client *client,
input_set_abs_params(input, ABS_Y, 0, features.y_max, 0, 0);
input_set_abs_params(input, ABS_PRESSURE,
 0, features.pressure_max, 0, 0);
-
+   input_set_abs_params(input, ABS_DISTANCE, 0, features.distance_max, 0, 
0);
+   input_set_abs_params(input, ABS_TILT_X, -features.tilt_x_max,
+features.tilt_x_max, 0, 0);
+   input_set_abs_params(input, ABS_TILT_Y, -features.tilt_y_max,
+features.tilt_y_max, 0, 0);
input_set_drvdata(input, wac_i2c);
 
error = request_threaded_irq(client->irq, NULL, wacom_i2c_irq,
-- 
2.31.0



[PATCH v4 04/10] Input: wacom_i2c - Add touchscren properties

2021-03-25 Thread Alistair Francis
Connect touchscreen properties to the wacom_i2c.

Signed-off-by: Alistair Francis 
---
v4:
 - Add touchscreen_report_pos() as well

 drivers/input/touchscreen/wacom_i2c.c | 5 +
 1 file changed, 5 insertions(+)

diff --git a/drivers/input/touchscreen/wacom_i2c.c 
b/drivers/input/touchscreen/wacom_i2c.c
index eada68770671..ee1829dd35f4 100644
--- a/drivers/input/touchscreen/wacom_i2c.c
+++ b/drivers/input/touchscreen/wacom_i2c.c
@@ -11,6 +11,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -33,6 +34,7 @@ struct wacom_features {
 struct wacom_i2c {
struct i2c_client *client;
struct input_dev *input;
+   struct touchscreen_properties props;
u8 data[WACOM_QUERY_SIZE];
bool prox;
int tool;
@@ -188,6 +190,9 @@ static int wacom_i2c_probe(struct i2c_client *client,
__set_bit(BTN_STYLUS2, input->keybit);
__set_bit(BTN_TOUCH, input->keybit);
 
+   touchscreen_parse_properties(input, true, _i2c->props);
+   touchscreen_report_pos(input, _i2c->props, features.x_max,
+  features.y_max, true);
input_set_abs_params(input, ABS_X, 0, features.x_max, 0, 0);
input_set_abs_params(input, ABS_Y, 0, features.y_max, 0, 0);
input_set_abs_params(input, ABS_PRESSURE,
-- 
2.31.0



[PATCH v4 03/10] Input: wacom_i2c - Add device tree support to wacom_i2c

2021-03-25 Thread Alistair Francis
Allow the wacom-i2c device to be exposed via device tree.

Signed-off-by: Alistair Francis 
---
v4:
 - Avoid unused variable warning by not using of_match_ptr()

 drivers/input/touchscreen/wacom_i2c.c | 8 
 1 file changed, 8 insertions(+)

diff --git a/drivers/input/touchscreen/wacom_i2c.c 
b/drivers/input/touchscreen/wacom_i2c.c
index 1afc6bde2891..eada68770671 100644
--- a/drivers/input/touchscreen/wacom_i2c.c
+++ b/drivers/input/touchscreen/wacom_i2c.c
@@ -12,6 +12,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 
 #define WACOM_CMD_QUERY0   0x04
@@ -262,10 +263,17 @@ static const struct i2c_device_id wacom_i2c_id[] = {
 };
 MODULE_DEVICE_TABLE(i2c, wacom_i2c_id);
 
+static const struct of_device_id wacom_i2c_of_match_table[] = {
+   { .compatible = "wacom,generic" },
+   {}
+};
+MODULE_DEVICE_TABLE(of, wacom_i2c_of_match_table);
+
 static struct i2c_driver wacom_i2c_driver = {
.driver = {
.name   = "wacom_i2c",
.pm = _i2c_pm,
+   .of_match_table = wacom_i2c_of_match_table,
},
 
.probe  = wacom_i2c_probe,
-- 
2.31.0



[PATCH v4 06/10] Input: wacom_i2c - Clean up the query device fields

2021-03-25 Thread Alistair Francis
Improve the query device fields to be more verbose.

Signed-off-by: Alistair Francis 
---
v4:
 - Remove the reset_control_reset() logic

 drivers/input/touchscreen/wacom_i2c.c | 64 ++-
 1 file changed, 44 insertions(+), 20 deletions(-)

diff --git a/drivers/input/touchscreen/wacom_i2c.c 
b/drivers/input/touchscreen/wacom_i2c.c
index 3b4bc514dc3f..84c7ccb737bd 100644
--- a/drivers/input/touchscreen/wacom_i2c.c
+++ b/drivers/input/touchscreen/wacom_i2c.c
@@ -13,15 +13,32 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 
-#define WACOM_CMD_QUERY0   0x04
-#define WACOM_CMD_QUERY1   0x00
-#define WACOM_CMD_QUERY2   0x33
-#define WACOM_CMD_QUERY3   0x02
-#define WACOM_CMD_THROW0   0x05
-#define WACOM_CMD_THROW1   0x00
+// Registers
+#define WACOM_COMMAND_LSB   0x04
+#define WACOM_COMMAND_MSB   0x00
+
+#define WACOM_DATA_LSB  0x05
+#define WACOM_DATA_MSB  0x00
+
+// Report types
+#define REPORT_FEATURE  0x30
+
+// Requests / operations
+#define OPCODE_GET_REPORT   0x02
+
+// Power settings
+#define POWER_ON0x00
+#define POWER_SLEEP 0x01
+
+// Input report ids
+#define WACOM_PEN_DATA_REPORT   2
+#define WACOM_SHINONOME_REPORT  26
+
+#define WACOM_QUERY_REPORT 3
 #define WACOM_QUERY_SIZE   22
 
 struct wacom_features {
@@ -48,27 +65,30 @@ static int wacom_query_device(struct i2c_client *client,
  struct wacom_features *features)
 {
int ret;
-   u8 cmd1[] = { WACOM_CMD_QUERY0, WACOM_CMD_QUERY1,
-   WACOM_CMD_QUERY2, WACOM_CMD_QUERY3 };
-   u8 cmd2[] = { WACOM_CMD_THROW0, WACOM_CMD_THROW1 };
u8 data[WACOM_QUERY_SIZE];
+
+   u8 get_query_data_cmd[] = {
+   WACOM_COMMAND_LSB,
+   WACOM_COMMAND_MSB,
+   REPORT_FEATURE | WACOM_QUERY_REPORT,
+   OPCODE_GET_REPORT,
+   WACOM_DATA_LSB,
+   WACOM_DATA_MSB,
+   };
+
struct i2c_msg msgs[] = {
+   // Request reading of feature ReportID: 3 (Pen Query Data)
{
.addr = client->addr,
.flags = 0,
-   .len = sizeof(cmd1),
-   .buf = cmd1,
-   },
-   {
-   .addr = client->addr,
-   .flags = 0,
-   .len = sizeof(cmd2),
-   .buf = cmd2,
+   .len = sizeof(get_query_data_cmd),
+   .buf = get_query_data_cmd,
},
+   // Read 21 bytes
{
.addr = client->addr,
.flags = I2C_M_RD,
-   .len = sizeof(data),
+   .len = WACOM_QUERY_SIZE - 1,
.buf = data,
},
};
@@ -89,9 +109,13 @@ static int wacom_query_device(struct i2c_client *client,
features->tilt_y_max = get_unaligned_le16([19]);
 
dev_dbg(>dev,
-   "x_max:%d, y_max:%d, pressure:%d, fw:%d\n",
+   "x_max:%d, y_max:%d, pressure:%d, fw:%d, "
+   "distance: %d, phys distance: %d, "
+   "tilt_x_max: %d, tilt_y_max: %d\n",
features->x_max, features->y_max,
-   features->pressure_max, features->fw_version);
+   features->pressure_max, features->fw_version,
+   features->distance_max, features->distance_physical_max,
+   features->tilt_x_max, features->tilt_y_max);
 
return 0;
 }
-- 
2.31.0



[PATCH v4 01/10] dt-bindings: Add Wacom to vendor bindings

2021-03-25 Thread Alistair Francis
Signed-off-by: Alistair Francis 
---
 Documentation/devicetree/bindings/vendor-prefixes.yaml | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/Documentation/devicetree/bindings/vendor-prefixes.yaml 
b/Documentation/devicetree/bindings/vendor-prefixes.yaml
index a8e1e8d2ef20..996f4de2fff5 100644
--- a/Documentation/devicetree/bindings/vendor-prefixes.yaml
+++ b/Documentation/devicetree/bindings/vendor-prefixes.yaml
@@ -1216,6 +1216,8 @@ patternProperties:
 description: Vision Optical Technology Co., Ltd.
   "^vxt,.*":
 description: VXT Ltd
+  "^wacom,.*":
+description: Wacom Co., Ltd
   "^wand,.*":
 description: Wandbord (Technexion)
   "^waveshare,.*":
-- 
2.31.0



[PATCH v4 02/10] dt-bindings: touchscreen: Initial commit of wacom,generic

2021-03-25 Thread Alistair Francis
Signed-off-by: Alistair Francis 
---
 .../input/touchscreen/wacom,generic.yaml  | 48 +++
 1 file changed, 48 insertions(+)
 create mode 100644 
Documentation/devicetree/bindings/input/touchscreen/wacom,generic.yaml

diff --git 
a/Documentation/devicetree/bindings/input/touchscreen/wacom,generic.yaml 
b/Documentation/devicetree/bindings/input/touchscreen/wacom,generic.yaml
new file mode 100644
index ..19bbfc55ed76
--- /dev/null
+++ b/Documentation/devicetree/bindings/input/touchscreen/wacom,generic.yaml
@@ -0,0 +1,48 @@
+# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/input/touchscreen/wacom,generic.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Wacom I2C Controller
+
+maintainers:
+  - Alistair Francis 
+
+allOf:
+  - $ref: touchscreen.yaml#
+
+properties:
+  compatible:
+const: wacom,generic
+
+  reg:
+maxItems: 1
+
+  interrupts:
+maxItems: 1
+
+  vdd-supply:
+maxItems: 1
+
+required:
+  - compatible
+  - reg
+  - interrupts
+
+additionalProperties: false
+
+examples:
+  - |
+#include "dt-bindings/interrupt-controller/irq.h"
+i2c {
+#address-cells = <1>;
+#size-cells = <0>;
+digitiser@9 {
+compatible = "wacom,generic";
+reg = <0x9>;
+interrupt-parent = <>;
+interrupts = <9 IRQ_TYPE_LEVEL_LOW>;
+vdd-supply = <_touch>;
+};
+};
-- 
2.31.0



Re: [PATCH 2/6] mfd: Initial commit of sy7636a

2021-03-25 Thread Alistair Francis
On Tue, Mar 23, 2021 at 5:35 AM Lee Jones  wrote:
>
> On Sat, 20 Mar 2021, Alistair Francis wrote:
>
> > On Thu, Feb 4, 2021 at 5:31 AM Lee Jones  wrote:
> > >
> > > On Sat, 16 Jan 2021, Alistair Francis wrote:
> > >
> > > > Initial support for the Silergy SY7636A Power Management chip
> > > > driver.
> > >
> > > Please remove "driver", as this is not support for the driver, it *is*
> > > the driver which supports the chip.
> >
> > Sorry for the long delay here.
> >
> > I have addressed your comments.
>
> [...]
>
> > > > diff --git a/drivers/mfd/sy7636a.c b/drivers/mfd/sy7636a.c
> > > > new file mode 100644
> > > > index ..39aac965d854
> > > > --- /dev/null
> > > > +++ b/drivers/mfd/sy7636a.c
> > > > @@ -0,0 +1,252 @@
> > > > +// SPDX-License-Identifier: GPL-2.0+
> > > > +/*
> > > > + * MFD driver for SY7636A chip
> > >
> > > "Parent driver".
> > >
> > > > + * Copyright (C) 2019 reMarkable AS - http://www.remarkable.com/
> > >
> > > This is quite out of date.  Please update.
> >
> > I don't own this copyright, so I would rather not change it.
>
> I'm not comfortable taking a new driver with an old Copyright.
>
> Maybe ask reMarkable if it's okay to bump it.
>
> > > > + * Author: Lars Ivar Miljeteig 
>
> Or ping this guy.

I reached out to him and have permission to bump the year.

>
> [...]
>
> > > > +int set_vcom_voltage_mv(struct regmap *regmap, unsigned int vcom)
> > > > +{
> > > > + int ret;
> > > > + unsigned int val;
> > > > +
> > > > + if (vcom < 0 || vcom > 5000)
> > >
> > > Please define min/max values.
> > >
> > > > + return -EINVAL;
> > > > +
> > > > + val = (unsigned int)(vcom / 10) & 0x1ff;
> > >
> > > As above.
> >
> > I have used defines for all of these.
> >
> > >
> > > > + ret = regmap_write(regmap, SY7636A_REG_VCOM_ADJUST_CTRL_L, val);
> > > > + if (ret)
> > > > + return ret;
> > > > +
> > > > + ret = regmap_write(regmap, SY7636A_REG_VCOM_ADJUST_CTRL_H, val >> 
> > > > 8);
> > > > + if (ret)
> > > > + return ret;
> > > > +
> > > > + return 0;
> > > > +}
> > >
> > > Who calls these?
> >
> > They sysfs store and show functions.
>
> They should be in a power/regulator driver really.

Ok, I have moved these to the regulator.

>
> [...]
>
> > > > + if (val >= ARRAY_SIZE(states)) {
> > > > + dev_err(sy7636a->dev, "Unexpected value read from device: 
> > > > %u\n", val);
> > > > + return -EINVAL;
> > > > + }
> > > > +
> > > > + return snprintf(buf, PAGE_SIZE, "%s\n", states[val]);
> > > > +}
> > > > +static DEVICE_ATTR(state, 0444, state_show, NULL);
> > >
> > > You need to document new sysfs entries.
> >
> > I'm not sure how to document this. Do you mind pointing out an example
> > I can use?
>
> See the final paragraph in:
>
>   Documentation/filesystems/sysfs.rst

Thanks!

>
> [...]
>
> > > > +static struct attribute *sy7636a_sysfs_attrs[] = {
> > > > + _attr_state.attr,
> > > > + _attr_power_good.attr,
> > > > + _attr_vcom.attr,
> > > > + NULL,
> > > > +};
> > >
> > > These all look like power options?  Do they really belong here?
> >
> > From what I can tell I think they do. Let me know if you don't think so.
>
> As above, I think they should be in power or regulator.

Done.

Alistair

>
> [...]
>
> --
> Lee Jones [李琼斯]
> Senior Technical Lead - Developer Services
> Linaro.org │ Open source software for Arm SoCs
> Follow Linaro: Facebook | Twitter | Blog


[PATCH v6 3/3] ARM: imx7d-remarkable2.dts: Initial device tree for reMarkable2

2021-03-22 Thread Alistair Francis
The reMarkable2 (https://remarkable.com) is an e-ink tablet based on
the imx7d SoC.

This commit is based on the DTS provide by reMarkable but ported to the
latest kernel (instead of 4.14). I have removed references to
non-upstream devices and have changed the UART so that the console can
be accessed without having to open up the device via the OTG pogo pins.

Currently the kernel boots, but there is no support for the display.

WiFi is untested (no display or UART RX makes it hard to test), but
should work with the current upstream driver. As it's untested it's not
included in this commit.

Signed-off-by: Alistair Francis 
---
v6:
 - Remove unneeded disables (crypt and dma_apbh)
 - Remove uneeded enables (sdma)
 - Fixup memory entry
 - Remove unused reference

 arch/arm/boot/dts/Makefile  |   1 +
 arch/arm/boot/dts/imx7d-remarkable2.dts | 146 
 2 files changed, 147 insertions(+)
 create mode 100644 arch/arm/boot/dts/imx7d-remarkable2.dts

diff --git a/arch/arm/boot/dts/Makefile b/arch/arm/boot/dts/Makefile
index 8e5d4ab4e75e..dc8e378689af 100644
--- a/arch/arm/boot/dts/Makefile
+++ b/arch/arm/boot/dts/Makefile
@@ -660,6 +660,7 @@ dtb-$(CONFIG_SOC_IMX7D) += \
imx7d-pico-hobbit.dtb \
imx7d-pico-nymph.dtb \
imx7d-pico-pi.dtb \
+   imx7d-remarkable2.dtb \
imx7d-sbc-imx7.dtb \
imx7d-sdb.dtb \
imx7d-sdb-reva.dtb \
diff --git a/arch/arm/boot/dts/imx7d-remarkable2.dts 
b/arch/arm/boot/dts/imx7d-remarkable2.dts
new file mode 100644
index ..8cbae656395c
--- /dev/null
+++ b/arch/arm/boot/dts/imx7d-remarkable2.dts
@@ -0,0 +1,146 @@
+// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
+/*
+ * Copyright (C) 2015 Freescale Semiconductor, Inc.
+ * Copyright (C) 2019 reMarkable AS - http://www.remarkable.com/
+ *
+ */
+
+/dts-v1/;
+
+#include "imx7d.dtsi"
+
+/ {
+   model = "reMarkable 2.0";
+   compatible = "remarkable,imx7d-remarkable2", "fsl,imx7d";
+
+   chosen {
+   stdout-path = 
+   };
+
+   memory@8000 {
+   device_type = "memory";
+   reg = <0x8000 0x4000>;
+   };
+};
+
+ {
+   assigned-clocks = < IMX7D_CLKO2_ROOT_SRC>,
+ < IMX7D_CLKO2_ROOT_DIV>;
+   assigned-clock-parents = < IMX7D_CKIL>;
+   assigned-clock-rates = <0>, <32768>;
+};
+
+_pwrkey {
+   status = "okay";
+};
+
+ {
+   pinctrl-names = "default";
+   pinctrl-0 = <_uart1>;
+   assigned-clocks = < IMX7D_UART1_ROOT_SRC>;
+   assigned-clock-parents = < IMX7D_OSC_24M_CLK>;
+   status = "okay";
+};
+
+ {
+   pinctrl-names = "default";
+   pinctrl-0 = <_uart6>;
+   assigned-clocks = < IMX7D_UART6_ROOT_SRC>;
+   assigned-clock-parents = < IMX7D_OSC_24M_CLK>;
+   status = "okay";
+};
+
+ {
+   srp-disable;
+   hnp-disable;
+   status = "okay";
+};
+
+ {
+   pinctrl-names = "default", "state_100mhz", "state_200mhz", "sleep";
+   pinctrl-0 = <_usdhc3>;
+   pinctrl-1 = <_usdhc3_100mhz>;
+   pinctrl-2 = <_usdhc3_200mhz>;
+   pinctrl-3 = <_usdhc3>;
+   assigned-clocks = < IMX7D_USDHC3_ROOT_CLK>;
+   assigned-clock-rates = <4>;
+   bus-width = <8>;
+   non-removable;
+   status = "okay";
+};
+
+ {
+   pinctrl-names = "default";
+   pinctrl-0 = <_wdog>;
+   fsl,ext-reset-output;
+};
+
+ {
+   pinctrl_uart1: uart1grp {
+   fsl,pins = <
+   MX7D_PAD_UART1_TX_DATA__UART1_DCE_TX0x79
+   MX7D_PAD_UART1_RX_DATA__UART1_DCE_RX0x79
+   >;
+   };
+
+   pinctrl_uart6: uart6grp {
+   fsl,pins = <
+   MX7D_PAD_EPDC_DATA09__UART6_DCE_TX  0x79
+   MX7D_PAD_EPDC_DATA08__UART6_DCE_RX  0x79
+   >;
+   };
+
+   pinctrl_usdhc3: usdhc3grp {
+   fsl,pins = <
+   MX7D_PAD_SD3_CMD__SD3_CMD   0x59
+   MX7D_PAD_SD3_CLK__SD3_CLK   0x19
+   MX7D_PAD_SD3_DATA0__SD3_DATA0   0x59
+   MX7D_PAD_SD3_DATA1__SD3_DATA1   0x59
+   MX7D_PAD_SD3_DATA2__SD3_DATA2   0x59
+   MX7D_PAD_SD3_DATA3__SD3_DATA3   0x59
+   MX7D_PAD_SD3_DATA4__SD3_DATA4   0x59
+   MX7D_PAD_SD3_DATA5__SD3_DATA5   0x59
+   MX7D_PAD_SD3_DATA6__SD3_DATA6   0x59
+   MX7D_PAD_SD3_DATA7__SD3_DATA7   0x59
+   

[PATCH v6 1/3] dt-bindings: Add vendor prefix for reMarkable

2021-03-22 Thread Alistair Francis
reMarkable AS produces eInk tablets

Signed-off-by: Alistair Francis 
---
 Documentation/devicetree/bindings/vendor-prefixes.yaml | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/Documentation/devicetree/bindings/vendor-prefixes.yaml 
b/Documentation/devicetree/bindings/vendor-prefixes.yaml
index f6064d84a424..a8e1e8d2ef20 100644
--- a/Documentation/devicetree/bindings/vendor-prefixes.yaml
+++ b/Documentation/devicetree/bindings/vendor-prefixes.yaml
@@ -932,6 +932,8 @@ patternProperties:
 description: Unisoc Communications, Inc.
   "^realtek,.*":
 description: Realtek Semiconductor Corp.
+  "^remarkable,.*":
+description: reMarkable AS
   "^renesas,.*":
 description: Renesas Electronics Corporation
   "^rex,.*":
-- 
2.30.1



[PATCH v6 2/3] dt-bindings: arm: fsl: Add the reMarkable 2 e-Ink tablet

2021-03-22 Thread Alistair Francis
Signed-off-by: Alistair Francis 
---
 Documentation/devicetree/bindings/arm/fsl.yaml | 1 +
 1 file changed, 1 insertion(+)

diff --git a/Documentation/devicetree/bindings/arm/fsl.yaml 
b/Documentation/devicetree/bindings/arm/fsl.yaml
index 297c87f45db8..d139440c86b6 100644
--- a/Documentation/devicetree/bindings/arm/fsl.yaml
+++ b/Documentation/devicetree/bindings/arm/fsl.yaml
@@ -617,6 +617,7 @@ properties:
   - kam,imx7d-flex-concentrator   # Kamstrup OMNIA Flex 
Concentrator
   - kam,imx7d-flex-concentrator-mfg   # Kamstrup OMNIA Flex 
Concentrator in manufacturing mode
   - novtech,imx7d-meerkat96   # i.MX7 Meerkat96 Board
+  - remarkable,imx7d-remarkable2  # i.MX7D ReMarkable 2 E-Ink 
Tablet
   - technexion,imx7d-pico-dwarf   # TechNexion i.MX7D Pico-Dwarf
   - technexion,imx7d-pico-hobbit  # TechNexion i.MX7D Pico-Hobbit
   - technexion,imx7d-pico-nymph   # TechNexion i.MX7D Pico-Nymph
-- 
2.30.1



[PATCH v3 2/2] mfd: sy7636a: Initial commit

2021-03-21 Thread Alistair Francis
Initial support for the Silergy SY7636A Power Management chip.

Signed-off-by: Alistair Francis 
---
v3:
 - Address comments in V2
 - Drop regulator patches

 drivers/mfd/Kconfig |  10 ++
 drivers/mfd/Makefile|   1 +
 drivers/mfd/sy7636a.c   | 246 
 include/linux/mfd/sy7636a.h |  46 +++
 4 files changed, 303 insertions(+)
 create mode 100644 drivers/mfd/sy7636a.c
 create mode 100644 include/linux/mfd/sy7636a.h

diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig
index b74efa469e90..a285d11d5be3 100644
--- a/drivers/mfd/Kconfig
+++ b/drivers/mfd/Kconfig
@@ -1351,6 +1351,16 @@ config MFD_SYSCON
  Select this option to enable accessing system control registers
  via regmap.
 
+config MFD_SY7636A
+   tristate "Silergy SY7636A Power Management chip"
+   select MFD_CORE
+   select REGMAP_I2C
+   select REGMAP_IRQ
+   depends on I2C=y
+   help
+ Select this option to enable support for the Silergy SY7636A
+ Power Management chip.
+
 config MFD_DAVINCI_VOICECODEC
tristate
select MFD_CORE
diff --git a/drivers/mfd/Makefile b/drivers/mfd/Makefile
index 834f5463af28..5bfa0d6e5dc5 100644
--- a/drivers/mfd/Makefile
+++ b/drivers/mfd/Makefile
@@ -265,6 +265,7 @@ obj-$(CONFIG_MFD_STMFX) += stmfx.o
 obj-$(CONFIG_MFD_KHADAS_MCU)   += khadas-mcu.o
 obj-$(CONFIG_MFD_ACER_A500_EC) += acer-ec-a500.o
 
+obj-$(CONFIG_MFD_SY7636A)  += sy7636a.o
 obj-$(CONFIG_SGI_MFD_IOC3) += ioc3.o
 obj-$(CONFIG_MFD_SIMPLE_MFD_I2C)   += simple-mfd-i2c.o
 obj-$(CONFIG_MFD_INTEL_M10_BMC)   += intel-m10-bmc.o
diff --git a/drivers/mfd/sy7636a.c b/drivers/mfd/sy7636a.c
new file mode 100644
index ..ecb7c58eb5f4
--- /dev/null
+++ b/drivers/mfd/sy7636a.c
@@ -0,0 +1,246 @@
+// SPDX-License-Identifier: GPL-2.0+
+//
+// MFD parent driver for SY7636A chip
+//
+// Copyright (C) 2019 reMarkable AS - http://www.remarkable.com/
+//
+// Authors: Lars Ivar Miljeteig 
+//  Alistair Francis 
+//
+// Based on the lp87565 driver by Keerthy 
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+
+static const struct regmap_config sy7636a_regmap_config = {
+   .reg_bits = 8,
+   .val_bits = 8,
+};
+
+static const struct mfd_cell sy7636a_cells[] = {
+   { .name = "sy7636a-regulator", },
+   { .name = "sy7636a-temperature", },
+   { .name = "sy7636a-thermal", },
+};
+
+static const struct of_device_id of_sy7636a_match_table[] = {
+   { .compatible = "silergy,sy7636a", },
+   {}
+};
+MODULE_DEVICE_TABLE(of, of_sy7636a_match_table);
+
+static const char * const states[] = {
+   "no fault event",
+   "UVP at VP rail",
+   "UVP at VN rail",
+   "UVP at VPOS rail",
+   "UVP at VNEG rail",
+   "UVP at VDDH rail",
+   "UVP at VEE rail",
+   "SCP at VP rail",
+   "SCP at VN rail",
+   "SCP at VPOS rail",
+   "SCP at VNEG rail",
+   "SCP at VDDH rail",
+   "SCP at VEE rail",
+   "SCP at V COM rail",
+   "UVLO",
+   "Thermal shutdown",
+};
+
+static int sy7636a_get_vcom_voltage_mv(struct regmap *regmap)
+{
+   int ret;
+   unsigned int val, val_h;
+
+   ret = regmap_read(regmap, SY7636A_REG_VCOM_ADJUST_CTRL_L, );
+   if (ret)
+   return ret;
+
+   ret = regmap_read(regmap, SY7636A_REG_VCOM_ADJUST_CTRL_H, _h);
+   if (ret)
+   return ret;
+
+   val |= (val_h << VCOM_ADJUST_CTRL_SHIFT);
+
+   return (val & VCOM_ADJUST_CTRL_MASK) * VCOM_ADJUST_CTRL_SCAL;
+}
+
+static int sy7636a_set_vcom_voltage_mv(struct regmap *regmap, unsigned int 
vcom)
+{
+   int ret;
+   unsigned int val;
+
+   if (vcom < VCOM_MIN || vcom > VCOM_MAX)
+   return -EINVAL;
+
+   val = (unsigned int)(vcom / VCOM_ADJUST_CTRL_SCAL) & 
VCOM_ADJUST_CTRL_MASK;
+
+   ret = regmap_write(regmap, SY7636A_REG_VCOM_ADJUST_CTRL_L, val);
+   if (ret)
+   return ret;
+
+   ret = regmap_write(regmap, SY7636A_REG_VCOM_ADJUST_CTRL_H, val >> 
VCOM_ADJUST_CTRL_SHIFT);
+   if (ret)
+   return ret;
+
+   return 0;
+}
+
+static ssize_t state_show(struct device *dev,
+ struct device_attribute *attr,
+ char *buf)
+{
+   int ret;
+   unsigned int val;
+   struct sy7636a *sy7636a = dev_get_drvdata(dev);
+
+   ret = regmap_read(sy7636a->regmap, SY7636A_REG_FAULT_FLAG, );
+   if (ret) {
+   dev_err(sy7636a->dev, "Failed to read from device\n");
+   return ret;
+   }
+
+   val = val >> FAULT_FLAG_SHIFT;
+
+   if (val >= ARRAY_SIZE(states)) {
+   dev_err(sy76

[PATCH v3 1/2] dt-bindings: mfd: Initial commit of silergy,sy7636a.yaml

2021-03-21 Thread Alistair Francis
Initial support for the Silergy SY7636A Power Management chip
and regulator.

Signed-off-by: Alistair Francis 
---
 .../bindings/mfd/silergy,sy7636a.yaml | 63 +++
 1 file changed, 63 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/mfd/silergy,sy7636a.yaml

diff --git a/Documentation/devicetree/bindings/mfd/silergy,sy7636a.yaml 
b/Documentation/devicetree/bindings/mfd/silergy,sy7636a.yaml
new file mode 100644
index ..f260a8eae226
--- /dev/null
+++ b/Documentation/devicetree/bindings/mfd/silergy,sy7636a.yaml
@@ -0,0 +1,63 @@
+# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/mfd/silergy,sy7636a.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: silergy sy7636a PMIC
+
+maintainers:
+  - Alistair Francis 
+
+properties:
+  compatible:
+const: silergy,sy7636a
+
+  reg:
+maxItems: 1
+
+  '#thermal-sensor-cells':
+const: 0
+
+  regulators:
+type: object
+$ref: /schemas/regulator/regulator.yaml#
+
+properties:
+  compatible:
+const: silergy,sy7636a-regulator
+
+  regulator-name:
+pattern: "vcom"
+
+required:
+  - compatible
+  - reg
+  - '#thermal-sensor-cells'
+
+additionalProperties: false
+
+examples:
+  - |
+i2c {
+  #address-cells = <1>;
+  #size-cells = <0>;
+
+  sy7636a@62 {
+compatible = "silergy,sy7636a";
+reg = <0x62>;
+status = "okay";
+pinctrl-names = "default";
+pinctrl-0 = <_epdpmic>;
+#thermal-sensor-cells = <0>;
+
+regulators {
+  compatible = "silergy,sy7636a-regulator";
+  reg_epdpmic: vcom {
+regulator-name = "vcom";
+regulator-boot-on;
+  };
+};
+  };
+};
+...
-- 
2.30.1



[PATCH v3 9/9] ARM: dts: imx7d: remarkable2: add wacom digitizer device

2021-03-21 Thread Alistair Francis
Enable the wacom_i2c touchscreen for the reMarkable2.

Signed-off-by: Alistair Francis 
---
 arch/arm/boot/dts/imx7d-remarkable2.dts | 52 +
 1 file changed, 52 insertions(+)

diff --git a/arch/arm/boot/dts/imx7d-remarkable2.dts 
b/arch/arm/boot/dts/imx7d-remarkable2.dts
index 7ed4eb5b8ea9..aa22b77af440 100644
--- a/arch/arm/boot/dts/imx7d-remarkable2.dts
+++ b/arch/arm/boot/dts/imx7d-remarkable2.dts
@@ -33,6 +33,19 @@ reg_brcm: regulator-brcm {
startup-delay-us = <150>;
};
 
+   reg_digitizer: regulator-digitizer {
+   compatible = "regulator-fixed";
+   regulator-name = "VDD_3V3_DIGITIZER";
+   regulator-min-microvolt = <330>;
+   regulator-max-microvolt = <330>;
+   pinctrl-names = "default", "sleep";
+   pinctrl-0 = <_digitizer_reg>;
+   pinctrl-1 = <_digitizer_reg>;
+   gpio = < 6 GPIO_ACTIVE_HIGH>;
+   enable-active-high;
+   startup-delay-us = <10>; /* 100 ms */
+   };
+
wifi_pwrseq: wifi_pwrseq {
compatible = "mmc-pwrseq-simple";
pinctrl-names = "default";
@@ -50,6 +63,28 @@  {
assigned-clock-rates = <0>, <32768>;
 };
 
+ {
+   clock-frequency = <40>;
+   pinctrl-names = "default";
+   pinctrl-0 = <_i2c1>;
+   status = "okay";
+
+   wacom_digitizer: digitizer@9 {
+   compatible = "wacom,generic";
+   reg = <0x09>;
+   pinctrl-names = "default";
+   pinctrl-0 = <_wacom>;
+   interrupt-parent = <>;
+   interrupts = <1 IRQ_TYPE_EDGE_FALLING>;
+   flip-tilt-x;
+   flip-tilt-y;
+   flip-pos-x;
+   flip-pos-y;
+   flip-distance;
+   vdd-supply = <_digitizer>;
+   };
+};
+
 _pwrkey {
status = "okay";
 };
@@ -123,6 +158,16 @@ pinctrl_digitizer_reg: digitizerreggrp {
MX7D_PAD_LPSR_GPIO1_IO06__GPIO1_IO6 0x14
>;
};
+
+   pinctrl_wacom: wacomgrp {
+   fsl,pins = <
+   /*MX7D_PAD_LPSR_GPIO1_IO05__GPIO1_IO5   0x0014 /* 
FWE */
+   MX7D_PAD_LPSR_GPIO1_IO04__GPIO1_IO4 0x0074 /* 
PDCTB */
+   MX7D_PAD_LPSR_GPIO1_IO01__GPIO1_IO1 0x0034 /* 
WACOM INT */
+   /*MX7D_PAD_LPSR_GPIO1_IO06__GPIO1_IO6   0x0014 /* 
WACOM PWR ENABLE */
+   /*MX7D_PAD_LPSR_GPIO1_IO00__GPIO1_IO0   0x0074 /* 
WACOM RESET */
+   >;
+   };
 };
 
  {
@@ -133,6 +178,13 @@ MX7D_PAD_SAI1_TX_BCLK__GPIO6_IO13  0x14
>;
};
 
+   pinctrl_i2c1: i2c1grp {
+   fsl,pins = <
+   MX7D_PAD_I2C1_SDA__I2C1_SDA 0x407f
+   MX7D_PAD_I2C1_SCL__I2C1_SCL 0x407f
+   >;
+   };
+
pinctrl_uart1: uart1grp {
fsl,pins = <
MX7D_PAD_UART1_TX_DATA__UART1_DCE_TX0x79
-- 
2.30.1



[PATCH v3 8/9] ARM: imx_v6_v7_defconfig: Enable Wacom I2C

2021-03-21 Thread Alistair Francis
Enable the Wacom I2C in the imx defconfig as it is used by the
reMarkable2 tablet.

Signed-off-by: Alistair Francis 
---
 arch/arm/configs/imx_v6_v7_defconfig | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/arm/configs/imx_v6_v7_defconfig 
b/arch/arm/configs/imx_v6_v7_defconfig
index 70928cc48939..cd80e85d37cf 100644
--- a/arch/arm/configs/imx_v6_v7_defconfig
+++ b/arch/arm/configs/imx_v6_v7_defconfig
@@ -174,6 +174,7 @@ CONFIG_TOUCHSCREEN_DA9052=y
 CONFIG_TOUCHSCREEN_EGALAX=y
 CONFIG_TOUCHSCREEN_GOODIX=y
 CONFIG_TOUCHSCREEN_ILI210X=y
+CONFIG_TOUCHSCREEN_WACOM_I2C=y
 CONFIG_TOUCHSCREEN_MAX11801=y
 CONFIG_TOUCHSCREEN_IMX6UL_TSC=y
 CONFIG_TOUCHSCREEN_EDT_FT5X06=y
-- 
2.30.1



[PATCH v3 6/9] Input: wacom_i2c - Clean up the query device fields

2021-03-21 Thread Alistair Francis
Improve the query device fields to be more verbose.

Signed-off-by: Alistair Francis 
---
 drivers/input/touchscreen/wacom_i2c.c | 71 +++
 1 file changed, 51 insertions(+), 20 deletions(-)

diff --git a/drivers/input/touchscreen/wacom_i2c.c 
b/drivers/input/touchscreen/wacom_i2c.c
index 929680dce9cf..7aa0d1c3dbc9 100644
--- a/drivers/input/touchscreen/wacom_i2c.c
+++ b/drivers/input/touchscreen/wacom_i2c.c
@@ -13,15 +13,32 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 
-#define WACOM_CMD_QUERY0   0x04
-#define WACOM_CMD_QUERY1   0x00
-#define WACOM_CMD_QUERY2   0x33
-#define WACOM_CMD_QUERY3   0x02
-#define WACOM_CMD_THROW0   0x05
-#define WACOM_CMD_THROW1   0x00
+// Registers
+#define WACOM_COMMAND_LSB   0x04
+#define WACOM_COMMAND_MSB   0x00
+
+#define WACOM_DATA_LSB  0x05
+#define WACOM_DATA_MSB  0x00
+
+// Report types
+#define REPORT_FEATURE  0x30
+
+// Requests / operations
+#define OPCODE_GET_REPORT   0x02
+
+// Power settings
+#define POWER_ON0x00
+#define POWER_SLEEP 0x01
+
+// Input report ids
+#define WACOM_PEN_DATA_REPORT   2
+#define WACOM_SHINONOME_REPORT  26
+
+#define WACOM_QUERY_REPORT 3
 #define WACOM_QUERY_SIZE   22
 
 struct wacom_features {
@@ -48,31 +65,41 @@ static int wacom_query_device(struct i2c_client *client,
  struct wacom_features *features)
 {
int ret;
-   u8 cmd1[] = { WACOM_CMD_QUERY0, WACOM_CMD_QUERY1,
-   WACOM_CMD_QUERY2, WACOM_CMD_QUERY3 };
-   u8 cmd2[] = { WACOM_CMD_THROW0, WACOM_CMD_THROW1 };
u8 data[WACOM_QUERY_SIZE];
+   struct reset_control *rstc;
+
+   u8 get_query_data_cmd[] = {
+   WACOM_COMMAND_LSB,
+   WACOM_COMMAND_MSB,
+   REPORT_FEATURE | WACOM_QUERY_REPORT,
+   OPCODE_GET_REPORT,
+   WACOM_DATA_LSB,
+   WACOM_DATA_MSB,
+   };
+
struct i2c_msg msgs[] = {
+   // Request reading of feature ReportID: 3 (Pen Query Data)
{
.addr = client->addr,
.flags = 0,
-   .len = sizeof(cmd1),
-   .buf = cmd1,
-   },
-   {
-   .addr = client->addr,
-   .flags = 0,
-   .len = sizeof(cmd2),
-   .buf = cmd2,
+   .len = sizeof(get_query_data_cmd),
+   .buf = get_query_data_cmd,
},
+   // Read 21 bytes
{
.addr = client->addr,
.flags = I2C_M_RD,
-   .len = sizeof(data),
+   .len = WACOM_QUERY_SIZE - 1,
.buf = data,
},
};
 
+   rstc = devm_reset_control_get_optional_exclusive(>dev, NULL);
+   if (IS_ERR(rstc))
+   dev_err(>dev, "Failed to get reset control before 
init\n");
+   else
+   reset_control_reset(rstc);
+
ret = i2c_transfer(client->adapter, msgs, ARRAY_SIZE(msgs));
if (ret < 0)
return ret;
@@ -89,9 +116,13 @@ static int wacom_query_device(struct i2c_client *client,
features->tilt_y_max = get_unaligned_le16([19]);
 
dev_dbg(>dev,
-   "x_max:%d, y_max:%d, pressure:%d, fw:%d\n",
+   "x_max:%d, y_max:%d, pressure:%d, fw:%d, "
+   "distance: %d, phys distance: %d, "
+   "tilt_x_max: %d, tilt_y_max: %d\n",
features->x_max, features->y_max,
-   features->pressure_max, features->fw_version);
+   features->pressure_max, features->fw_version,
+   features->distance_max, features->distance_physical_max,
+   features->tilt_x_max, features->tilt_y_max);
 
return 0;
 }
-- 
2.30.1



[PATCH v3 7/9] Input: wacom_i2c - Add support for vdd regulator

2021-03-21 Thread Alistair Francis
Add support for a VDD regulator. This allows the kernel to prove the
Wacom-I2C device on the rM2.

Signed-off-by: Alistair Francis 
---
 drivers/input/touchscreen/wacom_i2c.c | 22 ++
 1 file changed, 22 insertions(+)

diff --git a/drivers/input/touchscreen/wacom_i2c.c 
b/drivers/input/touchscreen/wacom_i2c.c
index 7aa0d1c3dbc9..00db516fa3de 100644
--- a/drivers/input/touchscreen/wacom_i2c.c
+++ b/drivers/input/touchscreen/wacom_i2c.c
@@ -13,6 +13,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -56,6 +57,7 @@ struct wacom_i2c {
struct i2c_client *client;
struct input_dev *input;
struct touchscreen_properties props;
+   struct regulator *vdd;
u8 data[WACOM_QUERY_SIZE];
bool prox;
int tool;
@@ -203,11 +205,29 @@ static int wacom_i2c_probe(struct i2c_client *client,
struct wacom_features features = { 0 };
int error;
 
+   wac_i2c = kzalloc(sizeof(*wac_i2c), GFP_KERNEL);
+   if (!wac_i2c)
+   return -ENOMEM;
+
if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) {
dev_err(>dev, "i2c_check_functionality error\n");
return -EIO;
}
 
+   wac_i2c->vdd = regulator_get(>dev, "vdd");
+   if (IS_ERR(wac_i2c->vdd)) {
+   error = PTR_ERR(wac_i2c->vdd);
+   kfree(wac_i2c);
+   return error;
+   }
+
+   error = regulator_enable(wac_i2c->vdd);
+   if (error) {
+   regulator_put(wac_i2c->vdd);
+   kfree(wac_i2c);
+   return error;
+   }
+
error = wacom_query_device(client, );
if (error)
return error;
@@ -275,6 +295,8 @@ static int wacom_i2c_probe(struct i2c_client *client,
 err_free_irq:
free_irq(client->irq, wac_i2c);
 err_free_mem:
+   regulator_disable(wac_i2c->vdd);
+   regulator_put(wac_i2c->vdd);
input_free_device(input);
kfree(wac_i2c);
 
-- 
2.30.1



[PATCH v3 4/9] Input: wacom_i2c - Add touchscren properties

2021-03-21 Thread Alistair Francis
Connect touchscreen properties to the wacom_i2c.

Signed-off-by: Alistair Francis 
---
 drivers/input/touchscreen/wacom_i2c.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/input/touchscreen/wacom_i2c.c 
b/drivers/input/touchscreen/wacom_i2c.c
index fc0bf583d33b..9b2ed0463d09 100644
--- a/drivers/input/touchscreen/wacom_i2c.c
+++ b/drivers/input/touchscreen/wacom_i2c.c
@@ -11,6 +11,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -33,6 +34,7 @@ struct wacom_features {
 struct wacom_i2c {
struct i2c_client *client;
struct input_dev *input;
+   struct touchscreen_properties props;
u8 data[WACOM_QUERY_SIZE];
bool prox;
int tool;
@@ -188,6 +190,7 @@ static int wacom_i2c_probe(struct i2c_client *client,
__set_bit(BTN_STYLUS2, input->keybit);
__set_bit(BTN_TOUCH, input->keybit);
 
+   touchscreen_parse_properties(input, true, _i2c->props);
input_set_abs_params(input, ABS_X, 0, features.x_max, 0, 0);
input_set_abs_params(input, ABS_Y, 0, features.y_max, 0, 0);
input_set_abs_params(input, ABS_PRESSURE,
-- 
2.30.1



[PATCH v3 5/9] Input: wacom_i2c - Add support for distance and tilt x/y

2021-03-21 Thread Alistair Francis
This is based on the out of tree rM2 driver.

Signed-off-by: Alistair Francis 
---
 drivers/input/touchscreen/wacom_i2c.c | 25 +++--
 1 file changed, 23 insertions(+), 2 deletions(-)

diff --git a/drivers/input/touchscreen/wacom_i2c.c 
b/drivers/input/touchscreen/wacom_i2c.c
index 9b2ed0463d09..929680dce9cf 100644
--- a/drivers/input/touchscreen/wacom_i2c.c
+++ b/drivers/input/touchscreen/wacom_i2c.c
@@ -22,12 +22,16 @@
 #define WACOM_CMD_QUERY3   0x02
 #define WACOM_CMD_THROW0   0x05
 #define WACOM_CMD_THROW1   0x00
-#define WACOM_QUERY_SIZE   19
+#define WACOM_QUERY_SIZE   22
 
 struct wacom_features {
int x_max;
int y_max;
int pressure_max;
+   int distance_max;
+   int distance_physical_max;
+   int tilt_x_max;
+   int tilt_y_max;
char fw_version;
 };
 
@@ -79,6 +83,10 @@ static int wacom_query_device(struct i2c_client *client,
features->y_max = get_unaligned_le16([5]);
features->pressure_max = get_unaligned_le16([11]);
features->fw_version = get_unaligned_le16([13]);
+   features->distance_max = data[15];
+   features->distance_physical_max = data[16];
+   features->tilt_x_max = get_unaligned_le16([17]);
+   features->tilt_y_max = get_unaligned_le16([19]);
 
dev_dbg(>dev,
"x_max:%d, y_max:%d, pressure:%d, fw:%d\n",
@@ -95,6 +103,7 @@ static irqreturn_t wacom_i2c_irq(int irq, void *dev_id)
u8 *data = wac_i2c->data;
unsigned int x, y, pressure;
unsigned char tsw, f1, f2, ers;
+   short tilt_x, tilt_y, distance;
int error;
 
error = i2c_master_recv(wac_i2c->client,
@@ -109,6 +118,11 @@ static irqreturn_t wacom_i2c_irq(int irq, void *dev_id)
x = le16_to_cpup((__le16 *)[4]);
y = le16_to_cpup((__le16 *)[6]);
pressure = le16_to_cpup((__le16 *)[8]);
+   distance = data[10];
+
+   /* Signed */
+   tilt_x = le16_to_cpup((__le16 *)[11]);
+   tilt_y = le16_to_cpup((__le16 *)[13]);
 
if (!wac_i2c->prox)
wac_i2c->tool = (data[3] & 0x0c) ?
@@ -123,6 +137,9 @@ static irqreturn_t wacom_i2c_irq(int irq, void *dev_id)
input_report_abs(input, ABS_X, x);
input_report_abs(input, ABS_Y, y);
input_report_abs(input, ABS_PRESSURE, pressure);
+   input_report_abs(input, ABS_DISTANCE, distance);
+   input_report_abs(input, ABS_TILT_X, tilt_x);
+   input_report_abs(input, ABS_TILT_Y, tilt_y);
input_sync(input);
 
 out:
@@ -195,7 +212,11 @@ static int wacom_i2c_probe(struct i2c_client *client,
input_set_abs_params(input, ABS_Y, 0, features.y_max, 0, 0);
input_set_abs_params(input, ABS_PRESSURE,
 0, features.pressure_max, 0, 0);
-
+   input_set_abs_params(input, ABS_DISTANCE, 0, features.distance_max, 0, 
0);
+   input_set_abs_params(input, ABS_TILT_X, -features.tilt_x_max,
+features.tilt_x_max, 0, 0);
+   input_set_abs_params(input, ABS_TILT_Y, -features.tilt_y_max,
+features.tilt_y_max, 0, 0);
input_set_drvdata(input, wac_i2c);
 
error = request_threaded_irq(client->irq, NULL, wacom_i2c_irq,
-- 
2.30.1



[PATCH v3 2/9] dt-bindings: touchscreen: Initial commit of wacom,generic

2021-03-21 Thread Alistair Francis
Signed-off-by: Alistair Francis 
---
 .../input/touchscreen/wacom,generic.yaml  | 48 +++
 1 file changed, 48 insertions(+)
 create mode 100644 
Documentation/devicetree/bindings/input/touchscreen/wacom,generic.yaml

diff --git 
a/Documentation/devicetree/bindings/input/touchscreen/wacom,generic.yaml 
b/Documentation/devicetree/bindings/input/touchscreen/wacom,generic.yaml
new file mode 100644
index ..19bbfc55ed76
--- /dev/null
+++ b/Documentation/devicetree/bindings/input/touchscreen/wacom,generic.yaml
@@ -0,0 +1,48 @@
+# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/input/touchscreen/wacom,generic.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Wacom I2C Controller
+
+maintainers:
+  - Alistair Francis 
+
+allOf:
+  - $ref: touchscreen.yaml#
+
+properties:
+  compatible:
+const: wacom,generic
+
+  reg:
+maxItems: 1
+
+  interrupts:
+maxItems: 1
+
+  vdd-supply:
+maxItems: 1
+
+required:
+  - compatible
+  - reg
+  - interrupts
+
+additionalProperties: false
+
+examples:
+  - |
+#include "dt-bindings/interrupt-controller/irq.h"
+i2c {
+#address-cells = <1>;
+#size-cells = <0>;
+digitiser@9 {
+compatible = "wacom,generic";
+reg = <0x9>;
+interrupt-parent = <>;
+interrupts = <9 IRQ_TYPE_LEVEL_LOW>;
+vdd-supply = <_touch>;
+};
+};
-- 
2.30.1



[PATCH v3 3/9] Input: wacom_i2c - Add device tree support to wacom_i2c

2021-03-21 Thread Alistair Francis
Allow the wacom-i2c device to be exposed via device tree.

Signed-off-by: Alistair Francis 
---
 drivers/input/touchscreen/wacom_i2c.c | 8 
 1 file changed, 8 insertions(+)

diff --git a/drivers/input/touchscreen/wacom_i2c.c 
b/drivers/input/touchscreen/wacom_i2c.c
index 1afc6bde2891..fc0bf583d33b 100644
--- a/drivers/input/touchscreen/wacom_i2c.c
+++ b/drivers/input/touchscreen/wacom_i2c.c
@@ -12,6 +12,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 
 #define WACOM_CMD_QUERY0   0x04
@@ -262,10 +263,17 @@ static const struct i2c_device_id wacom_i2c_id[] = {
 };
 MODULE_DEVICE_TABLE(i2c, wacom_i2c_id);
 
+static const struct of_device_id wacom_i2c_of_match_table[] __maybe_unused = {
+   { .compatible = "wacom,generic" },
+   {}
+};
+MODULE_DEVICE_TABLE(of, wacom_i2c_of_match_table);
+
 static struct i2c_driver wacom_i2c_driver = {
.driver = {
.name   = "wacom_i2c",
.pm = _i2c_pm,
+   .of_match_table = of_match_ptr(wacom_i2c_of_match_table),
},
 
.probe  = wacom_i2c_probe,
-- 
2.30.1



[PATCH v3 1/9] dt-bindings: Add Wacom to vendor bindings

2021-03-21 Thread Alistair Francis
Signed-off-by: Alistair Francis 
---
 Documentation/devicetree/bindings/vendor-prefixes.yaml | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/Documentation/devicetree/bindings/vendor-prefixes.yaml 
b/Documentation/devicetree/bindings/vendor-prefixes.yaml
index a8e1e8d2ef20..996f4de2fff5 100644
--- a/Documentation/devicetree/bindings/vendor-prefixes.yaml
+++ b/Documentation/devicetree/bindings/vendor-prefixes.yaml
@@ -1216,6 +1216,8 @@ patternProperties:
 description: Vision Optical Technology Co., Ltd.
   "^vxt,.*":
 description: VXT Ltd
+  "^wacom,.*":
+description: Wacom Co., Ltd
   "^wand,.*":
 description: Wandbord (Technexion)
   "^waveshare,.*":
-- 
2.30.1



[PATCH v3 0/9] Add Wacom I2C support to rM2

2021-03-21 Thread Alistair Francis
From: Alistair Francis 

Add support to the reMarkable2 (rM2) for the Wacom I2C device.

This is based on the reMarkable Linux fork and with this series I am
able to probe the Wacom digitiser.

Alistair Francis (9):
  dt-bindings: Add Wacom to vendor bindings
  dt-bindings: touchscreen: Initial commit of wacom,generic
  Input: wacom_i2c - Add device tree support to wacom_i2c
  Input: wacom_i2c - Add touchscren properties
  Input: wacom_i2c - Add support for distance and tilt x/y
  Input: wacom_i2c - Clean up the query device fields
  Input: wacom_i2c - Add support for vdd regulator
  ARM: imx_v6_v7_defconfig: Enable Wacom I2C
  ARM: dts: imx7d: remarkable2: add wacom digitizer device

 .../input/touchscreen/wacom,generic.yaml  |  48 +++
 .../devicetree/bindings/vendor-prefixes.yaml  |   2 +
 arch/arm/boot/dts/imx7d-remarkable2.dts   |  52 +++
 arch/arm/configs/imx_v6_v7_defconfig  |   1 +
 drivers/input/touchscreen/wacom_i2c.c | 129 +++---
 5 files changed, 210 insertions(+), 22 deletions(-)
 create mode 100644 
Documentation/devicetree/bindings/input/touchscreen/wacom,generic.yaml

-- 
2.30.1



Re: [PATCH 2/6] mfd: Initial commit of sy7636a

2021-03-20 Thread Alistair Francis
On Thu, Feb 4, 2021 at 5:31 AM Lee Jones  wrote:
>
> On Sat, 16 Jan 2021, Alistair Francis wrote:
>
> > Initial support for the Silergy SY7636A Power Management chip
> > driver.
>
> Please remove "driver", as this is not support for the driver, it *is*
> the driver which supports the chip.

Sorry for the long delay here.

I have addressed your comments.

>
> > Signed-off-by: Alistair Francis 
> > ---
> >  drivers/mfd/Kconfig |  10 ++
> >  drivers/mfd/Makefile|   2 +
> >  drivers/mfd/sy7636a.c   | 252 
> >  include/linux/mfd/sy7636a.h |  50 +++
> >  4 files changed, 314 insertions(+)
> >  create mode 100644 drivers/mfd/sy7636a.c
> >  create mode 100644 include/linux/mfd/sy7636a.h
> >
> > diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig
> > index bdfce7b15621..c8c62d92433c 100644
> > --- a/drivers/mfd/Kconfig
> > +++ b/drivers/mfd/Kconfig
> > @@ -1360,6 +1360,16 @@ config MFD_SYSCON
> > Select this option to enable accessing system control registers
> > via regmap.
> >
> > +config MFD_SY7636A
> > + tristate "Silergy SY7636A Power Management chip driver"
>
> Again, please remove the word "driver" here.
>
> > + select MFD_CORE
> > + select REGMAP_I2C
> > + select REGMAP_IRQ
> > + depends on I2C=y
> > + help
> > +   Select this option to enable support for the Silergy SY7636A
> > +   Power Management chip driver.
>
> And again.

I removed "driver" from all of these.

>
> >  config MFD_DAVINCI_VOICECODEC
> >   tristate
> >   select MFD_CORE
> > diff --git a/drivers/mfd/Makefile b/drivers/mfd/Makefile
> > index 14fdb188af02..1fa1e635f506 100644
> > --- a/drivers/mfd/Makefile
> > +++ b/drivers/mfd/Makefile
> > @@ -265,6 +265,8 @@ obj-$(CONFIG_MFD_ROHM_BD718XX)+= rohm-bd718x7.o
> >  obj-$(CONFIG_MFD_STMFX)  += stmfx.o
> >  obj-$(CONFIG_MFD_KHADAS_MCU) += khadas-mcu.o
> >
> > +obj-$(CONFIG_MFD_SY7636A)+= sy7636a.o
> > +
>
> Why does this have to be segregated?

Fixed

>
> >  obj-$(CONFIG_SGI_MFD_IOC3)   += ioc3.o
> >  obj-$(CONFIG_MFD_SIMPLE_MFD_I2C) += simple-mfd-i2c.o
> >  obj-$(CONFIG_MFD_INTEL_M10_BMC)   += intel-m10-bmc.o
> > diff --git a/drivers/mfd/sy7636a.c b/drivers/mfd/sy7636a.c
> > new file mode 100644
> > index ..39aac965d854
> > --- /dev/null
> > +++ b/drivers/mfd/sy7636a.c
> > @@ -0,0 +1,252 @@
> > +// SPDX-License-Identifier: GPL-2.0+
> > +/*
> > + * MFD driver for SY7636A chip
>
> "Parent driver".
>
> > + * Copyright (C) 2019 reMarkable AS - http://www.remarkable.com/
>
> This is quite out of date.  Please update.

I don't own this copyright, so I would rather not change it.

>
> > + * Author: Lars Ivar Miljeteig 
> > + *
> > + * This program is free software; you can redistribute it and/or
> > + * modify it under the terms of the GNU General Public License as
> > + * published by the Free Software Foundation version 2.
> > + *
> > + * This program is distributed "as is" WITHOUT ANY WARRANTY of any
> > + * kind, whether express or implied; without even the implied warranty
> > + * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> > + * GNU General Public License for more details.
>
> This test is replaced by the SPDX header above.

Removed.

>
> > + * Based on the lp87565 driver by Keerthy 
> > + */
> > +
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +
> > +#include 
> > +
> > +static const struct regmap_config sy7636a_regmap_config = {
> > + .reg_bits = 8,
> > + .val_bits = 8,
> > +};
> > +
> > +static const struct mfd_cell sy7636a_cells[] = {
> > + { .name = "sy7636a-regulator", },
> > + { .name = "sy7636a-temperature", },
> > + { .name = "sy7636a-thermal", },
> > +};
> > +
> > +static const struct of_device_id of_sy7636a_match_table[] = {
> > + { .compatible = "silergy,sy7636a", },
> > + {}
> > +};
> > +MODULE_DEVICE_TABLE(of, of_sy7636a_match_table);
>
> Please move this to where it is used i.e. at the bottom of the file.

Done.

>
> > +static const char * const states[] = {
> > + "no fault event",
> > + "UVP at VP rail",
> > + "UVP at VN rail",
> 

Re: [PATCH v5 3/3] ARM: imx7d-remarkable2.dts: Initial device tree for reMarkable2

2021-03-20 Thread Alistair Francis
On Fri, Mar 19, 2021 at 9:06 AM Marco Felsch  wrote:
>
> Hi Alistair,
>
> the patch looks quite good only a few notes inline.
>
> PS: It would be cool to have a log to previous patch versions.

I'm not sure how I could add that, I will add a changelog for this
version though.

>
> On 21-03-15 22:27, Alistair Francis wrote:
>
> ...
>
> > + {
> > + status = "disabled";
> > +};
>
> Why do you disable the crypto subsystem?
>
> > +_apbh {
> > + status = "disabled";
> > +};
>
> Why do you disable this dma controller?
>
> > +
> > + {
> > + status = "okay";
> > +};
>
> This is the default state so you can drop this node.

You are right, these are all just left over from the vendor DT, I have
removed all 3.

Alistair

>
> Regards,
>   Marco


[PATCH v5 3/3] ARM: imx7d-remarkable2.dts: Initial device tree for reMarkable2

2021-03-15 Thread Alistair Francis
The reMarkable2 (https://remarkable.com) is an e-ink tablet based on
the imx7d SoC.

This commit is based on the DTS provide by reMarkable but ported to the
latest kernel (instead of 4.14). I have removed references to
non-upstream devices and have changed the UART so that the console can
be accessed without having to open up the device via the OTG pogo pins.

Currently the kernel boots, but there is no support for the display.

WiFi is untested (no dispaly or UART RX makes it hard to test), but
should work with the current upstream driver. As it's untested it's not
included in this commit.

Signed-off-by: Alistair Francis 
---
 arch/arm/boot/dts/Makefile  |   1 +
 arch/arm/boot/dts/imx7d-remarkable2.dts | 166 
 2 files changed, 167 insertions(+)
 create mode 100644 arch/arm/boot/dts/imx7d-remarkable2.dts

diff --git a/arch/arm/boot/dts/Makefile b/arch/arm/boot/dts/Makefile
index 8e5d4ab4e75e..dc8e378689af 100644
--- a/arch/arm/boot/dts/Makefile
+++ b/arch/arm/boot/dts/Makefile
@@ -660,6 +660,7 @@ dtb-$(CONFIG_SOC_IMX7D) += \
imx7d-pico-hobbit.dtb \
imx7d-pico-nymph.dtb \
imx7d-pico-pi.dtb \
+   imx7d-remarkable2.dtb \
imx7d-sbc-imx7.dtb \
imx7d-sdb.dtb \
imx7d-sdb-reva.dtb \
diff --git a/arch/arm/boot/dts/imx7d-remarkable2.dts 
b/arch/arm/boot/dts/imx7d-remarkable2.dts
new file mode 100644
index ..86d555bd33c2
--- /dev/null
+++ b/arch/arm/boot/dts/imx7d-remarkable2.dts
@@ -0,0 +1,166 @@
+// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
+/*
+ * Copyright (C) 2015 Freescale Semiconductor, Inc.
+ * Copyright (C) 2019 reMarkable AS - http://www.remarkable.com/
+ *
+ */
+
+/dts-v1/;
+
+#include "imx7d.dtsi"
+
+/ {
+   model = "reMarkable 2.0";
+   compatible = "remarkable,imx7d-remarkable2", "fsl,imx7d";
+
+   chosen {
+   stdout-path = 
+   };
+
+   memory {
+   reg = <0x8000 0x4000>;
+   };
+};
+
+ {
+   assigned-clocks = < IMX7D_CLKO2_ROOT_SRC>,
+ < IMX7D_CLKO2_ROOT_DIV>;
+   assigned-clock-parents = < IMX7D_CKIL>;
+   assigned-clock-rates = <0>, <32768>;
+};
+
+ {
+   status = "disabled";
+};
+
+_apbh {
+   status = "disabled";
+};
+
+ {
+   status = "okay";
+};
+
+_pwrkey {
+   status = "okay";
+};
+
+ {
+   pinctrl-names = "default";
+   pinctrl-0 = <_uart1>;
+   assigned-clocks = < IMX7D_UART1_ROOT_SRC>;
+   assigned-clock-parents = < IMX7D_OSC_24M_CLK>;
+   status = "okay";
+};
+
+ {
+   pinctrl-names = "default";
+   pinctrl-0 = <_uart6>;
+   assigned-clocks = < IMX7D_UART6_ROOT_SRC>;
+   assigned-clock-parents = < IMX7D_OSC_24M_CLK>;
+   status = "okay";
+};
+
+ {
+   srp-disable;
+   hnp-disable;
+   status = "okay";
+};
+
+ {
+   pinctrl-names = "default", "state_100mhz", "state_200mhz", "sleep";
+   pinctrl-0 = <_usdhc3>;
+   pinctrl-1 = <_usdhc3_100mhz>;
+   pinctrl-2 = <_usdhc3_200mhz>;
+   pinctrl-3 = <_usdhc3>;
+   assigned-clocks = < IMX7D_USDHC3_ROOT_CLK>;
+   assigned-clock-rates = <4>;
+   bus-width = <8>;
+   non-removable;
+   status = "okay";
+};
+
+ {
+   pinctrl-names = "default";
+   pinctrl-0 = <_wdog>;
+   fsl,ext-reset-output;
+};
+
+_lpsr {
+   pinctrl_digitizer_reg: digitizerreggrp {
+   fsl,pins = <
+   /* DIGITIZER_PWR_EN */
+   MX7D_PAD_LPSR_GPIO1_IO06__GPIO1_IO6 0x14
+   >;
+   };
+};
+
+ {
+   pinctrl_uart1: uart1grp {
+   fsl,pins = <
+   MX7D_PAD_UART1_TX_DATA__UART1_DCE_TX0x79
+   MX7D_PAD_UART1_RX_DATA__UART1_DCE_RX0x79
+   >;
+   };
+
+   pinctrl_uart6: uart6grp {
+   fsl,pins = <
+   MX7D_PAD_EPDC_DATA09__UART6_DCE_TX  0x79
+   MX7D_PAD_EPDC_DATA08__UART6_DCE_RX  0x79
+   >;
+   };
+
+   pinctrl_usdhc3: usdhc3grp {
+   fsl,pins = <
+   MX7D_PAD_SD3_CMD__SD3_CMD   0x59
+   MX7D_PAD_SD3_CLK__SD3_CLK   0x19
+   MX7D_PAD_SD3_DATA0__SD3_DATA0   0x59
+   MX7D_PAD_SD3_DATA1__SD3_DATA1   0x59
+   MX7D_PAD_SD3_DATA2__SD3_DATA2   0x59
+   MX7D_PAD_SD3_DATA3__SD3_DATA3   0x59
+   MX7D_PAD_SD3_DATA4__SD3_DATA4   0x59
+   MX7D_PAD_SD3_DATA5__SD3_DAT

[PATCH v5 1/3] dt-bindings: Add vendor prefix for reMarkable

2021-03-15 Thread Alistair Francis
reMarkable AS produces eInk tablets

Signed-off-by: Alistair Francis 
---
 Documentation/devicetree/bindings/vendor-prefixes.yaml | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/Documentation/devicetree/bindings/vendor-prefixes.yaml 
b/Documentation/devicetree/bindings/vendor-prefixes.yaml
index f6064d84a424..a8e1e8d2ef20 100644
--- a/Documentation/devicetree/bindings/vendor-prefixes.yaml
+++ b/Documentation/devicetree/bindings/vendor-prefixes.yaml
@@ -932,6 +932,8 @@ patternProperties:
 description: Unisoc Communications, Inc.
   "^realtek,.*":
 description: Realtek Semiconductor Corp.
+  "^remarkable,.*":
+description: reMarkable AS
   "^renesas,.*":
 description: Renesas Electronics Corporation
   "^rex,.*":
-- 
2.30.1



[PATCH v5 2/3] dt-bindings: arm: fsl: Add the reMarkable 2 e-Ink tablet

2021-03-15 Thread Alistair Francis
Signed-off-by: Alistair Francis 
---
 Documentation/devicetree/bindings/arm/fsl.yaml | 1 +
 1 file changed, 1 insertion(+)

diff --git a/Documentation/devicetree/bindings/arm/fsl.yaml 
b/Documentation/devicetree/bindings/arm/fsl.yaml
index 297c87f45db8..d139440c86b6 100644
--- a/Documentation/devicetree/bindings/arm/fsl.yaml
+++ b/Documentation/devicetree/bindings/arm/fsl.yaml
@@ -617,6 +617,7 @@ properties:
   - kam,imx7d-flex-concentrator   # Kamstrup OMNIA Flex 
Concentrator
   - kam,imx7d-flex-concentrator-mfg   # Kamstrup OMNIA Flex 
Concentrator in manufacturing mode
   - novtech,imx7d-meerkat96   # i.MX7 Meerkat96 Board
+  - remarkable,imx7d-remarkable2  # i.MX7D ReMarkable 2 E-Ink 
Tablet
   - technexion,imx7d-pico-dwarf   # TechNexion i.MX7D Pico-Dwarf
   - technexion,imx7d-pico-hobbit  # TechNexion i.MX7D Pico-Hobbit
   - technexion,imx7d-pico-nymph   # TechNexion i.MX7D Pico-Nymph
-- 
2.30.1



[PATCH v4] ARM: imx7d-remarkable2.dts: Initial device tree for reMarkable2

2021-03-09 Thread Alistair Francis
The reMarkable2 (https://remarkable.com) is an e-ink tablet based on
the imx7d SoC.

This commit is based on the DTS provide by reMarkable but ported to the
latest kernel (instead of 4.14). I have removed references to
non-upstream devices and have changed the UART so that the console can
be accessed without having to open up the device via the OTG pogo pins.

Currently the kernel boots, but there is no support for the display.

WiFi is untested (no dispaly or UART RX makes it hard to test), but
should work with the current upstream driver. As it's untested it's not
included in this commit.

Signed-off-by: Alistair Francis 
---
 .../devicetree/bindings/arm/fsl.yaml  |   1 +
 .../devicetree/bindings/vendor-prefixes.yaml  |   2 +
 arch/arm/boot/dts/Makefile|   1 +
 arch/arm/boot/dts/imx7d-remarkable2.dts   | 166 ++
 4 files changed, 170 insertions(+)
 create mode 100644 arch/arm/boot/dts/imx7d-remarkable2.dts

diff --git a/Documentation/devicetree/bindings/arm/fsl.yaml 
b/Documentation/devicetree/bindings/arm/fsl.yaml
index 297c87f45db8..d139440c86b6 100644
--- a/Documentation/devicetree/bindings/arm/fsl.yaml
+++ b/Documentation/devicetree/bindings/arm/fsl.yaml
@@ -617,6 +617,7 @@ properties:
   - kam,imx7d-flex-concentrator   # Kamstrup OMNIA Flex 
Concentrator
   - kam,imx7d-flex-concentrator-mfg   # Kamstrup OMNIA Flex 
Concentrator in manufacturing mode
   - novtech,imx7d-meerkat96   # i.MX7 Meerkat96 Board
+  - remarkable,imx7d-remarkable2  # i.MX7D ReMarkable 2 E-Ink 
Tablet
   - technexion,imx7d-pico-dwarf   # TechNexion i.MX7D Pico-Dwarf
   - technexion,imx7d-pico-hobbit  # TechNexion i.MX7D Pico-Hobbit
   - technexion,imx7d-pico-nymph   # TechNexion i.MX7D Pico-Nymph
diff --git a/Documentation/devicetree/bindings/vendor-prefixes.yaml 
b/Documentation/devicetree/bindings/vendor-prefixes.yaml
index f6064d84a424..a8e1e8d2ef20 100644
--- a/Documentation/devicetree/bindings/vendor-prefixes.yaml
+++ b/Documentation/devicetree/bindings/vendor-prefixes.yaml
@@ -932,6 +932,8 @@ patternProperties:
 description: Unisoc Communications, Inc.
   "^realtek,.*":
 description: Realtek Semiconductor Corp.
+  "^remarkable,.*":
+description: reMarkable AS
   "^renesas,.*":
 description: Renesas Electronics Corporation
   "^rex,.*":
diff --git a/arch/arm/boot/dts/Makefile b/arch/arm/boot/dts/Makefile
index 8e5d4ab4e75e..dc8e378689af 100644
--- a/arch/arm/boot/dts/Makefile
+++ b/arch/arm/boot/dts/Makefile
@@ -660,6 +660,7 @@ dtb-$(CONFIG_SOC_IMX7D) += \
imx7d-pico-hobbit.dtb \
imx7d-pico-nymph.dtb \
imx7d-pico-pi.dtb \
+   imx7d-remarkable2.dtb \
imx7d-sbc-imx7.dtb \
imx7d-sdb.dtb \
imx7d-sdb-reva.dtb \
diff --git a/arch/arm/boot/dts/imx7d-remarkable2.dts 
b/arch/arm/boot/dts/imx7d-remarkable2.dts
new file mode 100644
index ..86d555bd33c2
--- /dev/null
+++ b/arch/arm/boot/dts/imx7d-remarkable2.dts
@@ -0,0 +1,166 @@
+// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
+/*
+ * Copyright (C) 2015 Freescale Semiconductor, Inc.
+ * Copyright (C) 2019 reMarkable AS - http://www.remarkable.com/
+ *
+ */
+
+/dts-v1/;
+
+#include "imx7d.dtsi"
+
+/ {
+   model = "reMarkable 2.0";
+   compatible = "remarkable,imx7d-remarkable2", "fsl,imx7d";
+
+   chosen {
+   stdout-path = 
+   };
+
+   memory {
+   reg = <0x8000 0x4000>;
+   };
+};
+
+ {
+   assigned-clocks = < IMX7D_CLKO2_ROOT_SRC>,
+ < IMX7D_CLKO2_ROOT_DIV>;
+   assigned-clock-parents = < IMX7D_CKIL>;
+   assigned-clock-rates = <0>, <32768>;
+};
+
+ {
+   status = "disabled";
+};
+
+_apbh {
+   status = "disabled";
+};
+
+ {
+   status = "okay";
+};
+
+_pwrkey {
+   status = "okay";
+};
+
+ {
+   pinctrl-names = "default";
+   pinctrl-0 = <_uart1>;
+   assigned-clocks = < IMX7D_UART1_ROOT_SRC>;
+   assigned-clock-parents = < IMX7D_OSC_24M_CLK>;
+   status = "okay";
+};
+
+ {
+   pinctrl-names = "default";
+   pinctrl-0 = <_uart6>;
+   assigned-clocks = < IMX7D_UART6_ROOT_SRC>;
+   assigned-clock-parents = < IMX7D_OSC_24M_CLK>;
+   status = "okay";
+};
+
+ {
+   srp-disable;
+   hnp-disable;
+   status = "okay";
+};
+
+ {
+   pinctrl-names = "default", "state_100mhz", "state_200mhz", "sleep";
+   pinctrl-0 = <_usdhc3>;
+   pinctrl-1 = <_usdhc3_100mhz>;
+   pinctrl-2 = <_usdhc3_200mhz>;
+   pinctrl-3 = <_usdhc3>;
+   assigned-clocks = < IMX7D_USDHC3_ROOT_CLK>

Re: [PATCH v3 1/3] ARM: imx7d-remarkable2.dts: Initial device tree for reMarkable2

2021-03-09 Thread Alistair Francis
On Wed, Mar 3, 2021 at 8:44 AM Shawn Guo  wrote:
>
> On Wed, Feb 03, 2021 at 07:03:14PM -0800, Alistair Francis wrote:
> > The reMarkable2 (https://remarkable.com) is an e-ink tablet based on
> > the imx7d SoC.
> >
> > This commit is based on the DTS provide by reMarkable but ported to the
> > latest kernel (instead of 4.14). I have removed references to
> > non-upstream devices and have changed the UART so that the console can
> > be accessed without having to open up the device via the OTG pogo pins.
>
> Just out of curiosity, this is a DIY cable or something generally
> available from vendor?

It's a DIY cable, it's a bit of a pain to put together. You can see
what it looks like here: https://github.com/ddvk/remarkable2-recovery

>
> >
> > Currently the kernel boots, but there is no support for the dispaly,
> > WiFi or the power controller chips.
>
> There are still some WiFi related devices.  Can we drop all those
> untested stuff?

I have WiFi working on the 5.4 NXP branch. I was actually thinking
that WiFi should just work if the rootFS and FW all match. The main
problem is that the kernel expects a firmware version that isn't in
linux-firmware.

I have removed it for now though.

>
> >
> > Signed-off-by: Alistair Francis 
> > ---
> >  arch/arm/boot/dts/Makefile  |   1 +
> >  arch/arm/boot/dts/imx7d-remarkable2.dts | 253 
> >  2 files changed, 254 insertions(+)
> >  create mode 100644 arch/arm/boot/dts/imx7d-remarkable2.dts
> >
> > diff --git a/arch/arm/boot/dts/Makefile b/arch/arm/boot/dts/Makefile
> > index 3d1ea0b25168..9608c363b25f 100644
> > --- a/arch/arm/boot/dts/Makefile
> > +++ b/arch/arm/boot/dts/Makefile
> > @@ -658,6 +658,7 @@ dtb-$(CONFIG_SOC_IMX7D) += \
> >   imx7d-pico-hobbit.dtb \
> >   imx7d-pico-nymph.dtb \
> >   imx7d-pico-pi.dtb \
> > + imx7d-remarkable2.dtb \
> >   imx7d-sbc-imx7.dtb \
> >   imx7d-sdb.dtb \
> >   imx7d-sdb-reva.dtb \
> > diff --git a/arch/arm/boot/dts/imx7d-remarkable2.dts 
> > b/arch/arm/boot/dts/imx7d-remarkable2.dts
> > new file mode 100644
> > index ..0aae13f5eed6
> > --- /dev/null
> > +++ b/arch/arm/boot/dts/imx7d-remarkable2.dts
> > @@ -0,0 +1,253 @@
> > +// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
> > +/*
> > + * Copyright (C) 2015 Freescale Semiconductor, Inc.
> > + * Copyright (C) 2019 reMarkable AS - http://www.remarkable.com/
> > + *
> > + */
> > +
> > +/dts-v1/;
> > +
> > +#include "imx7d.dtsi"
> > +
> > +/ {
> > + model = "reMarkable 2.0";
> > + compatible = "fsl,imx7d-remarkable2", "fsl,imx7d";
>
> The new compatible needs to be documented.  Also the compatible doesn't
> look right, as this is a device from reMarkable rather than FSL.

Done and done.

Alistair

>
> Shawn
>
> > +
> > + chosen {
> > + stdout-path = 
> > + };
> > +
> > + memory {
> > + reg = <0x8000 0x4000>;
> > + };
> > +
> > + reg_brcm: regulator-brcm {
> > + compatible = "regulator-fixed";
> > + regulator-name = "brcm_reg";
> > + regulator-min-microvolt = <330>;
> > + regulator-max-microvolt = <330>;
> > + pinctrl-names = "default";
> > + pinctrl-0 = <_brcm_reg>;
> > + gpio = < 13 GPIO_ACTIVE_HIGH>;
> > + enable-active-high;
> > + startup-delay-us = <150>;
> > + };
> > +
> > + wifi_pwrseq: wifi_pwrseq {
> > + compatible = "mmc-pwrseq-simple";
> > + pinctrl-names = "default";
> > + pinctrl-0 = <_wifi>;
> > + reset-gpios = < 9 GPIO_ACTIVE_LOW>;
> > + clocks = < IMX7D_CLKO2_ROOT_DIV>;
> > + clock-names = "ext_clock";
> > + };
> > +};
> > +
> > + {
> > + assigned-clocks = < IMX7D_CLKO2_ROOT_SRC>,
> > +   < IMX7D_CLKO2_ROOT_DIV>;
> > + assigned-clock-parents = < IMX7D_CKIL>;
> > + assigned-clock-rates = <0>, <32768>;
> > +};
> > +
> > + {
> > + status = "disabled";
> > +};
> > +
> > +_apbh {
> > + status = "disabled";
> > +};
> > +
> > + {
> > + status = "okay";
> > 

[PATCH v3 1/3] ARM: imx7d-remarkable2.dts: Initial device tree for reMarkable2

2021-02-04 Thread Alistair Francis
The reMarkable2 (https://remarkable.com) is an e-ink tablet based on
the imx7d SoC.

This commit is based on the DTS provide by reMarkable but ported to the
latest kernel (instead of 4.14). I have removed references to
non-upstream devices and have changed the UART so that the console can
be accessed without having to open up the device via the OTG pogo pins.

Currently the kernel boots, but there is no support for the dispaly,
WiFi or the power controller chips.

Signed-off-by: Alistair Francis 
---
 arch/arm/boot/dts/Makefile  |   1 +
 arch/arm/boot/dts/imx7d-remarkable2.dts | 253 
 2 files changed, 254 insertions(+)
 create mode 100644 arch/arm/boot/dts/imx7d-remarkable2.dts

diff --git a/arch/arm/boot/dts/Makefile b/arch/arm/boot/dts/Makefile
index 3d1ea0b25168..9608c363b25f 100644
--- a/arch/arm/boot/dts/Makefile
+++ b/arch/arm/boot/dts/Makefile
@@ -658,6 +658,7 @@ dtb-$(CONFIG_SOC_IMX7D) += \
imx7d-pico-hobbit.dtb \
imx7d-pico-nymph.dtb \
imx7d-pico-pi.dtb \
+   imx7d-remarkable2.dtb \
imx7d-sbc-imx7.dtb \
imx7d-sdb.dtb \
imx7d-sdb-reva.dtb \
diff --git a/arch/arm/boot/dts/imx7d-remarkable2.dts 
b/arch/arm/boot/dts/imx7d-remarkable2.dts
new file mode 100644
index ..0aae13f5eed6
--- /dev/null
+++ b/arch/arm/boot/dts/imx7d-remarkable2.dts
@@ -0,0 +1,253 @@
+// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
+/*
+ * Copyright (C) 2015 Freescale Semiconductor, Inc.
+ * Copyright (C) 2019 reMarkable AS - http://www.remarkable.com/
+ *
+ */
+
+/dts-v1/;
+
+#include "imx7d.dtsi"
+
+/ {
+   model = "reMarkable 2.0";
+   compatible = "fsl,imx7d-remarkable2", "fsl,imx7d";
+
+   chosen {
+   stdout-path = 
+   };
+
+   memory {
+   reg = <0x8000 0x4000>;
+   };
+
+   reg_brcm: regulator-brcm {
+   compatible = "regulator-fixed";
+   regulator-name = "brcm_reg";
+   regulator-min-microvolt = <330>;
+   regulator-max-microvolt = <330>;
+   pinctrl-names = "default";
+   pinctrl-0 = <_brcm_reg>;
+   gpio = < 13 GPIO_ACTIVE_HIGH>;
+   enable-active-high;
+   startup-delay-us = <150>;
+   };
+
+   wifi_pwrseq: wifi_pwrseq {
+   compatible = "mmc-pwrseq-simple";
+   pinctrl-names = "default";
+   pinctrl-0 = <_wifi>;
+   reset-gpios = < 9 GPIO_ACTIVE_LOW>;
+   clocks = < IMX7D_CLKO2_ROOT_DIV>;
+   clock-names = "ext_clock";
+   };
+};
+
+ {
+   assigned-clocks = < IMX7D_CLKO2_ROOT_SRC>,
+ < IMX7D_CLKO2_ROOT_DIV>;
+   assigned-clock-parents = < IMX7D_CKIL>;
+   assigned-clock-rates = <0>, <32768>;
+};
+
+ {
+   status = "disabled";
+};
+
+_apbh {
+   status = "disabled";
+};
+
+ {
+   status = "okay";
+};
+
+ {
+   pinctrl-names = "default";
+   pinctrl-0 = <_uart1>;
+   assigned-clocks = < IMX7D_UART1_ROOT_SRC>;
+   assigned-clock-parents = < IMX7D_OSC_24M_CLK>;
+   status = "okay";
+};
+
+ {
+   pinctrl-names = "default";
+   pinctrl-0 = <_uart6>;
+   assigned-clocks = < IMX7D_UART6_ROOT_SRC>;
+   assigned-clock-parents = < IMX7D_OSC_24M_CLK>;
+   status = "okay";
+};
+
+ {
+   srp-disable;
+   hnp-disable;
+   status = "okay";
+};
+
+ {
+   #address-cells = <1>;
+   #size-cells = <0>;
+   pinctrl-names = "default", "state_100mhz", "sleep";
+   pinctrl-0 = <_usdhc2>;
+   pinctrl-1 = <_usdhc2_100mhz>;
+   pinctrl-2 = <_usdhc2>;
+   mmc-pwrseq = <_pwrseq>;
+   vmmc-supply = <_brcm>;
+   bus-width = <4>;
+   non-removable;
+   keep-power-in-suspend;
+   cap-power-off-card;
+   status = "okay";
+
+   brcmf: bcrmf@1 {
+   reg = <1>;
+   compatible = "brcm,bcm4329-fmac";
+   };
+};
+
+ {
+   pinctrl-names = "default", "state_100mhz", "state_200mhz", "sleep";
+   pinctrl-0 = <_usdhc3>;
+   pinctrl-1 = <_usdhc3_100mhz>;
+   pinctrl-2 = <_usdhc3_200mhz>;
+   pinctrl-3 = <_usdhc3>;
+   assigned-clocks = < IMX7D_USDHC3_ROOT_CLK>;
+   assigned-clock-rates = <4>;
+   bus-width = <8>;
+   non-removable;
+   status = "okay";
+};
+
+ {
+   pinctrl-names = "default";
+   pinctrl-0 = <_wdog>;
+   fsl,ext-reset-output;
+};
+

[PATCH v3 2/3] ARM: dts: imx7d: remarkable2: Enable the power button

2021-02-04 Thread Alistair Francis
Signed-off-by: Alistair Francis 
---
 arch/arm/boot/dts/imx7d-remarkable2.dts | 4 
 1 file changed, 4 insertions(+)

diff --git a/arch/arm/boot/dts/imx7d-remarkable2.dts 
b/arch/arm/boot/dts/imx7d-remarkable2.dts
index 0aae13f5eed6..0978e26f5db5 100644
--- a/arch/arm/boot/dts/imx7d-remarkable2.dts
+++ b/arch/arm/boot/dts/imx7d-remarkable2.dts
@@ -62,6 +62,10 @@  {
status = "okay";
 };
 
+_pwrkey {
+   status = "okay";
+};
+
  {
pinctrl-names = "default";
pinctrl-0 = <_uart1>;
-- 
2.30.0



[PATCH v3 3/3] ARM: imx_v6_v7_defconfig: Regenerate

2021-02-04 Thread Alistair Francis
Run make imx_v6_v7_defconfig; make savedefconfig to regenerate the
defconfig.

Signed-off-by: Alistair Francis 
---
 arch/arm/configs/imx_v6_v7_defconfig | 36 
 1 file changed, 10 insertions(+), 26 deletions(-)

diff --git a/arch/arm/configs/imx_v6_v7_defconfig 
b/arch/arm/configs/imx_v6_v7_defconfig
index 221f5c340c86..55674cb1ffce 100644
--- a/arch/arm/configs/imx_v6_v7_defconfig
+++ b/arch/arm/configs/imx_v6_v7_defconfig
@@ -28,9 +28,6 @@ CONFIG_SOC_IMX6UL=y
 CONFIG_SOC_IMX7D=y
 CONFIG_SOC_IMX7ULP=y
 CONFIG_SOC_VF610=y
-CONFIG_PCI=y
-CONFIG_PCI_MSI=y
-CONFIG_PCI_IMX6=y
 CONFIG_SMP=y
 CONFIG_ARM_PSCI=y
 CONFIG_HIGHMEM=y
@@ -65,9 +62,6 @@ CONFIG_UNIX=y
 CONFIG_INET=y
 CONFIG_IP_PNP=y
 CONFIG_IP_PNP_DHCP=y
-# CONFIG_INET_XFRM_MODE_TRANSPORT is not set
-# CONFIG_INET_XFRM_MODE_TUNNEL is not set
-# CONFIG_INET_XFRM_MODE_BEET is not set
 CONFIG_NETFILTER=y
 CONFIG_CAN=y
 CONFIG_CAN_FLEXCAN=y
@@ -80,12 +74,14 @@ CONFIG_CFG80211_WEXT=y
 CONFIG_MAC80211=y
 CONFIG_RFKILL=y
 CONFIG_RFKILL_INPUT=y
+CONFIG_PCI=y
+CONFIG_PCI_MSI=y
+CONFIG_PCI_IMX6=y
 CONFIG_DEVTMPFS=y
 CONFIG_DEVTMPFS_MOUNT=y
 # CONFIG_STANDALONE is not set
 CONFIG_FW_LOADER_USER_HELPER=y
 CONFIG_FW_LOADER_USER_HELPER_FALLBACK=y
-CONFIG_CMA_SIZE_MBYTES=64
 CONFIG_IMX_WEIM=y
 CONFIG_CONNECTOR=y
 CONFIG_MTD=y
@@ -96,16 +92,13 @@ CONFIG_MTD_JEDECPROBE=y
 CONFIG_MTD_CFI_INTELEXT=y
 CONFIG_MTD_CFI_AMDSTD=y
 CONFIG_MTD_CFI_STAA=y
-CONFIG_MTD_PHYSMAP_OF=y
 CONFIG_MTD_DATAFLASH=y
-CONFIG_MTD_M25P80=y
 CONFIG_MTD_SST25L=y
 CONFIG_MTD_RAW_NAND=y
 CONFIG_MTD_NAND_GPMI_NAND=y
 CONFIG_MTD_NAND_VF610_NFC=y
 CONFIG_MTD_NAND_MXC=y
 CONFIG_MTD_SPI_NOR=y
-CONFIG_SPI_FSL_QUADSPI=y
 CONFIG_MTD_UBI=y
 CONFIG_MTD_UBI_FASTMAP=y
 CONFIG_MTD_UBI_BLOCK=y
@@ -139,9 +132,8 @@ CONFIG_SMC91X=y
 CONFIG_SMC911X=y
 CONFIG_SMSC911X=y
 # CONFIG_NET_VENDOR_STMICRO is not set
-CONFIG_AT803X_PHY=y
 CONFIG_MICREL_PHY=y
-CONFIG_SMSC_PHY=y
+CONFIG_AT803X_PHY=y
 CONFIG_USB_PEGASUS=m
 CONFIG_USB_RTL8150=m
 CONFIG_USB_RTL8152=y
@@ -202,6 +194,7 @@ CONFIG_I2C_ALGOPCA=m
 CONFIG_I2C_GPIO=y
 CONFIG_I2C_IMX=y
 CONFIG_SPI=y
+CONFIG_SPI_FSL_QUADSPI=y
 CONFIG_SPI_GPIO=y
 CONFIG_SPI_IMX=y
 CONFIG_SPI_FSL_DSPI=y
@@ -210,14 +203,13 @@ CONFIG_PINCTRL_IMX8MN=y
 CONFIG_PINCTRL_IMX8MP=y
 CONFIG_PINCTRL_IMX8MQ=y
 CONFIG_GPIO_SYSFS=y
+CONFIG_GPIO_MXC=y
 CONFIG_GPIO_SIOX=m
 CONFIG_GPIO_MAX732X=y
-CONFIG_GPIO_MC9S08DZ60=y
 CONFIG_GPIO_PCA953X=y
 CONFIG_GPIO_PCF857X=y
 CONFIG_GPIO_STMPE=y
 CONFIG_GPIO_74X164=y
-CONFIG_GPIO_MXC=y
 CONFIG_POWER_RESET=y
 CONFIG_POWER_RESET_SYSCON=y
 CONFIG_POWER_RESET_SYSCON_POWEROFF=y
@@ -230,8 +222,8 @@ CONFIG_THERMAL_WRITABLE_TRIPS=y
 CONFIG_CPU_THERMAL=y
 CONFIG_IMX_THERMAL=y
 CONFIG_WATCHDOG=y
-CONFIG_DA9062_WATCHDOG=y
 CONFIG_DA9063_WATCHDOG=m
+CONFIG_DA9062_WATCHDOG=y
 CONFIG_RN5T618_WATCHDOG=y
 CONFIG_IMX2_WDT=y
 CONFIG_IMX7ULP_WDT=y
@@ -242,7 +234,6 @@ CONFIG_MFD_MC13XXX_SPI=y
 CONFIG_MFD_MC13XXX_I2C=y
 CONFIG_MFD_RN5T618=y
 CONFIG_MFD_STMPE=y
-CONFIG_REGULATOR=y
 CONFIG_REGULATOR_FIXED_VOLTAGE=y
 CONFIG_REGULATOR_ANATOP=y
 CONFIG_REGULATOR_DA9052=y
@@ -257,9 +248,6 @@ CONFIG_RC_CORE=y
 CONFIG_RC_DEVICES=y
 CONFIG_IR_GPIO_CIR=y
 CONFIG_MEDIA_SUPPORT=y
-CONFIG_MEDIA_CAMERA_SUPPORT=y
-CONFIG_MEDIA_CONTROLLER=y
-CONFIG_VIDEO_V4L2_SUBDEV_API=y
 CONFIG_MEDIA_USB_SUPPORT=y
 CONFIG_USB_VIDEO_CLASS=m
 CONFIG_V4L_PLATFORM_DRIVERS=y
@@ -267,7 +255,6 @@ CONFIG_VIDEO_MUX=y
 CONFIG_V4L_MEM2MEM_DRIVERS=y
 CONFIG_VIDEO_CODA=m
 CONFIG_VIDEO_IMX_PXP=y
-# CONFIG_MEDIA_SUBDRV_AUTOSELECT is not set
 CONFIG_VIDEO_ADV7180=m
 CONFIG_VIDEO_OV2680=m
 CONFIG_VIDEO_OV5640=m
@@ -302,12 +289,10 @@ CONFIG_SND_USB_AUDIO=m
 CONFIG_SND_SOC=y
 CONFIG_SND_SOC_FSL_ASRC=y
 CONFIG_SND_IMX_SOC=y
-CONFIG_SND_SOC_PHYCORE_AC97=y
 CONFIG_SND_SOC_EUKREA_TLV320=y
 CONFIG_SND_SOC_IMX_ES8328=y
 CONFIG_SND_SOC_IMX_SGTL5000=y
 CONFIG_SND_SOC_IMX_SPDIF=y
-CONFIG_SND_SOC_IMX_MC13783=y
 CONFIG_SND_SOC_FSL_ASOC_CARD=y
 CONFIG_SND_SOC_AC97_CODEC=y
 CONFIG_SND_SOC_CS42XX8_I2C=y
@@ -319,7 +304,6 @@ CONFIG_HID_MULTITOUCH=y
 CONFIG_USB=y
 CONFIG_USB_ANNOUNCE_NEW_DEVICES=y
 CONFIG_USB_EHCI_HCD=y
-CONFIG_USB_EHCI_MXC=y
 CONFIG_USB_ACM=m
 CONFIG_USB_STORAGE=y
 CONFIG_USB_CHIPIDEA=y
@@ -334,7 +318,6 @@ CONFIG_USB_EHSET_TEST_FIXTURE=m
 CONFIG_NOP_USB_XCEIV=y
 CONFIG_USB_MXS_PHY=y
 CONFIG_USB_GADGET=y
-CONFIG_USB_FSL_USB2=y
 CONFIG_USB_CONFIGFS=y
 CONFIG_USB_CONFIGFS_SERIAL=y
 CONFIG_USB_CONFIGFS_ACM=y
@@ -383,11 +366,11 @@ CONFIG_RTC_DRV_ISL1208=y
 CONFIG_RTC_DRV_PCF8523=y
 CONFIG_RTC_DRV_PCF8563=y
 CONFIG_RTC_DRV_M41T80=y
+CONFIG_RTC_DRV_RC5T619=y
 CONFIG_RTC_DRV_DA9063=y
 CONFIG_RTC_DRV_MC13XXX=y
 CONFIG_RTC_DRV_MXC=y
 CONFIG_RTC_DRV_MXC_V2=y
-CONFIG_RTC_DRV_RC5T619=y
 CONFIG_RTC_DRV_SNVS=y
 CONFIG_DMADEVICES=y
 CONFIG_FSL_EDMA=y
@@ -464,13 +447,14 @@ CONFIG_CRC_CCITT=m
 CONFIG_CRC_T10DIF=y
 CONFIG_CRC7=m
 CONFIG_LIBCRC32C=m
+CONFIG_CMA_SIZE_MBYTES=64
 CONFIG_FONTS=y
 CONFIG_FONT_8x8=y
 CONFIG_FONT_8x16=y
 CONFIG_PRINTK_TIME=y
+# CONFIG_DEBUG_BUGVERBOSE is not set
 CONFIG_MAGIC_SYSRQ=y
 CONFIG_DEBUG_FS=y

Re: [PATCH v2 3/3] arch/arm/configs: Enable VMSPLIT_2G in imx_v6_v7_defconfig

2021-02-03 Thread Alistair Francis
On Tue, Feb 2, 2021 at 11:50 PM Arnd Bergmann  wrote:
>
> On Wed, Feb 3, 2021 at 3:37 AM Alistair Francis  wrote:
> >
> > On Thu, Jan 28, 2021 at 11:13 PM Shawn Guo  wrote:
> > >
> > > On Sun, Jan 17, 2021 at 10:03:01AM -0800, Alistair Francis wrote:
> > > > The reMarkable2 requires VMSPLIT_2G, so lets set this in the
> > > > imx_v6_v7_defconfig.
> > >
> > > Hmm, why is VMSPLIT_2G required by reMarkable2?
> >
> > I'm not too sure. It's difficult to debug problems as I only have a
> > UART but without this I don't see any kernel prints so it seems like
> > the kernel doesn't get very far. I haven't had any luck with earlycon
> > on the device so I don't know how I can get more information.
>
> In the dts file, I can see that the machine has 1GB of RAM at
> contiguous addresses. My first guess would be a problem with
> highmem, as this configuration means that with VMSPLIT_3G
> there are 768MB of lowmem and 256MB of highmem.
>
> Can you try these two things to narrow the problem down
> further?
>
> a) disable CONFIG_HIGHMEM when using VMSPLIT_3G
> b) use VMSPLIT_3G_OPT

Thanks Arnd,

I was working on testing the config changes you mentioned, but it
seems like all of them work now.

VMSPLIT_2G: Boots to userspace

VMSPLIT_3G && HIGHMEM: Boots to userspace

VMSPLIT_3G && !HIGHMEM: Boots to userspace

VMSPLIT_3G_OPT && HIGHMEM:Boots to userspace

>
> If both of them solve the problem, then highmem is likely
> the root cause. One possible issue might be that the boot
> loader loads the initramfs or the dtb into a location outside
> of the first 768 MB of lowmem where it is unreachable
> in the VMSPLIT_3G configuration.

It boots with u-boot, which I am building so I can change these addresses.

I'm guessing that I have changed the addresses at some point and now
it works. I'm going to drop this patch.

Alistair

>
> Arnd


Re: [PATCH v2 3/3] arch/arm/configs: Enable VMSPLIT_2G in imx_v6_v7_defconfig

2021-02-02 Thread Alistair Francis
On Thu, Jan 28, 2021 at 11:13 PM Shawn Guo  wrote:
>
> On Sun, Jan 17, 2021 at 10:03:01AM -0800, Alistair Francis wrote:
> > The reMarkable2 requires VMSPLIT_2G, so lets set this in the
> > imx_v6_v7_defconfig.
>
> Hmm, why is VMSPLIT_2G required by reMarkable2?

I'm not too sure. It's difficult to debug problems as I only have a
UART but without this I don't see any kernel prints so it seems like
the kernel doesn't get very far. I haven't had any luck with earlycon
on the device so I don't know how I can get more information.

Alistair

>
> Shawn
>
> >
> > Signed-off-by: Alistair Francis 
> > ---
> >  arch/arm/configs/imx_v6_v7_defconfig | 1 +
> >  1 file changed, 1 insertion(+)
> >
> > diff --git a/arch/arm/configs/imx_v6_v7_defconfig 
> > b/arch/arm/configs/imx_v6_v7_defconfig
> > index 55674cb1ffce..fa9229616106 100644
> > --- a/arch/arm/configs/imx_v6_v7_defconfig
> > +++ b/arch/arm/configs/imx_v6_v7_defconfig
> > @@ -29,6 +29,7 @@ CONFIG_SOC_IMX7D=y
> >  CONFIG_SOC_IMX7ULP=y
> >  CONFIG_SOC_VF610=y
> >  CONFIG_SMP=y
> > +CONFIG_VMSPLIT_2G=y
> >  CONFIG_ARM_PSCI=y
> >  CONFIG_HIGHMEM=y
> >  CONFIG_FORCE_MAX_ZONEORDER=14
> > --
> > 2.29.2
> >


Re: [PATCH 4/6] regulator: Initial commit of sy7636a

2021-01-23 Thread Alistair Francis
On Fri, Jan 22, 2021 at 5:37 AM Mark Brown  wrote:
>
> On Thu, Jan 21, 2021 at 10:24:10PM -0800, Alistair Francis wrote:
> > On Mon, Jan 18, 2021 at 4:32 AM Mark Brown  wrote:
> > > On Sat, Jan 16, 2021 at 08:25:37PM -0800, Alistair Francis wrote:
>
> > > > +static int get_vcom_voltage_op(struct regulator_dev *rdev)
> > > > +{
> > > > + int ret = get_vcom_voltage_mv(rdev->regmap);
> > > > +
>
> > > Why is this get_vcom_voltage_mv() function not in the regulator driver,
> > > and why is it not just inline here?  It also needs namespacing.
>
> > I'm not sure what you mean, can you please explain?
>
> This is a wrapper for a function that has exactly one caller but is not
> only a separate function but also in the MFD header, part of a separate
> driver.  This seems at best pointless.

Ah I see. I think I have fixed this.

>
> > > Why do you need this delay here, and what purpose is this lock intended
>
> > The delay is to allow a power ramp up, I have added a comment.
>
> Use the standard ramp_delay, don't open code it.
>
> > > > +static int sy7636a_regulator_suspend(struct device *dev)
> > > > +{
> > > > + int ret;
> > > > + struct sy7636a *sy7636a = dev_get_drvdata(dev->parent);
> > > > +
> > > > + ret = get_vcom_voltage_mv(sy7636a->regmap);
> > > > +
> > > > + if (ret > 0)
> > > > + sy7636a->vcom = (unsigned int)ret;
> > > > +
> > > > + return 0;
> > > > +}
>
> > > What's going on here, and if you are going to store this value over
> > > suspend why not store it in a variable of the correct type?  In general
>
> > It is part of the vendor's kernel, they specifically added it to
> > ensure vcom is set on resume.
>
> "I copied this from the vendor" isn't really a great explanation...  If
> the device is likely to get completely powered off and loosing settings
> then presumably the entire register map, not just this one value, needs
> to be saved and restored instead of just this one value.  If that is the
> case it's probably best to use a register cache and just resync it on
> resume.

Good point.

I don't have a good answer so I have removed the suspend/resume part.
I'll have to investigate in the future if/why this is required.

Alistair


Re: [PATCH v2 6/6] arch/arm: reMarkable2: Enable wacom_i2c

2021-01-23 Thread Alistair Francis
On Fri, Jan 22, 2021 at 7:32 AM Marco Felsch  wrote:
>
> Hi,
>
> thanks for the patch.
>
> On 21-01-20 22:56, Alistair Francis wrote:
> > Enable the wacom_i2c touchscreen for the reMarkable2.
> >
> > Signed-off-by: Alistair Francis 
> > ---
> >  arch/arm/boot/dts/imx7d-remarkable2.dts | 41 +
> >  arch/arm/configs/imx_v6_v7_defconfig|  1 +
>
> Those two changes should be splitted and the dts patch should be named:
> "ARM: dts: imx7d: remarkable2: add wacom digitizer device".
>
> >  2 files changed, 42 insertions(+)
> >
> > diff --git a/arch/arm/boot/dts/imx7d-remarkable2.dts 
> > b/arch/arm/boot/dts/imx7d-remarkable2.dts
> > index fba55a0e028a..8052d884a5e5 100644
> > --- a/arch/arm/boot/dts/imx7d-remarkable2.dts
> > +++ b/arch/arm/boot/dts/imx7d-remarkable2.dts
> > @@ -150,6 +150,30 @@ _apbh {
> >   status = "disabled";
> >  };
> >
> > + {
> > + clock-frequency = <40>;
> > + pinctrl-names = "default", "sleep";
> > + pinctrl-0 = <_i2c1>;
> > + pinctrl-1 = <_i2c1>;
>
> No need to specify the sleep state if both are using the same pinctrl
> config.
>
> > + status = "okay";
> > +
> > + digitizer: wacom-i2c@9 {
>
> this should be:
> wacom_digitizer: digitizer@9 {
>
> > + pinctrl-names = "default", "sleep";
> > + pinctrl-0 = <_wacom>;
> > + pinctrl-1 = <_wacom>;
>
> Same here, sleep and default refer to the same state.
>
> > + compatible = "wacom,wacom-i2c";
> > + reg = <0x09>;
>
> compatible and reg are always the first to properties.
>
> > + interrupt-parent = <>;
> > + interrupts = <1 2>;
>
> Please use defines.

I have addressed all your comments.

>
> > + flip-tilt-x;
> > + flip-tilt-y;
> > + flip-pos-x;
> > + flip-pos-y;
> > + flip-distance;
> > + vdd-supply = <_digitizer>;
>
> Where is this regulator added?

It's already in the DT, it will be added with the initial commit
(which is currently on the list).

Alistair

>
> > + };
> > +};
> > +
> >   {
> >   status = "okay";
> >  };
> > @@ -221,6 +245,16 @@  {
> >  };
> >
> >  _lpsr {
> > + pinctrl_wacom: wacomgrp {
> > + fsl,pins = <
> > + /*MX7D_PAD_LPSR_GPIO1_IO00__GPIO1_IO0   0x0074 /* 
> > WACOM RESET */
> > + MX7D_PAD_LPSR_GPIO1_IO01__GPIO1_IO1 0x0034 /* 
> > WACOM INT */
> > + MX7D_PAD_LPSR_GPIO1_IO04__GPIO1_IO4 0x0074 /* 
> > PDCTB */
> > + /*MX7D_PAD_LPSR_GPIO1_IO05__GPIO1_IO5   0x0014 /* 
> > FWE */
> > + /*MX7D_PAD_LPSR_GPIO1_IO06__GPIO1_IO6   0x0014 /* 
> > WACOM PWR ENABLE */
> > + >;
> > + };
>
> Pls, sort this alphabetical.
>
> > +
> >   pinctrl_digitizer_reg: digitizerreggrp {
> >   fsl,pins = <
> >   /* DIGITIZER_PWR_EN */
> > @@ -236,6 +270,13 @@ MX7D_PAD_SAI1_RX_SYNC__GPIO6_IO160x59
> >   >;
> >   };
> >
> > + pinctrl_i2c1: i2c1grp {
> > + fsl,pins = <
> > + MX7D_PAD_I2C1_SDA__I2C1_SDA 0x407f
> > + MX7D_PAD_I2C1_SCL__I2C1_SCL 0x407f
> > + >;
> > + };
> > +
> >   pinctrl_uart1: uart1grp {
> >   fsl,pins = <
> >   MX7D_PAD_UART1_TX_DATA__UART1_DCE_TX0x79
> > diff --git a/arch/arm/configs/imx_v6_v7_defconfig 
> > b/arch/arm/configs/imx_v6_v7_defconfig
> > index fa9229616106..2fc8dc6a8b0a 100644
> > --- a/arch/arm/configs/imx_v6_v7_defconfig
> > +++ b/arch/arm/configs/imx_v6_v7_defconfig
> > @@ -167,6 +167,7 @@ CONFIG_TOUCHSCREEN_DA9052=y
> >  CONFIG_TOUCHSCREEN_EGALAX=y
> >  CONFIG_TOUCHSCREEN_GOODIX=y
> >  CONFIG_TOUCHSCREEN_ILI210X=y
> > +CONFIG_TOUCHSCREEN_WACOM_I2C=y
> >  CONFIG_TOUCHSCREEN_MAX11801=y
> >  CONFIG_TOUCHSCREEN_IMX6UL_TSC=y
> >  CONFIG_TOUCHSCREEN_EDT_FT5X06=y
> > --
> > 2.29.2
> >
> >
> >
>
> --
> Pengutronix e.K.   | |
> Steuerwalder Str. 21   | http://www.pengutronix.de/  |
> 31137 Hildesheim, Germany  | Phone: +49-5121-206917-0|
> Amtsgericht Hildesheim, HRA 2686   | Fax:   +49-5121-206917- |


Re: [PATCH 4/6] regulator: Initial commit of sy7636a

2021-01-21 Thread Alistair Francis
On Mon, Jan 18, 2021 at 4:32 AM Mark Brown  wrote:
>
> On Sat, Jan 16, 2021 at 08:25:37PM -0800, Alistair Francis wrote:
>
> > --- /dev/null
> > +++ b/drivers/regulator/sy7636a-regulator.c
> > @@ -0,0 +1,233 @@
> > +// SPDX-License-Identifier: GPL-2.0+
> > +/*
> > + * Functions to access SY3686A power management chip voltages
> > + *
>
> Please make the entire comment a C++ one so things look more
> intentional.

Fixed.

>
> > + * Copyright (C) 2019 reMarkable AS - http://www.remarkable.com/
> > + *
> > + * Author: Lars Ivar Miljeteig 
>
> This probably needs an update.
>
> > + * This program is free software; you can redistribute it and/or
> > + * modify it under the terms of the GNU General Public License as
> > + * published by the Free Software Foundation version 2.
> > + *
> > + * This program is distributed "as is" WITHOUT ANY WARRANTY of any
> > + * kind, whether express or implied; without even the implied warranty
> > + * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> > + * GNU General Public License for more details.
>
> This boilerplate is redundant and should be removed.

Fixed.

>
> > +static int get_vcom_voltage_op(struct regulator_dev *rdev)
> > +{
> > + int ret = get_vcom_voltage_mv(rdev->regmap);
> > +
>
> Why is this get_vcom_voltage_mv() function not in the regulator driver,
> and why is it not just inline here?  It also needs namespacing.

I'm not sure what you mean, can you please explain?

>
> > +static int disable_regulator(struct regulator_dev *rdev)
> > +{
> > + struct sy7636a *sy7636a = dev_get_drvdata(rdev->dev.parent);
> > + int ret = 0;
> > +
> > + mutex_lock(>reglock);
> > + ret = regulator_disable_regmap(rdev);
> > + usleep_range(3, 35000);
> > + mutex_unlock(>reglock);
>
> Why do you need this delay here, and what purpose is this lock intended

The delay is to allow a power ramp up, I have added a comment.

> to serve?  I can't understand what it's intended to protect.

Apparently the mutex is to protect enable/disable, I don't think it's
required and I will remove it.

>
> > + mutex_lock(>reglock);
> > + ret = regulator_is_enabled_regmap(rdev);
> > + mutex_unlock(>reglock);
>
> This lock usage in particular looks confused.
>
> > + ret = regulator_enable_regmap(rdev);
> > + if (ret)
> > + goto finish;
>
> > + if (!pwr_good) {
> > + dev_err(>dev, "Power good signal timeout after %u ms\n",
> > + jiffies_to_msecs(t1 - t0));
> > + ret = -ETIME;
> > + goto finish;
> > + }
>
> This doesn't undo the underlying enable, leaving the regulator in a
> partially enabled state.

Thanks, fixed.

>
> > +static const struct regulator_ops sy7636a_vcom_volt_ops = {
> > + .get_voltage = get_vcom_voltage_op,
> > + .enable = enable_regulator_pgood,
> > + .disable = disable_regulator,
> > + .is_enabled = sy7636a_regulator_is_enabled,
> > +};
>
> The namespacing for functions is very random and prone to clashes.

Fixed.

> Given the power good signal I'd also expect a get_status() operation.

Added.

>
> > +static int sy7636a_regulator_suspend(struct device *dev)
> > +{
> > + int ret;
> > + struct sy7636a *sy7636a = dev_get_drvdata(dev->parent);
> > +
> > + ret = get_vcom_voltage_mv(sy7636a->regmap);
> > +
> > + if (ret > 0)
> > + sy7636a->vcom = (unsigned int)ret;
> > +
> > + return 0;
> > +}
>
> What's going on here, and if you are going to store this value over
> suspend why not store it in a variable of the correct type?  In general

It is part of the vendor's kernel, they specifically added it to
ensure vcom is set on resume.

I have fixed the variable type.

> it's surprising to need a suspend operation for a regulator.
>
> > + sy7636a->pgood_gpio = gdp;
> > + dev_info(sy7636a->dev,
> > + "Power good GPIO registered (gpio# %d)\n",
> > + desc_to_gpio(sy7636a->pgood_gpio));
>
> This print is just adding noise to the boot process.

Removed.


Alistair


Re: [PATCH 3/6] devicetree/bindings: Initial commit of silergy,sy7636a-regulator.yaml

2021-01-21 Thread Alistair Francis
On Mon, Jan 18, 2021 at 4:42 AM Mark Brown  wrote:
>
> On Mon, Jan 18, 2021 at 12:35:19PM +, Mark Brown wrote:
> > On Sat, Jan 16, 2021 at 08:25:36PM -0800, Alistair Francis wrote:
>
> > > +properties:
> > > +  compatible:
> > > +enum:
> > > +  - sy7636a-regulator
>
> > Compatible strings should be in the form vendor,device.
>
> You should not have separate binding documents for MFD subfunctions that
> don't have separate compatible strings in DT, include the documentation
> for the properties used by those subfunctions in the main MFD binding
> document.

Thanks for the review. I have updated the patch and will send a v2.

Alistair


[PATCH v2 4/6] touchscreen/wacom_i2c: Clean up the query device fields

2021-01-21 Thread Alistair Francis
Improve the query device fields to be more verbose.

Signed-off-by: Alistair Francis 
---
 drivers/input/touchscreen/wacom_i2c.c | 73 +++
 1 file changed, 52 insertions(+), 21 deletions(-)

diff --git a/drivers/input/touchscreen/wacom_i2c.c 
b/drivers/input/touchscreen/wacom_i2c.c
index 5f0b80d52ad5..a22570adc939 100644
--- a/drivers/input/touchscreen/wacom_i2c.c
+++ b/drivers/input/touchscreen/wacom_i2c.c
@@ -13,15 +13,32 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 
-#define WACOM_CMD_QUERY0   0x04
-#define WACOM_CMD_QUERY1   0x00
-#define WACOM_CMD_QUERY2   0x33
-#define WACOM_CMD_QUERY3   0x02
-#define WACOM_CMD_THROW0   0x05
-#define WACOM_CMD_THROW1   0x00
+// Registers
+#define WACOM_COMMAND_LSB   0x04
+#define WACOM_COMMAND_MSB   0x00
+
+#define WACOM_DATA_LSB  0x05
+#define WACOM_DATA_MSB  0x00
+
+// Report types
+#define REPORT_FEATURE  0x30
+
+// Requests / operations
+#define OPCODE_GET_REPORT   0x02
+
+// Power settings
+#define POWER_ON0x00
+#define POWER_SLEEP 0x01
+
+// Input report ids
+#define WACOM_PEN_DATA_REPORT   2
+#define WACOM_SHINONOME_REPORT  26
+
+#define WACOM_QUERY_REPORT 3
 #define WACOM_QUERY_SIZE   22
 
 struct wacom_features {
@@ -45,34 +62,44 @@ struct wacom_i2c {
 };
 
 static int wacom_query_device(struct i2c_client *client,
- struct wacom_features *features)
+ struct wacom_features *features)
 {
int ret;
-   u8 cmd1[] = { WACOM_CMD_QUERY0, WACOM_CMD_QUERY1,
-   WACOM_CMD_QUERY2, WACOM_CMD_QUERY3 };
-   u8 cmd2[] = { WACOM_CMD_THROW0, WACOM_CMD_THROW1 };
u8 data[WACOM_QUERY_SIZE];
+   struct reset_control *rstc;
+
+   u8 get_query_data_cmd[] = {
+   WACOM_COMMAND_LSB,
+   WACOM_COMMAND_MSB,
+   REPORT_FEATURE | WACOM_QUERY_REPORT,
+   OPCODE_GET_REPORT,
+   WACOM_DATA_LSB,
+   WACOM_DATA_MSB,
+   };
+
struct i2c_msg msgs[] = {
+   // Request reading of feature ReportID: 3 (Pen Query Data)
{
.addr = client->addr,
.flags = 0,
-   .len = sizeof(cmd1),
-   .buf = cmd1,
-   },
-   {
-   .addr = client->addr,
-   .flags = 0,
-   .len = sizeof(cmd2),
-   .buf = cmd2,
+   .len = sizeof(get_query_data_cmd),
+   .buf = get_query_data_cmd,
},
+   // Read 21 bytes
{
.addr = client->addr,
.flags = I2C_M_RD,
-   .len = sizeof(data),
+   .len = WACOM_QUERY_SIZE - 1,
.buf = data,
},
};
 
+   rstc = devm_reset_control_get_optional_exclusive(>dev, NULL);
+   if (IS_ERR(rstc))
+   dev_err(>dev, "Failed to get reset control before 
init\n");
+   else
+   reset_control_reset(rstc);
+
ret = i2c_transfer(client->adapter, msgs, ARRAY_SIZE(msgs));
if (ret < 0)
return ret;
@@ -89,9 +116,13 @@ static int wacom_query_device(struct i2c_client *client,
features->tilt_y_max = get_unaligned_le16([19]);
 
dev_dbg(>dev,
-   "x_max:%d, y_max:%d, pressure:%d, fw:%d\n",
+   "x_max:%d, y_max:%d, pressure:%d, fw:%d, "
+   "distance: %d, phys distance: %d, "
+   "tilt_x_max: %d, tilt_y_max: %d\n",
features->x_max, features->y_max,
-   features->pressure_max, features->fw_version);
+   features->pressure_max, features->fw_version,
+   features->distance_max, features->distance_physical_max,
+   features->tilt_x_max, features->tilt_y_max);
 
return 0;
 }
-- 
2.29.2



[PATCH v2 3/6] touchscreen/wacom_i2c: Add support for distance and tilt x/y

2021-01-21 Thread Alistair Francis
This is based on the out of tree rM2 driver.

Signed-off-by: Alistair Francis 
---
 drivers/input/touchscreen/wacom_i2c.c | 25 +++--
 1 file changed, 23 insertions(+), 2 deletions(-)

diff --git a/drivers/input/touchscreen/wacom_i2c.c 
b/drivers/input/touchscreen/wacom_i2c.c
index ec6e0aff8deb..5f0b80d52ad5 100644
--- a/drivers/input/touchscreen/wacom_i2c.c
+++ b/drivers/input/touchscreen/wacom_i2c.c
@@ -22,12 +22,16 @@
 #define WACOM_CMD_QUERY3   0x02
 #define WACOM_CMD_THROW0   0x05
 #define WACOM_CMD_THROW1   0x00
-#define WACOM_QUERY_SIZE   19
+#define WACOM_QUERY_SIZE   22
 
 struct wacom_features {
int x_max;
int y_max;
int pressure_max;
+   int distance_max;
+   int distance_physical_max;
+   int tilt_x_max;
+   int tilt_y_max;
char fw_version;
 };
 
@@ -79,6 +83,10 @@ static int wacom_query_device(struct i2c_client *client,
features->y_max = get_unaligned_le16([5]);
features->pressure_max = get_unaligned_le16([11]);
features->fw_version = get_unaligned_le16([13]);
+   features->distance_max = data[15];
+   features->distance_physical_max = data[16];
+   features->tilt_x_max = get_unaligned_le16([17]);
+   features->tilt_y_max = get_unaligned_le16([19]);
 
dev_dbg(>dev,
"x_max:%d, y_max:%d, pressure:%d, fw:%d\n",
@@ -95,6 +103,7 @@ static irqreturn_t wacom_i2c_irq(int irq, void *dev_id)
u8 *data = wac_i2c->data;
unsigned int x, y, pressure;
unsigned char tsw, f1, f2, ers;
+   short tilt_x, tilt_y, distance;
int error;
 
error = i2c_master_recv(wac_i2c->client,
@@ -109,6 +118,11 @@ static irqreturn_t wacom_i2c_irq(int irq, void *dev_id)
x = le16_to_cpup((__le16 *)[4]);
y = le16_to_cpup((__le16 *)[6]);
pressure = le16_to_cpup((__le16 *)[8]);
+   distance = data[10];
+
+   /* Signed */
+   tilt_x = le16_to_cpup((__le16 *)[11]);
+   tilt_y = le16_to_cpup((__le16 *)[13]);
 
if (!wac_i2c->prox)
wac_i2c->tool = (data[3] & 0x0c) ?
@@ -123,6 +137,9 @@ static irqreturn_t wacom_i2c_irq(int irq, void *dev_id)
input_report_abs(input, ABS_X, x);
input_report_abs(input, ABS_Y, y);
input_report_abs(input, ABS_PRESSURE, pressure);
+   input_report_abs(input, ABS_DISTANCE, distance);
+   input_report_abs(input, ABS_TILT_X, tilt_x);
+   input_report_abs(input, ABS_TILT_Y, tilt_y);
input_sync(input);
 
 out:
@@ -195,7 +212,11 @@ static int wacom_i2c_probe(struct i2c_client *client,
input_set_abs_params(input, ABS_Y, 0, features.y_max, 0, 0);
input_set_abs_params(input, ABS_PRESSURE,
 0, features.pressure_max, 0, 0);
-
+   input_set_abs_params(input, ABS_DISTANCE, 0, features.distance_max, 0, 
0);
+   input_set_abs_params(input, ABS_TILT_X, -features.tilt_x_max,
+features.tilt_x_max, 0, 0);
+   input_set_abs_params(input, ABS_TILT_Y, -features.tilt_y_max,
+features.tilt_y_max, 0, 0);
input_set_drvdata(input, wac_i2c);
 
error = request_threaded_irq(client->irq, NULL, wacom_i2c_irq,
-- 
2.29.2



[PATCH v2 1/6] devicetree/bindings: Initial commit of wacom,wacom-i2c

2021-01-20 Thread Alistair Francis
Signed-off-by: Alistair Francis 
---
 .../input/touchscreen/wacom,wacom-i2c.yaml| 44 +++
 .../devicetree/bindings/vendor-prefixes.yaml  |  2 +
 2 files changed, 46 insertions(+)
 create mode 100644 
Documentation/devicetree/bindings/input/touchscreen/wacom,wacom-i2c.yaml

diff --git 
a/Documentation/devicetree/bindings/input/touchscreen/wacom,wacom-i2c.yaml 
b/Documentation/devicetree/bindings/input/touchscreen/wacom,wacom-i2c.yaml
new file mode 100644
index ..b36d22cd20a2
--- /dev/null
+++ b/Documentation/devicetree/bindings/input/touchscreen/wacom,wacom-i2c.yaml
@@ -0,0 +1,44 @@
+# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/input/touchscreen/wacom,wacom-i2c.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Wacom I2C Controller
+
+maintainers:
+  - Alistair Francis 
+
+allOf:
+  - $ref: touchscreen.yaml#
+
+properties:
+  compatible:
+const: wacom,wacom-i2c
+
+  reg:
+maxItems: 1
+
+  interrupts:
+maxItems: 1
+
+required:
+  - compatible
+  - reg
+  - interrupts
+
+additionalProperties: false
+
+examples:
+  - |
+#include "dt-bindings/interrupt-controller/irq.h"
+i2c {
+#address-cells = <1>;
+#size-cells = <0>;
+digitiser@9 {
+compatible = "wacom,wacom-i2c";
+reg = <0x9>;
+interrupt-parent = <>;
+interrupts = <9 IRQ_TYPE_LEVEL_LOW>;
+};
+};
diff --git a/Documentation/devicetree/bindings/vendor-prefixes.yaml 
b/Documentation/devicetree/bindings/vendor-prefixes.yaml
index 041ae90b0d8f..5bca22f035a3 100644
--- a/Documentation/devicetree/bindings/vendor-prefixes.yaml
+++ b/Documentation/devicetree/bindings/vendor-prefixes.yaml
@@ -1202,6 +1202,8 @@ patternProperties:
 description: Vision Optical Technology Co., Ltd.
   "^vxt,.*":
 description: VXT Ltd
+  "^wacom,.*":
+description: Wacom Co., Ltd
   "^wand,.*":
 description: Wandbord (Technexion)
   "^waveshare,.*":
-- 
2.29.2



[PATCH v2 2/6] input/touchscreen: Add device tree support to wacom_i2c

2021-01-20 Thread Alistair Francis
Allow the wacom-i2c device to be exposed via device tree.

Signed-off-by: Alistair Francis 
---
 .../input/touchscreen/wacom,wacom-i2c.yaml   |  4 
 drivers/input/touchscreen/wacom_i2c.c| 16 
 2 files changed, 20 insertions(+)

diff --git 
a/Documentation/devicetree/bindings/input/touchscreen/wacom,wacom-i2c.yaml 
b/Documentation/devicetree/bindings/input/touchscreen/wacom,wacom-i2c.yaml
index b36d22cd20a2..06ad5ee561af 100644
--- a/Documentation/devicetree/bindings/input/touchscreen/wacom,wacom-i2c.yaml
+++ b/Documentation/devicetree/bindings/input/touchscreen/wacom,wacom-i2c.yaml
@@ -22,6 +22,9 @@ properties:
   interrupts:
 maxItems: 1
 
+  vdd-supply:
+maxItems: 1
+
 required:
   - compatible
   - reg
@@ -40,5 +43,6 @@ examples:
 reg = <0x9>;
 interrupt-parent = <>;
 interrupts = <9 IRQ_TYPE_LEVEL_LOW>;
+vdd-supply = <_touch>;
 };
 };
diff --git a/drivers/input/touchscreen/wacom_i2c.c 
b/drivers/input/touchscreen/wacom_i2c.c
index 1afc6bde2891..ec6e0aff8deb 100644
--- a/drivers/input/touchscreen/wacom_i2c.c
+++ b/drivers/input/touchscreen/wacom_i2c.c
@@ -11,7 +11,9 @@
 #include 
 #include 
 #include 
+#include 
 #include 
+#include 
 #include 
 
 #define WACOM_CMD_QUERY0   0x04
@@ -32,6 +34,7 @@ struct wacom_features {
 struct wacom_i2c {
struct i2c_client *client;
struct input_dev *input;
+   struct touchscreen_properties props;
u8 data[WACOM_QUERY_SIZE];
bool prox;
int tool;
@@ -187,6 +190,7 @@ static int wacom_i2c_probe(struct i2c_client *client,
__set_bit(BTN_STYLUS2, input->keybit);
__set_bit(BTN_TOUCH, input->keybit);
 
+   touchscreen_parse_properties(input, true, _i2c->props);
input_set_abs_params(input, ABS_X, 0, features.x_max, 0, 0);
input_set_abs_params(input, ABS_Y, 0, features.y_max, 0, 0);
input_set_abs_params(input, ABS_PRESSURE,
@@ -214,6 +218,7 @@ static int wacom_i2c_probe(struct i2c_client *client,
}
 
i2c_set_clientdata(client, wac_i2c);
+
return 0;
 
 err_free_irq:
@@ -262,10 +267,21 @@ static const struct i2c_device_id wacom_i2c_id[] = {
 };
 MODULE_DEVICE_TABLE(i2c, wacom_i2c_id);
 
+#ifdef CONFIG_OF
+static const struct of_device_id wacom_i2c_of_match_table[] = {
+   { .compatible = "wacom,wacom-i2c" },
+   {}
+};
+MODULE_DEVICE_TABLE(of, wacom_i2c_of_match_table);
+#endif
+
 static struct i2c_driver wacom_i2c_driver = {
.driver = {
.name   = "wacom_i2c",
.pm = _i2c_pm,
+#ifdef CONFIG_OF
+   .of_match_table = of_match_ptr(wacom_i2c_of_match_table),
+#endif
},
 
.probe  = wacom_i2c_probe,
-- 
2.29.2



[PATCH v2 0/6] Add Wacom I2C support to rM2

2021-01-20 Thread Alistair Francis
Add support to the reMarkable2 (rM2) for the Wacom I2C device.

This is based on the reMarkable Linux fork and with this series I am
able to probe the Wacom digitiser.

Alistair Francis (6):
  devicetree/bindings: Initial commit of wacom,wacom-i2c
  input/touchscreen: Add device tree support to wacom_i2c
  touchscreen/wacom_i2c: Add support for distance and tilt x/y
  touchscreen/wacom_i2c: Clean up the query device fields
  touchscreen/wacom_i2c: Add support for vdd regulator
  arch/arm: reMarkable2: Enable wacom_i2c

 .../input/touchscreen/wacom,wacom-i2c.yaml|  48 +++
 .../devicetree/bindings/vendor-prefixes.yaml  |   2 +
 arch/arm/boot/dts/imx7d-remarkable2.dts   |  41 ++
 arch/arm/configs/imx_v6_v7_defconfig  |   1 +
 drivers/input/touchscreen/wacom_i2c.c | 136 +++---
 5 files changed, 205 insertions(+), 23 deletions(-)
 create mode 100644 
Documentation/devicetree/bindings/input/touchscreen/wacom,wacom-i2c.yaml

-- 
2.29.2



[PATCH v2 5/6] touchscreen/wacom_i2c: Add support for vdd regulator

2021-01-20 Thread Alistair Francis
Add support for a VDD regulator. This allows the kernel to prove the
Wacom-I2C device on the rM2.

Signed-off-by: Alistair Francis 
---
 drivers/input/touchscreen/wacom_i2c.c | 22 ++
 1 file changed, 22 insertions(+)

diff --git a/drivers/input/touchscreen/wacom_i2c.c 
b/drivers/input/touchscreen/wacom_i2c.c
index a22570adc939..6d85a7bd0502 100644
--- a/drivers/input/touchscreen/wacom_i2c.c
+++ b/drivers/input/touchscreen/wacom_i2c.c
@@ -13,6 +13,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -56,6 +57,7 @@ struct wacom_i2c {
struct i2c_client *client;
struct input_dev *input;
struct touchscreen_properties props;
+   struct regulator *vdd;
u8 data[WACOM_QUERY_SIZE];
bool prox;
int tool;
@@ -203,11 +205,29 @@ static int wacom_i2c_probe(struct i2c_client *client,
struct wacom_features features = { 0 };
int error;
 
+   wac_i2c = kzalloc(sizeof(*wac_i2c), GFP_KERNEL);
+   if (!wac_i2c)
+   return -ENOMEM;
+
if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) {
dev_err(>dev, "i2c_check_functionality error\n");
return -EIO;
}
 
+   wac_i2c->vdd = regulator_get(>dev, "vdd");
+   if (IS_ERR(wac_i2c->vdd)) {
+   error = PTR_ERR(wac_i2c->vdd);
+   kfree(wac_i2c);
+   return error;
+   }
+
+   error = regulator_enable(wac_i2c->vdd);
+   if (error) {
+   regulator_put(wac_i2c->vdd);
+   kfree(wac_i2c);
+   return error;
+   }
+
error = wacom_query_device(client, );
if (error)
return error;
@@ -276,6 +296,8 @@ static int wacom_i2c_probe(struct i2c_client *client,
 err_free_irq:
free_irq(client->irq, wac_i2c);
 err_free_mem:
+   regulator_disable(wac_i2c->vdd);
+   regulator_put(wac_i2c->vdd);
input_free_device(input);
kfree(wac_i2c);
 
-- 
2.29.2



[PATCH v2 6/6] arch/arm: reMarkable2: Enable wacom_i2c

2021-01-20 Thread Alistair Francis
Enable the wacom_i2c touchscreen for the reMarkable2.

Signed-off-by: Alistair Francis 
---
 arch/arm/boot/dts/imx7d-remarkable2.dts | 41 +
 arch/arm/configs/imx_v6_v7_defconfig|  1 +
 2 files changed, 42 insertions(+)

diff --git a/arch/arm/boot/dts/imx7d-remarkable2.dts 
b/arch/arm/boot/dts/imx7d-remarkable2.dts
index fba55a0e028a..8052d884a5e5 100644
--- a/arch/arm/boot/dts/imx7d-remarkable2.dts
+++ b/arch/arm/boot/dts/imx7d-remarkable2.dts
@@ -150,6 +150,30 @@ _apbh {
status = "disabled";
 };
 
+ {
+   clock-frequency = <40>;
+   pinctrl-names = "default", "sleep";
+   pinctrl-0 = <_i2c1>;
+   pinctrl-1 = <_i2c1>;
+   status = "okay";
+
+   digitizer: wacom-i2c@9 {
+   pinctrl-names = "default", "sleep";
+   pinctrl-0 = <_wacom>;
+   pinctrl-1 = <_wacom>;
+   compatible = "wacom,wacom-i2c";
+   reg = <0x09>;
+   interrupt-parent = <>;
+   interrupts = <1 2>;
+   flip-tilt-x;
+   flip-tilt-y;
+   flip-pos-x;
+   flip-pos-y;
+   flip-distance;
+   vdd-supply = <_digitizer>;
+   };
+};
+
  {
status = "okay";
 };
@@ -221,6 +245,16 @@  {
 };
 
 _lpsr {
+   pinctrl_wacom: wacomgrp {
+   fsl,pins = <
+   /*MX7D_PAD_LPSR_GPIO1_IO00__GPIO1_IO0   0x0074 /* 
WACOM RESET */
+   MX7D_PAD_LPSR_GPIO1_IO01__GPIO1_IO1 0x0034 /* 
WACOM INT */
+   MX7D_PAD_LPSR_GPIO1_IO04__GPIO1_IO4 0x0074 /* 
PDCTB */
+   /*MX7D_PAD_LPSR_GPIO1_IO05__GPIO1_IO5   0x0014 /* 
FWE */
+   /*MX7D_PAD_LPSR_GPIO1_IO06__GPIO1_IO6   0x0014 /* 
WACOM PWR ENABLE */
+   >;
+   };
+
pinctrl_digitizer_reg: digitizerreggrp {
fsl,pins = <
/* DIGITIZER_PWR_EN */
@@ -236,6 +270,13 @@ MX7D_PAD_SAI1_RX_SYNC__GPIO6_IO16  0x59
>;
};
 
+   pinctrl_i2c1: i2c1grp {
+   fsl,pins = <
+   MX7D_PAD_I2C1_SDA__I2C1_SDA 0x407f
+   MX7D_PAD_I2C1_SCL__I2C1_SCL 0x407f
+   >;
+   };
+
pinctrl_uart1: uart1grp {
fsl,pins = <
MX7D_PAD_UART1_TX_DATA__UART1_DCE_TX0x79
diff --git a/arch/arm/configs/imx_v6_v7_defconfig 
b/arch/arm/configs/imx_v6_v7_defconfig
index fa9229616106..2fc8dc6a8b0a 100644
--- a/arch/arm/configs/imx_v6_v7_defconfig
+++ b/arch/arm/configs/imx_v6_v7_defconfig
@@ -167,6 +167,7 @@ CONFIG_TOUCHSCREEN_DA9052=y
 CONFIG_TOUCHSCREEN_EGALAX=y
 CONFIG_TOUCHSCREEN_GOODIX=y
 CONFIG_TOUCHSCREEN_ILI210X=y
+CONFIG_TOUCHSCREEN_WACOM_I2C=y
 CONFIG_TOUCHSCREEN_MAX11801=y
 CONFIG_TOUCHSCREEN_IMX6UL_TSC=y
 CONFIG_TOUCHSCREEN_EDT_FT5X06=y
-- 
2.29.2



Re: [PATCH 2/3] input/touchscreen: Add device tree support to wacom_i2c

2021-01-20 Thread Alistair Francis
On Tue, Jan 19, 2021 at 6:17 PM Dmitry Torokhov
 wrote:
>
> On Sat, Jan 16, 2021 at 08:24:27PM -0800, Alistair Francis wrote:
> > Allow the wacom-i2c device to be exposed via device tree.
>
> The patch seems incomplete. I see we are reading and storing properties,
> but we are not using them whatsoever, so I do not see the reason to have
> this in this form.

Good point. I am trying to split up the work, but I guess here I split
it up a little too much. I'm sending a v2 that should fix this.

Alistair

>
> Thanks.
>
> --
> Dmitry


Re: [PATCH 1/3] devicetree/bindings: Initial commit of wacom,wacom-i2c

2021-01-19 Thread Alistair Francis
On Tue, Jan 19, 2021 at 6:15 PM Dmitry Torokhov
 wrote:
>
> Hi Alistair,
>
> On Sat, Jan 16, 2021 at 08:24:26PM -0800, Alistair Francis wrote:
> > Signed-off-by: Alistair Francis 
> > ---
> >  .../input/touchscreen/wacom,wacom-i2c.yaml| 55 +++
> >  .../devicetree/bindings/vendor-prefixes.yaml  |  2 +
> >  2 files changed, 57 insertions(+)
> >  create mode 100644 
> > Documentation/devicetree/bindings/input/touchscreen/wacom,wacom-i2c.yaml
> >
> > diff --git 
> > a/Documentation/devicetree/bindings/input/touchscreen/wacom,wacom-i2c.yaml 
> > b/Documentation/devicetree/bindings/input/touchscreen/wacom,wacom-i2c.yaml
> > new file mode 100644
> > index ..6b0e0034f836
> > --- /dev/null
> > +++ 
> > b/Documentation/devicetree/bindings/input/touchscreen/wacom,wacom-i2c.yaml
> > @@ -0,0 +1,55 @@
> > +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
> > +%YAML 1.2
> > +---
> > +$id: http://devicetree.org/schemas/input/touchscreen/wacom,wacom-i2c.yaml#
> > +$schema: http://devicetree.org/meta-schemas/core.yaml#
> > +
> > +title: Wacom I2C Controller
> > +
> > +maintainers:
> > +  - Alistair Francis 
> > +
> > +allOf:
> > +  - $ref: touchscreen.yaml#
> > +
> > +properties:
> > +  compatible:
> > +const: wacom,wacom-i2c
> > +
> > +  reg:
> > +maxItems: 1
> > +
> > +  interrupts:
> > +maxItems: 1
> > +
> > +  flip-tilt-x:
> > +  flip-tilt-y:
>
> Does the device support tilt? The driver does not, at least at the
> moment. Also, does it make sense to flip tilt but not position?
>
> > +  flip-pos-x:
> > +  flip-pos-y:
>
> This needs to use standard touchscreen properties. See
> Documentation/devicetree/bindings/input/touchscreen/touchscreen.yaml
>
> > +  flip-distance:
>
> I am having trouble understanding when this one would be useful.

Thanks for the review. These came from the original out of tree DT. I
have removed them, I'm planning on using the standard touchscreen ones
you pointed out if they are required.

Alistair

>
> > +
> > +required:
> > +  - compatible
> > +  - reg
> > +  - interrupts
> > +
> > +additionalProperties: false
> > +
> > +examples:
> > +  - |
> > +#include "dt-bindings/interrupt-controller/irq.h"
> > +i2c {
> > +#address-cells = <1>;
> > +#size-cells = <0>;
> > +digitiser@9 {
> > +compatible = "wacom,wacom-i2c";
> > +reg = <0x9>;
> > +interrupt-parent = <>;
> > +interrupts = <9 IRQ_TYPE_LEVEL_LOW>;
> > +flip-tilt-x;
> > +flip-tilt-y;
> > +flip-pos-x;
> > +flip-pos-y;
> > +flip-distance;
> > +};
> > +};
> > diff --git a/Documentation/devicetree/bindings/vendor-prefixes.yaml 
> > b/Documentation/devicetree/bindings/vendor-prefixes.yaml
> > index 041ae90b0d8f..5bca22f035a3 100644
> > --- a/Documentation/devicetree/bindings/vendor-prefixes.yaml
> > +++ b/Documentation/devicetree/bindings/vendor-prefixes.yaml
> > @@ -1202,6 +1202,8 @@ patternProperties:
> >  description: Vision Optical Technology Co., Ltd.
> >"^vxt,.*":
> >  description: VXT Ltd
> > +  "^wacom,.*":
> > +description: Wacom Co., Ltd
> >"^wand,.*":
> >  description: Wandbord (Technexion)
> >"^waveshare,.*":
> > --
> > 2.29.2
> >
>
> Thanks.
>
> --
> Dmitry


Re: [PATCH 2/2] remarkable2_defconfig: Add initial support for the reMarkable2

2021-01-18 Thread Alistair Francis
On Sun, Jan 17, 2021 at 6:03 PM Olof Johansson  wrote:
>
> Hi,
>
> On Sun, Jan 17, 2021 at 5:36 PM Alistair Francis  wrote:
> >
> > On Sun, Jan 17, 2021 at 5:30 PM Olof Johansson  wrote:
> > >
> > > Hi Alistair,
> > >
> > > On Sun, Jan 17, 2021 at 3:09 PM Alistair Francis  
> > > wrote:
> > > >
> > > > This defconfig is based on the one released by reMarkable with their
> > > > 4.14 kernel. I have updated it to match the latest kernels.
> > > >
> > > > Signed-off-by: Alistair Francis 
> > >
> > > It's awesome to see upstream support for contemporary consumer
> > > products being posted, thanks!
> >
> > No worries!
> >
> > >
> > > When it comes to a dedicated defconfig, is that necessary in this
> > > case? The needed drivers should be possible to enable either in
> > > imx_v6_v7_defconfig, or in multi_v7_defconfig (or, rather, both)?
> >
> > Most of the defconfi could be shared with a standard imx7 config, but
> > some of the extra components like the Wacom digitiser,
> > cyttsp5_i2c_adapter, max77818 and bd71815 might be better off in it's
> > own defconfig.
> >
> > If the maintainers are happy with enabling some of those in a imx7
> > defconfig then I'm happy to do that. I have tried to split out the
> > config changes (I have two otehr series that build on this one) so it
> > should be easy to rebase it all on a standard one.
>
> Yeah, enabling those in imx_v6_v7_defconfig and multi_v7_defconfig is
> fine (or, really, desirable and preferred).
>
> Please enable as modules where possible (i.e anything that's fine to
> wait loading until after rootfs is mounted), to avoid kernel image
> growth on platforms that don't need those drivers.

I just sent a v2 of this series. Patch 1 is the same but I'm now using
the imx_v6_v7_defconfig in patch 2 and 3.

I only need a single change so hopefully that's fine. I'm sure more
features will need to be enabled but they can come with future
patches.

Alistair

>
> > > Adding new defconfigs is something we're avoiding as much as possible,
> > > since it adds CI overhead, and defconfigs easily get churny due to
> > > options moving around.
> > >
> > > In some cases we do it once per SoC family (i.e. the i.MX defconfigs),
> > > but we avoid it for products.
> >
> > Makes sense, I will update my patches not to use a custom defconfig.
>
> Awesome, thanks!
>
>
> -Olof


[PATCH v2 3/3] arch/arm/configs: Enable VMSPLIT_2G in imx_v6_v7_defconfig

2021-01-18 Thread Alistair Francis
The reMarkable2 requires VMSPLIT_2G, so lets set this in the
imx_v6_v7_defconfig.

Signed-off-by: Alistair Francis 
---
 arch/arm/configs/imx_v6_v7_defconfig | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/arm/configs/imx_v6_v7_defconfig 
b/arch/arm/configs/imx_v6_v7_defconfig
index 55674cb1ffce..fa9229616106 100644
--- a/arch/arm/configs/imx_v6_v7_defconfig
+++ b/arch/arm/configs/imx_v6_v7_defconfig
@@ -29,6 +29,7 @@ CONFIG_SOC_IMX7D=y
 CONFIG_SOC_IMX7ULP=y
 CONFIG_SOC_VF610=y
 CONFIG_SMP=y
+CONFIG_VMSPLIT_2G=y
 CONFIG_ARM_PSCI=y
 CONFIG_HIGHMEM=y
 CONFIG_FORCE_MAX_ZONEORDER=14
-- 
2.29.2



[PATCH v2 1/3] imx7d-remarkable2.dts: Initial device tree for reMarkable2

2021-01-18 Thread Alistair Francis
The reMarkable2 (https://remarkable.com) is an e-ink tablet based on
the imx7d SoC.

This commit is based on the DTS provide by reMarkable but ported to the
latest kernel (instead of 4.14). I have removed references to
non-upstream devices and have changed the UART so that the console can
be accessed without having to open up the device via the OTG pogo pins.

Currently the kernel boots, but there is no support for the dispaly,
WiFi or the power controller chips.

Signed-off-by: Alistair Francis 
---
v2:
 - No change to this patch, use the existing defconfig

 arch/arm/boot/dts/Makefile  |   1 +
 arch/arm/boot/dts/imx7d-remarkable2.dts | 375 
 2 files changed, 376 insertions(+)
 create mode 100644 arch/arm/boot/dts/imx7d-remarkable2.dts

diff --git a/arch/arm/boot/dts/Makefile b/arch/arm/boot/dts/Makefile
index 3d1ea0b25168..5fca2612ef58 100644
--- a/arch/arm/boot/dts/Makefile
+++ b/arch/arm/boot/dts/Makefile
@@ -664,6 +664,7 @@ dtb-$(CONFIG_SOC_IMX7D) += \
imx7d-sdb-sht11.dtb \
imx7d-zii-rmu2.dtb \
imx7d-zii-rpu2.dtb \
+   imx7d-remarkable2.dtb \
imx7s-colibri-aster.dtb \
imx7s-colibri-eval-v3.dtb \
imx7s-mba7.dtb \
diff --git a/arch/arm/boot/dts/imx7d-remarkable2.dts 
b/arch/arm/boot/dts/imx7d-remarkable2.dts
new file mode 100644
index ..fba55a0e028a
--- /dev/null
+++ b/arch/arm/boot/dts/imx7d-remarkable2.dts
@@ -0,0 +1,375 @@
+// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
+/*
+ * Copyright (C) 2015 Freescale Semiconductor, Inc.
+ * Copyright (C) 2019 reMarkable AS - http://www.remarkable.com/
+ *
+ * This file is dual-licensed: you can use it either under the terms
+ * of the GPL or the X11 license, at your option. Note that this dual
+ * licensing only applies to this file, and not this project as a
+ * whole.
+ *
+ *  a) This file is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This file is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * Or, alternatively,
+ *
+ *  b) Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation
+ * files (the "Software"), to deal in the Software without
+ * restriction, including without limitation the rights to use,
+ * copy, modify, merge, publish, distribute, sublicense, and/or
+ * sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following
+ * conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+/dts-v1/;
+
+#include "imx7d.dtsi"
+
+/ {
+   model = "reMarkable 2.0";
+   compatible = "fsl,imx7d-sdb", "fsl,imx7d";
+
+   chosen {
+   stdout-path = 
+   };
+
+   memory {
+   reg = <0x8000 0x4000>;
+   };
+
+   reg_vref_1v8: regulator-vref-1v8 {
+   compatible = "regulator-fixed";
+   regulator-name = "vref-1v8";
+   regulator-min-microvolt = <180>;
+   regulator-max-microvolt = <180>;
+   };
+
+   reg_brcm: regulator-brcm {
+   compatible = "regulator-fixed";
+   regulator-name = "brcm_reg";
+   regulator-min-microvolt = <330>;
+   regulator-max-microvolt = <330>;
+   pinctrl-names = "default", "sleep";
+   pinctrl-0 = <_brcm_reg>;
+   pinctrl-1 = <_brcm_reg>;
+   gpio = < 13 GPIO_ACTIVE_HIGH>;
+   enable-active-high;
+   startup-delay-us = <150>;
+   };
+
+   reg_digitizer: regulator-digitizer {
+   compatible = "regulator-fixed";
+   regulator-name = "VDD_3V3_DIGITIZER";
+   regulator-min-mic

[PATCH v2 2/3] arch/arm/configs: Regenerate imx_v6_v7_defconfig

2021-01-18 Thread Alistair Francis
Run make imx_v6_v7_defconfig; make savedefconfig to regenerate the
defconfig.

Signed-off-by: Alistair Francis 
---
 arch/arm/configs/imx_v6_v7_defconfig | 36 
 1 file changed, 10 insertions(+), 26 deletions(-)

diff --git a/arch/arm/configs/imx_v6_v7_defconfig 
b/arch/arm/configs/imx_v6_v7_defconfig
index 221f5c340c86..55674cb1ffce 100644
--- a/arch/arm/configs/imx_v6_v7_defconfig
+++ b/arch/arm/configs/imx_v6_v7_defconfig
@@ -28,9 +28,6 @@ CONFIG_SOC_IMX6UL=y
 CONFIG_SOC_IMX7D=y
 CONFIG_SOC_IMX7ULP=y
 CONFIG_SOC_VF610=y
-CONFIG_PCI=y
-CONFIG_PCI_MSI=y
-CONFIG_PCI_IMX6=y
 CONFIG_SMP=y
 CONFIG_ARM_PSCI=y
 CONFIG_HIGHMEM=y
@@ -65,9 +62,6 @@ CONFIG_UNIX=y
 CONFIG_INET=y
 CONFIG_IP_PNP=y
 CONFIG_IP_PNP_DHCP=y
-# CONFIG_INET_XFRM_MODE_TRANSPORT is not set
-# CONFIG_INET_XFRM_MODE_TUNNEL is not set
-# CONFIG_INET_XFRM_MODE_BEET is not set
 CONFIG_NETFILTER=y
 CONFIG_CAN=y
 CONFIG_CAN_FLEXCAN=y
@@ -80,12 +74,14 @@ CONFIG_CFG80211_WEXT=y
 CONFIG_MAC80211=y
 CONFIG_RFKILL=y
 CONFIG_RFKILL_INPUT=y
+CONFIG_PCI=y
+CONFIG_PCI_MSI=y
+CONFIG_PCI_IMX6=y
 CONFIG_DEVTMPFS=y
 CONFIG_DEVTMPFS_MOUNT=y
 # CONFIG_STANDALONE is not set
 CONFIG_FW_LOADER_USER_HELPER=y
 CONFIG_FW_LOADER_USER_HELPER_FALLBACK=y
-CONFIG_CMA_SIZE_MBYTES=64
 CONFIG_IMX_WEIM=y
 CONFIG_CONNECTOR=y
 CONFIG_MTD=y
@@ -96,16 +92,13 @@ CONFIG_MTD_JEDECPROBE=y
 CONFIG_MTD_CFI_INTELEXT=y
 CONFIG_MTD_CFI_AMDSTD=y
 CONFIG_MTD_CFI_STAA=y
-CONFIG_MTD_PHYSMAP_OF=y
 CONFIG_MTD_DATAFLASH=y
-CONFIG_MTD_M25P80=y
 CONFIG_MTD_SST25L=y
 CONFIG_MTD_RAW_NAND=y
 CONFIG_MTD_NAND_GPMI_NAND=y
 CONFIG_MTD_NAND_VF610_NFC=y
 CONFIG_MTD_NAND_MXC=y
 CONFIG_MTD_SPI_NOR=y
-CONFIG_SPI_FSL_QUADSPI=y
 CONFIG_MTD_UBI=y
 CONFIG_MTD_UBI_FASTMAP=y
 CONFIG_MTD_UBI_BLOCK=y
@@ -139,9 +132,8 @@ CONFIG_SMC91X=y
 CONFIG_SMC911X=y
 CONFIG_SMSC911X=y
 # CONFIG_NET_VENDOR_STMICRO is not set
-CONFIG_AT803X_PHY=y
 CONFIG_MICREL_PHY=y
-CONFIG_SMSC_PHY=y
+CONFIG_AT803X_PHY=y
 CONFIG_USB_PEGASUS=m
 CONFIG_USB_RTL8150=m
 CONFIG_USB_RTL8152=y
@@ -202,6 +194,7 @@ CONFIG_I2C_ALGOPCA=m
 CONFIG_I2C_GPIO=y
 CONFIG_I2C_IMX=y
 CONFIG_SPI=y
+CONFIG_SPI_FSL_QUADSPI=y
 CONFIG_SPI_GPIO=y
 CONFIG_SPI_IMX=y
 CONFIG_SPI_FSL_DSPI=y
@@ -210,14 +203,13 @@ CONFIG_PINCTRL_IMX8MN=y
 CONFIG_PINCTRL_IMX8MP=y
 CONFIG_PINCTRL_IMX8MQ=y
 CONFIG_GPIO_SYSFS=y
+CONFIG_GPIO_MXC=y
 CONFIG_GPIO_SIOX=m
 CONFIG_GPIO_MAX732X=y
-CONFIG_GPIO_MC9S08DZ60=y
 CONFIG_GPIO_PCA953X=y
 CONFIG_GPIO_PCF857X=y
 CONFIG_GPIO_STMPE=y
 CONFIG_GPIO_74X164=y
-CONFIG_GPIO_MXC=y
 CONFIG_POWER_RESET=y
 CONFIG_POWER_RESET_SYSCON=y
 CONFIG_POWER_RESET_SYSCON_POWEROFF=y
@@ -230,8 +222,8 @@ CONFIG_THERMAL_WRITABLE_TRIPS=y
 CONFIG_CPU_THERMAL=y
 CONFIG_IMX_THERMAL=y
 CONFIG_WATCHDOG=y
-CONFIG_DA9062_WATCHDOG=y
 CONFIG_DA9063_WATCHDOG=m
+CONFIG_DA9062_WATCHDOG=y
 CONFIG_RN5T618_WATCHDOG=y
 CONFIG_IMX2_WDT=y
 CONFIG_IMX7ULP_WDT=y
@@ -242,7 +234,6 @@ CONFIG_MFD_MC13XXX_SPI=y
 CONFIG_MFD_MC13XXX_I2C=y
 CONFIG_MFD_RN5T618=y
 CONFIG_MFD_STMPE=y
-CONFIG_REGULATOR=y
 CONFIG_REGULATOR_FIXED_VOLTAGE=y
 CONFIG_REGULATOR_ANATOP=y
 CONFIG_REGULATOR_DA9052=y
@@ -257,9 +248,6 @@ CONFIG_RC_CORE=y
 CONFIG_RC_DEVICES=y
 CONFIG_IR_GPIO_CIR=y
 CONFIG_MEDIA_SUPPORT=y
-CONFIG_MEDIA_CAMERA_SUPPORT=y
-CONFIG_MEDIA_CONTROLLER=y
-CONFIG_VIDEO_V4L2_SUBDEV_API=y
 CONFIG_MEDIA_USB_SUPPORT=y
 CONFIG_USB_VIDEO_CLASS=m
 CONFIG_V4L_PLATFORM_DRIVERS=y
@@ -267,7 +255,6 @@ CONFIG_VIDEO_MUX=y
 CONFIG_V4L_MEM2MEM_DRIVERS=y
 CONFIG_VIDEO_CODA=m
 CONFIG_VIDEO_IMX_PXP=y
-# CONFIG_MEDIA_SUBDRV_AUTOSELECT is not set
 CONFIG_VIDEO_ADV7180=m
 CONFIG_VIDEO_OV2680=m
 CONFIG_VIDEO_OV5640=m
@@ -302,12 +289,10 @@ CONFIG_SND_USB_AUDIO=m
 CONFIG_SND_SOC=y
 CONFIG_SND_SOC_FSL_ASRC=y
 CONFIG_SND_IMX_SOC=y
-CONFIG_SND_SOC_PHYCORE_AC97=y
 CONFIG_SND_SOC_EUKREA_TLV320=y
 CONFIG_SND_SOC_IMX_ES8328=y
 CONFIG_SND_SOC_IMX_SGTL5000=y
 CONFIG_SND_SOC_IMX_SPDIF=y
-CONFIG_SND_SOC_IMX_MC13783=y
 CONFIG_SND_SOC_FSL_ASOC_CARD=y
 CONFIG_SND_SOC_AC97_CODEC=y
 CONFIG_SND_SOC_CS42XX8_I2C=y
@@ -319,7 +304,6 @@ CONFIG_HID_MULTITOUCH=y
 CONFIG_USB=y
 CONFIG_USB_ANNOUNCE_NEW_DEVICES=y
 CONFIG_USB_EHCI_HCD=y
-CONFIG_USB_EHCI_MXC=y
 CONFIG_USB_ACM=m
 CONFIG_USB_STORAGE=y
 CONFIG_USB_CHIPIDEA=y
@@ -334,7 +318,6 @@ CONFIG_USB_EHSET_TEST_FIXTURE=m
 CONFIG_NOP_USB_XCEIV=y
 CONFIG_USB_MXS_PHY=y
 CONFIG_USB_GADGET=y
-CONFIG_USB_FSL_USB2=y
 CONFIG_USB_CONFIGFS=y
 CONFIG_USB_CONFIGFS_SERIAL=y
 CONFIG_USB_CONFIGFS_ACM=y
@@ -383,11 +366,11 @@ CONFIG_RTC_DRV_ISL1208=y
 CONFIG_RTC_DRV_PCF8523=y
 CONFIG_RTC_DRV_PCF8563=y
 CONFIG_RTC_DRV_M41T80=y
+CONFIG_RTC_DRV_RC5T619=y
 CONFIG_RTC_DRV_DA9063=y
 CONFIG_RTC_DRV_MC13XXX=y
 CONFIG_RTC_DRV_MXC=y
 CONFIG_RTC_DRV_MXC_V2=y
-CONFIG_RTC_DRV_RC5T619=y
 CONFIG_RTC_DRV_SNVS=y
 CONFIG_DMADEVICES=y
 CONFIG_FSL_EDMA=y
@@ -464,13 +447,14 @@ CONFIG_CRC_CCITT=m
 CONFIG_CRC_T10DIF=y
 CONFIG_CRC7=m
 CONFIG_LIBCRC32C=m
+CONFIG_CMA_SIZE_MBYTES=64
 CONFIG_FONTS=y
 CONFIG_FONT_8x8=y
 CONFIG_FONT_8x16=y
 CONFIG_PRINTK_TIME=y
+# CONFIG_DEBUG_BUGVERBOSE is not set
 CONFIG_MAGIC_SYSRQ=y
 CONFIG_DEBUG_FS=y

Re: [PATCH 2/2] remarkable2_defconfig: Add initial support for the reMarkable2

2021-01-17 Thread Alistair Francis
On Sun, Jan 17, 2021 at 5:30 PM Olof Johansson  wrote:
>
> Hi Alistair,
>
> On Sun, Jan 17, 2021 at 3:09 PM Alistair Francis  
> wrote:
> >
> > This defconfig is based on the one released by reMarkable with their
> > 4.14 kernel. I have updated it to match the latest kernels.
> >
> > Signed-off-by: Alistair Francis 
>
> It's awesome to see upstream support for contemporary consumer
> products being posted, thanks!

No worries!

>
> When it comes to a dedicated defconfig, is that necessary in this
> case? The needed drivers should be possible to enable either in
> imx_v6_v7_defconfig, or in multi_v7_defconfig (or, rather, both)?

Most of the defconfi could be shared with a standard imx7 config, but
some of the extra components like the Wacom digitiser,
cyttsp5_i2c_adapter, max77818 and bd71815 might be better off in it's
own defconfig.

If the maintainers are happy with enabling some of those in a imx7
defconfig then I'm happy to do that. I have tried to split out the
config changes (I have two otehr series that build on this one) so it
should be easy to rebase it all on a standard one.

>
> Adding new defconfigs is something we're avoiding as much as possible,
> since it adds CI overhead, and defconfigs easily get churny due to
> options moving around.
>
> In some cases we do it once per SoC family (i.e. the i.MX defconfigs),
> but we avoid it for products.

Makes sense, I will update my patches not to use a custom defconfig.

Alistair

>
>
> -Olof


[PATCH 5/6] arch/arm: reMarkable2: Enable silergy,sy7636a

2021-01-17 Thread Alistair Francis
Enable the silergy,sy7636a and silergy,sy7636a-regulator on the
reMarkable2.

Signed-off-by: Alistair Francis 
---
 arch/arm/boot/dts/imx7d-remarkable2.dts | 61 +
 arch/arm/configs/remarkable2_defconfig  |  2 +
 2 files changed, 63 insertions(+)

diff --git a/arch/arm/boot/dts/imx7d-remarkable2.dts 
b/arch/arm/boot/dts/imx7d-remarkable2.dts
index 8052d884a5e5..f419ab704f06 100644
--- a/arch/arm/boot/dts/imx7d-remarkable2.dts
+++ b/arch/arm/boot/dts/imx7d-remarkable2.dts
@@ -58,6 +58,27 @@ memory {
reg = <0x8000 0x4000>;
};
 
+   thermal-zones {
+   epd-thermal {
+   thermal-sensors = <_pmic>;
+   polling-delay-passive = <3>;
+   polling-delay = <3>;
+   trips {
+   trip0 {
+   temperature = <49000>;
+   hysteresis = <2000>;
+   type = "passive";
+   };
+
+   trip1 {
+   temperature = <5>;
+   hysteresis = <2000>;
+   type = "critical";
+   };
+   };
+   };
+   };
+
reg_vref_1v8: regulator-vref-1v8 {
compatible = "regulator-fixed";
regulator-name = "vref-1v8";
@@ -174,6 +195,32 @@ digitizer: wacom-i2c@9 {
};
 };
 
+ {
+   clock-frequency = <10>;
+   pinctrl-names = "default", "sleep";
+   pinctrl-0 = <_i2c4>;
+   pinctrl-1 = <_i2c4>;
+   status = "okay";
+
+   epd_pmic: sy7636a@62 {
+   compatible = "silergy,sy7636a";
+   reg = <0x62>;
+   status = "okay";
+   pinctrl-names = "default";
+   pinctrl-0 = <_epdpmic>;
+   #thermal-sensor-cells = <0>;
+
+   epd-pwr-good-gpios = < 21 GPIO_ACTIVE_HIGH>;
+   regulators {
+   compatible = "silergy,sy7636a-regulator";
+   reg_epdpmic: vcom {
+   regulator-name = "vcom";
+   regulator-boot-on;
+   };
+   };
+   };
+};
+
  {
status = "okay";
 };
@@ -277,6 +324,13 @@ MX7D_PAD_I2C1_SCL__I2C1_SCL0x407f
>;
};
 
+   pinctrl_i2c4: i2c4grp {
+   fsl,pins = <
+   MX7D_PAD_I2C4_SDA__I2C4_SDA 0x407f
+   MX7D_PAD_I2C4_SCL__I2C4_SCL 0x407f
+   >;
+   };
+
pinctrl_uart1: uart1grp {
fsl,pins = <
MX7D_PAD_UART1_TX_DATA__UART1_DCE_TX0x79
@@ -389,6 +443,13 @@ MX7D_PAD_SD1_WP__CCM_CLKO2 0x0014
>;
};
 
+   pinctrl_epdpmic: epdpmicgrp {
+   fsl,pins = <
+   MX7D_PAD_SAI2_RX_DATA__GPIO6_IO21 0x0074
+   MX7D_PAD_ENET1_RGMII_TXC__GPIO7_IO11 0x0014
+   >;
+   };
+
pinctrl_wdog: wdoggrp {
fsl,pins = <
MX7D_PAD_ENET1_COL__WDOG1_WDOG_ANY  0x74
diff --git a/arch/arm/configs/remarkable2_defconfig 
b/arch/arm/configs/remarkable2_defconfig
index 8c978cda..6306568772c3 100644
--- a/arch/arm/configs/remarkable2_defconfig
+++ b/arch/arm/configs/remarkable2_defconfig
@@ -193,6 +193,7 @@ CONFIG_MFD_MC13XXX_SPI=y
 CONFIG_MFD_MC13XXX_I2C=y
 CONFIG_MFD_SI476X_CORE=y
 CONFIG_MFD_STMPE=y
+CONFIG_MFD_SY7636A=y
 CONFIG_REGULATOR=y
 CONFIG_REGULATOR_FIXED_VOLTAGE=y
 CONFIG_REGULATOR_ANATOP=y
@@ -201,6 +202,7 @@ CONFIG_REGULATOR_GPIO=y
 CONFIG_REGULATOR_MC13783=y
 CONFIG_REGULATOR_MC13892=y
 CONFIG_REGULATOR_PFUZE100=y
+CONFIG_REGULATOR_SY7636A=y
 CONFIG_MEDIA_SUPPORT=y
 CONFIG_MEDIA_USB_SUPPORT=y
 CONFIG_USB_VIDEO_CLASS=m
-- 
2.29.2



[PATCH 4/6] regulator: Initial commit of sy7636a

2021-01-17 Thread Alistair Francis
Initial support for the Silergy SY7636A-regulator Power Management chip
driver.

Signed-off-by: Alistair Francis 
---
 drivers/regulator/Kconfig |   6 +
 drivers/regulator/Makefile|   1 +
 drivers/regulator/sy7636a-regulator.c | 233 ++
 3 files changed, 240 insertions(+)
 create mode 100644 drivers/regulator/sy7636a-regulator.c

diff --git a/drivers/regulator/Kconfig b/drivers/regulator/Kconfig
index 5abdd29fb9f3..76510a0db4f9 100644
--- a/drivers/regulator/Kconfig
+++ b/drivers/regulator/Kconfig
@@ -1097,6 +1097,12 @@ config REGULATOR_STW481X_VMMC
  This driver supports the internal VMMC regulator in the STw481x
  PMIC chips.
 
+config REGULATOR_SY7636A
+   tristate "Silergy SY7636A voltage regulator"
+   depends on MFD_SY7636A
+   help
+ This driver supports Silergy SY3686A voltage regulator.
+
 config REGULATOR_SY8106A
tristate "Silergy SY8106A regulator"
depends on I2C && (OF || COMPILE_TEST)
diff --git a/drivers/regulator/Makefile b/drivers/regulator/Makefile
index 680e539f6579..fe05347cbf84 100644
--- a/drivers/regulator/Makefile
+++ b/drivers/regulator/Makefile
@@ -131,6 +131,7 @@ obj-$(CONFIG_REGULATOR_STM32_VREFBUF) += stm32-vrefbuf.o
 obj-$(CONFIG_REGULATOR_STM32_PWR) += stm32-pwr.o
 obj-$(CONFIG_REGULATOR_STPMIC1) += stpmic1_regulator.o
 obj-$(CONFIG_REGULATOR_STW481X_VMMC) += stw481x-vmmc.o
+obj-$(CONFIG_REGULATOR_SY7636A) += sy7636a-regulator.o
 obj-$(CONFIG_REGULATOR_SY8106A) += sy8106a-regulator.o
 obj-$(CONFIG_REGULATOR_SY8824X) += sy8824x.o
 obj-$(CONFIG_REGULATOR_SY8827N) += sy8827n.o
diff --git a/drivers/regulator/sy7636a-regulator.c 
b/drivers/regulator/sy7636a-regulator.c
new file mode 100644
index ..a639830298d6
--- /dev/null
+++ b/drivers/regulator/sy7636a-regulator.c
@@ -0,0 +1,233 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Functions to access SY3686A power management chip voltages
+ *
+ * Copyright (C) 2019 reMarkable AS - http://www.remarkable.com/
+ *
+ * Author: Lars Ivar Miljeteig 
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation version 2.
+ *
+ * This program is distributed "as is" WITHOUT ANY WARRANTY of any
+ * kind, whether express or implied; without even the implied warranty
+ * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+
+#include 
+#include 
+#include 
+#include 
+
+#include 
+
+static int get_vcom_voltage_op(struct regulator_dev *rdev)
+{
+   int ret = get_vcom_voltage_mv(rdev->regmap);
+
+   if (ret < 0)
+   return ret;
+
+   return ret * 1000;
+}
+
+static int disable_regulator(struct regulator_dev *rdev)
+{
+   struct sy7636a *sy7636a = dev_get_drvdata(rdev->dev.parent);
+   int ret = 0;
+
+   mutex_lock(>reglock);
+   ret = regulator_disable_regmap(rdev);
+   usleep_range(3, 35000);
+   mutex_unlock(>reglock);
+
+   return ret;
+}
+
+static int sy7636a_regulator_is_enabled(struct regulator_dev *rdev)
+{
+   struct sy7636a *sy7636a = dev_get_drvdata(rdev->dev.parent);
+   int ret;
+
+   mutex_lock(>reglock);
+   ret = regulator_is_enabled_regmap(rdev);
+   mutex_unlock(>reglock);
+
+   return ret;
+}
+
+static int enable_regulator_pgood(struct regulator_dev *rdev)
+{
+   struct sy7636a *sy7636a = dev_get_drvdata(rdev->dev.parent);
+   int pwr_good = 0;
+   int ret = 0;
+   unsigned long t0, t1;
+   const unsigned int wait_time = 500;
+   unsigned int wait_cnt;
+
+   t0 = jiffies;
+
+   mutex_lock(>reglock);
+
+   ret = regulator_enable_regmap(rdev);
+   if (ret)
+   goto finish;
+
+   for (wait_cnt = 0; wait_cnt < wait_time; wait_cnt++) {
+   pwr_good = gpiod_get_value_cansleep(sy7636a->pgood_gpio);
+   if (pwr_good < 0) {
+   dev_err(>dev, "Failed to read pgood gpio: %d\n", 
pwr_good);
+   ret = pwr_good;
+   goto finish;
+   } else if (pwr_good)
+   break;
+
+   usleep_range(1000, 1500);
+   }
+
+   t1 = jiffies;
+
+   if (!pwr_good) {
+   dev_err(>dev, "Power good signal timeout after %u ms\n",
+   jiffies_to_msecs(t1 - t0));
+   ret = -ETIME;
+   goto finish;
+   }
+
+   dev_dbg(>dev, "Power good OK (took %u ms, %u waits)\n",
+   jiffies_to_msecs(t1 - t0),
+   wait_cnt);
+
+finish:
+   mutex_unlock(>reglock);
+   return ret;
+}
+
+static const struct regulator_ops sy7636a_vcom_volt_ops = {
+   .get_voltage = get_vcom_voltage_op,
+   .en

[PATCH 3/6] devicetree/bindings: Initial commit of silergy,sy7636a-regulator.yaml

2021-01-17 Thread Alistair Francis
Initial support for the Silergy SY7636A-regulator Power Management chip
driver.

Signed-off-by: Alistair Francis 
---
 .../bindings/regulator/silergy,sy7636a.yaml   | 39 +++
 1 file changed, 39 insertions(+)
 create mode 100644 
Documentation/devicetree/bindings/regulator/silergy,sy7636a.yaml

diff --git a/Documentation/devicetree/bindings/regulator/silergy,sy7636a.yaml 
b/Documentation/devicetree/bindings/regulator/silergy,sy7636a.yaml
new file mode 100644
index ..d88c4ab1be02
--- /dev/null
+++ b/Documentation/devicetree/bindings/regulator/silergy,sy7636a.yaml
@@ -0,0 +1,39 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/regulator/silergy,sy7636a-regulator.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: silergy sy7636a PMIC
+
+maintainers:
+  - Alistair Francis 
+
+allOf:
+  - $ref: regulator.yaml#
+
+properties:
+  compatible:
+enum:
+  - sy7636a-regulator
+
+required:
+  - compatible
+
+unevaluatedProperties: false
+
+examples:
+  - |
+i2c {
+#address-cells = <1>;
+#size-cells = <0>;
+regulator@60 {
+  compatible = "sy7636a-regulator";
+  reg_epdpmic: vcom {
+regulator-name = "vcom";
+regulator-boot-on;
+  };
+};
+};
+
+...
-- 
2.29.2



[PATCH 2/6] mfd: Initial commit of sy7636a

2021-01-17 Thread Alistair Francis
Initial support for the Silergy SY7636A Power Management chip
driver.

Signed-off-by: Alistair Francis 
---
 drivers/mfd/Kconfig |  10 ++
 drivers/mfd/Makefile|   2 +
 drivers/mfd/sy7636a.c   | 252 
 include/linux/mfd/sy7636a.h |  50 +++
 4 files changed, 314 insertions(+)
 create mode 100644 drivers/mfd/sy7636a.c
 create mode 100644 include/linux/mfd/sy7636a.h

diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig
index bdfce7b15621..c8c62d92433c 100644
--- a/drivers/mfd/Kconfig
+++ b/drivers/mfd/Kconfig
@@ -1360,6 +1360,16 @@ config MFD_SYSCON
  Select this option to enable accessing system control registers
  via regmap.
 
+config MFD_SY7636A
+   tristate "Silergy SY7636A Power Management chip driver"
+   select MFD_CORE
+   select REGMAP_I2C
+   select REGMAP_IRQ
+   depends on I2C=y
+   help
+ Select this option to enable support for the Silergy SY7636A
+ Power Management chip driver.
+
 config MFD_DAVINCI_VOICECODEC
tristate
select MFD_CORE
diff --git a/drivers/mfd/Makefile b/drivers/mfd/Makefile
index 14fdb188af02..1fa1e635f506 100644
--- a/drivers/mfd/Makefile
+++ b/drivers/mfd/Makefile
@@ -265,6 +265,8 @@ obj-$(CONFIG_MFD_ROHM_BD718XX)  += rohm-bd718x7.o
 obj-$(CONFIG_MFD_STMFX)+= stmfx.o
 obj-$(CONFIG_MFD_KHADAS_MCU)   += khadas-mcu.o
 
+obj-$(CONFIG_MFD_SY7636A)  += sy7636a.o
+
 obj-$(CONFIG_SGI_MFD_IOC3) += ioc3.o
 obj-$(CONFIG_MFD_SIMPLE_MFD_I2C)   += simple-mfd-i2c.o
 obj-$(CONFIG_MFD_INTEL_M10_BMC)   += intel-m10-bmc.o
diff --git a/drivers/mfd/sy7636a.c b/drivers/mfd/sy7636a.c
new file mode 100644
index ..39aac965d854
--- /dev/null
+++ b/drivers/mfd/sy7636a.c
@@ -0,0 +1,252 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * MFD driver for SY7636A chip
+ *
+ * Copyright (C) 2019 reMarkable AS - http://www.remarkable.com/
+ *
+ * Author: Lars Ivar Miljeteig 
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation version 2.
+ *
+ * This program is distributed "as is" WITHOUT ANY WARRANTY of any
+ * kind, whether express or implied; without even the implied warranty
+ * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * Based on the lp87565 driver by Keerthy 
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+
+static const struct regmap_config sy7636a_regmap_config = {
+   .reg_bits = 8,
+   .val_bits = 8,
+};
+
+static const struct mfd_cell sy7636a_cells[] = {
+   { .name = "sy7636a-regulator", },
+   { .name = "sy7636a-temperature", },
+   { .name = "sy7636a-thermal", },
+};
+
+static const struct of_device_id of_sy7636a_match_table[] = {
+   { .compatible = "silergy,sy7636a", },
+   {}
+};
+MODULE_DEVICE_TABLE(of, of_sy7636a_match_table);
+
+static const char * const states[] = {
+   "no fault event",
+   "UVP at VP rail",
+   "UVP at VN rail",
+   "UVP at VPOS rail",
+   "UVP at VNEG rail",
+   "UVP at VDDH rail",
+   "UVP at VEE rail",
+   "SCP at VP rail",
+   "SCP at VN rail",
+   "SCP at VPOS rail",
+   "SCP at VNEG rail",
+   "SCP at VDDH rail",
+   "SCP at VEE rail",
+   "SCP at V COM rail",
+   "UVLO",
+   "Thermal shutdown",
+};
+
+int get_vcom_voltage_mv(struct regmap *regmap)
+{
+   int ret;
+   unsigned int val, val_h;
+
+   ret = regmap_read(regmap, SY7636A_REG_VCOM_ADJUST_CTRL_L, );
+   if (ret)
+   return ret;
+
+   ret = regmap_read(regmap, SY7636A_REG_VCOM_ADJUST_CTRL_H, _h);
+   if (ret)
+   return ret;
+
+   val |= (val_h << 8);
+
+   return (val & 0x1FF) * 10;
+}
+
+int set_vcom_voltage_mv(struct regmap *regmap, unsigned int vcom)
+{
+   int ret;
+   unsigned int val;
+
+   if (vcom < 0 || vcom > 5000)
+   return -EINVAL;
+
+   val = (unsigned int)(vcom / 10) & 0x1ff;
+
+   ret = regmap_write(regmap, SY7636A_REG_VCOM_ADJUST_CTRL_L, val);
+   if (ret)
+   return ret;
+
+   ret = regmap_write(regmap, SY7636A_REG_VCOM_ADJUST_CTRL_H, val >> 8);
+   if (ret)
+   return ret;
+
+   return 0;
+}
+
+static ssize_t state_show(struct device *dev, struct device_attribute *attr,
+   char *buf)
+{
+   int ret;
+   unsigned int val;
+   struct sy7636a *sy7636a = dev_get_drvdata(dev);
+
+   ret = regmap_read(sy7636a->regmap, SY7636A_REG_FAULT_FLAG, );
+   if (ret) {
+ 

[PATCH 6/6] arch/arm: reMarkable2: Enable lcdif

2021-01-17 Thread Alistair Francis
Connect the dispaly on the reMarkable2.

Signed-off-by: Alistair Francis 
---
 arch/arm/boot/dts/imx7d-remarkable2.dts | 70 +
 1 file changed, 70 insertions(+)

diff --git a/arch/arm/boot/dts/imx7d-remarkable2.dts 
b/arch/arm/boot/dts/imx7d-remarkable2.dts
index f419ab704f06..d4e93f7ca7ea 100644
--- a/arch/arm/boot/dts/imx7d-remarkable2.dts
+++ b/arch/arm/boot/dts/imx7d-remarkable2.dts
@@ -221,6 +221,42 @@ reg_epdpmic: vcom {
};
 };
 
+ {
+   pinctrl-names = "default", "sleep";
+   pinctrl-0 = <_lcdif>;
+   pinctrl-1 = <_lcdif>;
+   lcd-supply = <_epdpmic>;
+   lcd2-supply = <_sdoe>;
+   display = <>;
+   prevent-frying-pan;
+   status = "okay";
+
+   display0: display {
+   bits-per-pixel = <24>;
+   bus-width = <24>;
+
+   display-timings {
+   native-mode = <>;
+
+   timing0: timing0 {
+   clock-frequency = <4000>;
+   hactive = <334>;
+   vactive = <1405>;
+   hfront-porch = <1>;
+   hback-porch = <1>;
+   hsync-len = <1>;
+   vback-porch = <1>;
+   vfront-porch = <1>;
+   vsync-len = <1>;
+   hsync-active = <0>;
+   vsync-active = <0>;
+   de-active = <1>;
+   pixelclk-active = <1>;
+   };
+   };
+   };
+};
+
  {
status = "okay";
 };
@@ -331,6 +367,40 @@ MX7D_PAD_I2C4_SCL__I2C4_SCL0x407f
>;
};
 
+   pinctrl_lcdif: lcdifgrp {
+   fsl,pins = <
+   MX7D_PAD_LCD_DATA00__LCD_DATA0  0x79
+   MX7D_PAD_LCD_DATA01__LCD_DATA1  0x79
+   MX7D_PAD_LCD_DATA02__LCD_DATA2  0x79
+   MX7D_PAD_LCD_DATA03__LCD_DATA3  0x79
+   MX7D_PAD_LCD_DATA04__LCD_DATA4  0x79
+   MX7D_PAD_LCD_DATA05__LCD_DATA5  0x79
+   MX7D_PAD_LCD_DATA06__LCD_DATA6  0x79
+   MX7D_PAD_LCD_DATA07__LCD_DATA7  0x79
+   MX7D_PAD_LCD_DATA08__LCD_DATA8  0x79
+   MX7D_PAD_LCD_DATA09__LCD_DATA9  0x79
+   MX7D_PAD_LCD_DATA10__LCD_DATA10 0x79
+   MX7D_PAD_LCD_DATA11__LCD_DATA11 0x79
+   MX7D_PAD_LCD_DATA12__LCD_DATA12 0x79
+   MX7D_PAD_LCD_DATA13__LCD_DATA13 0x79
+   MX7D_PAD_LCD_DATA14__LCD_DATA14 0x79
+   MX7D_PAD_LCD_DATA15__LCD_DATA15 0x79
+
+   MX7D_PAD_LCD_DATA17__LCD_DATA17 0x79
+   MX7D_PAD_LCD_DATA18__LCD_DATA18 0x79
+   MX7D_PAD_LCD_DATA19__LCD_DATA19 0x79
+   MX7D_PAD_LCD_DATA20__LCD_DATA20 0x79
+   MX7D_PAD_LCD_DATA21__LCD_DATA21 0x79
+
+   MX7D_PAD_LCD_DATA23__LCD_DATA23 0x79
+   MX7D_PAD_LCD_CLK__LCD_CLK   0x79
+   MX7D_PAD_LCD_ENABLE__LCD_ENABLE 0x79
+   MX7D_PAD_LCD_VSYNC__LCD_VSYNC   0x79
+   MX7D_PAD_LCD_HSYNC__LCD_HSYNC   0x79
+   MX7D_PAD_LCD_RESET__LCD_RESET   0x79
+   >;
+   };
+
pinctrl_uart1: uart1grp {
fsl,pins = <
MX7D_PAD_UART1_TX_DATA__UART1_DCE_TX0x79
-- 
2.29.2



[PATCH 1/6] devicetree/bindings: Initial commit of silergy,sy7636a.yaml

2021-01-17 Thread Alistair Francis
Initial support for the Silergy SY7636A Power Management chip
driver.

Signed-off-by: Alistair Francis 
---
 .../bindings/mfd/silergy,sy7636a.yaml | 37 +++
 1 file changed, 37 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/mfd/silergy,sy7636a.yaml

diff --git a/Documentation/devicetree/bindings/mfd/silergy,sy7636a.yaml 
b/Documentation/devicetree/bindings/mfd/silergy,sy7636a.yaml
new file mode 100644
index ..37541a7fcc5d
--- /dev/null
+++ b/Documentation/devicetree/bindings/mfd/silergy,sy7636a.yaml
@@ -0,0 +1,37 @@
+# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/regulator/silergy,sy7636a.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: silergy sy7636a PMIC
+
+maintainers:
+  - Alistair Francis 
+
+properties:
+  compatible:
+enum:
+  - silergy,sy7636a
+
+  reg:
+maxItems: 1
+
+required:
+  - compatible
+  - reg
+
+additionalProperties: false
+
+examples:
+  - |
+i2c {
+#address-cells = <1>;
+#size-cells = <0>;
+regulator@60 {
+  compatible = "silergy,sy7636a";
+  reg = <0x60>;
+};
+};
+
+...
-- 
2.29.2



[PATCH 1/3] devicetree/bindings: Initial commit of wacom,wacom-i2c

2021-01-17 Thread Alistair Francis
Signed-off-by: Alistair Francis 
---
 .../input/touchscreen/wacom,wacom-i2c.yaml| 55 +++
 .../devicetree/bindings/vendor-prefixes.yaml  |  2 +
 2 files changed, 57 insertions(+)
 create mode 100644 
Documentation/devicetree/bindings/input/touchscreen/wacom,wacom-i2c.yaml

diff --git 
a/Documentation/devicetree/bindings/input/touchscreen/wacom,wacom-i2c.yaml 
b/Documentation/devicetree/bindings/input/touchscreen/wacom,wacom-i2c.yaml
new file mode 100644
index ..6b0e0034f836
--- /dev/null
+++ b/Documentation/devicetree/bindings/input/touchscreen/wacom,wacom-i2c.yaml
@@ -0,0 +1,55 @@
+# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/input/touchscreen/wacom,wacom-i2c.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Wacom I2C Controller
+
+maintainers:
+  - Alistair Francis 
+
+allOf:
+  - $ref: touchscreen.yaml#
+
+properties:
+  compatible:
+const: wacom,wacom-i2c
+
+  reg:
+maxItems: 1
+
+  interrupts:
+maxItems: 1
+
+  flip-tilt-x:
+  flip-tilt-y:
+  flip-pos-x:
+  flip-pos-y:
+  flip-distance:
+
+required:
+  - compatible
+  - reg
+  - interrupts
+
+additionalProperties: false
+
+examples:
+  - |
+#include "dt-bindings/interrupt-controller/irq.h"
+i2c {
+#address-cells = <1>;
+#size-cells = <0>;
+digitiser@9 {
+compatible = "wacom,wacom-i2c";
+reg = <0x9>;
+interrupt-parent = <>;
+interrupts = <9 IRQ_TYPE_LEVEL_LOW>;
+flip-tilt-x;
+flip-tilt-y;
+flip-pos-x;
+flip-pos-y;
+flip-distance;
+};
+};
diff --git a/Documentation/devicetree/bindings/vendor-prefixes.yaml 
b/Documentation/devicetree/bindings/vendor-prefixes.yaml
index 041ae90b0d8f..5bca22f035a3 100644
--- a/Documentation/devicetree/bindings/vendor-prefixes.yaml
+++ b/Documentation/devicetree/bindings/vendor-prefixes.yaml
@@ -1202,6 +1202,8 @@ patternProperties:
 description: Vision Optical Technology Co., Ltd.
   "^vxt,.*":
 description: VXT Ltd
+  "^wacom,.*":
+description: Wacom Co., Ltd
   "^wand,.*":
 description: Wandbord (Technexion)
   "^waveshare,.*":
-- 
2.29.2



[PATCH 2/3] input/touchscreen: Add device tree support to wacom_i2c

2021-01-17 Thread Alistair Francis
Allow the wacom-i2c device to be exposed via device tree.

Signed-off-by: Alistair Francis 
---
 drivers/input/touchscreen/wacom_i2c.c | 38 +++
 1 file changed, 38 insertions(+)

diff --git a/drivers/input/touchscreen/wacom_i2c.c 
b/drivers/input/touchscreen/wacom_i2c.c
index 1afc6bde2891..54af2934ba17 100644
--- a/drivers/input/touchscreen/wacom_i2c.c
+++ b/drivers/input/touchscreen/wacom_i2c.c
@@ -12,6 +12,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 
 #define WACOM_CMD_QUERY0   0x04
@@ -35,6 +36,13 @@ struct wacom_i2c {
u8 data[WACOM_QUERY_SIZE];
bool prox;
int tool;
+
+   bool flip_tilt_x;
+   bool flip_tilt_y;
+   bool flip_pos_x;
+   bool flip_pos_y;
+   bool flip_distance;
+   bool flip_pressure;
 };
 
 static int wacom_query_device(struct i2c_client *client,
@@ -144,6 +152,20 @@ static void wacom_i2c_close(struct input_dev *dev)
disable_irq(client->irq);
 }
 
+#ifdef CONFIG_OF
+static void wacom_of_read(struct wacom_i2c *wac_i2c)
+{
+   struct i2c_client *client = wac_i2c->client;
+
+   wac_i2c->flip_tilt_x = of_property_read_bool(client->dev.of_node, 
"flip-tilt-x");
+   wac_i2c->flip_tilt_y = of_property_read_bool(client->dev.of_node, 
"flip-tilt-y");
+   wac_i2c->flip_pos_x = of_property_read_bool(client->dev.of_node, 
"flip-pos-x");
+   wac_i2c->flip_pos_y = of_property_read_bool(client->dev.of_node, 
"flip-pos-y");
+   wac_i2c->flip_distance = of_property_read_bool(client->dev.of_node, 
"flip-distance");
+   wac_i2c->flip_pressure = of_property_read_bool(client->dev.of_node, 
"flip-pressure");
+}
+#endif
+
 static int wacom_i2c_probe(struct i2c_client *client,
 const struct i2c_device_id *id)
 {
@@ -214,6 +236,11 @@ static int wacom_i2c_probe(struct i2c_client *client,
}
 
i2c_set_clientdata(client, wac_i2c);
+
+#ifdef CONFIG_OF
+   wacom_of_read(wac_i2c);
+#endif
+
return 0;
 
 err_free_irq:
@@ -262,10 +289,21 @@ static const struct i2c_device_id wacom_i2c_id[] = {
 };
 MODULE_DEVICE_TABLE(i2c, wacom_i2c_id);
 
+#ifdef CONFIG_OF
+static const struct of_device_id wacom_i2c_of_match_table[] = {
+   { .compatible = "wacom,wacom-i2c" },
+   {}
+};
+MODULE_DEVICE_TABLE(of, wacom_i2c_of_match_table);
+#endif
+
 static struct i2c_driver wacom_i2c_driver = {
.driver = {
.name   = "wacom_i2c",
.pm = _i2c_pm,
+#ifdef CONFIG_OF
+   .of_match_table = of_match_ptr(wacom_i2c_of_match_table),
+#endif
},
 
.probe  = wacom_i2c_probe,
-- 
2.29.2



[PATCH 3/3] arch/arm: reMarkable2: Enable wacom_i2c

2021-01-17 Thread Alistair Francis
Enable the wacom_i2c touchscreen for the reMarkable2.

Signed-off-by: Alistair Francis 
---
 arch/arm/boot/dts/imx7d-remarkable2.dts | 41 +
 1 file changed, 41 insertions(+)

diff --git a/arch/arm/boot/dts/imx7d-remarkable2.dts 
b/arch/arm/boot/dts/imx7d-remarkable2.dts
index fba55a0e028a..8052d884a5e5 100644
--- a/arch/arm/boot/dts/imx7d-remarkable2.dts
+++ b/arch/arm/boot/dts/imx7d-remarkable2.dts
@@ -150,6 +150,30 @@ _apbh {
status = "disabled";
 };
 
+ {
+   clock-frequency = <40>;
+   pinctrl-names = "default", "sleep";
+   pinctrl-0 = <_i2c1>;
+   pinctrl-1 = <_i2c1>;
+   status = "okay";
+
+   digitizer: wacom-i2c@9 {
+   pinctrl-names = "default", "sleep";
+   pinctrl-0 = <_wacom>;
+   pinctrl-1 = <_wacom>;
+   compatible = "wacom,wacom-i2c";
+   reg = <0x09>;
+   interrupt-parent = <>;
+   interrupts = <1 2>;
+   flip-tilt-x;
+   flip-tilt-y;
+   flip-pos-x;
+   flip-pos-y;
+   flip-distance;
+   vdd-supply = <_digitizer>;
+   };
+};
+
  {
status = "okay";
 };
@@ -221,6 +245,16 @@  {
 };
 
 _lpsr {
+   pinctrl_wacom: wacomgrp {
+   fsl,pins = <
+   /*MX7D_PAD_LPSR_GPIO1_IO00__GPIO1_IO0   0x0074 /* 
WACOM RESET */
+   MX7D_PAD_LPSR_GPIO1_IO01__GPIO1_IO1 0x0034 /* 
WACOM INT */
+   MX7D_PAD_LPSR_GPIO1_IO04__GPIO1_IO4 0x0074 /* 
PDCTB */
+   /*MX7D_PAD_LPSR_GPIO1_IO05__GPIO1_IO5   0x0014 /* 
FWE */
+   /*MX7D_PAD_LPSR_GPIO1_IO06__GPIO1_IO6   0x0014 /* 
WACOM PWR ENABLE */
+   >;
+   };
+
pinctrl_digitizer_reg: digitizerreggrp {
fsl,pins = <
/* DIGITIZER_PWR_EN */
@@ -236,6 +270,13 @@ MX7D_PAD_SAI1_RX_SYNC__GPIO6_IO16  0x59
>;
};
 
+   pinctrl_i2c1: i2c1grp {
+   fsl,pins = <
+   MX7D_PAD_I2C1_SDA__I2C1_SDA 0x407f
+   MX7D_PAD_I2C1_SCL__I2C1_SCL 0x407f
+   >;
+   };
+
pinctrl_uart1: uart1grp {
fsl,pins = <
MX7D_PAD_UART1_TX_DATA__UART1_DCE_TX0x79
-- 
2.29.2



[PATCH 1/2] imx7d-remarkable2.dts: Initial device tree for reMarkable2

2021-01-17 Thread Alistair Francis
The reMarkable2 (https://remarkable.com) is an e-ink tablet based on
the imx7d SoC.

This commit is based on the DTS provide by reMarkable but ported to the
latest kernel (instead of 4.14). I have removed references to
non-upstream devices and have changed the UART so that the console can
be accessed without having to open up the device via the OTG pogo pins.

Currently the kernel boots, but there is no support for the dispaly,
WiFi or the power controller chips.

Signed-off-by: Alistair Francis 
---
 arch/arm/boot/dts/Makefile  |   1 +
 arch/arm/boot/dts/imx7d-remarkable2.dts | 375 
 2 files changed, 376 insertions(+)
 create mode 100644 arch/arm/boot/dts/imx7d-remarkable2.dts

diff --git a/arch/arm/boot/dts/Makefile b/arch/arm/boot/dts/Makefile
index 3d1ea0b25168..5fca2612ef58 100644
--- a/arch/arm/boot/dts/Makefile
+++ b/arch/arm/boot/dts/Makefile
@@ -664,6 +664,7 @@ dtb-$(CONFIG_SOC_IMX7D) += \
imx7d-sdb-sht11.dtb \
imx7d-zii-rmu2.dtb \
imx7d-zii-rpu2.dtb \
+   imx7d-remarkable2.dtb \
imx7s-colibri-aster.dtb \
imx7s-colibri-eval-v3.dtb \
imx7s-mba7.dtb \
diff --git a/arch/arm/boot/dts/imx7d-remarkable2.dts 
b/arch/arm/boot/dts/imx7d-remarkable2.dts
new file mode 100644
index ..fba55a0e028a
--- /dev/null
+++ b/arch/arm/boot/dts/imx7d-remarkable2.dts
@@ -0,0 +1,375 @@
+// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
+/*
+ * Copyright (C) 2015 Freescale Semiconductor, Inc.
+ * Copyright (C) 2019 reMarkable AS - http://www.remarkable.com/
+ *
+ * This file is dual-licensed: you can use it either under the terms
+ * of the GPL or the X11 license, at your option. Note that this dual
+ * licensing only applies to this file, and not this project as a
+ * whole.
+ *
+ *  a) This file is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This file is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * Or, alternatively,
+ *
+ *  b) Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation
+ * files (the "Software"), to deal in the Software without
+ * restriction, including without limitation the rights to use,
+ * copy, modify, merge, publish, distribute, sublicense, and/or
+ * sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following
+ * conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+/dts-v1/;
+
+#include "imx7d.dtsi"
+
+/ {
+   model = "reMarkable 2.0";
+   compatible = "fsl,imx7d-sdb", "fsl,imx7d";
+
+   chosen {
+   stdout-path = 
+   };
+
+   memory {
+   reg = <0x8000 0x4000>;
+   };
+
+   reg_vref_1v8: regulator-vref-1v8 {
+   compatible = "regulator-fixed";
+   regulator-name = "vref-1v8";
+   regulator-min-microvolt = <180>;
+   regulator-max-microvolt = <180>;
+   };
+
+   reg_brcm: regulator-brcm {
+   compatible = "regulator-fixed";
+   regulator-name = "brcm_reg";
+   regulator-min-microvolt = <330>;
+   regulator-max-microvolt = <330>;
+   pinctrl-names = "default", "sleep";
+   pinctrl-0 = <_brcm_reg>;
+   pinctrl-1 = <_brcm_reg>;
+   gpio = < 13 GPIO_ACTIVE_HIGH>;
+   enable-active-high;
+   startup-delay-us = <150>;
+   };
+
+   reg_digitizer: regulator-digitizer {
+   compatible = "regulator-fixed";
+   regulator-name = "VDD_3V3_DIGITIZER";
+   regulator-min-microvolt = <330>;
+   regulat

[PATCH 2/2] remarkable2_defconfig: Add initial support for the reMarkable2

2021-01-17 Thread Alistair Francis
This defconfig is based on the one released by reMarkable with their
4.14 kernel. I have updated it to match the latest kernels.

Signed-off-by: Alistair Francis 
---
 arch/arm/configs/remarkable2_defconfig | 358 +
 1 file changed, 358 insertions(+)
 create mode 100644 arch/arm/configs/remarkable2_defconfig

diff --git a/arch/arm/configs/remarkable2_defconfig 
b/arch/arm/configs/remarkable2_defconfig
new file mode 100644
index ..8c978cda
--- /dev/null
+++ b/arch/arm/configs/remarkable2_defconfig
@@ -0,0 +1,358 @@
+CONFIG_KERNEL_LZO=y
+CONFIG_SYSVIPC=y
+CONFIG_NO_HZ=y
+CONFIG_HIGH_RES_TIMERS=y
+CONFIG_PREEMPT=y
+CONFIG_IKCONFIG=y
+CONFIG_IKCONFIG_PROC=y
+CONFIG_LOG_BUF_SHIFT=18
+CONFIG_CGROUPS=y
+CONFIG_RELAY=y
+CONFIG_BLK_DEV_INITRD=y
+CONFIG_EXPERT=y
+CONFIG_KALLSYMS_ALL=y
+CONFIG_PERF_EVENTS=y
+# CONFIG_SLUB_DEBUG is not set
+# CONFIG_COMPAT_BRK is not set
+CONFIG_ARCH_MXC=y
+CONFIG_SOC_IMX50=y
+CONFIG_SOC_IMX53=y
+CONFIG_SOC_IMX6Q=y
+CONFIG_SOC_IMX6SL=y
+CONFIG_SOC_IMX6SLL=y
+CONFIG_SOC_IMX6SX=y
+CONFIG_SOC_IMX7D=y
+CONFIG_SOC_IMX7ULP=y
+CONFIG_SOC_VF610=y
+CONFIG_SMP=y
+CONFIG_VMSPLIT_2G=y
+CONFIG_ARM_PSCI=y
+CONFIG_HIGHMEM=y
+CONFIG_CMDLINE="noinitrd console=ttymxc0,115200"
+CONFIG_CPU_FREQ=y
+CONFIG_CPU_FREQ_STAT=y
+CONFIG_CPU_FREQ_DEFAULT_GOV_ONDEMAND=y
+CONFIG_CPU_FREQ_GOV_POWERSAVE=y
+CONFIG_CPU_FREQ_GOV_USERSPACE=y
+CONFIG_CPU_FREQ_GOV_CONSERVATIVE=y
+CONFIG_CPUFREQ_DT=y
+CONFIG_CPU_IDLE=y
+CONFIG_VFP=y
+CONFIG_NEON=y
+CONFIG_PM_DEBUG=y
+CONFIG_PM_TEST_SUSPEND=y
+CONFIG_MODULES=y
+CONFIG_MODULE_UNLOAD=y
+CONFIG_MODVERSIONS=y
+CONFIG_MODULE_SRCVERSION_ALL=y
+# CONFIG_BLK_DEV_BSG is not set
+CONFIG_BINFMT_MISC=m
+CONFIG_CMA=y
+CONFIG_NET=y
+CONFIG_PACKET=y
+CONFIG_UNIX=y
+CONFIG_INET=y
+CONFIG_IP_PNP=y
+CONFIG_IP_PNP_DHCP=y
+CONFIG_VLAN_8021Q=y
+CONFIG_LLC2=y
+CONFIG_CAN=y
+CONFIG_CAN_FLEXCAN=y
+CONFIG_CAN_M_CAN=y
+CONFIG_BT=y
+CONFIG_BT_RFCOMM=y
+CONFIG_BT_RFCOMM_TTY=y
+CONFIG_BT_BNEP=y
+CONFIG_BT_BNEP_MC_FILTER=y
+CONFIG_BT_BNEP_PROTO_FILTER=y
+CONFIG_BT_HIDP=y
+CONFIG_BT_HCIBTUSB=y
+CONFIG_BT_HCIUART=y
+CONFIG_BT_HCIUART_BCSP=y
+CONFIG_BT_HCIUART_ATH3K=y
+CONFIG_BT_HCIBCM203X=y
+CONFIG_BT_ATH3K=y
+CONFIG_CFG80211=y
+CONFIG_NL80211_TESTMODE=y
+CONFIG_CFG80211_WEXT=y
+CONFIG_MAC80211=y
+CONFIG_DEVTMPFS=y
+CONFIG_DEVTMPFS_MOUNT=y
+# CONFIG_STANDALONE is not set
+CONFIG_IMX_WEIM=y
+CONFIG_CONNECTOR=y
+CONFIG_MTD=y
+CONFIG_MTD_CMDLINE_PARTS=y
+CONFIG_MTD_BLOCK=y
+CONFIG_MTD_CFI=y
+CONFIG_MTD_JEDECPROBE=y
+CONFIG_MTD_CFI_INTELEXT=y
+CONFIG_MTD_CFI_AMDSTD=y
+CONFIG_MTD_CFI_STAA=y
+CONFIG_MTD_DATAFLASH=y
+CONFIG_MTD_SST25L=y
+CONFIG_MTD_SPI_NOR=y
+# CONFIG_MTD_SPI_NOR_USE_4K_SECTORS is not set
+CONFIG_MTD_UBI=y
+CONFIG_BLK_DEV_LOOP=y
+CONFIG_BLK_DEV_RAM=y
+CONFIG_BLK_DEV_RAM_SIZE=65536
+CONFIG_EEPROM_AT24=y
+CONFIG_EEPROM_AT25=y
+# CONFIG_SCSI_PROC_FS is not set
+CONFIG_BLK_DEV_SD=y
+CONFIG_SCSI_CONSTANTS=y
+CONFIG_SCSI_LOGGING=y
+CONFIG_SCSI_SCAN_ASYNC=y
+# CONFIG_SCSI_LOWLEVEL is not set
+CONFIG_ATA=y
+CONFIG_SATA_AHCI_PLATFORM=y
+CONFIG_AHCI_IMX=y
+CONFIG_PATA_IMX=y
+CONFIG_NETDEVICES=y
+# CONFIG_NET_VENDOR_BROADCOM is not set
+CONFIG_CS89x0=y
+CONFIG_CS89x0_PLATFORM=y
+# CONFIG_NET_VENDOR_FARADAY is not set
+# CONFIG_NET_VENDOR_INTEL is not set
+# CONFIG_NET_VENDOR_MARVELL is not set
+# CONFIG_NET_VENDOR_MICREL is not set
+# CONFIG_NET_VENDOR_MICROCHIP is not set
+# CONFIG_NET_VENDOR_NATSEMI is not set
+# CONFIG_NET_VENDOR_SEEQ is not set
+CONFIG_SMC91X=y
+CONFIG_SMC911X=y
+CONFIG_SMSC911X=y
+# CONFIG_NET_VENDOR_STMICRO is not set
+CONFIG_MICREL_PHY=y
+CONFIG_USB_KAWETH=y
+CONFIG_USB_PEGASUS=y
+CONFIG_USB_RTL8150=y
+CONFIG_USB_RTL8152=y
+CONFIG_USB_USBNET=y
+CONFIG_USB_NET_CDC_EEM=m
+CONFIG_ATH6KL=m
+CONFIG_ATH6KL_SDIO=m
+CONFIG_BRCMFMAC=m
+CONFIG_HOSTAP=y
+CONFIG_INPUT_EVDEV=y
+CONFIG_INPUT_EVBUG=m
+CONFIG_KEYBOARD_GPIO=y
+CONFIG_KEYBOARD_IMX=y
+CONFIG_MOUSE_PS2=m
+CONFIG_MOUSE_PS2_ELANTECH=y
+CONFIG_INPUT_TOUCHSCREEN=y
+CONFIG_TOUCHSCREEN_ADS7846=y
+CONFIG_TOUCHSCREEN_EGALAX=y
+CONFIG_TOUCHSCREEN_WACOM_I2C=y
+CONFIG_TOUCHSCREEN_MAX11801=y
+CONFIG_TOUCHSCREEN_IMX6UL_TSC=y
+CONFIG_TOUCHSCREEN_MC13783=y
+CONFIG_TOUCHSCREEN_TSC2007=y
+CONFIG_TOUCHSCREEN_STMPE=y
+CONFIG_INPUT_MISC=y
+CONFIG_INPUT_MMA8450=y
+CONFIG_SERIO_SERPORT=m
+# CONFIG_LEGACY_PTYS is not set
+CONFIG_SERIAL_IMX=y
+CONFIG_SERIAL_IMX_CONSOLE=y
+CONFIG_SERIAL_FSL_LPUART=y
+CONFIG_SERIAL_FSL_LPUART_CONSOLE=y
+# CONFIG_I2C_COMPAT is not set
+CONFIG_I2C_CHARDEV=y
+# CONFIG_I2C_HELPER_AUTO is not set
+CONFIG_I2C_ALGOPCF=m
+CONFIG_I2C_ALGOPCA=m
+CONFIG_I2C_IMX=y
+CONFIG_I2C_IMX_LPI2C=y
+CONFIG_SPI=y
+CONFIG_SPI_FSL_LPSPI=y
+CONFIG_SPI_FSL_QUADSPI=y
+CONFIG_SPI_GPIO=y
+CONFIG_SPI_IMX=y
+CONFIG_SPI_SPIDEV=y
+CONFIG_SPI_SLAVE=y
+CONFIG_SPI_SLAVE_TIME=y
+CONFIG_SPI_SLAVE_SYSTEM_CONTROL=y
+CONFIG_GPIO_SYSFS=y
+CONFIG_GPIO_MAX732X=y
+CONFIG_GPIO_PCA953X=y
+CONFIG_GPIO_74X164=y
+CONFIG_POWER_RESET=y
+CONFIG_POWER_RESET_SYSCON_POWEROFF=y
+CONFIG_POWER_SUPPLY=y
+CONFIG_THERMAL=y
+CONFIG_THERMAL_WRIT

Re: [PATCH v3] RISC-V: Use SBI SRST extension when available

2020-11-30 Thread Alistair Francis
On Wed, 2020-11-25 at 10:47 +0530, Anup Patel wrote:
> The SBI SRST extension provides a standard way to poweroff and
> reboot the system irrespective to whether Linux RISC-V S-mode
> is running natively (HS-mode) or inside Guest/VM (VS-mode).
> 
> The SBI SRST extension is available in latest SBI v0.3-draft
> specification at: https://github.com/riscv/riscv-sbi-doc.
> 
> This patch extends Linux RISC-V SBI implementation to detect
> and use SBI SRST extension.
> 
> Signed-off-by: Anup Patel 

Acked-by: Alistair Francis 

Alistair

> ---
> Changes since v2:
>  - Rebased on Linux-5.10-rc5
>  - Updated patch as-per SBI SRST extension available in the latest
>    SBI v0.3-draft specification
> Changes since v1:
>  - Updated patch as-per latest SBI SRST extension draft spec where
>    we have only one SBI call with "reset_type" parameter
> ---
>  arch/riscv/include/asm/sbi.h | 16 
>  arch/riscv/kernel/sbi.c  | 34 ++
>  2 files changed, 50 insertions(+)
> 
> diff --git a/arch/riscv/include/asm/sbi.h
> b/arch/riscv/include/asm/sbi.h
> index 653edb25d495..5b2d6d614c20 100644
> --- a/arch/riscv/include/asm/sbi.h
> +++ b/arch/riscv/include/asm/sbi.h
> @@ -27,6 +27,7 @@ enum sbi_ext_id {
> SBI_EXT_IPI = 0x735049,
> SBI_EXT_RFENCE = 0x52464E43,
> SBI_EXT_HSM = 0x48534D,
> +   SBI_EXT_SRST = 0x53525354,
>  };
>  
>  enum sbi_ext_base_fid {
> @@ -70,6 +71,21 @@ enum sbi_hsm_hart_status {
> SBI_HSM_HART_STATUS_STOP_PENDING,
>  };
>  
> +enum sbi_ext_srst_fid {
> +   SBI_EXT_SRST_RESET = 0,
> +};
> +
> +enum sbi_srst_reset_type {
> +   SBI_SRST_RESET_TYPE_SHUTDOWN = 0,
> +   SBI_SRST_RESET_TYPE_COLD_REBOOT,
> +   SBI_SRST_RESET_TYPE_WARM_REBOOT,
> +};
> +
> +enum sbi_srst_reset_reason {
> +   SBI_SRST_RESET_REASON_NONE = 0,
> +   SBI_SRST_RESET_REASON_SYS_FAILURE,
> +};
> +
>  #define SBI_SPEC_VERSION_DEFAULT   0x1
>  #define SBI_SPEC_VERSION_MAJOR_SHIFT   24
>  #define SBI_SPEC_VERSION_MAJOR_MASK0x7f
> diff --git a/arch/riscv/kernel/sbi.c b/arch/riscv/kernel/sbi.c
> index 226ccce0f9e0..33b834ecd195 100644
> --- a/arch/riscv/kernel/sbi.c
> +++ b/arch/riscv/kernel/sbi.c
> @@ -7,6 +7,7 @@
>  
>  #include 
>  #include 
> +#include 
>  #include 
>  #include 
>  
> @@ -501,6 +502,32 @@ int sbi_remote_hfence_vvma_asid(const unsigned
> long *hart_mask,
>  }
>  EXPORT_SYMBOL(sbi_remote_hfence_vvma_asid);
>  
> +static void sbi_srst_reset(unsigned long type, unsigned long reason)
> +{
> +   sbi_ecall(SBI_EXT_SRST, SBI_EXT_SRST_RESET, type, reason,
> + 0, 0, 0, 0);
> +   pr_warn("%s: type=0x%lx reason=0x%lx failed\n",
> +   __func__, type, reason);
> +}
> +
> +static int sbi_srst_reboot(struct notifier_block *this,
> +  unsigned long mode, void *cmd)
> +{
> +   sbi_srst_reset((mode == REBOOT_WARM || mode == REBOOT_SOFT) ?
> +  SBI_SRST_RESET_TYPE_WARM_REBOOT :
> +  SBI_SRST_RESET_TYPE_COLD_REBOOT,
> +  SBI_SRST_RESET_REASON_NONE);
> +   return NOTIFY_DONE;
> +}
> +
> +static struct notifier_block sbi_srst_reboot_nb;
> +
> +static void sbi_srst_power_off(void)
> +{
> +   sbi_srst_reset(SBI_SRST_RESET_TYPE_SHUTDOWN,
> +  SBI_SRST_RESET_REASON_NONE);
> +}
> +
>  /**
>   * sbi_probe_extension() - Check if an SBI extension ID is supported
> or not.
>   * @extid: The extension ID to be probed.
> @@ -593,6 +620,13 @@ int __init sbi_init(void)
> } else {
> __sbi_rfence= __sbi_rfence_v01;
> }
> +   if (sbi_probe_extension(SBI_EXT_SRST) > 0) {
> +   pr_info("SBI v0.2 SRST extension
> detected\n");
> +   pm_power_off = sbi_srst_power_off;
> +   sbi_srst_reboot_nb.notifier_call =
> sbi_srst_reboot;
> +   sbi_srst_reboot_nb.priority = 192;
> +   register_restart_handler(_srst_reboot_nb)
> ;
> +   }
> } else {
> __sbi_set_timer = __sbi_set_timer_v01;
> __sbi_send_ipi  = __sbi_send_ipi_v01;



Re: [PATCH] riscv: Add SiFive drivers to rv32_defconfig

2020-07-16 Thread Alistair Francis
On Wed, 2020-07-15 at 21:39 -0700, Bin Meng wrote:
> From: Bin Meng 
> 
> This adds SiFive drivers to rv32_defconfig, to keep in sync with the
> 64-bit config. This is useful when testing 32-bit kernel with QEMU
> 'sifive_u' 32-bit machine.
> 
> Signed-off-by: Bin Meng 

Reviewed-by: Alistair Francis 

Alistair

> ---
> 
>  arch/riscv/configs/rv32_defconfig | 5 +
>  1 file changed, 5 insertions(+)
> 
> diff --git a/arch/riscv/configs/rv32_defconfig
> b/arch/riscv/configs/rv32_defconfig
> index 05bbf52..8759501 100644
> --- a/arch/riscv/configs/rv32_defconfig
> +++ b/arch/riscv/configs/rv32_defconfig
> @@ -14,6 +14,7 @@ CONFIG_CHECKPOINT_RESTORE=y
>  CONFIG_BLK_DEV_INITRD=y
>  CONFIG_EXPERT=y
>  CONFIG_BPF_SYSCALL=y
> +CONFIG_SOC_SIFIVE=y
>  CONFIG_SOC_VIRT=y
>  CONFIG_ARCH_RV32I=y
>  CONFIG_SMP=y
> @@ -61,6 +62,8 @@ CONFIG_HVC_RISCV_SBI=y
>  CONFIG_VIRTIO_CONSOLE=y
>  CONFIG_HW_RANDOM=y
>  CONFIG_HW_RANDOM_VIRTIO=y
> +CONFIG_SPI=y
> +CONFIG_SPI_SIFIVE=y
>  # CONFIG_PTP_1588_CLOCK is not set
>  CONFIG_POWER_RESET=y
>  CONFIG_DRM=y
> @@ -76,6 +79,8 @@ CONFIG_USB_OHCI_HCD=y
>  CONFIG_USB_OHCI_HCD_PLATFORM=y
>  CONFIG_USB_STORAGE=y
>  CONFIG_USB_UAS=y
> +CONFIG_MMC=y
> +CONFIG_MMC_SPI=y
>  CONFIG_RTC_CLASS=y
>  CONFIG_VIRTIO_PCI=y
>  CONFIG_VIRTIO_BALLOON=y


[PATCH v2] spi: sun6i: Add support for GPIO chip select lines

2020-05-10 Thread Alistair Francis
Set use_gpio_descriptors as true to support using generic GPIO
lines for the chip select.

Signed-off-by: Alistair Francis 
---
v2:
 - Use use_gpio_descriptors instead of spi_setup

 drivers/spi/spi-sun6i.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/spi/spi-sun6i.c b/drivers/spi/spi-sun6i.c
index ec7967be9e2f..ecea15534c42 100644
--- a/drivers/spi/spi-sun6i.c
+++ b/drivers/spi/spi-sun6i.c
@@ -470,6 +470,7 @@ static int sun6i_spi_probe(struct platform_device *pdev)
 
master->max_speed_hz = 100 * 1000 * 1000;
master->min_speed_hz = 3 * 1000;
+   master->use_gpio_descriptors = true;
master->set_cs = sun6i_spi_set_cs;
master->transfer_one = sun6i_spi_transfer_one;
master->num_chipselect = 4;
-- 
2.26.2



[PATCH] spi: sun6i: Add support for GPIO chip select lines

2020-05-05 Thread Alistair Francis
Add a setup function that can be used to support using generic GPIO
lines for the chip select.

Signed-off-by: Alistair Francis 
---
 drivers/spi/spi-sun6i.c | 27 +++
 1 file changed, 27 insertions(+)

diff --git a/drivers/spi/spi-sun6i.c b/drivers/spi/spi-sun6i.c
index ec7967be9e2f..fd4e19434942 100644
--- a/drivers/spi/spi-sun6i.c
+++ b/drivers/spi/spi-sun6i.c
@@ -10,6 +10,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -171,6 +172,31 @@ static inline void sun6i_spi_fill_fifo(struct sun6i_spi 
*sspi, int len)
}
 }
 
+static int sun6i_spi_setup(struct spi_device *spi)
+{
+   int ret;
+
+   /* sanity check for native cs */
+   if (spi->mode & SPI_NO_CS)
+   return 0;
+   if (gpio_is_valid(spi->cs_gpio)) {
+   /* with gpio-cs set the GPIO to the correct level
+* and as output (in case the dt has the gpio not configured
+* as output but native cs)
+*/
+   ret = gpio_direction_output(spi->cs_gpio,
+   (spi->mode & SPI_CS_HIGH) ? 0 : 1);
+   if (ret)
+   dev_err(>dev,
+   "could not set gpio %i as output: %i\n",
+   spi->cs_gpio, ret);
+
+   return ret;
+   }
+
+   return 0;
+}
+
 static void sun6i_spi_set_cs(struct spi_device *spi, bool enable)
 {
struct sun6i_spi *sspi = spi_master_get_devdata(spi->master);
@@ -470,6 +496,7 @@ static int sun6i_spi_probe(struct platform_device *pdev)
 
master->max_speed_hz = 100 * 1000 * 1000;
master->min_speed_hz = 3 * 1000;
+   master->setup = sun6i_spi_setup;
master->set_cs = sun6i_spi_set_cs;
master->transfer_one = sun6i_spi_transfer_one;
master->num_chipselect = 4;
-- 
2.26.2



Re: [PATCH v2 2/2] RISC-V: defconfig: Enable Goldfish RTC driver

2019-10-23 Thread Alistair Francis
On Tue, 2019-10-22 at 18:06 -0700, Paul Walmsley wrote:
> On Tue, 22 Oct 2019, Alistair Francis wrote:
> 
> > I think it makese sense for this to go into Linux first.
> > 
> > The QEMU patches are going to be accepted, just some nit picking to
> > do
> > first :)
> > 
> > After that we have to wait for a PR and then a QEMU release until
> > most
> > people will see the change in QEMU. In that time Linux 5.4 will be
> > released, if this can make it into 5.4 then everyone using 5.4 will
> > get
> > the new RTC as soon as they upgrade QEMU (QEMU provides the device
> > tree). If this has to wait until QEMU has support then it won't be
> > supported for users until even later.
> > 
> > Users are generally slow to update kernels (buildroot is still
> > using
> > 5.1 by default for example) so the sooner changes like this go in
> > the
> > better.
> 
> The defconfigs are really just for kernel developers.  We expect
> users to 
> define their own Kconfigs for their own needs.

From experience most people use the defconfig, at least as a starting
point.

> 
> If using the Goldfish code really is what we all want to do (see
> below), 
> then the kernel patch that should go in right away -- which also has
> no 
> dependence on what QEMU does -- would be the first patch of this
> series:
> 
> https://lore.kernel.org/linux-riscv/20190925063706.56175-2-anup.pa...@wdc.com/

Ok, so it looks like this patch will be a 5.5 patch not a 5.4 patch. It
looks like that can't be helped. I just don't want the defconfig change
waiting on QEMU as I think that just slows everything down.

> 
> And that should go in via whoever is maintaining the Goldfish driver,
> not 
> the RISC-V tree.  (It looks like drivers/platform/goldfish is
> completely 
> unmaintained - a red flag! - so probably someone needs to persuade
> Greg or 
> Andrew to take it.)
> 
> Incidentally, just looking at drivers/platform/goldfish, that driver
> seems 
> to be some sort of Google-specific RPC driver.  Are you all really
> sure 
> you want to enable that just for an RTC?  Seems like overkill - there
> are 
> much simpler RTCs out there.

I was under the impression that everyone was on board with this going
in. In QEMU land it doesn't make sense to add it if the kernel isn't
going to, so we need to be on the same page here.

From the other discussions it looks like you are happy with this change
overall right?

Alistair

> 
> 
> - Paul
> 
> ___
> linux-riscv mailing list
> linux-ri...@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-riscv


Re: [PATCH v2 2/2] RISC-V: defconfig: Enable Goldfish RTC driver

2019-10-22 Thread Alistair Francis
On Tue, 2019-10-22 at 12:23 -0700, Paul Walmsley wrote:
> On Mon, 14 Oct 2019, Anup Patel wrote:
> 
> > > -Original Message-
> > > From: Palmer Dabbelt 
> > > Sent: Saturday, October 12, 2019 11:09 PM
> > > To: Anup Patel 
> > > Cc: Paul Walmsley ; 
> > > a...@eecs.berkeley.edu;
> > > Greg KH ; r...@google.com; Atish
> > > Patra
> > > ; Alistair Francis  > > >;
> > > Christoph Hellwig ; a...@brainfault.org;
> > > linux-
> > > ri...@lists.infradead.org; linux-kernel@vger.kernel.org; Anup
> > > Patel
> > > 
> > > Subject: Re: [PATCH v2 2/2] RISC-V: defconfig: Enable Goldfish
> > > RTC driver
> > > 
> > > On Tue, 24 Sep 2019 23:38:08 PDT (-0700), Anup Patel wrote:
> > > > We have Goldfish RTC device available on QEMU RISC-V virt
> > > > machine
> > > > hence enable required driver in RV32 and RV64 defconfigs.
> 
> My understanding is that the Goldfish support is still under 
> discussion on the QEMU side and isn't merged yet - is that accurate?
> 
> https://lists.gnu.org/archive/html/qemu-devel/2019-10/msg04904.html
> 
> > > Reviewed-by: Palmer Dabbelt 
> > > 
> > > IIRC there was supposed to be a follow-up to your QEMU patch set
> > > to rebase
> > > it on top of a refactoring of their RTC code, but I don't see it
> > > in my inbox.  LMK
> > > if I missed it, as QEMU's soft freeze is in a few weeks and I'd
> > > like to make
> > > sure I get everything in.
> > 
> > I was hoping for QEMU RTC refactoring to be merged soon but it has
> > not
> > happened so far. I will wait couple of more days then send v3 of
> > QEMU
> > patches.
> 
> The patch looks fine to me, but let's wait until the underlying
> support 
> actually appears on the QEMU "hardware".  Could you resend once
> that's 
> happened?

I think it makese sense for this to go into Linux first.

The QEMU patches are going to be accepted, just some nit picking to do
first :)

After that we have to wait for a PR and then a QEMU release until most
people will see the change in QEMU. In that time Linux 5.4 will be
released, if this can make it into 5.4 then everyone using 5.4 will get
the new RTC as soon as they upgrade QEMU (QEMU provides the device
tree). If this has to wait until QEMU has support then it won't be
supported for users until even later.

Users are generally slow to update kernels (buildroot is still using
5.1 by default for example) so the sooner changes like this go in the
better.

Alistair

> 
> thanks,
> 
> - Paul


Re: [PATCH] arm64: dts: sun50i: sopine-baseboard: Expose serial1, serial2 and serial3

2019-10-16 Thread Alistair Francis
On Wed, Oct 16, 2019 at 7:54 AM Chen-Yu Tsai  wrote:
>
> On Wed, Oct 16, 2019 at 10:49 PM Maxime Ripard  wrote:
> >
> > Hi,
> >
> > On Sat, Oct 12, 2019 at 01:05:24PM -0700, Alistair Francis wrote:
> > > Follow what the sun50i-a64-pine64.dts does and expose all 5 serial
> > > connections.
> > >
> > > Signed-off-by: Alistair Francis 
> > > ---
> > >  .../allwinner/sun50i-a64-sopine-baseboard.dts | 25 +++
> > >  1 file changed, 25 insertions(+)
> > >
> > > diff --git 
> > > a/arch/arm64/boot/dts/allwinner/sun50i-a64-sopine-baseboard.dts 
> > > b/arch/arm64/boot/dts/allwinner/sun50i-a64-sopine-baseboard.dts
> > > index 124b0b030b28..49c37b21ab36 100644
> > > --- a/arch/arm64/boot/dts/allwinner/sun50i-a64-sopine-baseboard.dts
> > > +++ b/arch/arm64/boot/dts/allwinner/sun50i-a64-sopine-baseboard.dts
> > > @@ -56,6 +56,10 @@
> > >   aliases {
> > >   ethernet0 = 
> > >   serial0 = 
> > > + serial1 = 
> > > + serial2 = 
> > > + serial3 = 
> > > + serial4 = 
> > >   };
> > >
> > >   chosen {
> > > @@ -280,6 +284,27 @@
> > >   };
> > >  };
> > >
> > > +/* On Pi-2 connector */
> > > + {
> > > + pinctrl-names = "default";
> > > + pinctrl-0 = <_pins>;
> > > + status = "disabled";
> > > +};
> > > +
> > > +/* On Euler connector */
> > > + {
> > > + pinctrl-names = "default";
> > > + pinctrl-0 = <_pins>;
> > > + status = "disabled";
> > > +};
> > > +
> > > +/* On Euler connector, RTS/CTS optional */
> > > + {
> > > + pinctrl-names = "default";
> > > + pinctrl-0 = <_pins>;
> > > + status = "disabled";
> > > +};
> >
> > Since these are all the default muxing, maybe we should just set that
> > in the DTSI?
>
> Maybe not, since people may want to only use RX/TX, and leave the other
> two pins for GPIO?

I think this makes the most sense for the default.

Alistair

>
> ChenYu


[PATCH] arm64: dts: sun50i: sopine-baseboard: Expose serial1, serial2 and serial3

2019-10-12 Thread Alistair Francis
Follow what the sun50i-a64-pine64.dts does and expose all 5 serial
connections.

Signed-off-by: Alistair Francis 
---
 .../allwinner/sun50i-a64-sopine-baseboard.dts | 25 +++
 1 file changed, 25 insertions(+)

diff --git a/arch/arm64/boot/dts/allwinner/sun50i-a64-sopine-baseboard.dts 
b/arch/arm64/boot/dts/allwinner/sun50i-a64-sopine-baseboard.dts
index 124b0b030b28..49c37b21ab36 100644
--- a/arch/arm64/boot/dts/allwinner/sun50i-a64-sopine-baseboard.dts
+++ b/arch/arm64/boot/dts/allwinner/sun50i-a64-sopine-baseboard.dts
@@ -56,6 +56,10 @@
aliases {
ethernet0 = 
serial0 = 
+   serial1 = 
+   serial2 = 
+   serial3 = 
+   serial4 = 
};
 
chosen {
@@ -280,6 +284,27 @@
};
 };
 
+/* On Pi-2 connector */
+ {
+   pinctrl-names = "default";
+   pinctrl-0 = <_pins>;
+   status = "disabled";
+};
+
+/* On Euler connector */
+ {
+   pinctrl-names = "default";
+   pinctrl-0 = <_pins>;
+   status = "disabled";
+};
+
+/* On Euler connector, RTS/CTS optional */
+ {
+   pinctrl-names = "default";
+   pinctrl-0 = <_pins>;
+   status = "disabled";
+};
+
 _otg {
dr_mode = "host";
status = "okay";
-- 
2.23.0



Re: [PATCH v7 02/21] RISC-V: Add bitmap reprensenting ISA features common across CPUs

2019-09-23 Thread Alistair Francis
On Sat, 2019-09-21 at 03:01 -0700, Paul Walmsley wrote:
> Hi Anup,
> 
> Thanks for changing this to use a bitmap.  A few comments below -
> 
> On Wed, 4 Sep 2019, Anup Patel wrote:
> 
> > This patch adds riscv_isa bitmap which represents Host ISA features
> > common across all Host CPUs. The riscv_isa is not same as elf_hwcap
> > because elf_hwcap will only have ISA features relevant for user-
> > space
> > apps whereas riscv_isa will have ISA features relevant to both
> > kernel
> > and user-space apps.
> > 
> > One of the use-case for riscv_isa bitmap is in KVM hypervisor where
> > we will use it to do following operations:
> > 
> > 1. Check whether hypervisor extension is available
> > 2. Find ISA features that need to be virtualized (e.g. floating
> >point support, vector extension, etc.)
> > 
> > Signed-off-by: Anup Patel 
> > Signed-off-by: Atish Patra 
> > Reviewed-by: Alexander Graf 
> > ---
> >  arch/riscv/include/asm/hwcap.h | 26 +++
> >  arch/riscv/kernel/cpufeature.c | 79
> > --
> >  2 files changed, 102 insertions(+), 3 deletions(-)
> > 
> > diff --git a/arch/riscv/include/asm/hwcap.h
> > b/arch/riscv/include/asm/hwcap.h
> > index 7ecb7c6a57b1..9b657375aa51 100644
> > --- a/arch/riscv/include/asm/hwcap.h
> > +++ b/arch/riscv/include/asm/hwcap.h
> > @@ -8,6 +8,7 @@
> >  #ifndef __ASM_HWCAP_H
> >  #define __ASM_HWCAP_H
> >  
> > +#include 
> >  #include 
> >  
> >  #ifndef __ASSEMBLY__
> > @@ -22,5 +23,30 @@ enum {
> >  };
> >  
> >  extern unsigned long elf_hwcap;
> > +
> > +#define RISCV_ISA_EXT_a('a' - 'a')
> > +#define RISCV_ISA_EXT_c('c' - 'a')
> > +#define RISCV_ISA_EXT_d('d' - 'a')
> > +#define RISCV_ISA_EXT_f('f' - 'a')
> > +#define RISCV_ISA_EXT_h('h' - 'a')
> > +#define RISCV_ISA_EXT_i('i' - 'a')
> > +#define RISCV_ISA_EXT_m('m' - 'a')
> > +#define RISCV_ISA_EXT_s('s' - 'a')
> > +#define RISCV_ISA_EXT_u('u' - 'a')
> > +#define RISCV_ISA_EXT_zicsr(('z' - 'a') + 1)
> > +#define RISCV_ISA_EXT_zifencei (('z' - 'a') + 2)
> > +#define RISCV_ISA_EXT_zam  (('z' - 'a') + 3)
> > +#define RISCV_ISA_EXT_ztso (('z' - 'a') + 4)
> 
> If we add the Z extensions here, it's probably best if we drop Zam
> from 
> this list.  The rationale is, as maintainers, we're planning to hold
> off 
> on merging any support for extensions or modules that aren't in the 
> "frozen" or "ratified" states, and according to the RISC-V specs,
> Zicsr, 
> Zifencei, and Ztso are all either frozen or ratified.  However, see 
> below -

Hey Paul,

I think that this should be documented somewhere in the kernel tree. In
QEMU land we have decieded that draft extensions will be accepted and
there are currently two extension series on list (Hypervisor from WDC
and Vector from CSKY). I suspect as RISC-V grows there are going to be
more and more groups that are interested in some specific extension and
want it upstream. In this case it makes sense to have it very clearly
documeneted so that everyone knows what will/won't be accepted.

If it's clearly documented then everyone will be on the same page as to
what will/won't be accepted by individual projects. As a side note I'll
probably look at adding something for QEMU as well :)

Alistair

> 
> > +
> > +#define RISCV_ISA_EXT_MAX  256
> > +
> > +unsigned long riscv_isa_extension_base(const unsigned long
> > *isa_bitmap);
> > +
> > +#define riscv_isa_extension_mask(ext)
> > BIT_MASK(RISCV_ISA_EXT_##ext)
> > +
> > +bool __riscv_isa_extension_available(const unsigned long
> > *isa_bitmap, int bit);
> > +#define riscv_isa_extension_available(isa_bitmap, ext) \
> > +   __riscv_isa_extension_available(isa_bitmap,
> > RISCV_ISA_EXT_##ext)
> > +
> >  #endif
> >  #endif
> > diff --git a/arch/riscv/kernel/cpufeature.c
> > b/arch/riscv/kernel/cpufeature.c
> > index b1ade9a49347..4ce71ce5e290 100644
> > --- a/arch/riscv/kernel/cpufeature.c
> > +++ b/arch/riscv/kernel/cpufeature.c
> > @@ -6,21 +6,64 @@
> >   * Copyright (C) 2017 SiFive
> >   */
> >  
> > +#include 
> >  #include 
> >  #include 
> >  #include 
> >  #include 
> >  
> >  unsigned long elf_hwcap __read_mostly;
> > +
> > +/* Host ISA bitmap */
> > +static DECLARE_BITMAP(riscv_isa, RISCV_ISA_EXT_MAX) __read_mostly;
> > +
> >  #ifdef CONFIG_FPU
> >  bool has_fpu __read_mostly;
> >  #endif
> >  
> > +/**
> > + * riscv_isa_extension_base - Get base extension word
> > + *
> > + * @isa_bitmap ISA bitmap to use
> > + * @returns base extension word as unsigned long value
> > + *
> > + * NOTE: If isa_bitmap is NULL then Host ISA bitmap will be used.
> > + */
> 
> Am happy to see comments that can be automatically parsed, but could
> you 
> reformat them into kernel-doc format? 
> 
> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/doc-guide/kernel-doc.rst
> 
> > +unsigned long riscv_isa_extension_base(const unsigned long
> > *isa_bitmap)
> > 

Re: [PATCH v2] RISC-V: Fix FIXMAP area corruption on RV32 systems

2019-08-28 Thread Alistair Francis
On Tue, 2019-08-27 at 08:11 +0530, Anup Patel wrote:
> On Tue, Aug 27, 2019 at 5:43 AM Paul Walmsley <
> paul.walms...@sifive.com> wrote:
> > Hello Anup,
> > 
> > On Mon, 19 Aug 2019, Anup Patel wrote:
> > 
> > > Currently, various virtual memory areas of Linux RISC-V are
> > > organized
> > > in increasing order of their virtual addresses is as follows:
> > > 1. User space area (This is lowest area and starts at 0x0)
> > > 2. FIXMAP area
> > > 3. VMALLOC area
> > > 4. Kernel area (This is highest area and starts at PAGE_OFFSET)
> > > 
> > > The maximum size of user space aread is represented by TASK_SIZE.
> > > 
> > > On RV32 systems, TASK_SIZE is defined as VMALLOC_START which
> > > causes the
> > > user space area to overlap the FIXMAP area. This allows user
> > > space apps
> > > to potentially corrupt the FIXMAP area and kernel OF APIs will
> > > crash
> > > whenever they access corrupted FDT in the FIXMAP area.
> > > 
> > > On RV64 systems, TASK_SIZE is set to fixed 256GB and no other
> > > areas
> > > happen to overlap so we don't see any FIXMAP area corruptions.
> > > 
> > > This patch fixes FIXMAP area corruption on RV32 systems by
> > > setting
> > > TASK_SIZE to FIXADDR_START.
> > 
> > This part -- the TASK_SIZE change -- makes sense to me.
> > 
> > However, the patch also changes FIXADDR_SIZE to be defined in terms
> > of
> > page table-related constants.  Previously, FIXADDR_SIZE was based
> > on
> > __end_of_fixed_addresses, as it is for most other architectures.
> > The part
> > of the patch that changes FIXADDR_SIZE seems unrelated to the
> > actual fix.
> > 
> > If that's indeed the case -- that the change to FIXADDR_SIZE is
> > unrelated
> > from the fix -- could you please split that into a separate patch,
> > with a
> > description of the rationale?  I think I understand why you're
> > proposing
> > it, but it seems odd to explicitly connect it to page table-related
> > constants, rather than the contents of "enum fixed_addresses", and
> > I'm
> > reluctant to merge that part of this patch without a bit more
> > discussion.
> 
> The FIXADDR_SIZE change is related to the TASK_SIZE requirement and
> it is not a separate change because:
> 
> 1. TASK_SIZE must be evenly divisible by PGDIR_SIZE. The
> FIXADDR_START
> is defined as (FIXADDR_TOP - FIXADDR_SIZE). The original FIXADDR_SIZE
> defined in-terms of __end_of_fixed_addresses is not a multiple of
> PGDIR_SIZE
> hence it makes sense to make FIXADDR_SIZE as PGDIR_SIZE.
> 
> 2. Let say we ignore point1 above then still we cannot continue to
> express
> FIXADDR_SIZE in-terms of __end_of_fixed_addresses because of cyclic
> header dependency where asm/fixmap.h includes asm/pgtable.h and
> __end_of_fixed_addresses is defined in asm/fixmap.h. We certainly
> need
> to move FIXADDR_TOP, FIXADDR_START, and FIXADDR_SIZE to
> asm/pgtable.h so that we can express TASK_SIZE as FIXADDR_START
> for RV32. If we don't simplify FIXADDR_SIZE then it will result in
> compile
> errors.

Ping!

Are we going to regress 32-bit support in 5.3?

Alistair

> 
> Regards,
> Anup
> 
> > 
> > > We also move FIXADDR_TOP, FIXADDR_SIZE, and FIXADDR_START defines
> > > to
> > > asm/pgtable.h so that we can avoid cyclic header includes.
> > > 
> > > Signed-off-by: Anup Patel 
> > > Tested-by: Alistair Francis 
> > > Reviewed-by: Christoph Hellwig 
> > > ---
> > > Changes since v1:
> > > - Drop braces from "#define FIXADDR_TOP"
> > > ---
> > >  arch/riscv/include/asm/fixmap.h  |  4 
> > >  arch/riscv/include/asm/pgtable.h | 12 ++--
> > >  2 files changed, 10 insertions(+), 6 deletions(-)
> > > 
> > > diff --git a/arch/riscv/include/asm/fixmap.h
> > > b/arch/riscv/include/asm/fixmap.h
> > > index 9c66033c3a54..161f28d04a07 100644
> > > --- a/arch/riscv/include/asm/fixmap.h
> > > +++ b/arch/riscv/include/asm/fixmap.h
> > > @@ -30,10 +30,6 @@ enum fixed_addresses {
> > >   __end_of_fixed_addresses
> > >  };
> > > 
> > > -#define FIXADDR_SIZE (__end_of_fixed_addresses *
> > > PAGE_SIZE)
> > > -#define FIXADDR_TOP  (VMALLOC_START)
> > > -#define FIXADDR_START(FIXADDR_TOP -
> > > FIXADDR_SIZE)
> > > -
> > >  #define FIXMAP_PAGE_IO   PAGE_KERNEL

Re: [PATCH] RISC-V: Fix FIXMAP area corruption on RV32 systems

2019-08-26 Thread Alistair Francis
On Mon, 2019-08-26 at 14:17 -0700, Palmer Dabbelt wrote:
> On Sun, 18 Aug 2019 21:49:01 PDT (-0700), a...@brainfault.org wrote:
> > On Sun, Aug 18, 2019 at 11:49 PM Christoph Hellwig <
> > h...@infradead.org> wrote:
> > > > +#define FIXADDR_TOP  (VMALLOC_START)
> > > 
> > > Nit: no need for the braces, the definitions below don't use it
> > > either.
> > 
> > Sure, I will update and send v2 soon.
> > 
> > > > +#ifdef CONFIG_64BIT
> > > > +#define FIXADDR_SIZE PMD_SIZE
> > > > +#else
> > > > +#define FIXADDR_SIZE PGDIR_SIZE
> > > > +#endif
> > > > +#define FIXADDR_START(FIXADDR_TOP - FIXADDR_SIZE)
> > > > +
> > > >  /*
> > > > - * Task size is 0x40 for RV64 or 0xb80 for RV32.
> > > > + * Task size is 0x40 for RV64 or 0x9fc0 for RV32.
> > > >   * Note that PGDIR_SIZE must evenly divide TASK_SIZE.
> > > >   */
> > > >  #ifdef CONFIG_64BIT
> > > >  #define TASK_SIZE (PGDIR_SIZE * PTRS_PER_PGD / 2)
> > > >  #else
> > > > -#define TASK_SIZE VMALLOC_START
> > > > +#define TASK_SIZE FIXADDR_START
> > > >  #endif
> > > 
> > > Mentioning the addresses is a little weird.  IMHO this would be
> > > a much nicer place to explain the high-level memory layout,
> > > including
> > > maybe a little ASCII art.  Also we could have one #ifdef
> > > CONFIG_64BIT
> > > for both related values.  Last but not least instead of saying
> > > that
> > > something should be dividable it would be nice to have a
> > > BUILD_BUG_ON
> > > to enforce it.
> > > 
> > > Either way we are late in the cycle, so I guess this is ok for
> > > now:
> > > 
> > > Reviewed-by: Christoph Hellwig 
> > > 
> > > But I'd love to see this area improved a little further as it is
> > > full
> > > of mine fields.
> > 
> > I agree with you. We also have Sparsemem and KASAN patches which
> > touch virtual memory layout so it's important to have virtual
> > memory layout
> > documented clearly. I can add the required documentation as
> > separate patch.
> 
> Documentation is great, but if we document something that is broken
> then it's 
> still broken :)

I'm confused here. What is broken?

Right now RV32 does not work with the 5.3 kernel and this patch fixes
the regression.

> 
> I think this needs to just be redone -- we keep running into issues
> here and 
> fixing them, but there are probably more issues and it'll probably be
> faster to 
> just think through the memory map than to keep fixing bugs as they
> crop up.  
> This was one of the areas of the port I didn't rewrite as part of the
> upstream 
> submission process, and as a result it's pretty crusty.

I can't speak for rewriting the code, but that seems like something
that should happen in the 5.4 merge window right? With RC6 already out 
this patch seems like the only option for 5.3. Unless we are just going
to drop RV32 support from Linux in the 5.3 release?

Alistair

> 
> > I think the best place to add ASCII art would be asm/pgtable.h
> > where all
> > virtual memory related defines are placed. Suggestions??


  1   2   >