mirror of
https://github.com/archr-linux/Arch-R.git
synced 2026-03-31 14:41:55 -07:00
RK3566 port to 6.17
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -61,7 +61,7 @@
|
||||
# for a list of additional drivers see packages/linux-drivers
|
||||
# Space separated list is supported,
|
||||
# e.g. ADDITIONAL_DRIVERS="DRIVER1 DRIVER2"
|
||||
ADDITIONAL_DRIVERS="RTL8812AU RTL8814AU RTL8821AU RTL8821CU RTL88x2BU RTL8851BU RTL8733BU mali-bifrost"
|
||||
ADDITIONAL_DRIVERS="RTL8821CU mali-bifrost"
|
||||
|
||||
# Additional Firmware to use ( )
|
||||
# Space separated list is supported,
|
||||
|
||||
@@ -4,24 +4,22 @@ Date: Tue, 16 Apr 2024 02:28:56 +0300
|
||||
Subject: [PATCH] arm64: dts: rockchip: add support for mali bifrost driver
|
||||
|
||||
---
|
||||
arch/arm64/boot/dts/rockchip/rk356x.dtsi | 15 ++++++++++++++-
|
||||
arch/arm64/boot/dts/rockchip/rk356x-base.dtsi | 15 ++++++++++++++-
|
||||
1 file changed, 14 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/arch/arm64/boot/dts/rockchip/rk356x.dtsi b/arch/arm64/boot/dts/rockchip/rk356x.dtsi
|
||||
index 0ee0ada6f0ab..6ef97c2802c3 100644
|
||||
--- a/arch/arm64/boot/dts/rockchip/rk356x.dtsi
|
||||
+++ b/arch/arm64/boot/dts/rockchip/rk356x.dtsi
|
||||
@@ -628,10 +628,23 @@ gpu: gpu@fde60000 {
|
||||
diff --git a/arch/arm64/boot/dts/rockchip/rk356x-base.dtsi b/arch/arm64/boot/dts/rockchip/rk356x-base.dtsi
|
||||
index fd2214b6fad4..dd1bd1401985 100644
|
||||
--- a/arch/arm64/boot/dts/rockchip/rk356x-base.dtsi
|
||||
+++ b/arch/arm64/boot/dts/rockchip/rk356x-base.dtsi
|
||||
@@ -559,9 +559,22 @@ gpu: gpu@fde60000 {
|
||||
interrupt-names = "job", "mmu", "gpu";
|
||||
clocks = <&scmi_clk 1>, <&cru CLK_GPU>;
|
||||
clock-names = "gpu", "bus";
|
||||
+ resets = <&cru SRST_GPU>;
|
||||
#cooling-cells = <2>;
|
||||
operating-points-v2 = <&gpu_opp_table>;
|
||||
power-domains = <&power RK3568_PD_GPU>;
|
||||
- status = "disabled";
|
||||
status = "disabled";
|
||||
+ power_policy = "always_on";
|
||||
+ status = "disabled";
|
||||
+ power_model@0 {
|
||||
+ compatible = "arm,mali-simple-power-model";
|
||||
+ static-coefficient = <100000>;
|
||||
@@ -36,6 +34,3 @@ index 0ee0ada6f0ab..6ef97c2802c3 100644
|
||||
};
|
||||
|
||||
vpu: video-codec@fdea0400 {
|
||||
--
|
||||
2.34.1
|
||||
|
||||
|
||||
@@ -1,66 +0,0 @@
|
||||
From d250a94a8156b31c64fe0cde62f245ddac440e4d Mon Sep 17 00:00:00 2001
|
||||
From: spycat88 <spycat88@users.noreply.github.com>
|
||||
Date: Mon, 29 Apr 2024 16:20:23 +0100
|
||||
Subject: [PATCH] arm64: dts: rockchip: add device tree for powkiddy rgb20sx
|
||||
|
||||
---
|
||||
.../dts/rockchip/rk3566-powkiddy-rgb20sx.dts | 47 +++++++++++++++++++
|
||||
1 file changed, 47 insertions(+)
|
||||
create mode 100644 arch/arm64/boot/dts/rockchip/rk3566-powkiddy-rgb20sx.dts
|
||||
|
||||
diff --git a/arch/arm64/boot/dts/rockchip/rk3566-powkiddy-rgb20sx.dts b/arch/arm64/boot/dts/rockchip/rk3566-powkiddy-rgb20sx.dts
|
||||
new file mode 100644
|
||||
index 000000000000..ed7439d1b806
|
||||
--- /dev/null
|
||||
+++ b/arch/arm64/boot/dts/rockchip/rk3566-powkiddy-rgb20sx.dts
|
||||
@@ -0,0 +1,47 @@
|
||||
+// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
|
||||
+/*
|
||||
+ * Copyright (c) 2024 ROCKNIX (https://github.com/ROCKNIX)
|
||||
+ */
|
||||
+
|
||||
+/dts-v1/;
|
||||
+
|
||||
+#include "rk3566-powkiddy-rgb30.dts"
|
||||
+
|
||||
+/ {
|
||||
+ compatible = "powkiddy,rgb20sx", "rockchip,rk3566";
|
||||
+ model = "Powkiddy RGB20SX";
|
||||
+
|
||||
+ adc_keys: adc-keys {
|
||||
+ compatible = "adc-keys";
|
||||
+ io-channels = <&saradc 0>;
|
||||
+ io-channel-names = "buttons";
|
||||
+ keyup-threshold-microvolt = <1800000>;
|
||||
+ poll-interval = <60>;
|
||||
+
|
||||
+ button-mode {
|
||||
+ label = "MODE";
|
||||
+ linux,code = <BTN_MODE>;
|
||||
+ press-threshold-microvolt = <1750>;
|
||||
+ };
|
||||
+ };
|
||||
+};
|
||||
+
|
||||
+/delete-node/ &vdd_cpu;
|
||||
+
|
||||
+&i2c0 {
|
||||
+ vdd_cpu: regulator@40 {
|
||||
+ compatible = "fcs,fan53555";
|
||||
+ reg = <0x40>;
|
||||
+ fcs,suspend-voltage-selector = <1>;
|
||||
+ regulator-always-on;
|
||||
+ regulator-boot-on;
|
||||
+ regulator-min-microvolt = <712500>;
|
||||
+ regulator-max-microvolt = <1390000>;
|
||||
+ regulator-name = "vdd_cpu";
|
||||
+ regulator-ramp-delay = <2300>;
|
||||
+ vin-supply = <&vcc_sys>;
|
||||
+ regulator-state-mem {
|
||||
+ regulator-off-in-suspend;
|
||||
+ };
|
||||
+ };
|
||||
+};
|
||||
--
|
||||
2.34.1
|
||||
|
||||
@@ -1,37 +0,0 @@
|
||||
From 80206c7cad1e0710d73dde47e3f91031f3b3f89e Mon Sep 17 00:00:00 2001
|
||||
From: Paul Reioux <reioux@gmail.com>
|
||||
Date: Tue, 4 Jun 2024 00:01:21 -0700
|
||||
Subject: [PATCH] arm64: dts: rockchip: change GPU to coarse_demand to enable
|
||||
more runtime energy savings
|
||||
|
||||
and clean up GPU related dts settings
|
||||
|
||||
Signed-off-by: Paul Reioux <reioux@gmail.com>
|
||||
---
|
||||
arch/arm64/boot/dts/rockchip/rk356x.dtsi | 6 +++---
|
||||
1 file changed, 3 insertions(+), 3 deletions(-)
|
||||
|
||||
diff --git a/arch/arm64/boot/dts/rockchip/rk356x.dtsi b/arch/arm64/boot/dts/rockchip/rk356x.dtsi
|
||||
index 6ef97c2802c3..415ff216402b 100644
|
||||
--- a/arch/arm64/boot/dts/rockchip/rk356x.dtsi
|
||||
+++ b/arch/arm64/boot/dts/rockchip/rk356x.dtsi
|
||||
@@ -626,13 +626,13 @@ gpu: gpu@fde60000 {
|
||||
<GIC_SPI 41 IRQ_TYPE_LEVEL_HIGH>,
|
||||
<GIC_SPI 39 IRQ_TYPE_LEVEL_HIGH>;
|
||||
interrupt-names = "job", "mmu", "gpu";
|
||||
- clocks = <&scmi_clk 1>, <&cru CLK_GPU>;
|
||||
- clock-names = "gpu", "bus";
|
||||
+ clocks = <&cru CLK_GPU>;
|
||||
+ clock-names = "gpu";
|
||||
resets = <&cru SRST_GPU>;
|
||||
#cooling-cells = <2>;
|
||||
operating-points-v2 = <&gpu_opp_table>;
|
||||
power-domains = <&power RK3568_PD_GPU>;
|
||||
- power_policy = "always_on";
|
||||
+ power_policy = "coarse_demand";
|
||||
status = "disabled";
|
||||
power_model@0 {
|
||||
compatible = "arm,mali-simple-power-model";
|
||||
--
|
||||
2.34.1
|
||||
|
||||
@@ -7,10 +7,10 @@ Subject: [PATCH] arm64: dts: rockchip: fix missing dma-names
|
||||
arch/arm64/boot/dts/rockchip/rk356x.dtsi | 1 +
|
||||
1 file changed, 1 insertion(+)
|
||||
|
||||
diff --git a/arch/arm64/boot/dts/rockchip/rk356x.dtsi b/arch/arm64/boot/dts/rockchip/rk356x.dtsi
|
||||
diff --git a/arch/arm64/boot/dts/rockchip/rk356x.dtsi b/arch/arm64/boot/dts/rockchip/rk356x-base.dtsi
|
||||
index 415ff216402b..c06351da0942 100644
|
||||
--- a/arch/arm64/boot/dts/rockchip/rk356x.dtsi
|
||||
+++ b/arch/arm64/boot/dts/rockchip/rk356x.dtsi
|
||||
--- a/arch/arm64/boot/dts/rockchip/rk356x-base.dtsi
|
||||
+++ b/arch/arm64/boot/dts/rockchip/rk356x-base.dtsi
|
||||
@@ -1412,6 +1412,7 @@ uart1: serial@fe650000 {
|
||||
clocks = <&cru SCLK_UART1>, <&cru PCLK_UART1>;
|
||||
clock-names = "baudclk", "apb_pclk";
|
||||
|
||||
@@ -6,13 +6,13 @@ Subject: [PATCH] arm64: dts: rockchip: rk3568: Add otp device node
|
||||
Signed-off-by: Finley Xiao <finley.xiao@rock-chips.com>
|
||||
Change-Id: I4ec51ba8d4e1381f787c0137cb475a21e546789d
|
||||
---
|
||||
arch/arm64/boot/dts/rockchip/rk356x.dtsi | 41 ++++++++++++++++++++++++
|
||||
arch/arm64/boot/dts/rockchip/rk356x-base.dtsi | 41 ++++++++++++++++++++++++
|
||||
1 file changed, 41 insertions(+)
|
||||
|
||||
diff --git a/arch/arm64/boot/dts/rockchip/rk356x.dtsi b/arch/arm64/boot/dts/rockchip/rk356x.dtsi
|
||||
diff --git a/arch/arm64/boot/dts/rockchip/rk356x-base.dtsi b/arch/arm64/boot/dts/rockchip/rk356x-base.dtsi
|
||||
index c06351da0942..938df18a81ff 100644
|
||||
--- a/arch/arm64/boot/dts/rockchip/rk356x.dtsi
|
||||
+++ b/arch/arm64/boot/dts/rockchip/rk356x.dtsi
|
||||
--- a/arch/arm64/boot/dts/rockchip/rk356x-base.dtsi
|
||||
+++ b/arch/arm64/boot/dts/rockchip/rk356x-base.dtsi
|
||||
@@ -895,6 +895,47 @@ hdmi_out: port@1 {
|
||||
};
|
||||
};
|
||||
|
||||
@@ -9,13 +9,13 @@ RG353P device based around the rk3566 SoC.
|
||||
|
||||
Signed-off-by: Chris Morgan <macromorgan@hotmail.com>
|
||||
---
|
||||
arch/arm64/boot/dts/rockchip/rk356x.dtsi | 16 ++++++++++++++++
|
||||
arch/arm64/boot/dts/rockchip/rk356x-base.dtsi | 16 ++++++++++++++++
|
||||
1 file changed, 16 insertions(+)
|
||||
|
||||
diff --git a/arch/arm64/boot/dts/rockchip/rk356x.dtsi b/arch/arm64/boot/dts/rockchip/rk356x.dtsi
|
||||
diff --git a/arch/arm64/boot/dts/rockchip/rk356x-base.dtsi b/arch/arm64/boot/dts/rockchip/rk356x-base.dtsi
|
||||
index 938df18a81ff..cd08110720f5 100644
|
||||
--- a/arch/arm64/boot/dts/rockchip/rk356x.dtsi
|
||||
+++ b/arch/arm64/boot/dts/rockchip/rk356x.dtsi
|
||||
--- a/arch/arm64/boot/dts/rockchip/rk356x-base.dtsi
|
||||
+++ b/arch/arm64/boot/dts/rockchip/rk356x-base.dtsi
|
||||
@@ -55,6 +55,7 @@ cpu0: cpu@0 {
|
||||
reg = <0x0 0x0>;
|
||||
clocks = <&scmi_clk 0>;
|
||||
|
||||
@@ -1,221 +0,0 @@
|
||||
From c9d37fdc0aa2cc9ee48d9614cd72ac948cb4a754 Mon Sep 17 00:00:00 2001
|
||||
From: spycat88 <spycat88@users.noreply.github.com>
|
||||
Date: Sat, 4 Jan 2025 21:25:57 +0000
|
||||
Subject: [PATCH] Input: add support for mh248 hall sensor
|
||||
|
||||
---
|
||||
drivers/input/misc/Makefile | 1 +
|
||||
drivers/input/misc/mh248.c | 192 ++++++++++++++++++++++++++++++++++++
|
||||
2 files changed, 193 insertions(+)
|
||||
create mode 100644 drivers/input/misc/mh248.c
|
||||
|
||||
diff --git a/drivers/input/misc/Makefile b/drivers/input/misc/Makefile
|
||||
index 4f7f736831ba..dabe0321b208 100644
|
||||
--- a/drivers/input/misc/Makefile
|
||||
+++ b/drivers/input/misc/Makefile
|
||||
@@ -92,3 +92,4 @@ obj-$(CONFIG_INPUT_WM831X_ON) += wm831x-on.o
|
||||
obj-$(CONFIG_INPUT_XEN_KBDDEV_FRONTEND) += xen-kbdfront.o
|
||||
obj-$(CONFIG_INPUT_YEALINK) += yealink.o
|
||||
obj-$(CONFIG_INPUT_IDEAPAD_SLIDEBAR) += ideapad_slidebar.o
|
||||
+obj-m += mh248.o
|
||||
diff --git a/drivers/input/misc/mh248.c b/drivers/input/misc/mh248.c
|
||||
new file mode 100644
|
||||
index 000000000000..afb58cbc028b
|
||||
--- /dev/null
|
||||
+++ b/drivers/input/misc/mh248.c
|
||||
@@ -0,0 +1,192 @@
|
||||
+/* SPDX-License-Identifier: GPL-2.0 */
|
||||
+/*
|
||||
+ * mh248 hall sensor driver
|
||||
+ *
|
||||
+ * Copyright (C) 2025 ROCKNIX (https://github.com/ROCKNIX)
|
||||
+ */
|
||||
+
|
||||
+#include <linux/module.h>
|
||||
+#include <linux/platform_device.h>
|
||||
+#include <linux/interrupt.h>
|
||||
+#include <linux/gpio/consumer.h>
|
||||
+#include <linux/input.h>
|
||||
+#include <linux/mutex.h>
|
||||
+#include <linux/of.h>
|
||||
+#include <linux/of_device.h>
|
||||
+#include <linux/of_gpio.h>
|
||||
+#include <linux/pm.h>
|
||||
+#include <linux/slab.h>
|
||||
+
|
||||
+struct mh248_para {
|
||||
+ struct device *dev;
|
||||
+ struct input_dev *input;
|
||||
+ struct gpio_desc *gpio_pin;
|
||||
+ struct mutex ops_lock;
|
||||
+ int irq;
|
||||
+ int active_value;
|
||||
+ bool is_suspend;
|
||||
+};
|
||||
+
|
||||
+static irqreturn_t hall_mh248_interrupt(int irq, void *dev_id)
|
||||
+{
|
||||
+ struct mh248_para *mh248 = dev_id;
|
||||
+ int gpio_value;
|
||||
+
|
||||
+ gpio_value = gpiod_get_value(mh248->gpio_pin);
|
||||
+
|
||||
+ if (!mh248->is_suspend) {
|
||||
+ if (gpio_value == mh248->active_value)
|
||||
+ input_report_key(mh248->input, KEY_POWER, 1);
|
||||
+ else
|
||||
+ input_report_key(mh248->input, KEY_POWER, 0);
|
||||
+ input_sync(mh248->input);
|
||||
+ }
|
||||
+
|
||||
+ return IRQ_HANDLED;
|
||||
+}
|
||||
+
|
||||
+#ifdef CONFIG_PM_SLEEP
|
||||
+static int hall_mh248_suspend(struct device *dev)
|
||||
+{
|
||||
+ struct mh248_para *mh248 = dev_get_drvdata(dev);
|
||||
+ int ret;
|
||||
+
|
||||
+ mutex_lock(&mh248->ops_lock);
|
||||
+ mh248->is_suspend = true;
|
||||
+
|
||||
+ /* Enable IRQ as a wakeup source */
|
||||
+ if (device_may_wakeup(dev)) {
|
||||
+ ret = enable_irq_wake(mh248->irq);
|
||||
+ if (ret)
|
||||
+ dev_err(dev, "Failed to enable IRQ wake: %d\n", ret);
|
||||
+ }
|
||||
+ mutex_unlock(&mh248->ops_lock);
|
||||
+
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+static int hall_mh248_resume(struct device *dev)
|
||||
+{
|
||||
+ struct mh248_para *mh248 = dev_get_drvdata(dev);
|
||||
+ int ret;
|
||||
+
|
||||
+ mutex_lock(&mh248->ops_lock);
|
||||
+ mh248->is_suspend = false;
|
||||
+
|
||||
+ /* Disable IRQ wakeup */
|
||||
+ if (device_may_wakeup(dev)) {
|
||||
+ ret = disable_irq_wake(mh248->irq);
|
||||
+ if (ret)
|
||||
+ dev_err(dev, "Failed to disable IRQ wake: %d\n", ret);
|
||||
+ }
|
||||
+ mutex_unlock(&mh248->ops_lock);
|
||||
+
|
||||
+ return 0;
|
||||
+}
|
||||
+#endif
|
||||
+
|
||||
+static int hall_mh248_probe(struct platform_device *pdev)
|
||||
+{
|
||||
+ struct device_node *np = pdev->dev.of_node;
|
||||
+ struct mh248_para *mh248;
|
||||
+ int ret;
|
||||
+
|
||||
+ mh248 = devm_kzalloc(&pdev->dev, sizeof(*mh248), GFP_KERNEL);
|
||||
+ if (!mh248)
|
||||
+ return -ENOMEM;
|
||||
+
|
||||
+ mh248->dev = &pdev->dev;
|
||||
+
|
||||
+ mh248->gpio_pin = devm_gpiod_get(mh248->dev, "irq", GPIOD_IN);
|
||||
+ if (IS_ERR(mh248->gpio_pin)) {
|
||||
+ dev_err(mh248->dev, "Failed to get GPIO\n");
|
||||
+ return PTR_ERR(mh248->gpio_pin);
|
||||
+ }
|
||||
+
|
||||
+ ret = of_property_read_u32(np, "hall-active", &mh248->active_value);
|
||||
+ if (ret) {
|
||||
+ dev_err(mh248->dev, "Failed to read hall-active property\n");
|
||||
+ return ret;
|
||||
+ }
|
||||
+
|
||||
+ mh248->irq = gpiod_to_irq(mh248->gpio_pin);
|
||||
+ if (mh248->irq < 0) {
|
||||
+ dev_err(mh248->dev, "Failed to get IRQ\n");
|
||||
+ return mh248->irq;
|
||||
+ }
|
||||
+
|
||||
+ mutex_init(&mh248->ops_lock);
|
||||
+
|
||||
+ mh248->input = devm_input_allocate_device(mh248->dev);
|
||||
+ if (!mh248->input) {
|
||||
+ dev_err(mh248->dev, "Failed to allocate input device\n");
|
||||
+ return -ENOMEM;
|
||||
+ }
|
||||
+
|
||||
+ mh248->input->name = "mh248 hall sensor";
|
||||
+ mh248->input->id.bustype = BUS_HOST;
|
||||
+ mh248->input->dev.parent = mh248->dev;
|
||||
+ input_set_capability(mh248->input, EV_KEY, KEY_POWER);
|
||||
+
|
||||
+ ret = input_register_device(mh248->input);
|
||||
+ if (ret) {
|
||||
+ dev_err(mh248->dev, "Failed to register input device\n");
|
||||
+ return ret;
|
||||
+ }
|
||||
+
|
||||
+ ret = devm_request_threaded_irq(mh248->dev, mh248->irq, NULL,
|
||||
+ hall_mh248_interrupt,
|
||||
+ IRQF_ONESHOT | IRQF_TRIGGER_RISING |
|
||||
+ IRQF_TRIGGER_FALLING,
|
||||
+ "hall_mh248", mh248);
|
||||
+ if (ret) {
|
||||
+ dev_err(mh248->dev, "Failed to request IRQ\n");
|
||||
+ return ret;
|
||||
+ }
|
||||
+
|
||||
+ device_set_wakeup_capable(&pdev->dev, true);
|
||||
+ device_set_wakeup_enable(&pdev->dev, true);
|
||||
+ platform_set_drvdata(pdev, mh248);
|
||||
+
|
||||
+ dev_info(mh248->dev, "mh248 hall sensor initialized\n");
|
||||
+
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+static void hall_mh248_remove(struct platform_device *pdev)
|
||||
+{
|
||||
+ struct mh248_para *mh248 = platform_get_drvdata(pdev);
|
||||
+
|
||||
+ device_set_wakeup_capable(&pdev->dev, false);
|
||||
+ device_set_wakeup_enable(&pdev->dev, false);
|
||||
+ input_unregister_device(mh248->input);
|
||||
+}
|
||||
+
|
||||
+static const struct of_device_id hall_mh248_match[] = {
|
||||
+ { .compatible = "hall-mh248" },
|
||||
+ { }
|
||||
+};
|
||||
+MODULE_DEVICE_TABLE(of, hall_mh248_match);
|
||||
+
|
||||
+static const struct dev_pm_ops hall_mh248_pm_ops = {
|
||||
+#ifdef CONFIG_PM_SLEEP
|
||||
+ .suspend = hall_mh248_suspend,
|
||||
+ .resume = hall_mh248_resume,
|
||||
+#endif
|
||||
+};
|
||||
+
|
||||
+static struct platform_driver hall_mh248_driver = {
|
||||
+ .probe = hall_mh248_probe,
|
||||
+ .remove_new = hall_mh248_remove,
|
||||
+ .driver = {
|
||||
+ .name = "mh248",
|
||||
+ .of_match_table = hall_mh248_match,
|
||||
+ .pm = &hall_mh248_pm_ops,
|
||||
+ },
|
||||
+};
|
||||
+module_platform_driver(hall_mh248_driver);
|
||||
+
|
||||
+MODULE_ALIAS("platform:mh248");
|
||||
+MODULE_AUTHOR("ROCKNIX (https://github.com/ROCKNIX)");
|
||||
+MODULE_LICENSE("GPL v2");
|
||||
+MODULE_DESCRIPTION("mh248 hall sensor driver");
|
||||
--
|
||||
2.34.1
|
||||
|
||||
@@ -1,31 +0,0 @@
|
||||
--- a/product/kernel/drivers/gpu/arm/midgard/mali_kbase_defs.h 2024-02-19 17:24:21.000000000 +0300
|
||||
+++ b/product/kernel/drivers/gpu/arm/midgard/mali_kbase_defs.h 2024-03-18 23:51:35.201950500 +0300
|
||||
@@ -141,7 +141,7 @@
|
||||
* This is dependent on support for of_property_read_u64_array() in the
|
||||
* kernel.
|
||||
*/
|
||||
-#define BASE_MAX_NR_CLOCKS_REGULATORS (2)
|
||||
+#define BASE_MAX_NR_CLOCKS_REGULATORS (1)
|
||||
|
||||
/* Forward declarations */
|
||||
struct kbase_context;
|
||||
--- a/product/kernel/drivers/gpu/arm/midgard/mali_kbase_core_linux.c 2024-03-19 00:26:38.775395807 +0300
|
||||
+++ b/product/kernel/drivers/gpu/arm/midgard/mali_kbase_core_linux.c 2024-03-19 00:23:39.644058337 +0300
|
||||
@@ -4725,7 +4725,7 @@
|
||||
int err = 0;
|
||||
unsigned int i;
|
||||
#if defined(CONFIG_REGULATOR)
|
||||
- static const char *const regulator_names[] = { "mali", "shadercores" };
|
||||
+ static const char *const regulator_names[] = { "mali", NULL };
|
||||
BUILD_BUG_ON(ARRAY_SIZE(regulator_names) < BASE_MAX_NR_CLOCKS_REGULATORS);
|
||||
#endif /* CONFIG_REGULATOR */
|
||||
|
||||
@@ -4771,7 +4771,7 @@
|
||||
* operating with a partial initialization of clocks.
|
||||
*/
|
||||
for (i = 0; i < BASE_MAX_NR_CLOCKS_REGULATORS; i++) {
|
||||
- kbdev->clocks[i] = of_clk_get(kbdev->dev->of_node, (int)i);
|
||||
+ kbdev->clocks[i] = of_clk_get_by_name(kbdev->dev->of_node, "bus");
|
||||
if (IS_ERR(kbdev->clocks[i])) {
|
||||
err = PTR_ERR(kbdev->clocks[i]);
|
||||
kbdev->clocks[i] = NULL;
|
||||
@@ -1,7 +1,8 @@
|
||||
diff -ur build.ROCKNIX-RK3566.aarch64/mali-bifrost-r48p0-01eac0.orig/product/kernel/drivers/gpu/arm/midgard/mali_kbase_core_linux.c build.ROCKNIX-RK3566.aarch64/mali-bifrost-r48p0-01eac0/product/kernel/drivers/gpu/arm/midgard/mali_kbase_core_linux.c
|
||||
--- mali-bifrost-r48p0-01eac0.orig/product/kernel/drivers/gpu/arm/midgard/mali_kbase_core_linux.c 2024-04-10 00:29:25.679588022 +0300
|
||||
+++ mali-bifrost-r48p0-01eac0/product/kernel/drivers/gpu/arm/midgard/mali_kbase_core_linux.c 2024-04-10 00:33:32.693922486 +0300
|
||||
@@ -548,9 +548,9 @@
|
||||
diff --git a/product/kernel/drivers/gpu/arm/midgard/mali_kbase_core_linux.c b/product/kernel/drivers/gpu/arm/midgard/mali_kbase_core_linux.c
|
||||
index a6e8d66..4f380de 100644
|
||||
--- a/product/kernel/drivers/gpu/arm/midgard/mali_kbase_core_linux.c
|
||||
+++ b/product/kernel/drivers/gpu/arm/midgard/mali_kbase_core_linux.c
|
||||
@@ -440,9 +440,9 @@ static struct kbase_device *to_kbase_device(struct device *dev)
|
||||
static int get_irqs(struct kbase_device *kbdev, struct platform_device *pdev)
|
||||
{
|
||||
int i;
|
||||
@@ -13,7 +14,7 @@ diff -ur build.ROCKNIX-RK3566.aarch64/mali-bifrost-r48p0-01eac0.orig/product/ker
|
||||
struct irq_data *irqdata;
|
||||
int irq;
|
||||
|
||||
@@ -560,11 +560,11 @@
|
||||
@@ -452,11 +452,11 @@ static int get_irqs(struct kbase_device *kbdev, struct platform_device *pdev)
|
||||
* first then try using Lower case names. If both attempts fail then
|
||||
* we assume there is no IRQ resource specified for the GPU.
|
||||
*/
|
||||
|
||||
@@ -1,199 +0,0 @@
|
||||
From 5b1c50b3e181a57f5ce0a7d8c50f0f0823ac1609 Mon Sep 17 00:00:00 2001
|
||||
From: Paul Reioux <reioux@gmail.com>
|
||||
Date: Wed, 12 Jun 2024 07:36:52 -0700
|
||||
Subject: [PATCH] midgard: refactor power init and fixed unbalanced runtime PM
|
||||
calls
|
||||
|
||||
Signed-off-by: Paul Reioux <reioux@gmail.com>
|
||||
---
|
||||
.../gpu/arm/midgard/mali_kbase_core_linux.c | 124 ++++++++++++------
|
||||
.../platform/meson/mali_kbase_runtime_pm.c | 11 +-
|
||||
2 files changed, 88 insertions(+), 47 deletions(-)
|
||||
|
||||
diff --git a/product/kernel/drivers/gpu/arm/midgard/mali_kbase_core_linux.c b/product/kernel/drivers/gpu/arm/midgard/mali_kbase_core_linux.c
|
||||
index 0ad8a70..8db0c13 100644
|
||||
--- a/product/kernel/drivers/gpu/arm/midgard/mali_kbase_core_linux.c
|
||||
+++ b/product/kernel/drivers/gpu/arm/midgard/mali_kbase_core_linux.c
|
||||
@@ -4507,31 +4507,44 @@ int power_control_init(struct kbase_device *kbdev)
|
||||
|
||||
pdev = to_platform_device(kbdev->dev);
|
||||
|
||||
-#if defined(CONFIG_REGULATOR)
|
||||
- /* Since the error code EPROBE_DEFER causes the entire probing
|
||||
- * procedure to be restarted from scratch at a later time,
|
||||
- * all regulators will be released before returning.
|
||||
- *
|
||||
- * Any other error is ignored and the driver will continue
|
||||
- * operating with a partial initialization of regulators.
|
||||
- */
|
||||
- for (i = 0; i < BASE_MAX_NR_CLOCKS_REGULATORS; i++) {
|
||||
- kbdev->regulators[i] = regulator_get_optional(kbdev->dev, regulator_names[i]);
|
||||
- if (IS_ERR(kbdev->regulators[i])) {
|
||||
- err = PTR_ERR(kbdev->regulators[i]);
|
||||
- kbdev->regulators[i] = NULL;
|
||||
- break;
|
||||
- }
|
||||
- }
|
||||
- if (err == -EPROBE_DEFER) {
|
||||
- while (i > 0)
|
||||
- regulator_put(kbdev->regulators[--i]);
|
||||
- return err;
|
||||
+// #if defined(CONFIG_REGULATOR)
|
||||
+// /* Since the error code EPROBE_DEFER causes the entire probing
|
||||
+// * procedure to be restarted from scratch at a later time,
|
||||
+// * all regulators will be released before returning.
|
||||
+// *
|
||||
+// * Any other error is ignored and the driver will continue
|
||||
+// * operating with a partial initialization of regulators.
|
||||
+// */
|
||||
+// for (i = 0; i < BASE_MAX_NR_CLOCKS_REGULATORS; i++) {
|
||||
+// kbdev->regulators[i] = regulator_get_optional(kbdev->dev, regulator_names[i]);
|
||||
+// if (IS_ERR(kbdev->regulators[i])) {
|
||||
+// err = PTR_ERR(kbdev->regulators[i]);
|
||||
+// kbdev->regulators[i] = NULL;
|
||||
+// break;
|
||||
+// }
|
||||
+// }
|
||||
+// if (err == -EPROBE_DEFER) {
|
||||
+// while (i > 0)
|
||||
+// regulator_put(kbdev->regulators[--i]);
|
||||
+// return err;
|
||||
+// }
|
||||
+ kbdev->regulators[0] = devm_regulator_get_optional(kbdev->dev, regulator_names[0]);
|
||||
+
|
||||
+ if (IS_ERR(kbdev->regulators[0])) {
|
||||
+ err = PTR_ERR(kbdev->regulators[0]);
|
||||
+ kbdev->regulators[0] = NULL;
|
||||
+ kbdev->nr_regulators = 0;
|
||||
+ } else {
|
||||
+ kbdev->nr_regulators = 1;
|
||||
+
|
||||
+ err = regulator_enable(kbdev->regulators[0]);
|
||||
+ if (err)
|
||||
+ dev_dbg(&pdev->dev, "regulator_enable failed\n");
|
||||
}
|
||||
|
||||
- kbdev->nr_regulators = i;
|
||||
dev_dbg(&pdev->dev, "Regulators probed: %u\n", kbdev->nr_regulators);
|
||||
-#endif
|
||||
+
|
||||
+// #endif
|
||||
|
||||
/* Having more clocks than regulators is acceptable, while the
|
||||
* opposite shall not happen.
|
||||
@@ -4543,30 +4556,55 @@ int power_control_init(struct kbase_device *kbdev)
|
||||
* Any other error is ignored and the driver will continue
|
||||
* operating with a partial initialization of clocks.
|
||||
*/
|
||||
- for (i = 0; i < BASE_MAX_NR_CLOCKS_REGULATORS; i++) {
|
||||
- kbdev->clocks[i] = of_clk_get_by_name(kbdev->dev->of_node, "bus");
|
||||
- if (IS_ERR(kbdev->clocks[i])) {
|
||||
- err = PTR_ERR(kbdev->clocks[i]);
|
||||
- kbdev->clocks[i] = NULL;
|
||||
- break;
|
||||
- }
|
||||
|
||||
- err = clk_prepare_enable(kbdev->clocks[i]);
|
||||
- if (err) {
|
||||
- dev_err(kbdev->dev, "Failed to prepare and enable clock (%d)\n", err);
|
||||
- clk_put(kbdev->clocks[i]);
|
||||
- break;
|
||||
- }
|
||||
- }
|
||||
- if (err == -EPROBE_DEFER) {
|
||||
- while (i > 0) {
|
||||
- clk_disable_unprepare(kbdev->clocks[--i]);
|
||||
- clk_put(kbdev->clocks[i]);
|
||||
- }
|
||||
- goto clocks_probe_defer;
|
||||
+ kbdev->clocks[0] = devm_clk_get_optional(kbdev->dev, NULL);
|
||||
+ if (!IS_ERR(kbdev->clocks[0]))
|
||||
+ dev_dbg(kbdev->dev, "clk_get: %s\n", __clk_get_name(kbdev->clocks[0]));
|
||||
+ else
|
||||
+ dev_err(kbdev->dev, "clk_get: is NULL");
|
||||
+
|
||||
+ /* if platform device is enabled, disable it now */
|
||||
+ //if (__clk_is_enabled(kbdev->clocks[0])) {
|
||||
+ // clk_disable(kbdev->clocks[0]);
|
||||
+ //}
|
||||
+ /* delete from clk tree */
|
||||
+ //clk_unprepare(kbdev->clocks[0]);
|
||||
+ //clk_put(kbdev->clocks[0]);
|
||||
+
|
||||
+ /* now grab the gpu clock node from device tree definition */
|
||||
+ //kbdev->clocks[0] = of_clk_get_by_name(kbdev->dev->of_node, "gpu");
|
||||
+
|
||||
+ /* we are kinda commited here.. if this fails, the system will lock up */
|
||||
+ err = clk_prepare_enable(kbdev->clocks[0]);
|
||||
+ if (err) {
|
||||
+ dev_err(kbdev->dev, "Failed to prepare and enable clock (%d)\n", err);
|
||||
+ clk_put(kbdev->clocks[0]);
|
||||
}
|
||||
|
||||
- kbdev->nr_clocks = i;
|
||||
+ // for (i = 0; i < BASE_MAX_NR_CLOCKS_REGULATORS; i++) {
|
||||
+ // kbdev->clocks[i] = of_clk_get(kbdev->dev->of_node, (int)i);
|
||||
+ // if (IS_ERR(kbdev->clocks[i])) {
|
||||
+ // err = PTR_ERR(kbdev->clocks[i]);
|
||||
+ // kbdev->clocks[i] = NULL;
|
||||
+ // break;
|
||||
+ // }
|
||||
+
|
||||
+ // err = clk_prepare_enable(kbdev->clocks[i]);
|
||||
+ // if (err) {
|
||||
+ // dev_err(kbdev->dev, "Failed to prepare and enable clock (%d)\n", err);
|
||||
+ // clk_put(kbdev->clocks[i]);
|
||||
+ // break;
|
||||
+ // }
|
||||
+ // }
|
||||
+ // if (err == -EPROBE_DEFER) {
|
||||
+ // while (i > 0) {
|
||||
+ // clk_disable_unprepare(kbdev->clocks[--i]);
|
||||
+ // clk_put(kbdev->clocks[i]);
|
||||
+ // }
|
||||
+ // goto clocks_probe_defer;
|
||||
+ // }
|
||||
+
|
||||
+ kbdev->nr_clocks = 1;
|
||||
dev_dbg(&pdev->dev, "Clocks probed: %u\n", kbdev->nr_clocks);
|
||||
|
||||
/* Any error in parsing the OPP table from the device file
|
||||
diff --git a/product/kernel/drivers/gpu/arm/midgard/platform/meson/mali_kbase_runtime_pm.c b/product/kernel/drivers/gpu/arm/midgard/platform/meson/mali_kbase_runtime_pm.c
|
||||
index bd3b4b5..33a24bb 100644
|
||||
--- a/product/kernel/drivers/gpu/arm/midgard/platform/meson/mali_kbase_runtime_pm.c
|
||||
+++ b/product/kernel/drivers/gpu/arm/midgard/platform/meson/mali_kbase_runtime_pm.c
|
||||
@@ -113,7 +113,8 @@ static void enable_gpu_power_control(struct kbase_device *kbdev)
|
||||
if (WARN_ON(kbdev->clocks[i] == NULL))
|
||||
;
|
||||
else if (!__clk_is_enabled(kbdev->clocks[i]))
|
||||
- WARN_ON(clk_prepare_enable(kbdev->clocks[i]));
|
||||
+ //WARN_ON(clk_prepare_enable(kbdev->clocks[i]));
|
||||
+ ;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -125,8 +126,9 @@ static void disable_gpu_power_control(struct kbase_device *kbdev)
|
||||
if (WARN_ON(kbdev->clocks[i] == NULL))
|
||||
;
|
||||
else if (__clk_is_enabled(kbdev->clocks[i])) {
|
||||
- clk_disable_unprepare(kbdev->clocks[i]);
|
||||
- WARN_ON(__clk_is_enabled(kbdev->clocks[i]));
|
||||
+ //clk_disable_unprepare(kbdev->clocks[i]);
|
||||
+ //WARN_ON(__clk_is_enabled(kbdev->clocks[i]));
|
||||
+ ;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -135,7 +137,8 @@ static void disable_gpu_power_control(struct kbase_device *kbdev)
|
||||
if (WARN_ON(kbdev->regulators[i] == NULL))
|
||||
;
|
||||
else if (regulator_is_enabled(kbdev->regulators[i]))
|
||||
- WARN_ON(regulator_disable(kbdev->regulators[i]));
|
||||
+ //WARN_ON(regulator_disable(kbdev->regulators[i]));
|
||||
+ ;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
--
|
||||
2.34.1
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
# Copyright (C) 2023 JELOS (https://github.com/JustEnoughLinuxOS)
|
||||
|
||||
PKG_NAME="RTL8821CU"
|
||||
PKG_VERSION="3eacc28b721950b51b0249508cc31e6e54988a0c"
|
||||
PKG_VERSION="3d1fcf4bc838542ceb03b0b4e9e40600720cf6ae"
|
||||
PKG_LICENSE="GPL"
|
||||
PKG_SITE="https://github.com/morrownr/8821cu-20210916"
|
||||
PKG_URL="${PKG_SITE}.git"
|
||||
|
||||
@@ -640,13 +640,9 @@ static void generic_panel_shutdown(struct mipi_dsi_device *dsi)
|
||||
struct generic_panel *ctx = mipi_dsi_get_drvdata(dsi);
|
||||
int ret;
|
||||
|
||||
ret = drm_panel_unprepare(&ctx->panel);
|
||||
if (ret < 0)
|
||||
dev_err(&dsi->dev, "Failed to unprepare panel: %d\n", ret);
|
||||
drm_panel_unprepare(&ctx->panel);
|
||||
|
||||
ret = drm_panel_disable(&ctx->panel);
|
||||
if (ret < 0)
|
||||
dev_err(&dsi->dev, "Failed to disable panel: %d\n", ret);
|
||||
drm_panel_disable(&ctx->panel);
|
||||
}
|
||||
|
||||
static void generic_panel_remove(struct mipi_dsi_device *dsi)
|
||||
|
||||
@@ -2,25 +2,23 @@
|
||||
# Copyright (C) 2023 JELOS (https://github.com/JustEnoughLinuxOS)
|
||||
|
||||
PKG_NAME="mali-bifrost"
|
||||
PKG_VERSION="r52p0-00eac0"
|
||||
PKG_LICENSE="GPL"
|
||||
PKG_SITE="https://developer.arm.com/downloads/-/mali-drivers/bifrost-kernel"
|
||||
#PKG_URL="https://developer.arm.com/-/media/Files/downloads/mali-drivers/kernel/mali-bifrost-gpu/BX304L01B-SW-99002-${PKG_VERSION}.tar"
|
||||
PKG_URL="https://developer.arm.com/-/media/Files/downloads/mali-drivers/kernel/mali-valhall-gpu/VX504X08X-SW-99002-${PKG_VERSION}.tar"
|
||||
PKG_LONGDESC="mali-bifrost: Linux drivers for Mali Bifrost GPUs"
|
||||
PKG_TOOLCHAIN="manual"
|
||||
PKG_IS_KERNEL_PKG="yes"
|
||||
|
||||
if [ "${DEVICE}" = "S922X" ]; then
|
||||
# For S922X use sydarn's ported driver, no patches required for build
|
||||
PKG_VERSION="f86d3dd4923b5d5de11ae7eaf7a6c4fee136528e" # BX304L01B-SW-99002-r54p1-12eac0
|
||||
PKG_SITE="https://github.com/sydarn/mali_kbase"
|
||||
PKG_URL="${PKG_SITE}.git"
|
||||
PKG_GIT_CLONE_BRANCH="bifrost_port"
|
||||
else
|
||||
# Patches required for build
|
||||
case ${DEVICE} in
|
||||
RK3326)
|
||||
PKG_VERSION="r52p0-00eac0"
|
||||
PKG_URL="https://developer.arm.com/-/media/Files/downloads/mali-drivers/kernel/mali-valhall-gpu/VX504X08X-SW-99002-${PKG_VERSION}.tar"
|
||||
PKG_PATCH_DIRS+=" 6.12-LTS"
|
||||
fi
|
||||
;;
|
||||
*)
|
||||
PKG_VERSION="f86d3dd4923b5d5de11ae7eaf7a6c4fee136528e"
|
||||
PKG_URL="http://github.com/sydarn/mali_kbase/archive/${PKG_VERSION}.tar.gz"
|
||||
;;
|
||||
esac
|
||||
|
||||
make_target() {
|
||||
kernel_make KDIR=$(kernel_path) -C ${PKG_BUILD} \
|
||||
|
||||
@@ -31,7 +31,7 @@ case ${DEVICE} in
|
||||
;;
|
||||
*)
|
||||
case ${DEVICE} in
|
||||
S922X|SM8550|SM8250|H700|SM8650)
|
||||
S922X|SM8550|SM8250|H700|SM8650|RK3566)
|
||||
PKG_VERSION="6.17.7"
|
||||
;;
|
||||
*)
|
||||
|
||||
@@ -1,51 +0,0 @@
|
||||
From: Chris Morgan <macroalpha82@gmail.com>
|
||||
To: linux-pm@vger.kernel.org
|
||||
Cc: sre@kernel.org, Chris Morgan <macromorgan@hotmail.com>
|
||||
Subject: [PATCH 1/2] power: supply: rk817: stop updating info in suspend
|
||||
Date: Thu, 26 Sep 2024 09:43:45 -0500 [thread overview]
|
||||
Message-ID: <20240926144346.94630-2-macroalpha82@gmail.com> (raw)
|
||||
In-Reply-To: <20240926144346.94630-1-macroalpha82@gmail.com>
|
||||
|
||||
From: Chris Morgan <macromorgan@hotmail.com>
|
||||
|
||||
The driver has a thread that checks the battery every 8 seconds. Stop
|
||||
this thread during device suspend as while the device is suspended not
|
||||
all values seem to be read correctly (such as battery voltage). The
|
||||
resume function triggers the thread to start again.
|
||||
|
||||
Signed-off-by: Chris Morgan <macromorgan@hotmail.com>
|
||||
---
|
||||
drivers/power/supply/rk817_charger.c | 11 ++++++++++-
|
||||
1 file changed, 10 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/drivers/power/supply/rk817_charger.c b/drivers/power/supply/rk817_charger.c
|
||||
index a3d377a32b49..d81fc7bd1cd2 100644
|
||||
--- a/drivers/power/supply/rk817_charger.c
|
||||
+++ b/drivers/power/supply/rk817_charger.c
|
||||
@@ -1202,6 +1202,15 @@ static int rk817_charger_probe(struct platform_device *pdev)
|
||||
return 0;
|
||||
}
|
||||
|
||||
+static int __maybe_unused rk817_suspend(struct device *dev)
|
||||
+{
|
||||
+ struct rk817_charger *charger = dev_get_drvdata(dev);
|
||||
+
|
||||
+ cancel_delayed_work_sync(&charger->work);
|
||||
+
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
static int __maybe_unused rk817_resume(struct device *dev)
|
||||
{
|
||||
|
||||
@@ -1213,7 +1222,7 @@ static int __maybe_unused rk817_resume(struct device *dev)
|
||||
return 0;
|
||||
}
|
||||
|
||||
-static SIMPLE_DEV_PM_OPS(rk817_charger_pm, NULL, rk817_resume);
|
||||
+static SIMPLE_DEV_PM_OPS(rk817_charger_pm, rk817_suspend, rk817_resume);
|
||||
|
||||
static struct platform_driver rk817_charger_driver = {
|
||||
.probe = rk817_charger_probe,
|
||||
--
|
||||
2.34.1
|
||||
@@ -1,169 +0,0 @@
|
||||
From: Chris Morgan <macroalpha82@gmail.com>
|
||||
To: linux-pm@vger.kernel.org
|
||||
Cc: sre@kernel.org, Chris Morgan <macromorgan@hotmail.com>
|
||||
Subject: [PATCH 2/2] power: supply: rk817: Update battery capacity calibration
|
||||
Date: Thu, 26 Sep 2024 09:43:46 -0500 [thread overview]
|
||||
Message-ID: <20240926144346.94630-3-macroalpha82@gmail.com> (raw)
|
||||
In-Reply-To: <20240926144346.94630-1-macroalpha82@gmail.com>
|
||||
|
||||
From: Chris Morgan <macromorgan@hotmail.com>
|
||||
|
||||
The battery capacity calibration function continues to be a source of
|
||||
bugs for end users, especially when coming out of suspend. This occurs
|
||||
when the device has incorrect readings for voltage, and causes the
|
||||
current code to set fully charged capacity incorrectly.
|
||||
|
||||
Add checks to ensure we don't attempt a capacity calibration when we
|
||||
have invalid voltage values or no battery present, and remove the code
|
||||
that attempts to automatically set the fully charged capacity in lieu of
|
||||
making the value writeable. This way userspace is able to adjust the
|
||||
fully charged capacity for a degraded battery.
|
||||
|
||||
Signed-off-by: Chris Morgan <macromorgan@hotmail.com>
|
||||
---
|
||||
drivers/power/supply/rk817_charger.c | 101 +++++++++++++++------------
|
||||
1 file changed, 55 insertions(+), 46 deletions(-)
|
||||
|
||||
diff --git a/drivers/power/supply/rk817_charger.c b/drivers/power/supply/rk817_charger.c
|
||||
index d81fc7bd1cd2..958d375e1063 100644
|
||||
--- a/drivers/power/supply/rk817_charger.c
|
||||
+++ b/drivers/power/supply/rk817_charger.c
|
||||
@@ -240,9 +240,32 @@ static int rk817_record_battery_nvram_values(struct rk817_charger *charger)
|
||||
static int rk817_bat_calib_cap(struct rk817_charger *charger)
|
||||
{
|
||||
struct rk808 *rk808 = charger->rk808;
|
||||
- int tmp, charge_now, charge_now_adc, volt_avg;
|
||||
+ int charge_now, charge_now_adc;
|
||||
u8 bulk_reg[4];
|
||||
|
||||
+ /* Don't do anything if there's no battery. */
|
||||
+ if (!charger->battery_present)
|
||||
+ return 0;
|
||||
+
|
||||
+ /*
|
||||
+ * When resuming from suspend, sometimes the voltage value would be
|
||||
+ * incorrect. BSP would simply wait two seconds and try reading the
|
||||
+ * values again. Do not do any sort of calibration activity when the
|
||||
+ * reported value is incorrect. The next scheduled update of battery
|
||||
+ * vaules should then return valid data and the driver can continue.
|
||||
+ * Use 2.7v as the sanity value because per the datasheet the PMIC
|
||||
+ * can in no way support a battery voltage lower than this. BSP only
|
||||
+ * checked for values too low, but I'm adding in a check for values
|
||||
+ * too high just in case; again the PMIC can in no way support
|
||||
+ * voltages above 4.45v, so this seems like a good value.
|
||||
+ */
|
||||
+ if ((charger->volt_avg_uv < 2700000) || (charger->volt_avg_uv > 4450000)) {
|
||||
+ dev_dbg(charger->dev,
|
||||
+ "Battery voltage of %d is invalid, ignoring.\n",
|
||||
+ charger->volt_avg_uv);
|
||||
+ return -EINVAL;
|
||||
+ }
|
||||
+
|
||||
/* Calibrate the soc and fcc on a fully charged battery */
|
||||
|
||||
if (charger->charge_status == CHARGE_FINISH && (!charger->soc_cal)) {
|
||||
@@ -304,51 +327,6 @@ static int rk817_bat_calib_cap(struct rk817_charger *charger)
|
||||
}
|
||||
}
|
||||
|
||||
- /*
|
||||
- * Calibrate the fully charged capacity when we previously had a full
|
||||
- * battery (soc_cal = 1) and are now empty (at or below minimum design
|
||||
- * voltage). If our columb counter is still positive, subtract that
|
||||
- * from our fcc value to get a calibrated fcc, and if our columb
|
||||
- * counter is negative add that to our fcc (but not to exceed our
|
||||
- * design capacity).
|
||||
- */
|
||||
- regmap_bulk_read(charger->rk808->regmap, RK817_GAS_GAUGE_BAT_VOL_H,
|
||||
- bulk_reg, 2);
|
||||
- tmp = get_unaligned_be16(bulk_reg);
|
||||
- volt_avg = (charger->voltage_k * tmp) + 1000 * charger->voltage_b;
|
||||
- if (volt_avg <= charger->bat_voltage_min_design_uv &&
|
||||
- charger->soc_cal) {
|
||||
- regmap_bulk_read(rk808->regmap, RK817_GAS_GAUGE_Q_PRES_H3,
|
||||
- bulk_reg, 4);
|
||||
- charge_now_adc = get_unaligned_be32(bulk_reg);
|
||||
- charge_now = ADC_TO_CHARGE_UAH(charge_now_adc,
|
||||
- charger->res_div);
|
||||
- /*
|
||||
- * Note, if charge_now is negative this will add it (what we
|
||||
- * want) and if it's positive this will subtract (also what
|
||||
- * we want).
|
||||
- */
|
||||
- charger->fcc_mah = charger->fcc_mah - (charge_now / 1000);
|
||||
-
|
||||
- dev_dbg(charger->dev,
|
||||
- "Recalibrating full charge capacity to %d uah\n",
|
||||
- charger->fcc_mah * 1000);
|
||||
- }
|
||||
-
|
||||
- /*
|
||||
- * Set the SOC to 0 if we are below the minimum system voltage.
|
||||
- */
|
||||
- if (volt_avg <= charger->bat_voltage_min_design_uv) {
|
||||
- charger->soc = 0;
|
||||
- charge_now_adc = CHARGE_TO_ADC(0, charger->res_div);
|
||||
- put_unaligned_be32(charge_now_adc, bulk_reg);
|
||||
- regmap_bulk_write(rk808->regmap,
|
||||
- RK817_GAS_GAUGE_Q_INIT_H3, bulk_reg, 4);
|
||||
- dev_warn(charger->dev,
|
||||
- "Battery voltage %d below minimum voltage %d\n",
|
||||
- volt_avg, charger->bat_voltage_min_design_uv);
|
||||
- }
|
||||
-
|
||||
rk817_record_battery_nvram_values(charger);
|
||||
|
||||
return 0;
|
||||
@@ -648,6 +626,24 @@ static irqreturn_t rk817_plug_out_isr(int irq, void *cg)
|
||||
return IRQ_HANDLED;
|
||||
}
|
||||
|
||||
+static int rk817_bat_set_prop(struct power_supply *ps,
|
||||
+ enum power_supply_property prop,
|
||||
+ const union power_supply_propval *val)
|
||||
+{
|
||||
+ struct rk817_charger *charger = power_supply_get_drvdata(ps);
|
||||
+
|
||||
+ switch (prop) {
|
||||
+ case POWER_SUPPLY_PROP_CHARGE_FULL:
|
||||
+ if ((val->intval < 500000) ||
|
||||
+ (val->intval > charger->bat_charge_full_design_uah))
|
||||
+ return -EINVAL;
|
||||
+ charger->fcc_mah = val->intval / 1000;
|
||||
+ return rk817_bat_calib_cap(charger);
|
||||
+ default:
|
||||
+ return -EINVAL;
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
static enum power_supply_property rk817_bat_props[] = {
|
||||
POWER_SUPPLY_PROP_PRESENT,
|
||||
POWER_SUPPLY_PROP_STATUS,
|
||||
@@ -673,12 +669,25 @@ static enum power_supply_property rk817_chg_props[] = {
|
||||
POWER_SUPPLY_PROP_VOLTAGE_AVG,
|
||||
};
|
||||
|
||||
+static int rk817_bat_prop_writeable(struct power_supply *psy,
|
||||
+ enum power_supply_property psp)
|
||||
+{
|
||||
+ switch (psp) {
|
||||
+ case POWER_SUPPLY_PROP_CHARGE_FULL:
|
||||
+ return 1;
|
||||
+ default:
|
||||
+ return 0;
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
static const struct power_supply_desc rk817_bat_desc = {
|
||||
.name = "rk817-battery",
|
||||
.type = POWER_SUPPLY_TYPE_BATTERY,
|
||||
.properties = rk817_bat_props,
|
||||
+ .property_is_writeable = rk817_bat_prop_writeable,
|
||||
.num_properties = ARRAY_SIZE(rk817_bat_props),
|
||||
.get_property = rk817_bat_get_prop,
|
||||
+ .set_property = rk817_bat_set_prop,
|
||||
};
|
||||
|
||||
static const struct power_supply_desc rk817_chg_desc = {
|
||||
--
|
||||
2.34.1
|
||||
Reference in New Issue
Block a user