[xt-q8l-v10] Updates for CSC board (#1539)

* Added ALSA configuration bits for rk3288 HDMI and SPDIF to allow
pulseaudio show proper sound device/profile/mapping names instead of
just "Built-in Audio" for all of them

* Added ALSA device description in asound.conf to provide correct labels for PulseAudio for RK3288 devices when SPDIF and DW-I2S-HDMI simple audio cards are exposed
Removed unnecessary ALSA configuration files previously added from rockchip.conf

* Fixed cpu operating points tables and raised a bit (+5°C) cooling for non-critical temperatures for xt-q8l-v10 in dev and next kernel flavours

* Fixed again cpu opp table

* Removed whole cpu opp table and retouch only necessary operating points

* Enabled gpiomem driver for xt-q8l-v10 in next kernel flavour

* Added debounce delay and card detect gpio pins for sdmmc card holder for xt-q8l-v10 board

* Added card-detect and debounce delay for sdmmc for xt-q8l-v10 board in next kernel flavour too

* Fixed missing comment in xt-q8l-v10 device tree patch

* Added gpiomem to xt-q8l-v10 board for dev kernel

* Fixed FAN53555/Silergy patches to accomodate changes in u-boot v2019.04

* Changed property property flags for USB regulators in u-boot and kernel: kernel is now informed that bootloader is going to turn the USB power on

* Removed assert-phy-reset-when-waking-up-in-rk3288-platform patch due to inclusion in mainline 5.2 kernel
Reenabled ARM-DTSI-rk3288-add-usbphy-reset patch to include USB PHY reset lines to all rk3288 devices

* Removed ARM-DTSI-rk3288-add-usbphy-reset.patch due to inclusion in mainline kernel 5.2
This commit is contained in:
Paolo 2019-08-31 22:02:25 +02:00 committed by Igor Pečovnik
parent 405e0781f6
commit f82001666b
7 changed files with 156 additions and 679 deletions

View file

@ -1,31 +0,0 @@
diff --git a/arch/arm/boot/dts/rk3288.dtsi b/arch/arm/boot/dts/rk3288.dtsi
index 0840ffb3..5393f2cd 100644
--- a/arch/arm/boot/dts/rk3288.dtsi
+++ b/arch/arm/boot/dts/rk3288.dtsi
@@ -894,6 +894,8 @@
reg = <0x320>;
clocks = <&cru SCLK_OTGPHY0>;
clock-names = "phyclk";
+ resets = <&cru SRST_USBOTG_PHY>;
+ reset-names = "phy-reset";
#clock-cells = <0>;
};
@@ -902,6 +904,8 @@
reg = <0x334>;
clocks = <&cru SCLK_OTGPHY1>;
clock-names = "phyclk";
+ resets = <&cru SRST_USBHOST0_PHY>;
+ reset-names = "phy-reset";
#clock-cells = <0>;
};
@@ -910,6 +914,8 @@
reg = <0x348>;
clocks = <&cru SCLK_OTGPHY2>;
clock-names = "phyclk";
+ resets = <&cru SRST_USBHOST1_PHY>;
+ reset-names = "phy-reset";
#clock-cells = <0>;
};
};

View file

