2021-10-15 22:50:13

by Alistair Francis

[permalink] [raw]
Subject: [PATCH v13 0/9] Add support for the silergy,sy7636a

v13:
- Address comments on thermal driver
- Rebase on master (without other patches)
v12:
- Rebase
v11:
- Address comments on hwmon
- Improve "mfd: simple-mfd-i2c: Add a Kconfig name" commit message
v10:
- Use dev_get_regmap() instead of dev_get_drvdata()
v9:
- Convert to use the simple-mfd-i2c instead

Alistair Francis (9):
dt-bindings: mfd: Initial commit of silergy,sy7636a.yaml
mfd: simple-mfd-i2c: Add a Kconfig name
mfd: simple-mfd-i2c: Enable support for the silergy,sy7636a
regulator: sy7636a: Remove requirement on sy7636a mfd
thermal: sy7636a: Add thermal driver for sy7636a
hwmon: sy7636a: Add temperature driver for sy7636a
ARM: imx_v6_v7_defconfig: Enable silergy,sy7636a
ARM: dts: imx7d: remarkable2: Enable silergy,sy7636a
ARM: dts: imx7d: remarkable2: Enable lcdif

.../bindings/mfd/silergy,sy7636a.yaml | 79 ++++++++++
Documentation/hwmon/sy7636a-hwmon.rst | 24 ++++
arch/arm/boot/dts/imx7d-remarkable2.dts | 136 ++++++++++++++++++
arch/arm/configs/imx_v6_v7_defconfig | 4 +
drivers/hwmon/Kconfig | 9 ++
drivers/hwmon/Makefile | 1 +
drivers/hwmon/sy7636a-hwmon.c | 75 ++++++++++
drivers/mfd/Kconfig | 2 +-
drivers/mfd/simple-mfd-i2c.c | 12 ++
drivers/regulator/Kconfig | 1 -
drivers/regulator/sy7636a-regulator.c | 2 +-
drivers/thermal/Kconfig | 6 +
drivers/thermal/Makefile | 1 +
drivers/thermal/sy7636a_thermal.c | 94 ++++++++++++
include/linux/mfd/sy7636a.h | 41 ++++++
15 files changed, 484 insertions(+), 3 deletions(-)
create mode 100644 Documentation/devicetree/bindings/mfd/silergy,sy7636a.yaml
create mode 100644 Documentation/hwmon/sy7636a-hwmon.rst
create mode 100644 drivers/hwmon/sy7636a-hwmon.c
create mode 100644 drivers/thermal/sy7636a_thermal.c
create mode 100644 include/linux/mfd/sy7636a.h

--
2.31.1


2021-10-15 22:50:13

by Alistair Francis

[permalink] [raw]
Subject: [PATCH v13 2/9] mfd: simple-mfd-i2c: Add a Kconfig name

Add a Kconfig name to the "Simple Multi-Functional Device support (I2C)"
device so that it can be enabled via menuconfig.

Signed-off-by: Alistair Francis <[email protected]>
---
drivers/mfd/Kconfig | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig
index ca0edab91aeb..e465ddd9ee77 100644
--- a/drivers/mfd/Kconfig
+++ b/drivers/mfd/Kconfig
@@ -1192,7 +1192,7 @@ config MFD_SI476X_CORE
module will be called si476x-core.

config MFD_SIMPLE_MFD_I2C
- tristate
+ tristate "Simple Multi-Functional Device support (I2C)"
depends on I2C
select REGMAP_I2C
help
--
2.31.1

2021-10-15 22:50:14

by Alistair Francis

[permalink] [raw]
Subject: [PATCH v13 4/9] regulator: sy7636a: Remove requirement on sy7636a mfd

Signed-off-by: Alistair Francis <[email protected]>
---
drivers/regulator/Kconfig | 1 -
drivers/regulator/sy7636a-regulator.c | 2 +-
2 files changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/regulator/Kconfig b/drivers/regulator/Kconfig
index 4fd13b06231f..21077cb14625 100644
--- a/drivers/regulator/Kconfig
+++ b/drivers/regulator/Kconfig
@@ -1199,7 +1199,6 @@ config REGULATOR_STW481X_VMMC

config REGULATOR_SY7636A
tristate "Silergy SY7636A voltage regulator"
- depends on MFD_SY7636A
help
This driver supports Silergy SY3686A voltage regulator.

