mirror of
https://github.com/armbian/build.git
synced 2025-09-20 05:01:25 +02:00
161 lines
5.1 KiB
Diff
161 lines
5.1 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Patrick Yavitz <pyavitz@armbian.com>
|
|
Date: Fri, 21 Jun 2024 11:54:06 -0400
|
|
Subject: add spacemit patch set
|
|
|
|
source: https://gitee.com/bianbu-linux/linux-6.1
|
|
|
|
Signed-off-by: Patrick Yavitz <pyavitz@armbian.com>
|
|
---
|
|
drivers/regulator/Kconfig | 8 +
|
|
drivers/regulator/Makefile | 1 +
|
|
drivers/regulator/spacemit-regulator.c | 109 ++++++++++
|
|
3 files changed, 118 insertions(+)
|
|
|
|
diff --git a/drivers/regulator/Kconfig b/drivers/regulator/Kconfig
|
|
index 111111111111..222222222222 100644
|
|
--- a/drivers/regulator/Kconfig
|
|
+++ b/drivers/regulator/Kconfig
|
|
@@ -1524,4 +1524,12 @@ config REGULATOR_QCOM_LABIBB
|
|
boost regulator and IBB can be used as a negative boost regulator
|
|
for LCD display panel.
|
|
|
|
+config REGULATOR_SPACEMIT
|
|
+ tristate "Spacemit regulator support"
|
|
+ depends on MFD_SPACEMIT_PMIC
|
|
+ select REGULATOR_FIXED_VOLTAGE
|
|
+ help
|
|
+ This driver provides support for the voltage regulators on the
|
|
+ spacemit pmic.
|
|
+
|
|
endif
|
|
diff --git a/drivers/regulator/Makefile b/drivers/regulator/Makefile
|
|
index 111111111111..222222222222 100644
|
|
--- a/drivers/regulator/Makefile
|
|
+++ b/drivers/regulator/Makefile
|
|
@@ -182,5 +182,6 @@ obj-$(CONFIG_REGULATOR_WM831X) += wm831x-ldo.o
|
|
obj-$(CONFIG_REGULATOR_WM8350) += wm8350-regulator.o
|
|
obj-$(CONFIG_REGULATOR_WM8400) += wm8400-regulator.o
|
|
obj-$(CONFIG_REGULATOR_WM8994) += wm8994-regulator.o
|
|
+obj-$(CONFIG_REGULATOR_SPACEMIT) += spacemit-regulator.o
|
|
|
|
ccflags-$(CONFIG_REGULATOR_DEBUG) += -DDEBUG
|
|
diff --git a/drivers/regulator/spacemit-regulator.c b/drivers/regulator/spacemit-regulator.c
|
|
new file mode 100644
|
|
index 000000000000..111111111111
|
|
--- /dev/null
|
|
+++ b/drivers/regulator/spacemit-regulator.c
|
|
@@ -0,0 +1,109 @@
|
|
+// SPDX-License-Identifier: GPL-2.0-or-later
|
|
+/*
|
|
+ * Regulator driver for Spacemit PMIC
|
|
+ *
|
|
+ * Copyright (c) 2023, SPACEMIT Co., Ltd
|
|
+ *
|
|
+ */
|
|
+
|
|
+#include <linux/delay.h>
|
|
+#include <linux/gpio.h>
|
|
+#include <linux/i2c.h>
|
|
+#include <linux/module.h>
|
|
+#include <linux/of_device.h>
|
|
+#include <linux/of_gpio.h>
|
|
+#include <linux/regulator/driver.h>
|
|
+#include <linux/regulator/of_regulator.h>
|
|
+#include <linux/gpio/consumer.h>
|
|
+#include <linux/mfd/spacemit/spacemit_pmic.h>
|
|
+
|
|
+static const struct regulator_ops pmic_dcdc_ldo_ops = {
|
|
+ .list_voltage = regulator_list_voltage_linear_range,
|
|
+ .map_voltage = regulator_map_voltage_linear_range,
|
|
+ .get_voltage_sel = regulator_get_voltage_sel_regmap,
|
|
+ .set_voltage_sel = regulator_set_voltage_sel_regmap,
|
|
+ .set_voltage_time_sel = regulator_set_voltage_time_sel,
|
|
+ .enable = regulator_enable_regmap,
|
|
+ .disable = regulator_disable_regmap,
|
|
+ .is_enabled = regulator_is_enabled_regmap,
|
|
+};
|
|
+
|
|
+static const struct regulator_ops pmic_switch_ops = {
|
|
+ .enable = regulator_enable_regmap,
|
|
+ .disable = regulator_disable_regmap,
|
|
+ .is_enabled = regulator_is_enabled_regmap,
|
|
+};
|
|
+
|
|
+SPM8821_BUCK_LINER_RANGE;SPM8821_LDO_LINER_RANGE;SPM8821_REGULATOR_DESC;
|
|
+SPM8821_REGULATOR_MATCH_DATA;
|
|
+
|
|
+PM853_BUCK_LINER_RANGE1;PM853_BUCK_LINER_RANGE2;PM853_LDO_LINER_RANGE1;
|
|
+PM853_LDO_LINER_RANGE2;PM853_LDO_LINER_RANGE3;PM853_LDO_LINER_RANGE4;
|
|
+PM853_REGULATOR_DESC;PM853_REGULATOR_MATCH_DATA;
|
|
+
|
|
+SY8810L_BUCK_LINER_RANGE;SY8810L_REGULATOR_DESC;SY8810L_REGULATOR_MATCH_DATA;
|
|
+
|
|
+static const struct of_device_id spacemit_regulator_of_match[] = {
|
|
+ { .compatible = "pmic,regulator,spm8821", .data = (void *)&spm8821_regulator_match_data },
|
|
+ { .compatible = "pmic,regulator,pm853", .data = (void *)&pm853_regulator_match_data },
|
|
+ { .compatible = "pmic,regulator,sy8810l", .data = (void *)&sy8810l_regulator_match_data },
|
|
+ { },
|
|
+};
|
|
+MODULE_DEVICE_TABLE(of, spacemit_regulator_of_match);
|
|
+
|
|
+static int spacemit_regulator_probe(struct platform_device *pdev)
|
|
+{
|
|
+ struct regulator_config config = {};
|
|
+ struct spacemit_pmic *pmic = dev_get_drvdata(pdev->dev.parent);
|
|
+ struct i2c_client *client;
|
|
+ const struct of_device_id *of_id;
|
|
+ struct regulator_match_data *match_data;
|
|
+ struct regulator_dev *regulator_dev;
|
|
+ int i;
|
|
+
|
|
+ of_id = of_match_device(spacemit_regulator_of_match, &pdev->dev);
|
|
+ if (!of_id) {
|
|
+ pr_err("Unable to match OF ID\n");
|
|
+ return -ENODEV;
|
|
+ }
|
|
+
|
|
+ match_data = (struct regulator_match_data *)of_id->data;
|
|
+
|
|
+ client = pmic->i2c;
|
|
+ config.dev = &client->dev;
|
|
+ config.regmap = pmic->regmap;
|
|
+
|
|
+ if (strcmp(match_data->name, "pm853") == 0) {
|
|
+ client = pmic->sub->power_page;
|
|
+ config.dev = &pmic->i2c->dev;
|
|
+ config.regmap = pmic->sub->power_regmap;
|
|
+ }
|
|
+
|
|
+ for (i = 0; i < match_data->nr_desc; ++i) {
|
|
+ regulator_dev = devm_regulator_register(&pdev->dev,
|
|
+ match_data->desc + i, &config);
|
|
+ if (IS_ERR(regulator_dev)) {
|
|
+ pr_err("failed to register %d regulator\n", i);
|
|
+ return PTR_ERR(regulator_dev);
|
|
+ }
|
|
+ }
|
|
+
|
|
+ return 0;
|
|
+}
|
|
+
|
|
+static struct platform_driver spacemit_regulator_driver = {
|
|
+ .probe = spacemit_regulator_probe,
|
|
+ .driver = {
|
|
+ .name = "spacemit-regulator",
|
|
+ .of_match_table = spacemit_regulator_of_match,
|
|
+ },
|
|
+};
|
|
+
|
|
+static int spacemit_regulator_init(void)
|
|
+{
|
|
+ return platform_driver_register(&spacemit_regulator_driver);
|
|
+}
|
|
+subsys_initcall(spacemit_regulator_init);
|
|
+
|
|
+MODULE_DESCRIPTION("regulator drivers for the Spacemit series PMICs");
|
|
+
|
|
--
|
|
Armbian
|
|
|