@ -1,68 +0,0 @@
diff --git a/drivers/usb/dwc2/core.h b/drivers/usb/dwc2/core.h
index cc9c93af..3ff41d87 100644
--- a/drivers/usb/dwc2/core.h
+++ b/drivers/usb/dwc2/core.h
@@ -1021,6 +1021,7 @@ struct dwc2_hsotg {
u16 frame_number;
struct phy *phy;
+ struct work_struct phy_rst_work;
struct usb_phy *uphy;
struct dwc2_hsotg_plat *plat;
struct regulator_bulk_data supplies[DWC2_NUM_SUPPLIES];
diff --git a/drivers/usb/dwc2/core_intr.c b/drivers/usb/dwc2/core_intr.c
index 19ae2595..f1270bf1 100644
--- a/drivers/usb/dwc2/core_intr.c
+++ b/drivers/usb/dwc2/core_intr.c
@@ -396,6 +396,7 @@ static void dwc2_wakeup_from_lpm_l1(struct dwc2_hsotg *hsotg)
static void dwc2_handle_wakeup_detected_intr(struct dwc2_hsotg *hsotg)
{
int ret;
+ struct device_node *np = hsotg->dev->of_node;
/* Clear interrupt */
dwc2_writel(hsotg, GINTSTS_WKUPINT, GINTSTS);
@@ -435,6 +436,16 @@ static void dwc2_handle_wakeup_detected_intr(struct dwc2_hsotg *hsotg)
/* Restart the Phy Clock */
pcgcctl &= ~PCGCTL_STOPPCLK;
dwc2_writel(hsotg, pcgcctl, PCGCTL);
+
+ /*
+ * It is a quirk in Rockchip RK3288, causing by
+ * a hardware bug. This will propagate out and
+ * eventually we'll re-enumerate the device.
+ * Not great but the best we can do.
+ */
+ if (of_device_is_compatible(np, "rockchip,rk3288-usb"))
+ schedule_work(&hsotg->phy_rst_work);
+
mod_timer(&hsotg->wkp_timer,
jiffies + msecs_to_jiffies(71));
} else {
diff --git a/drivers/usb/dwc2/platform.c b/drivers/usb/dwc2/platform.c
index 57764289..748763bd 100644
--- a/drivers/usb/dwc2/platform.c
+++ b/drivers/usb/dwc2/platform.c
@@ -208,6 +208,14 @@ int dwc2_lowlevel_hw_disable(struct dwc2_hsotg *hsotg)
return ret;
}
+/* Only used to reset usb phy at interrupter runtime */
+static void dwc2_reset_phy_work(struct work_struct *data)
+{
+ struct dwc2_hsotg *hsotg = container_of(data, struct dwc2_hsotg,
+ phy_rst_work);
+ phy_reset(hsotg->phy);
+}
+
static int dwc2_lowlevel_hw_init(struct dwc2_hsotg *hsotg)
{
int i, ret;
@@ -252,6 +260,7 @@ static int dwc2_lowlevel_hw_init(struct dwc2_hsotg *hsotg)
return ret;
}
}
+ INIT_WORK(&hsotg->phy_rst_work, dwc2_reset_phy_work);
if (!hsotg->phy) {
hsotg->uphy = devm_usb_get_phy(hsotg->dev, USB_PHY_TYPE_USB2);

View file

@ -1,6 +1,6 @@
--- /dev/null
+++ b/arch/arm/boot/dts/rk3288-xt-q8l-v10.dts 2018-12-06 21:46:51.493688015 +0000
@@ -0,0 +1,969 @@
+++ b/arch/arm/boot/dts/rk3288-xt-q8l-v10.dts 2019-08-03 13:55:48.719992666 +0000
@@ -0,0 +1,982 @@
+/*
+ * Copyright (c) 2014, 2015 FUKAUMI Naoki <naobsd@gmail.com>
+ * 2018 Paolo Sabatino <paolo.sabatino@gm**l.com>
@ -57,51 +57,7 @@
+ reg = <0x0 0x0 0x0 0x80000000>;
+ device_type = "memory";
+ };
+
+ cpu0_opp_table: opp_table {
+ compatible = "operating-points-v2";
+ opp-shared;
+
+ opp@600000000 {
+ opp-hz = /bits/ 64 <600000000>;
+ opp-microvolt = <900000>;
+ };
+ opp@816000000 {
+ opp-hz = /bits/ 64 <816000000>;
+ opp-microvolt = <1000000>;
+ };
+ opp@1008000000 {
+ opp-hz = /bits/ 64 <1008000000>;
+ opp-microvolt = <1050000>;
+ };
+ opp@1200000000 {
+ opp-hz = /bits/ 64 <1200000000>;
+ opp-microvolt = <1100000>;
+ };
+ opp@1416000000 {
+ opp-hz = /bits/ 64 <1416000000>;
+ opp-microvolt = <1200000>;
+ };
+ opp@1512000000 {
+ opp-hz = /bits/ 64 <1512000000>;
+ opp-microvolt = <1250000>;
+ };
+ opp@1608000000 {
+ opp-hz = /bits/ 64 <1608000000>;
+ opp-microvolt = <1300000>;
+ };
+ /*
+ opp@1704000000 {
+ opp-hz = /bits/ 64 <1704000000>;
+ opp-microvolt = <1350000>;
+ };
+ opp@1800000000 {
+ opp-hz = /bits/ 64 <1800000000>;
+ opp-microvolt = <1400000>;
+ };
+ */
+ };
+
+ /*
+ * Peripheral from original q8 device tree, currently no references
+ * for drivers in linux kernel.
@ -212,29 +168,23 @@
+ vcc_host_5v: usb-host-regulator {
+ compatible = "regulator-fixed";
+ gpio = <&gpio0 14 GPIO_ACTIVE_HIGH>;
+ pinctrl-names = "default";
+ pinctrl-0 = <&host_vbus_drv>;
+ regulator-name = "vcc_host_5v";
+ regulator-min-microvolt = <5000000>;
+ regulator-max-microvolt = <5000000>;
+ regulator-always-on;
+ enable-active-high;
+// startup-delay-us = <1000>;
+ regulator-boot-on;
+ enable-active-high;
+ vin-supply = <&vcc_sys>;
+ };
+
+
+ vcc_otg_5v: usb-otg-regulator {
+ compatible = "regulator-fixed";
+ enable-active-high;
+ gpio = <&gpio0 12 GPIO_ACTIVE_HIGH>;
+ pinctrl-names = "default";
+ pinctrl-0 = <&otg_vbus_drv>;
+ regulator-name = "vcc_otg_5v";
+ regulator-min-microvolt = <5000000>;
+ regulator-max-microvolt = <5000000>;
+// startup-delay-us = <1000>;
+ regulator-always-on;
+ regulator-boot-on;
+ enable-active-high;
+ vin-supply = <&vcc_sys>;
+ };
+
@ -249,7 +199,7 @@
+ reset-gpios = <&gpio4 28 GPIO_ACTIVE_LOW>, <&gpio4 29 GPIO_ACTIVE_LOW>;
+ post-power-on-delay-ms = <100>;
+ };
+
+
+ /*
+ * Sound taken from tinkerboard device tree, adapted to q8.
+ */
@ -309,23 +259,6 @@
+
+&cpu0 {
+ cpu0-supply = <&vdd_cpu>;
+ operating-points-v2 = <&cpu0_opp_table>;
+ /delete-node/operating-points;
+};
+
+&cpu1 {
+ operating-points-v2 = <&cpu0_opp_table>;
+ /delete-node/operating-points;
+};
+
+&cpu2 {
+ operating-points-v2 = <&cpu0_opp_table>;
+ /delete-node/operating-points;
+};
+
+&cpu3 {
+ operating-points-v2 = <&cpu0_opp_table>;
+ /delete-node/operating-points;
+};
+
+&gmac {
@ -369,6 +302,9 @@
+ regulator-always-on;
+ regulator-boot-on;
+ vin-supply = <&vcc_sys>;
+ regulator-state-mem {
+ regulator-off-in-suspend;
+ };
+ };
+
+ vdd_gpu: syr828@41 {
@ -381,6 +317,9 @@
+ regulator-ramp-delay = <8000>;
+ regulator-always-on;
+ vin-supply = <&vcc_sys>;
+ regulator-state-mem {
+ regulator-off-in-suspend;
+ };
+ };
+
+ hym8563: hym8563@51 {
@ -421,6 +360,9 @@
+ regulator-min-microvolt = <1200000>;
+ regulator-max-microvolt = <1200000>;
+ regulator-always-on;
+ regulator-state-mem {
+ regulator-on-in-suspend;
+ };
+ };
+
+ /*
@ -432,6 +374,9 @@
+ regulator-min-microvolt = <3300000>;
+ regulator-max-microvolt = <3300000>;
+ regulator-always-on;
+ regulator-state-mem {
+ regulator-on-in-suspend;
+ };
+ };
+
+ /*
@ -445,6 +390,9 @@
+ regulator-min-microvolt = <1100000>;
+ regulator-max-microvolt = <1100000>;
+ regulator-always-on;
+ regulator-state-mem {
+ regulator-on-in-suspend;
+ };
+ };
+
+ /*
@ -457,6 +405,9 @@
+ regulator-min-microvolt = <2000000>;
+ regulator-max-microvolt = <2000000>;
+ regulator-always-on;
+ regulator-state-mem {
+ regulator-on-in-suspend;
+ };
+ };
+
+ /*
@ -468,6 +419,10 @@
+ regulator-min-microvolt = <1800000>;
+ regulator-max-microvolt = <3300000>;
+ regulator-always-on;
+ regulator-state-mem {
+ regulator-on-in-suspend;
+ regulator-suspend-microvolt = <3300000>;
+ };
+ };
+
+ /*
@ -479,6 +434,9 @@
+ regulator-min-microvolt = <1000000>;
+ regulator-max-microvolt = <1000000>;
+ regulator-always-on;
+ regulator-state-mem {
+ regulator-on-in-suspend;
+ };
+ };
+
+ /*
@ -491,6 +449,9 @@
+ regulator-min-microvolt = <1800000>;
+ regulator-max-microvolt = <1800000>;
+ regulator-always-on;
+ regulator-state-mem {
+ regulator-off-in-suspend;
+ };
+ };
+
+ /*
@ -502,6 +463,9 @@
+ regulator-min-microvolt = <3300000>;
+ regulator-max-microvolt = <3300000>;
+ regulator-always-on; // Turn this on to get SPDIF!
+ regulator-state-mem {
+ regulator-off-in-suspend;
+ };
+ };
+
+ /*
@ -511,6 +475,9 @@
+ regulator-name = "vcc_lan";
+ regulator-min-microvolt = <3300000>;
+ regulator-max-microvolt = <3300000>;
+ regulator-state-mem {
+ regulator-on-in-suspend;
+ };
+ };
+
+ /*
@ -522,6 +489,9 @@
+ regulator-min-microvolt = <1000000>;
+ regulator-max-microvolt = <1000000>;
+ regulator-always-on;
+ regulator-state-mem {
+ regulator-on-in-suspend;
+ };
+ };
+
+ /*
@ -533,6 +503,9 @@
+ regulator-min-microvolt = <1800000>;
+ regulator-max-microvolt = <1800000>;
+ regulator-always-on;
+ regulator-state-mem {
+ regulator-on-in-suspend;
+ };
+ };
+
+ /*
@ -545,6 +518,9 @@
+ regulator-min-microvolt = <1800000>;
+ regulator-max-microvolt = <1800000>;
+ regulator-always-on;
+ regulator-state-mem {
+ regulator-off-in-suspend;
+ };
+ };
+ };
+ };
@ -769,7 +745,10 @@
+ bus-width = <4>;
+ cap-mmc-highspeed;
+ cap-sd-highspeed;
+ card-detect-delay = <200>;
+ cd-gpios = <&gpio6 RK_PC6 GPIO_ACTIVE_LOW>;
+ cd-debounce-delay-ms = <200>;
+ post-power-on-delay-ms = <50>;
+ supports-cqe;
+ disable-wp;
+ pinctrl-names = "default";
+ pinctrl-0 = <&sdmmc_clk>, <&sdmmc_cmd>, <&sdmmc_cd>, <&sdmmc_bus4>;
@ -780,6 +759,7 @@
+ sd-uhs-sdr50;
+ sd-uhs-sdr104;
+ sd-uhs-ddr50;
+
+ status = "okay";
+};
+
@ -970,3 +950,36 @@
+&spdif {
+ status = "okay";
+};
+
+/*
+ * Redefine some thermals to give a bit more headroom (+5°C)
+ */
+&cpu_alert0 {
+ temperature = <75000>;
+};
+
+&cpu_alert1 {
+ temperature = <80000>;
+};
+
+&gpu_alert0 {
+ temperature = <75000>;
+};
+
+/*
+ * Retouch the operating points for higher frequencies to reduce
+ * the voltage required
+ */
+&cpu_opp_table {
+ opp-1512000000 {
+ opp-microvolt = <1250000>;
+ };
+
+ opp-1608000000 {
+ opp-microvolt = <1300000>;
+ };
+};
+
+&gpiomem {
+ status = "okay";
+};