diff --git a/drivers/regulator/sy7636a-regulator.c b/drivers/regulator/sy7636a-regulator.c
index 8360b3947ead..22fddf868e4c 100644
--- a/drivers/regulator/sy7636a-regulator.c
+++ b/drivers/regulator/sy7636a-regulator.c
@@ -70,7 +70,7 @@ static const struct regulator_desc desc = {

static int sy7636a_regulator_probe(struct platform_device *pdev)
{
- struct regmap *regmap = dev_get_drvdata(pdev->dev.parent);
+ struct regmap *regmap = dev_get_regmap(pdev->dev.parent, NULL);
struct regulator_config config = { };
struct regulator_dev *rdev;
struct gpio_desc *gdp;
--
2.31.1

2021-10-15 22:54:04

by Alistair Francis

[permalink] [raw]
Subject: [PATCH v13 6/9] hwmon: sy7636a: Add temperature driver for sy7636a

This is a multi-function device to interface with the sy7636a
EPD PMIC chip from Silergy.

Signed-off-by: Alistair Francis <[email protected]>
---
Documentation/hwmon/sy7636a-hwmon.rst | 24 +++++++++
drivers/hwmon/Kconfig | 9 ++++
drivers/hwmon/Makefile | 1 +
drivers/hwmon/sy7636a-hwmon.c | 75 +++++++++++++++++++++++++++
4 files changed, 109 insertions(+)
create mode 100644 Documentation/hwmon/sy7636a-hwmon.rst
create mode 100644 drivers/hwmon/sy7636a-hwmon.c

diff --git a/Documentation/hwmon/sy7636a-hwmon.rst b/Documentation/hwmon/sy7636a-hwmon.rst
new file mode 100644
index 000000000000..6b3e36d028dd
--- /dev/null
+++ b/Documentation/hwmon/sy7636a-hwmon.rst
@@ -0,0 +1,24 @@
+Kernel driver sy7636a-hwmon
+=========================
+
+Supported chips:
+
+ * Silergy SY7636A PMIC
+
+
+Description
+-----------
+
+This driver adds hardware temperature reading support for
+the Silergy SY7636A PMIC.
+
+The following sensors are supported
+
+ * Temperature
+ - SoC on-die temperature in milli-degree C
+
+sysfs-Interface
+---------------
+
+temp0_input
+ - SoC on-die temperature (milli-degree C)
diff --git a/drivers/hwmon/Kconfig b/drivers/hwmon/Kconfig
index c4578e8f34bb..d768b833b721 100644
--- a/drivers/hwmon/Kconfig
+++ b/drivers/hwmon/Kconfig
@@ -1651,6 +1651,15 @@ config SENSORS_SIS5595
This driver can also be built as a module. If so, the module
will be called sis5595.

+config SENSORS_SY7636A
+ tristate "Silergy SY7636A"
+ help
+ If you say yes here you get support for the thermistor readout of
+ the Silergy SY7636A PMIC.
+
+ This driver can also be built as a module. If so, the module
+ will be called sy7636a-hwmon.
+
config SENSORS_DME1737
tristate "SMSC DME1737, SCH311x and compatibles"
depends on I2C && !PPC
diff --git a/drivers/hwmon/Makefile b/drivers/hwmon/Makefile
index 162940270661..1355ffdb1481 100644
--- a/drivers/hwmon/Makefile
+++ b/drivers/hwmon/Makefile
@@ -181,6 +181,7 @@ obj-$(CONFIG_SENSORS_SMSC47M1) += smsc47m1.o
obj-$(CONFIG_SENSORS_SMSC47M192)+= smsc47m192.o
obj-$(CONFIG_SENSORS_SPARX5) += sparx5-temp.o
obj-$(CONFIG_SENSORS_STTS751) += stts751.o
+obj-$(CONFIG_SENSORS_SY7636A) += sy7636a-hwmon.o
obj-$(CONFIG_SENSORS_AMC6821) += amc6821.o
obj-$(CONFIG_SENSORS_TC74) += tc74.o
obj-$(CONFIG_SENSORS_THMC50) += thmc50.o
diff --git a/drivers/hwmon/sy7636a-hwmon.c b/drivers/hwmon/sy7636a-hwmon.c
new file mode 100644
index 000000000000..a59628f87ff3
--- /dev/null
+++ b/drivers/hwmon/sy7636a-hwmon.c
@@ -0,0 +1,75 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Functions to access SY3686A power management chip temperature
+ *
+ * Copyright (C) 2019 reMarkable AS - http://www.remarkable.com/
+ *
+ * Authors: Lars Ivar Miljeteig <[email protected]>
+ * Alistair Francis <[email protected]>
+ */
+
+#include <linux/err.h>
+#include <linux/hwmon.h>
+#include <linux/hwmon-sysfs.h>
+#include <linux/init.h>
+#include <linux/module.h>
+#include <linux/regmap.h>
+#include <linux/sysfs.h>
+#include <linux/platform_device.h>
+
+#include <linux/mfd/sy7636a.h>
+
+static ssize_t show_temp(struct device *dev,
+ struct device_attribute *attr, char *buf)
+{
+ unsigned int reg_val;
+ struct regmap *regmap = dev_get_drvdata(dev);
+ int ret;
+
+ ret = regmap_read(regmap, SY7636A_REG_TERMISTOR_READOUT, &reg_val);
+ if (ret)
+ return ret;
+
+ return snprintf(buf, PAGE_SIZE, "%d\n", reg_val);
+}
+
+static SENSOR_DEVICE_ATTR(temp0, 0444, show_temp, NULL, 0);
+
+static struct attribute *sy7636a_attrs[] = {
+ &sensor_dev_attr_temp0.dev_attr.attr,
+ NULL
+};
+
+ATTRIBUTE_GROUPS(sy7636a);
+
+static int sy7636a_sensor_probe(struct platform_device *pdev)
+{
+ struct regmap *regmap = dev_get_regmap(pdev->dev.parent, NULL);
+ struct device *hwmon_dev;
+ int err;
+
+ if (!regmap)
+ return -EPROBE_DEFER;
+
+ hwmon_dev = devm_hwmon_device_register_with_info(&pdev->dev,
+ "sy7636a_temperature", regmap, NULL, sy7636a_groups);
+
+ if (IS_ERR(hwmon_dev)) {
+ err = PTR_ERR(hwmon_dev);
+ dev_err(&pdev->dev, "Unable to register hwmon device, returned %d\n", err);
+ return err;
+ }
+
+ return 0;
+}
+
+static struct platform_driver sy7636a_sensor_driver = {
+ .probe = sy7636a_sensor_probe,
+ .driver = {
+ .name = "sy7636a-temperature",
+ },
+};
+module_platform_driver(sy7636a_sensor_driver);
+
+MODULE_DESCRIPTION("SY7636A sensor driver");
+MODULE_LICENSE("GPL");
--
2.31.1

2021-10-15 22:54:13

by Alistair Francis

[permalink] [raw]
Subject: [PATCH v13 5/9] thermal: sy7636a: Add thermal driver for sy7636a

Add thermal driver to enable kernel based polling
and shutdown of device for temperatures out of spec

Signed-off-by: Alistair Francis <[email protected]>
---
drivers/thermal/Kconfig | 6 ++
drivers/thermal/Makefile | 1 +
drivers/thermal/sy7636a_thermal.c | 94 +++++++++++++++++++++++++++++++
3 files changed, 101 insertions(+)
create mode 100644 drivers/thermal/sy7636a_thermal.c

diff --git a/drivers/thermal/Kconfig b/drivers/thermal/Kconfig
index d7f44deab5b1..6ee0e7de1b37 100644
--- a/drivers/thermal/Kconfig
+++ b/drivers/thermal/Kconfig
@@ -450,6 +450,12 @@ depends on (ARCH_STI || ARCH_STM32) && OF
source "drivers/thermal/st/Kconfig"
endmenu

+config SY7636A_THERMAL
+ tristate "SY7636A thermal management"
+ help
+ Enable the sy7636a thermal driver, which supports the
+ temperature sensor embedded in Silabs SY7636A IC.
+
source "drivers/thermal/tegra/Kconfig"

config GENERIC_ADC_THERMAL
diff --git a/drivers/thermal/Makefile b/drivers/thermal/Makefile
index 82fc3e616e54..2e1aca8a0a09 100644
--- a/drivers/thermal/Makefile
+++ b/drivers/thermal/Makefile
@@ -51,6 +51,7 @@ obj-$(CONFIG_DA9062_THERMAL) += da9062-thermal.o
obj-y += intel/
obj-$(CONFIG_TI_SOC_THERMAL) += ti-soc-thermal/
obj-y += st/
+obj-$(CONFIG_SY7636A_THERMAL) += sy7636a_thermal.o
obj-$(CONFIG_QCOM_TSENS) += qcom/
obj-y += tegra/
obj-$(CONFIG_HISI_THERMAL) += hisi_thermal.o
diff --git a/drivers/thermal/sy7636a_thermal.c b/drivers/thermal/sy7636a_thermal.c
new file mode 100644
index 000000000000..9e58305ca3ce
--- /dev/null
+++ b/drivers/thermal/sy7636a_thermal.c
@@ -0,0 +1,94 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Functions to access SY3686A power management chip temperature
+ *
+ * Copyright (C) 2019 reMarkable AS - http://www.remarkable.com/
+ *
+ * Authors: Lars Ivar Miljeteig <[email protected]>
+ * Alistair Francis <[email protected]>
+ */
+
+#include <linux/module.h>
+#include <linux/platform_device.h>
+#include <linux/thermal.h>
+
+#include <linux/mfd/sy7636a.h>
+
+static int sy7636a_get_temp(void *arg, int *res)
+{
+ unsigned int mode_ctr;
+ int ret, reg_val;
+ struct regmap *regmap = arg;
+ bool isVoltageActive;
+
+ ret = regmap_read(regmap,
+ SY7636A_REG_OPERATION_MODE_CRL, &mode_ctr);
+ if (ret)
+ return ret;
+
+ isVoltageActive = mode_ctr & SY7636A_OPERATION_MODE_CRL_ONOFF;
+
+ /* If operation mode isn't set to control, then let's set it. */
+ if (!isVoltageActive) {
+ ret = regmap_write(regmap,
+ SY7636A_REG_OPERATION_MODE_CRL,
+ mode_ctr | SY7636A_OPERATION_MODE_CRL_ONOFF);
+ if (ret)
+ return ret;
+ }
+
+ ret = regmap_read(regmap,
+ SY7636A_REG_TERMISTOR_READOUT, &reg_val);
+ if (ret)
+ return ret;
+
+ /* Restore the operation mode if it wasn't set */
+ if (!isVoltageActive) {
+ ret = regmap_write(regmap,
+ SY7636A_REG_OPERATION_MODE_CRL,
+ mode_ctr);
+ if (ret)
+ return ret;
+ }
+
+ *res = reg_val * 1000;
+
+ return ret;
+}
+
+static const struct thermal_zone_of_device_ops ops = {
+ .get_temp = sy7636a_get_temp,
+};
+
+static int sy7636a_thermal_probe(struct platform_device *pdev)
+{
+ struct regmap *regmap = dev_get_regmap(pdev->dev.parent, NULL);
+ struct thermal_zone_device *thermal_zone_dev;
+
+ thermal_zone_dev = devm_thermal_zone_of_sensor_register(
+ pdev->dev.parent,
+ 0,
+ regmap,
+ &ops);
+
+ return PTR_ERR_OR_ZERO(thermal_zone_dev);
+}
+
+static const struct platform_device_id sy7636a_thermal_id_table[] = {
+ { "sy7636a-thermal", },
+ { }
+};
+MODULE_DEVICE_TABLE(platform, sy7636a_thermal_id_table);
+
+static struct platform_driver sy7636a_thermal_driver = {
+ .driver = {
+ .name = "sy7636a-thermal",
+ },
+ .probe = sy7636a_thermal_probe,
+ .id_table = sy7636a_thermal_id_table,
+};
+module_platform_driver(sy7636a_thermal_driver);
+
+MODULE_AUTHOR("Lars Ivar Miljeteig <[email protected]>");
+MODULE_DESCRIPTION("SY7636A thermal driver");
+MODULE_LICENSE("GPL v2");
--
2.31.1

2021-10-15 22:54:27

by Alistair Francis

[permalink] [raw]
Subject: [PATCH v13 7/9] ARM: imx_v6_v7_defconfig: Enable silergy,sy7636a

Enable the silergy,sy7636a and silergy,sy7636a-regulator for the
reMarkable2.

Signed-off-by: Alistair Francis <[email protected]>
---
arch/arm/configs/imx_v6_v7_defconfig | 4 ++++
1 file changed, 4 insertions(+)

diff --git a/arch/arm/configs/imx_v6_v7_defconfig b/arch/arm/configs/imx_v6_v7_defconfig
index 5e4128dadd8d..948494074de4 100644
--- a/arch/arm/configs/imx_v6_v7_defconfig
+++ b/arch/arm/configs/imx_v6_v7_defconfig
@@ -228,10 +228,12 @@ CONFIG_RN5T618_POWER=m
CONFIG_SENSORS_MC13783_ADC=y
CONFIG_SENSORS_GPIO_FAN=y
CONFIG_SENSORS_IIO_HWMON=y
+CONFIG_SENSORS_SY7636A=y
CONFIG_THERMAL_STATISTICS=y
CONFIG_THERMAL_WRITABLE_TRIPS=y
CONFIG_CPU_THERMAL=y
CONFIG_IMX_THERMAL=y
+CONFIG_SY7636A_THERMAL=y
CONFIG_WATCHDOG=y
CONFIG_DA9062_WATCHDOG=y
CONFIG_DA9063_WATCHDOG=m
@@ -247,6 +249,7 @@ CONFIG_MFD_RN5T618=y
CONFIG_MFD_STMPE=y
CONFIG_REGULATOR=y
CONFIG_REGULATOR_FIXED_VOLTAGE=y
+CONFIG_MFD_SIMPLE_MFD_I2C=y
CONFIG_REGULATOR_ANATOP=y
CONFIG_REGULATOR_DA9052=y
CONFIG_REGULATOR_DA9062=y
@@ -257,6 +260,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

2021-10-15 22:57:53

by Alistair Francis

[permalink] [raw]
Subject: [PATCH v13 8/9] ARM: dts: imx7d: remarkable2: Enable silergy,sy7636a

Enable the silergy,sy7636a and silergy,sy7636a-regulator on the
reMarkable2.

Signed-off-by: Alistair Francis <[email protected]>
---
arch/arm/boot/dts/imx7d-remarkable2.dts | 62 +++++++++++++++++++++++++
1 file changed, 62 insertions(+)

diff --git a/arch/arm/boot/dts/imx7d-remarkable2.dts b/arch/arm/boot/dts/imx7d-remarkable2.dts
index 89cbf13097a4..b66d28b30d75 100644
--- a/arch/arm/boot/dts/imx7d-remarkable2.dts
+++ b/arch/arm/boot/dts/imx7d-remarkable2.dts
@@ -22,6 +22,27 @@ memory@80000000 {
reg = <0x80000000 0x40000000>;
};

+ thermal-zones {
+ epd-thermal {
+ thermal-sensors = <&epd_pmic>;
+ polling-delay-passive = <30000>;
+ polling-delay = <30000>;
+ trips {
+ trip0 {
+ temperature = <49000>;
+ hysteresis = <2000>;
+ type = "passive";
+ };
+
+ trip1 {
+ temperature = <50000>;
+ hysteresis = <2000>;
+ type = "critical";
+ };
+ };
+ };
+ };
+
reg_brcm: regulator-brcm {
compatible = "regulator-fixed";
regulator-name = "brcm_reg";
@@ -51,6 +72,33 @@ &clks {
assigned-clock-rates = <0>, <32768>;
};

+&i2c4 {
+ clock-frequency = <100000>;
+ pinctrl-names = "default", "sleep";
+ pinctrl-0 = <&pinctrl_i2c4>;
+ pinctrl-1 = <&pinctrl_i2c4>;
+ status = "okay";
+
+ epd_pmic: sy7636a@62 {
+ compatible = "silergy,sy7636a";
+ reg = <0x62>;
+ status = "okay";
+ pinctrl-names = "default";
+ pinctrl-0 = <&pinctrl_epdpmic>;
+ #address-cells = <1>;
+ #size-cells = <0>;
+ #thermal-sensor-cells = <0>;
+
+ epd-pwr-good-gpios = <&gpio6 21 GPIO_ACTIVE_HIGH>;
+ regulators {
+ reg_epdpmic: vcom {
+ regulator-name = "vcom";
+ regulator-boot-on;
+ };
+ };
+ };
+};
+
&snvs_pwrkey {
status = "okay";
};
@@ -125,6 +173,20 @@ MX7D_PAD_SAI1_TX_BCLK__GPIO6_IO13 0x14
>;
};

+ pinctrl_epdpmic: epdpmicgrp {
+ fsl,pins = <
+ MX7D_PAD_SAI2_RX_DATA__GPIO6_IO21 0x00000074
+ MX7D_PAD_ENET1_RGMII_TXC__GPIO7_IO11 0x00000014
+ >;
+ };
+
+ pinctrl_i2c4: i2c4grp {
+ fsl,pins = <
+ MX7D_PAD_I2C4_SDA__I2C4_SDA 0x4000007f
+ MX7D_PAD_I2C4_SCL__I2C4_SCL 0x4000007f
+ >;
+ };
+
pinctrl_uart1: uart1grp {
fsl,pins = <
MX7D_PAD_UART1_TX_DATA__UART1_DCE_TX 0x79
--
2.31.1

2021-10-15 22:58:06

by Alistair Francis

[permalink] [raw]
Subject: [PATCH v13 9/9] ARM: dts: imx7d: remarkable2: Enable lcdif

Connect the dispaly on the reMarkable2.

Signed-off-by: Alistair Francis <[email protected]>
---
arch/arm/boot/dts/imx7d-remarkable2.dts | 74 +++++++++++++++++++++++++
1 file changed, 74 insertions(+)

diff --git a/arch/arm/boot/dts/imx7d-remarkable2.dts b/arch/arm/boot/dts/imx7d-remarkable2.dts
index b66d28b30d75..fe68f6eaa2ec 100644
--- a/arch/arm/boot/dts/imx7d-remarkable2.dts
+++ b/arch/arm/boot/dts/imx7d-remarkable2.dts
@@ -55,6 +55,16 @@ reg_brcm: regulator-brcm {
startup-delay-us = <150>;
};

+ reg_sdoe: regulator-sdoe {
+ compatible = "regulator-fixed";
+ regulator-name = "SDOE";
+ pinctrl-names = "default", "sleep";
+ pinctrl-0 = <&pinctrl_sdoe_reg>;
+ pinctrl-1 = <&pinctrl_sdoe_reg>;
+ gpio = <&gpio3 27 GPIO_ACTIVE_HIGH>;
+ enable-active-high;
+ };
+
wifi_pwrseq: wifi_pwrseq {
compatible = "mmc-pwrseq-simple";
pinctrl-names = "default";
@@ -63,6 +73,16 @@ wifi_pwrseq: wifi_pwrseq {
clocks = <&clks IMX7D_CLKO2_ROOT_DIV>;
clock-names = "ext_clock";
};
+
+ panel {
+ compatible = "eink,vb3300-kca";
+
+ port {
+ panel_in: endpoint {
+ remote-endpoint = <&display_out>;
+ };
+ };
+ };
};

&clks {
@@ -99,6 +119,20 @@ reg_epdpmic: vcom {
};
};

+&lcdif {
+ pinctrl-names = "default";
+ pinctrl-0 = <&pinctrl_lcdif>;
+ lcd-supply = <&reg_epdpmic>;
+ lcd2-supply = <&reg_sdoe>;
+ status = "okay";
+
+ port {
+ display_out: endpoint {
+ remote-endpoint = <&panel_in>;
+ };
+ };
+};
+
&snvs_pwrkey {
status = "okay";
};
@@ -187,6 +221,46 @@ MX7D_PAD_I2C4_SCL__I2C4_SCL 0x4000007f
>;
};

+ 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_sdoe_reg: sdoereggrp {
+ fsl,pins = <
+ MX7D_PAD_LCD_DATA22__GPIO3_IO27 0x74
+ >;
+ };
+
pinctrl_uart1: uart1grp {
fsl,pins = <
MX7D_PAD_UART1_TX_DATA__UART1_DCE_TX 0x79
--
2.31.1

2021-10-16 11:09:55

by Guenter Roeck

[permalink] [raw]
Subject: Re: [PATCH v13 6/9] hwmon: sy7636a: Add temperature driver for sy7636a

On 10/15/21 5:25 AM, Alistair Francis wrote:
> This is a multi-function device to interface with the sy7636a
> EPD PMIC chip from Silergy.
>
> Signed-off-by: Alistair Francis <[email protected]>
> ---
> Documentation/hwmon/sy7636a-hwmon.rst | 24 +++++++++
> drivers/hwmon/Kconfig | 9 ++++
> drivers/hwmon/Makefile | 1 +
> drivers/hwmon/sy7636a-hwmon.c | 75 +++++++++++++++++++++++++++
> 4 files changed, 109 insertions(+)
> create mode 100644 Documentation/hwmon/sy7636a-hwmon.rst
> create mode 100644 drivers/hwmon/sy7636a-hwmon.c
>
> diff --git a/Documentation/hwmon/sy7636a-hwmon.rst b/Documentation/hwmon/sy7636a-hwmon.rst
> new file mode 100644
> index 000000000000..6b3e36d028dd
> --- /dev/null
> +++ b/Documentation/hwmon/sy7636a-hwmon.rst
> @@ -0,0 +1,24 @@
> +Kernel driver sy7636a-hwmon
> +=========================
> +
> +Supported chips:
> +
> + * Silergy SY7636A PMIC
> +
> +
> +Description
> +-----------
> +
> +This driver adds hardware temperature reading support for
> +the Silergy SY7636A PMIC.
> +
> +The following sensors are supported
> +
> + * Temperature
> + - SoC on-die temperature in milli-degree C
> +
> +sysfs-Interface
> +---------------
> +
> +temp0_input
> + - SoC on-die temperature (milli-degree C)
> diff --git a/drivers/hwmon/Kconfig b/drivers/hwmon/Kconfig
> index c4578e8f34bb..d768b833b721 100644
> --- a/drivers/hwmon/Kconfig
> +++ b/drivers/hwmon/Kconfig
> @@ -1651,6 +1651,15 @@ config SENSORS_SIS5595
> This driver can also be built as a module. If so, the module
> will be called sis5595.
>
> +config SENSORS_SY7636A
> + tristate "Silergy SY7636A"
> + help
> + If you say yes here you get support for the thermistor readout of
> + the Silergy SY7636A PMIC.
> +
> + This driver can also be built as a module. If so, the module
> + will be called sy7636a-hwmon.
> +
> config SENSORS_DME1737
> tristate "SMSC DME1737, SCH311x and compatibles"
> depends on I2C && !PPC
> diff --git a/drivers/hwmon/Makefile b/drivers/hwmon/Makefile
> index 162940270661..1355ffdb1481 100644
> --- a/drivers/hwmon/Makefile
> +++ b/drivers/hwmon/Makefile
> @@ -181,6 +181,7 @@ obj-$(CONFIG_SENSORS_SMSC47M1) += smsc47m1.o
> obj-$(CONFIG_SENSORS_SMSC47M192)+= smsc47m192.o
> obj-$(CONFIG_SENSORS_SPARX5) += sparx5-temp.o
> obj-$(CONFIG_SENSORS_STTS751) += stts751.o
> +obj-$(CONFIG_SENSORS_SY7636A) += sy7636a-hwmon.o
> obj-$(CONFIG_SENSORS_AMC6821) += amc6821.o
> obj-$(CONFIG_SENSORS_TC74) += tc74.o
> obj-$(CONFIG_SENSORS_THMC50) += thmc50.o
> diff --git a/drivers/hwmon/sy7636a-hwmon.c b/drivers/hwmon/sy7636a-hwmon.c
> new file mode 100644
> index 000000000000..a59628f87ff3
> --- /dev/null
> +++ b/drivers/hwmon/sy7636a-hwmon.c
> @@ -0,0 +1,75 @@
> +// SPDX-License-Identifier: GPL-2.0+
> +/*
> + * Functions to access SY3686A power management chip temperature
> + *
> + * Copyright (C) 2019 reMarkable AS - http://www.remarkable.com/
> + *
> + * Authors: Lars Ivar Miljeteig <[email protected]>
> + * Alistair Francis <[email protected]>
> + */
> +
> +#include <linux/err.h>
> +#include <linux/hwmon.h>
> +#include <linux/hwmon-sysfs.h>
> +#include <linux/init.h>
> +#include <linux/module.h>
> +#include <linux/regmap.h>
> +#include <linux/sysfs.h>
> +#include <linux/platform_device.h>
> +
> +#include <linux/mfd/sy7636a.h>
> +
> +static ssize_t show_temp(struct device *dev,
> + struct device_attribute *attr, char *buf)
> +{
> + unsigned int reg_val;
> + struct regmap *regmap = dev_get_drvdata(dev);
> + int ret;
> +
> + ret = regmap_read(regmap, SY7636A_REG_TERMISTOR_READOUT, &reg_val);
> + if (ret)
> + return ret;
> +
> + return snprintf(buf, PAGE_SIZE, "%d\n", reg_val);
> +}
> +
> +static SENSOR_DEVICE_ATTR(temp0, 0444, show_temp, NULL, 0);
> +

This must be temp1_input. "temp0" is not a standard attribute,
and without standard attributes the driver is pointless.

> +static struct attribute *sy7636a_attrs[] = {
> + &sensor_dev_attr_temp0.dev_attr.attr,
> + NULL
> +};
> +
> +ATTRIBUTE_GROUPS(sy7636a);
> +
> +static int sy7636a_sensor_probe(struct platform_device *pdev)
> +{
> + struct regmap *regmap = dev_get_regmap(pdev->dev.parent, NULL);
> + struct device *hwmon_dev;
> + int err;
> +
> + if (!regmap)
> + return -EPROBE_DEFER;
> +
> + hwmon_dev = devm_hwmon_device_register_with_info(&pdev->dev,
> + "sy7636a_temperature", regmap, NULL, sy7636a_groups);


I am not going to accept this. The groups pointer is only supposed
to be used for non-standard attributes.

Anyway, it is pointless to have both a thermal driver and a hwmon
driver. The hwmon driver can register the thermal node if the _info
interface is used properly, and the thermal driver can register
a hwmon interface using [devm_]thermal_add_hwmon_sysfs(). If you don't
want to use the _info API in the hwmon driver, please drop this
driver and register the hwmon interface from the thermal driver.

Thanks,
Guenter

> +
> + if (IS_ERR(hwmon_dev)) {
> + err = PTR_ERR(hwmon_dev);
> + dev_err(&pdev->dev, "Unable to register hwmon device, returned %d\n", err);
> + return err;
> + }
> +
> + return 0;
> +}
> +
> +static struct platform_driver sy7636a_sensor_driver = {
> + .probe = sy7636a_sensor_probe,
> + .driver = {
> + .name = "sy7636a-temperature",
> + },
> +};
> +module_platform_driver(sy7636a_sensor_driver);
> +
> +MODULE_DESCRIPTION("SY7636A sensor driver");
> +MODULE_LICENSE("GPL");
>

2021-10-18 03:34:15

by Daniel Lezcano

[permalink] [raw]
Subject: Re: [PATCH v13 5/9] thermal: sy7636a: Add thermal driver for sy7636a

On 15/10/2021 14:25, Alistair Francis wrote:
> Add thermal driver to enable kernel based polling
> and shutdown of device for temperatures out of spec

As it is an initial submission, could you give a brief description of
the sensor even if it is very simple ?

> Signed-off-by: Alistair Francis <[email protected]>
> ---
> drivers/thermal/Kconfig | 6 ++
> drivers/thermal/Makefile | 1 +
> drivers/thermal/sy7636a_thermal.c | 94 +++++++++++++++++++++++++++++++
> 3 files changed, 101 insertions(+)
> create mode 100644 drivers/thermal/sy7636a_thermal.c
>
> diff --git a/drivers/thermal/Kconfig b/drivers/thermal/Kconfig
> index d7f44deab5b1..6ee0e7de1b37 100644
> --- a/drivers/thermal/Kconfig
> +++ b/drivers/thermal/Kconfig
> @@ -450,6 +450,12 @@ depends on (ARCH_STI || ARCH_STM32) && OF
> source "drivers/thermal/st/Kconfig"
> endmenu
>
> +config SY7636A_THERMAL
> + tristate "SY7636A thermal management"

no deps ?

> + help
> + Enable the sy7636a thermal driver, which supports the
> + temperature sensor embedded in Silabs SY7636A IC.
> +
> source "drivers/thermal/tegra/Kconfig"
>
> config GENERIC_ADC_THERMAL
> diff --git a/drivers/thermal/Makefile b/drivers/thermal/Makefile
> index 82fc3e616e54..2e1aca8a0a09 100644
> --- a/drivers/thermal/Makefile
> +++ b/drivers/thermal/Makefile
> @@ -51,6 +51,7 @@ obj-$(CONFIG_DA9062_THERMAL) += da9062-thermal.o
> obj-y += intel/
> obj-$(CONFIG_TI_SOC_THERMAL) += ti-soc-thermal/
> obj-y += st/
> +obj-$(CONFIG_SY7636A_THERMAL) += sy7636a_thermal.o
> obj-$(CONFIG_QCOM_TSENS) += qcom/
> obj-y += tegra/
> obj-$(CONFIG_HISI_THERMAL) += hisi_thermal.o
> diff --git a/drivers/thermal/sy7636a_thermal.c b/drivers/thermal/sy7636a_thermal.c
> new file mode 100644
> index 000000000000..9e58305ca3ce
> --- /dev/null
> +++ b/drivers/thermal/sy7636a_thermal.c
> @@ -0,0 +1,94 @@
> +// SPDX-License-Identifier: GPL-2.0+
> +/*
> + * Functions to access SY3686A power management chip temperature
> + *
> + * Copyright (C) 2019 reMarkable AS - http://www.remarkable.com/

2021

> + *
> + * Authors: Lars Ivar Miljeteig <[email protected]>
> + * Alistair Francis <[email protected]>
> + */

From Documentation/process/submitting-drivers.rst

"""
Copyright:
The copyright owner must agree to use of GPL.
It's best if the submitter and copyright owner
are the same person/entity. If not, the name of
the person/entity authorizing use of GPL should be
listed in case it's necessary to verify the will of
the copyright owner.
"""

[Cc'ed Lars Ivar Miljeteig]

> +#include <linux/module.h>
> +#include <linux/platform_device.h>
> +#include <linux/thermal.h>
> +
> +#include <linux/mfd/sy7636a.h>
> +
> +static int sy7636a_get_temp(void *arg, int *res)

...(struct thermal_zone_device *tz, int *temp)


> +{
> + unsigned int mode_ctr;
> + int ret, reg_val;
> + struct regmap *regmap = arg;
> + bool isVoltageActive;

Looks like c++ code

> + ret = regmap_read(regmap,
> + SY7636A_REG_OPERATION_MODE_CRL, &mode_ctr);
> + if (ret)
> + return ret;
> +
> + isVoltageActive = mode_ctr & SY7636A_OPERATION_MODE_CRL_ONOFF;
> +
> + /* If operation mode isn't set to control, then let's set it. */
> + if (!isVoltageActive) {
> + ret = regmap_write(regmap,
> + SY7636A_REG_OPERATION_MODE_CRL,
> + mode_ctr | SY7636A_OPERATION_MODE_CRL_ONOFF);
> + if (ret)
> + return ret;
> + }

Who is turnning off the 'control' outside of this driver?

> + ret = regmap_read(regmap,
> + SY7636A_REG_TERMISTOR_READOUT, &reg_val);
> + if (ret)
> + return ret;
> +
> + /* Restore the operation mode if it wasn't set */
> + if (!isVoltageActive) {
> + ret = regmap_write(regmap,
> + SY7636A_REG_OPERATION_MODE_CRL,
> + mode_ctr);
> + if (ret)
> + return ret;
> + }

IIUC, this is a mfd, so if a component outside of this driver is
touching this SY7636A_REG_OPERATION_MODE_CRL, there is no guarantee
these operations will stay consistent.

Is that correct ?

> + *res = reg_val * 1000;
> +
> + return ret;
> +}
> +
> +static const struct thermal_zone_of_device_ops ops = {
> + .get_temp = sy7636a_get_temp,
> +};
> +
> +static int sy7636a_thermal_probe(struct platform_device *pdev)
> +{
> + struct regmap *regmap = dev_get_regmap(pdev->dev.parent, NULL);
> + struct thermal_zone_device *thermal_zone_dev;

regmap return value check, please

> + thermal_zone_dev = devm_thermal_zone_of_sensor_register(
> + pdev->dev.parent,
> + 0,
> + regmap,
> + &ops);

Fix indent please

> +
> + return PTR_ERR_OR_ZERO(thermal_zone_dev);
> +}
> +
> +static const struct platform_device_id sy7636a_thermal_id_table[] = {
> + { "sy7636a-thermal", },
> + { }
> +};
> +MODULE_DEVICE_TABLE(platform, sy7636a_thermal_id_table);
> +
> +static struct platform_driver sy7636a_thermal_driver = {
> + .driver = {
> + .name = "sy7636a-thermal",
> + },
> + .probe = sy7636a_thermal_probe,
> + .id_table = sy7636a_thermal_id_table,
> +};
> +module_platform_driver(sy7636a_thermal_driver);
> +
> +MODULE_AUTHOR("Lars Ivar Miljeteig <[email protected]>");
> +MODULE_DESCRIPTION("SY7636A thermal driver");
> +MODULE_LICENSE("GPL v2");
>


--
<http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs

Follow Linaro: <http://www.facebook.com/pages/Linaro> Facebook |
<http://twitter.com/#!/linaroorg> Twitter |
<http://www.linaro.org/linaro-blog/> Blog

2021-10-22 00:54:05

by Mark Brown

[permalink] [raw]
Subject: Re: (subset) [PATCH v13 0/9] Add support for the silergy,sy7636a

On Fri, 15 Oct 2021 22:25:42 +1000, Alistair Francis wrote:
> v13:
> - Address comments on thermal driver
> - Rebase on master (without other patches)
> v12:
> - Rebase
> v11:
> - Address comments on hwmon
> - Improve "mfd: simple-mfd-i2c: Add a Kconfig name" commit message
> v10:
> - Use dev_get_regmap() instead of dev_get_drvdata()
> v9:
> - Convert to use the simple-mfd-i2c instead
>
> [...]

Applied to

https://git.kernel.org/pub/scm/linux/kernel/git/broonie/regulator.git for-next

Thanks!

[4/9] regulator: sy7636a: Remove requirement on sy7636a mfd
commit: cb17820ef71ed70f70ee1eed2b378664746b6fde

All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying
to this mail.

Thanks,
Mark

2021-10-22 10:33:07

by Lee Jones

[permalink] [raw]
Subject: Re: [PATCH v13 2/9] mfd: simple-mfd-i2c: Add a Kconfig name

On Fri, 15 Oct 2021, Alistair Francis wrote:

> Add a Kconfig name to the "Simple Multi-Functional Device support (I2C)"
> device so that it can be enabled via menuconfig.
>
> Signed-off-by: Alistair Francis <[email protected]>
> ---
> drivers/mfd/Kconfig | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)

For my own reference (apply this as-is to your sign-off block):

Acked-for-MFD-by: Lee Jones <[email protected]>

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