View file

@ -1,6 +1,6 @@
--- /dev/null
+++ b/arch/arm/boot/dts/rk3288-xt-q8l-v10.dts 2018-12-06 21:46:51.493688015 +0000
@@ -0,0 +1,969 @@
+++ b/arch/arm/boot/dts/rk3288-xt-q8l-v10.dts 2019-07-14 13:14:47.511892375 +0000
@@ -0,0 +1,973 @@
+/*
+ * Copyright (c) 2014, 2015 FUKAUMI Naoki <naobsd@gmail.com>
+ * 2018 Paolo Sabatino <paolo.sabatino@gm**l.com>
@ -57,51 +57,7 @@
+ reg = <0x0 0x0 0x0 0x80000000>;
+ device_type = "memory";
+ };
+
+ cpu0_opp_table: opp_table {
+ compatible = "operating-points-v2";
+ opp-shared;
+
+ opp@600000000 {
+ opp-hz = /bits/ 64 <600000000>;
+ opp-microvolt = <900000>;
+ };
+ opp@816000000 {
+ opp-hz = /bits/ 64 <816000000>;
+ opp-microvolt = <1000000>;
+ };
+ opp@1008000000 {
+ opp-hz = /bits/ 64 <1008000000>;
+ opp-microvolt = <1050000>;
+ };
+ opp@1200000000 {
+ opp-hz = /bits/ 64 <1200000000>;
+ opp-microvolt = <1100000>;
+ };
+ opp@1416000000 {
+ opp-hz = /bits/ 64 <1416000000>;
+ opp-microvolt = <1200000>;
+ };
+ opp@1512000000 {
+ opp-hz = /bits/ 64 <1512000000>;
+ opp-microvolt = <1250000>;
+ };
+ opp@1608000000 {
+ opp-hz = /bits/ 64 <1608000000>;
+ opp-microvolt = <1300000>;
+ };
+ /*
+ opp@1704000000 {
+ opp-hz = /bits/ 64 <1704000000>;
+ opp-microvolt = <1350000>;
+ };
+ opp@1800000000 {
+ opp-hz = /bits/ 64 <1800000000>;
+ opp-microvolt = <1400000>;
+ };
+ */
+ };
+
+ /*
+ * Peripheral from original q8 device tree, currently no references
+ * for drivers in linux kernel.
@ -309,22 +265,21 @@
+
+&cpu0 {
+ cpu0-supply = <&vdd_cpu>;
+ operating-points-v2 = <&cpu0_opp_table>;
+ /delete-node/operating-points;
+};
+
+&cpu1 {
+ operating-points-v2 = <&cpu0_opp_table>;
+ operating-points-v2 = <&cpu_opp_table>;
+ /delete-node/operating-points;
+};
+
+&cpu2 {
+ operating-points-v2 = <&cpu0_opp_table>;
+ operating-points-v2 = <&cpu_opp_table>;
+ /delete-node/operating-points;
+};
+
+&cpu3 {
+ operating-points-v2 = <&cpu0_opp_table>;
+ operating-points-v2 = <&cpu_opp_table>;
+ /delete-node/operating-points;
+};
+
@ -769,7 +724,10 @@
+ bus-width = <4>;
+ cap-mmc-highspeed;
+ cap-sd-highspeed;
+ card-detect-delay = <200>;
+ cd-gpios = <&gpio6 RK_PC6 GPIO_ACTIVE_LOW>;
+ cd-debounce-delay-ms = <200>;
+ post-power-on-delay-ms = <50>;
+ supports-cqe;
+ disable-wp;
+ pinctrl-names = "default";
+ pinctrl-0 = <&sdmmc_clk>, <&sdmmc_cmd>, <&sdmmc_cd>, <&sdmmc_bus4>;
@ -857,6 +815,19 @@
+ //dmas = <&dmac_peri 1 &dmac_peri 2>;
+ //dma-names = "tx", "rx";
+ status = "okay";
+
+ uart-has-rtscts;
+
+ bluetooth {
+ compatible = "brcm,bcm4330-bt";
+ clocks = <&hym8563>;
+ clock-names = "lpo";
+ //device-wakeup-gpios = <&pio 7 24 GPIO_ACTIVE_LOW>;
+ //host-wakeup-gpios = <&pio 7 25 GPIO_ACTIVE_LOW>;
+ shutdown-gpios = <&gpio4 29 GPIO_ACTIVE_LOW>; /* PH18 */
+ max-speed = <1500000>;
+ };
+
+};
+
+&uart1 {
@ -970,3 +941,36 @@
+&spdif {
+ status = "okay";
+};
+
+/*
+ * Redefine some thermals to give a bit more headroom (+5°C)
+ */
+&cpu_alert0 {
+ temperature = <75000>;
+};
+
+&cpu_alert1 {
+ temperature = <80000>;
+};
+
+&gpu_alert0 {
+ temperature = <75000>;
+};
+
+/*
+ * Retouch the operating points for higher frequencies to reduce
+ * the voltage required
+ */
+&cpu_opp_table {
+ opp-1512000000 {
+ opp-microvolt = <1250000>;
+ };
+
+ opp-1608000000 {
+ opp-microvolt = <1300000>;
+ };
+};
+
+&gpiomem {
+ status = "okay";
+};

View file

@ -1,438 +0,0 @@
From patchwork Sun Nov 26 20:45:55 2017
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Subject: [U-Boot,v4,1/2] power: regulator: add driver for the FAN53555 family
X-Patchwork-Submitter: "Dr. Philipp Tomsich"
<philipp.tomsich@theobroma-systems.com>
X-Patchwork-Id: 841423
X-Patchwork-Delegate: philipp.tomsich@theobroma-systems.com
Message-Id: <1511729156-30197-1-git-send-email-philipp.tomsich@theobroma-systems.com>
To: u-boot@lists.denx.de
Cc: Jacob Chen <jacob-chen@iotwrt.com>
Date: Sun, 26 Nov 2017 21:45:55 +0100
From: Philipp Tomsich <philipp.tomsich@theobroma-systems.com>
List-Id: U-Boot discussion <u-boot.lists.denx.de>
This adds a driver for the FAN53555 family of regulators.
While these devices support a 'normal' and 'suspend' mode (controlled
via an external pin) to switch between two programmable voltages, this
incarnation of the driver assumes that the device is always operating
in 'normal' mode.
Only setting/reading the programmed voltage is supported at this time
and the following device functionality remains unsupported:
- switching the selected voltage (via a GPIO)
- disabling the voltage output via software-control
This matches the functionality of the Linux driver.
Tested on a RK3399-Q7 (with 'option 5' devices): setting voltages from
the U-Boot shell and verifying output voltages on the board.
Signed-off-by: Philipp Tomsich <philipp.tomsich@theobroma-systems.com>
Tested-by: Klaus Goger <klaus.goger@theobroma-systems.com>
---
Changes in v4:
- fix issues introduced when updating for review comments (sorry for
this: my submit-branch had diverged from the WIP-branch I used for
testing and I didn't notice)
Changes in v3:
- update for review comments
Changes in v2:
- adapted documentation on the device-tree binding from Linux
doc/device-tree-bindings/regulator/fan53555.txt | 23 +++
drivers/power/regulator/Kconfig | 14 ++
drivers/power/regulator/Makefile | 1 +
drivers/power/regulator/fan53555.c | 262 ++++++++++++++++++++++++
4 files changed, 300 insertions(+)
create mode 100644 doc/device-tree-bindings/regulator/fan53555.txt
create mode 100644 drivers/power/regulator/fan53555.c
diff --git a/doc/device-tree-bindings/regulator/fan53555.txt b/doc/device-tree-bindings/regulator/fan53555.txt
new file mode 100644
index 0000000..b183738
--- /dev/null
+++ b/doc/device-tree-bindings/regulator/fan53555.txt
@@ -0,0 +1,23 @@
+Binding for Fairchild FAN53555 regulators
+
+Required properties:
+ - compatible: "fcs,fan53555"
+ - reg: I2C address
+
+Optional properties:
+ - fcs,suspend-voltage-selector: declare which of the two available
+ voltage selector registers should be used for the suspend
+ voltage. The other one is used for the runtime voltage setting
+ Possible values are either <0> or <1>
+ - vin-supply: regulator supplying the vin pin
+
+Example:
+
+ regulator@40 {
+ compatible = "fcs,fan53555";
+ regulator-name = "fan53555";
+ regulator-min-microvolt = <1000000>;
+ regulator-max-microvolt = <1800000>;
+ vin-supply = <&parent_reg>;
+ fcs,suspend-voltage-selector = <1>;
+ };
diff --git a/drivers/power/regulator/Kconfig b/drivers/power/regulator/Kconfig
index 8892fa1..c26a765 100644
--- a/drivers/power/regulator/Kconfig
+++ b/drivers/power/regulator/Kconfig
@@ -69,6 +69,20 @@ config DM_REGULATOR_MAX77686
features for REGULATOR MAX77686. The driver implements get/set api for:
value, enable and mode.
+config DM_REGULATOR_FAN53555
+ bool "Enable Driver Model for REGULATOR FAN53555"
+ depends on DM_REGULATOR && DM_I2C
+ ---help---
+ This config enables implementation of driver-model regulator uclass
+ features for the FAN53555 regulator. The FAN53555 is a (family of)
+ single-output regulators that supports transitioning between two
+ different output voltages based on an voltage selection pin.
+
+ The driver implements a get/set api for the voltage of the 'normal
+ mode' voltage only. Switching to 'suspend mode' (i.e. the alternate
+ voltage), disabling output via software, or switching the mode is
+ not supported by this driver (at this time).
+
config DM_REGULATOR_FIXED
bool "Enable Driver Model for REGULATOR Fixed value"
depends on DM_REGULATOR
diff --git a/drivers/power/regulator/Makefile b/drivers/power/regulator/Makefile
index 6c149a9..21040ea 100644
--- a/drivers/power/regulator/Makefile
+++ b/drivers/power/regulator/Makefile
@@ -11,6 +11,7 @@ obj-$(CONFIG_REGULATOR_AS3722) += as3722_regulator.o
obj-$(CONFIG_DM_REGULATOR_MAX77686) += max77686.o
obj-$(CONFIG_DM_REGULATOR_PFUZE100) += pfuze100.o
obj-$(CONFIG_REGULATOR_PWM) += pwm_regulator.o
+obj-$(CONFIG_$(SPL_)DM_REGULATOR_FAN53555) += fan53555.o
obj-$(CONFIG_$(SPL_)DM_REGULATOR_FIXED) += fixed.o
obj-$(CONFIG_$(SPL_)DM_REGULATOR_GPIO) += gpio-regulator.o
obj-$(CONFIG_REGULATOR_RK8XX) += rk8xx.o
diff --git a/drivers/power/regulator/fan53555.c b/drivers/power/regulator/fan53555.c
new file mode 100644
index 0000000..297e53f
--- /dev/null
+++ b/drivers/power/regulator/fan53555.c
@@ -0,0 +1,262 @@
+/*
+ * (C) 2017 Theobroma Systems Design und Consulting GmbH
+ *
+ * SPDX-License-Identifier: GPL-2.0+
+ */
+
+#include <common.h>
+#include <bitfield.h>
+#include <errno.h>
+#include <dm.h>
+#include <fdtdec.h>
+#include <i2c.h>
+#include <asm/gpio.h>
+#include <power/pmic.h>
+#include <power/regulator.h>
+
+DECLARE_GLOBAL_DATA_PTR;
+
+/**
+ * struct ic_types - definition of fan53555-family devices
+ *
+ * @die_id: Identifies the DIE_ID (lower nibble of the ID1 register)
+ * @die_rev: Identifies the DIE_REV (lower nibble of the ID2 register)
+ * @vsel_min: starting voltage (step 0) in uV
+ * @vsel_step: increment of the voltage in uV
+ *
+ * The voltage ramp (i.e. minimum voltage and step) is selected from the
+ * combination of 2 nibbles: DIE_ID and DIE_REV.
+ *
+ * See http://www.onsemi.com/pub/Collateral/FAN53555-D.pdf for details.
+ */
+static const struct {
+ u8 die_id;
+ u8 die_rev;
+ u32 vsel_min;
+ u32 vsel_step;
+} ic_types[] = {
+ { 0x0, 0x3, 600000, 10000 }, /* Option 00 */
+ { 0x0, 0xf, 800000, 10000 }, /* Option 13 */
+ { 0x0, 0xc, 600000, 12500 }, /* Option 23 */
+ { 0x1, 0x3, 600000, 10000 }, /* Option 01 */
+ { 0x3, 0x3, 600000, 10000 }, /* Option 03 */
+ { 0x4, 0xf, 603000, 12826 }, /* Option 04 */
+ { 0x5, 0x3, 600000, 10000 }, /* Option 05 */
+ { 0x8, 0x1, 600000, 10000 }, /* Option 08 */
+ { 0x8, 0xf, 600000, 10000 }, /* Option 08 */
+ { 0xc, 0xf, 603000, 12826 }, /* Option 09 */
+};
+
+/* I2C-accessible byte-sized registers */
+enum {
+ /* Voltage setting */
+ FAN53555_VSEL0 = 0x00,
+ FAN53555_VSEL1,
+ /* Control register */
+ FAN53555_CONTROL,
+ /* IC Type */
+ FAN53555_ID1,
+ /* IC mask version */
+ FAN53555_ID2,
+ /* Monitor register */
+ FAN53555_MONITOR,
+};
+
+struct fan53555_platdata {
+ /* Voltage setting register */
+ unsigned int vol_reg;
+ unsigned int sleep_reg;
+
+};
+
+struct fan53555_priv {
+ /* IC Vendor */
+ unsigned int vendor;
+ /* IC Type and Rev */
+ unsigned int die_id;
+ unsigned int die_rev;
+ /* Voltage range and step(linear) */
+ unsigned int vsel_min;
+ unsigned int vsel_step;
+ /* Voltage slew rate limiting */
+ unsigned int slew_rate;
+ /* Sleep voltage cache */
+ unsigned int sleep_vol_cache;
+};
+
+static int fan53555_write(struct udevice *dev, uint reg, u8 *buff, int len)
+{
+ int ret;
+
+ ret = dm_i2c_write(dev, reg, buff, len);
+ if (ret) {
+ debug("%s: %s() failed to read reg %d\n",
+ dev->name, __func__, reg);
+ return ret;
+ }
+
+ return 0;
+}
+
+static int fan53555_read(struct udevice *dev, uint reg, u8 *buff, int len)
+{
+ int ret;
+
+ ret = dm_i2c_read(dev, reg, buff, len);
+ if (ret) {
+ debug("%s: %s() failed to read reg %d\n",
+ dev->name, __func__, reg);
+ return ret;
+ }
+
+ return 0;
+}
+
+static int fan53555_regulator_ofdata_to_platdata(struct udevice *dev)
+{
+ struct fan53555_platdata *dev_pdata = dev_get_platdata(dev);
+ struct dm_regulator_uclass_platdata *uc_pdata =
+ dev_get_uclass_platdata(dev);
+ u32 sleep_vsel;
+
+ /* This is a buck regulator */
+ uc_pdata->type = REGULATOR_TYPE_BUCK;
+
+ sleep_vsel = dev_read_u32_default(dev, "fcs,suspend-voltage-selector",
+ FAN53555_VSEL1);
+
+ /*
+ * Depending on the device-tree settings, the 'normal mode'
+ * voltage is either controlled by VSEL0 or VSEL1.
+ */
+ switch (sleep_vsel) {
+ case FAN53555_VSEL0:
+ dev_pdata->sleep_reg = FAN53555_VSEL0;
+ dev_pdata->vol_reg = FAN53555_VSEL1;
+ break;
+ case FAN53555_VSEL1:
+ dev_pdata->sleep_reg = FAN53555_VSEL1;
+ dev_pdata->vol_reg = FAN53555_VSEL0;
+ break;
+ default:
+ pr_err("%s: invalid vsel id %d\n", dev->name, sleep_vsel);
+ return -EINVAL;
+ }
+
+ return 0;
+}
+
+static int fan53555_regulator_get_value(struct udevice *dev)
+{
+ struct fan53555_platdata *pdata = dev_get_platdata(dev);
+ struct fan53555_priv *priv = dev_get_priv(dev);
+ u8 vol;
+ int voltage;
+ int ret;
+
+ /* We only support a single voltage selector (i.e. 'normal' mode). */
+ ret = fan53555_read(dev, pdata->vol_reg, &vol, 1);
+ if (ret)
+ return ret;
+ voltage = priv->vsel_min + (vol & 0x3f) * priv->vsel_step;
+
+ debug("%s: %d uV\n", __func__, voltage);
+ return voltage;
+}
+
+static int fan53555_regulator_set_value(struct udevice *dev, int uV)
+{
+ struct fan53555_platdata *pdata = dev_get_platdata(dev);
+ struct fan53555_priv *priv = dev_get_priv(dev);
+ u8 vol, oldbits, newbits;
+ int ret = 0;
+
+ vol = (uV - priv->vsel_min) / priv->vsel_step;
+ ret = fan53555_read(dev, pdata->vol_reg, &oldbits, 1);
+ if (ret)
+ return ret;
+ newbits = bitfield_replace(oldbits, 0, 6, vol);
+ ret = fan53555_write(dev, pdata->vol_reg, &newbits, 1);
+
+ debug("%s: uV=%d; reg %d: %02x -> %02x\n",
+ __func__, uV, pdata->vol_reg, oldbits, newbits);
+
+ return ret;
+}
+
+static int fan53555_voltages_setup(struct udevice *dev)
+{
+ struct fan53555_priv *priv = dev_get_priv(dev);
+ int i;
+
+ /* Init voltage range and step */
+ for (i = 0; i < ARRAY_SIZE(ic_types); ++i) {
+ if (ic_types[i].die_id != priv->die_id)
+ continue;
+
+ if (ic_types[i].die_rev != priv->die_rev)
+ continue;
+
+ priv->vsel_min = ic_types[i].vsel_min;
+ priv->vsel_step = ic_types[i].vsel_step;
+
+ return 0;
+ }
+
+ pr_err("%s: %s: die id %d rev %d not supported!\n",
+ dev->name, __func__, priv->die_id, priv->die_rev);
+ return -EINVAL;
+}
+
+enum {
+ DIE_ID_SHIFT = 0,
+ DIE_ID_WIDTH = 4,
+ DIE_REV_SHIFT = 0,
+ DIE_REV_WIDTH = 4,
+};
+
+static int fan53555_probe(struct udevice *dev)
+{
+ struct fan53555_priv *priv = dev_get_priv(dev);
+ u8 id[2];
+ int ret;
+
+ /* read chip ID1 and ID2 (two registers, starting at ID1) */
+ ret = fan53555_read(dev, FAN53555_ID1, &id[0], 2);
+ if (ret)
+ return ret;
+
+ /* extract vendor, die_id and die_rev */
+ priv->vendor = bitfield_extract(id[0], 5, 3);
+ priv->die_id = id[0] & GENMASK(3, 0);
+ priv->die_rev = id[1] & GENMASK(3, 0);
+
+ if (fan53555_voltages_setup(dev) < 0)
+ return -ENODATA;
+
+ debug("%s: FAN53555 option %d rev %d detected\n",
+ __func__, priv->die_id, priv->die_rev);
+
+ return 0;
+}
+
+static const struct dm_regulator_ops fan53555_regulator_ops = {
+ .get_value = fan53555_regulator_get_value,
+ .set_value = fan53555_regulator_set_value,
+};
+
+static const struct udevice_id fan53555_regulator_ids[] = {
+ { .compatible = "fcs,fan53555" },
+ { },
+};
+
+U_BOOT_DRIVER(fan53555_regulator) = {
+ .name = "fan53555 regulator",
+ .id = UCLASS_REGULATOR,
+ .ops = &fan53555_regulator_ops,
+ .of_match = fan53555_regulator_ids,
+ .ofdata_to_platdata = fan53555_regulator_ofdata_to_platdata,
+ .platdata_auto_alloc_size = sizeof(struct fan53555_platdata),
+ .priv_auto_alloc_size = sizeof(struct fan53555_priv),
+ .probe = fan53555_probe,
+};
From patchwork Sun Nov 26 20:45:56 2017
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Subject: [U-Boot, v4,
2/2] rockchip: defconfig: puma-rk3399: enable FAN53555 regulator
driver
X-Patchwork-Submitter: "Dr. Philipp Tomsich"
<philipp.tomsich@theobroma-systems.com>
X-Patchwork-Id: 841424
X-Patchwork-Delegate: philipp.tomsich@theobroma-systems.com
Message-Id: <1511729156-30197-2-git-send-email-philipp.tomsich@theobroma-systems.com>
To: u-boot@lists.denx.de
Cc: Klaus Goger <klaus.goger@theobroma-systems.com>
Date: Sun, 26 Nov 2017 21:45:56 +0100
From: Philipp Tomsich <philipp.tomsich@theobroma-systems.com>
List-Id: U-Boot discussion <u-boot.lists.denx.de>
With a driver for the FAN53555 regulator family available, let's
enable it for the RK3399-Q7 (which has two of these devices
on-module).
We enable this for the full U-Boot stage only, as these regulators
provide a suitable default voltage and supply non-critical (i.e.
for booting up) power rails only.
Signed-off-by: Philipp Tomsich <philipp.tomsich@theobroma-systems.com>
---
Changes in v4: None
Changes in v3: None
Changes in v2: None
configs/puma-rk3399_defconfig | 1 +
1 file changed, 1 insertion(+)
diff --git a/configs/puma-rk3399_defconfig b/configs/puma-rk3399_defconfig
index ebbf8a9..233c15a 100644
--- a/configs/puma-rk3399_defconfig
+++ b/configs/puma-rk3399_defconfig
@@ -67,6 +67,7 @@ CONFIG_PINCTRL_ROCKCHIP_RK3399=y
CONFIG_DM_PMIC=y
CONFIG_PMIC_RK8XX=y
CONFIG_SPL_DM_REGULATOR=y
+CONFIG_DM_REGULATOR_FAN53555=y
CONFIG_DM_REGULATOR_FIXED=y
CONFIG_SPL_DM_REGULATOR_FIXED=y
CONFIG_DM_REGULATOR_GPIO=y

View file

@ -13,13 +13,18 @@
{ 0x8, 0xf, 600000, 10000 }, /* Option 08 */
{ 0xc, 0xf, 603000, 12826 }, /* Option 09 */
+ // Silergy vendor parts
+ { 0x7, 0xf, 712500, 12500 }, // silergy827/828
+ { 0x7, 0x7, 712500, 12500 }, // silergy827/828
};
/* I2C-accessible byte-sized registers */
@@ -247,6 +250,8 @@
diff --git a/drivers/power/pmic/fan53555.c b/drivers/power/pmic/fan53555.c
index 1ca59c5..cbf740e 100644
--- a/drivers/power/pmic/fan53555.c
+++ b/drivers/power/pmic/fan53555.c
@@ -70,6 +70,8 @@ static struct dm_pmic_ops pmic_fan53555_ops = {
static const struct udevice_id fan53555_regulator_ids[] = {
static const struct udevice_id pmic_fan53555_match[] = {
{ .compatible = "fcs,fan53555" },
+ { .compatible = "silergy,syr827" },
+ { .compatible = "silergy,syr828" },

View file

@ -1,6 +1,6 @@
--- /dev/null
+++ b/arch/arm/dts/rk3288-xt-q8l-v10.dts 2018-09-23 12:59:27.000000000 +0000
@@ -0,0 +1,740 @@
+++ b/arch/arm/dts/rk3288-xt-q8l-v10.dts 2019-08-03 13:57:27.064767599 +0000
@@ -0,0 +1,732 @@
+/*
+ * Copyright (c) 2014, 2015 FUKAUMI Naoki <naobsd@gmail.com>
+ * 2018 Paolo Sabatino <paolo.sabatino@gm**l.com>
@ -180,31 +180,23 @@
+ vcc_host_5v: usb-host-regulator {
+ compatible = "regulator-fixed";
+ gpio = <&gpio0 14 GPIO_ACTIVE_HIGH>;
+ pinctrl-names = "default";
+ pinctrl-0 = <&host_vbus_drv>;
+ regulator-name = "vcc_host_5v";
+ regulator-min-microvolt = <5000000>;
+ regulator-max-microvolt = <5000000>;
+ regulator-always-on;
+ regulator-boot-on;
+ enable-active-high;
+ startup-delay-us = <1000>;
+ regulator-boot-on;
+ enable-active-high;
+ vin-supply = <&vcc_sys>;
+ };
+
+
+ vcc_otg_5v: usb-otg-regulator {
+ compatible = "regulator-fixed";
+ enable-active-high;
+ gpio = <&gpio0 12 GPIO_ACTIVE_HIGH>;
+ pinctrl-names = "default";
+ pinctrl-0 = <&otg_vbus_drv>;
+ regulator-name = "vcc_otg_5v";
+ regulator-min-microvolt = <5000000>;
+ regulator-max-microvolt = <5000000>;
+ startup-delay-us = <1000>;
+ regulator-always-on;
+ regulator-boot-on;
+ enable-active-high;
+ vin-supply = <&vcc_sys>;
+ };
+