Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
86 changes: 86 additions & 0 deletions Documentation/devicetree/bindings/mfd/spacemit,p1.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause
%YAML 1.2
---
$id: http://devicetree.org/schemas/mfd/spacemit,p1.yaml#
$schema: http://devicetree.org/meta-schemas/core.yaml#

title: SpacemiT P1 Power Management Integrated Circuit

maintainers:
- Troy Mitchell <troymitchell988@gmail.com>

description:
P1 is an I2C-controlled PMIC produced by SpacemiT. It implements six
constant-on-time buck converters and twelve low-dropout regulators.
It also contains a load switch, watchdog timer, real-time clock, eight
12-bit ADC channels, and six GPIOs. Additional details are available
in the "Power Stone/P1" section at the following link.
https://developer.spacemit.com/documentation

properties:
compatible:
const: spacemit,p1

reg:
maxItems: 1

interrupts:
maxItems: 1

vin-supply:
description: Input supply phandle.

regulators:
type: object

patternProperties:
"^(buck[1-6]|aldo[1-4]|dldo[1-7])$":
type: object
$ref: /schemas/regulator/regulator.yaml#
unevaluatedProperties: false

unevaluatedProperties: false

required:
- compatible
- reg
- interrupts

unevaluatedProperties: false

examples:
- |
i2c {
#address-cells = <1>;
#size-cells = <0>;

pmic@41 {
compatible = "spacemit,p1";
reg = <0x41>;
interrupts = <64>;

regulators {
buck1 {
regulator-name = "buck1";
regulator-min-microvolt = <500000>;
regulator-max-microvolt = <3450000>;
regulator-ramp-delay = <5000>;
regulator-always-on;
};

aldo1 {
regulator-name = "aldo1";
regulator-min-microvolt = <500000>;
regulator-max-microvolt = <3400000>;
regulator-boot-on;
};

dldo1 {
regulator-name = "dldo1";
regulator-min-microvolt = <500000>;
regulator-max-microvolt = <3400000>;
regulator-boot-on;
};
};
};
};
135 changes: 135 additions & 0 deletions arch/riscv/boot/dts/spacemit/k1-bananapi-f3.dts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,25 @@
default-state = "on";
};
};

reg_dc_in: dc-in-12v {
compatible = "regulator-fixed";
regulator-name = "dc_in_12v";
regulator-min-microvolt = <12000000>;
regulator-max-microvolt = <12000000>;
regulator-boot-on;
regulator-always-on;
};

reg_vcc_4v: vcc-4v {
compatible = "regulator-fixed";
regulator-name = "vcc_4v";
regulator-min-microvolt = <4000000>;
regulator-max-microvolt = <4000000>;
regulator-boot-on;
regulator-always-on;
vin-supply = <&reg_dc_in>;
};
};

&emmc {
Expand All @@ -40,6 +59,122 @@
status = "okay";
};

&i2c8 {
pinctrl-0 = <&i2c8_cfg>;
pinctrl-names = "default";
status = "okay";

pmic@41 {
compatible = "spacemit,p1";
reg = <0x41>;
interrupts = <64>;
vin-supply = <&reg_vcc_4v>;

regulators {
buck1 {
regulator-min-microvolt = <500000>;
regulator-max-microvolt = <3450000>;
regulator-ramp-delay = <5000>;
regulator-always-on;
};

buck2 {
regulator-min-microvolt = <500000>;
regulator-max-microvolt = <3450000>;
regulator-ramp-delay = <5000>;
regulator-always-on;
};

buck3 {
regulator-min-microvolt = <500000>;
regulator-max-microvolt = <1800000>;
regulator-ramp-delay = <5000>;
regulator-always-on;
};

buck4 {
regulator-min-microvolt = <500000>;
regulator-max-microvolt = <3300000>;
regulator-ramp-delay = <5000>;
regulator-always-on;
};

buck5 {
regulator-min-microvolt = <500000>;
regulator-max-microvolt = <3450000>;
regulator-ramp-delay = <5000>;
regulator-always-on;
};

buck6 {
regulator-min-microvolt = <500000>;
regulator-max-microvolt = <3450000>;
regulator-ramp-delay = <5000>;
regulator-always-on;
};

aldo1 {
regulator-min-microvolt = <500000>;
regulator-max-microvolt = <3400000>;
regulator-boot-on;
};

aldo2 {
regulator-min-microvolt = <500000>;
regulator-max-microvolt = <3400000>;
};

aldo3 {
regulator-min-microvolt = <500000>;
regulator-max-microvolt = <3400000>;
};

aldo4 {
regulator-min-microvolt = <500000>;
regulator-max-microvolt = <3400000>;
};

dldo1 {
regulator-min-microvolt = <500000>;
regulator-max-microvolt = <3400000>;
regulator-boot-on;
};

dldo2 {
regulator-min-microvolt = <500000>;
regulator-max-microvolt = <3400000>;
};

dldo3 {
regulator-min-microvolt = <500000>;
regulator-max-microvolt = <3400000>;
};

dldo4 {
regulator-min-microvolt = <500000>;
regulator-max-microvolt = <3400000>;
regulator-always-on;
};

dldo5 {
regulator-min-microvolt = <500000>;
regulator-max-microvolt = <3400000>;
};

dldo6 {
regulator-min-microvolt = <500000>;
regulator-max-microvolt = <3400000>;
regulator-always-on;
};

dldo7 {
regulator-min-microvolt = <500000>;
regulator-max-microvolt = <3400000>;
};
};
};
};

&uart0 {
pinctrl-names = "default";
pinctrl-0 = <&uart0_2_cfg>;
Expand Down
7 changes: 7 additions & 0 deletions arch/riscv/boot/dts/spacemit/k1-pinctrl.dtsi
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,13 @@
#define K1_GPIO(x) (x / 32) (x % 32)

&pinctrl {
i2c8_cfg: i2c8-cfg {
i2c8-0-pins {
pinmux = <K1_PADCONF(93, 0)>, /* PWR_SCL */
<K1_PADCONF(94, 0)>; /* PWR_SDA */
};
};

uart0_2_cfg: uart0-2-cfg {
uart0-2-pins {
pinmux = <K1_PADCONF(68, 2)>,
Expand Down
13 changes: 13 additions & 0 deletions arch/riscv/boot/dts/spacemit/k1.dtsi
Original file line number Diff line number Diff line change
Expand Up @@ -459,6 +459,19 @@
status = "disabled";
};

i2c8: i2c@d401d800 {
compatible = "spacemit,k1-i2c";
reg = <0x0 0xd401d800 0x0 0x38>;
#address-cells = <1>;
#size-cells = <0>;
clocks = <&syscon_apbc CLK_TWSI8>,
<&syscon_apbc CLK_TWSI8_BUS>;
clock-names = "func", "bus";
clock-frequency = <400000>;
interrupts = <19>;
status = "disabled";
};

pinctrl: pinctrl@d401e000 {
compatible = "spacemit,k1-pinctrl";
reg = <0x0 0xd401e000 0x0 0x400>;
Expand Down
11 changes: 11 additions & 0 deletions drivers/mfd/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -1238,6 +1238,17 @@ config MFD_QCOM_RPM
Say M here if you want to include support for the Qualcomm RPM as a
module. This will build a module called "qcom_rpm".

config MFD_SPACEMIT_P1
tristate "SpacemiT P1 PMIC"
depends on I2C
select MFD_SIMPLE_MFD_I2C
help
This option supports the I2C-based SpacemiT P1 PMIC, which
contains regulators, a power switch, GPIOs, an RTC, and more.
This option is selected when any of the supported sub-devices
is configured. The basic functionality is implemented by the
simple MFD I2C driver.

config MFD_SPMI_PMIC
tristate "Qualcomm SPMI PMICs"
depends on ARCH_QCOM || COMPILE_TEST
Expand Down
18 changes: 18 additions & 0 deletions drivers/mfd/simple-mfd-i2c.c
Original file line number Diff line number Diff line change
Expand Up @@ -93,12 +93,30 @@ static const struct simple_mfd_data maxim_mon_max77705 = {
.mfd_cell_size = ARRAY_SIZE(max77705_sensor_cells),
};


static const struct regmap_config spacemit_p1_regmap_config = {
.reg_bits = 8,
.val_bits = 8,
};

static const struct mfd_cell spacemit_p1_cells[] = {
{ .name = "spacemit-p1-regulator", },
{ .name = "spacemit-p1-rtc", },
};

static const struct simple_mfd_data spacemit_p1 = {
.regmap_config = &spacemit_p1_regmap_config,
.mfd_cell = spacemit_p1_cells,
.mfd_cell_size = ARRAY_SIZE(spacemit_p1_cells),
};

static const struct of_device_id simple_mfd_i2c_of_match[] = {
{ .compatible = "kontron,sl28cpld" },
{ .compatible = "silergy,sy7636a", .data = &silergy_sy7636a},
{ .compatible = "maxim,max5970", .data = &maxim_max5970},
{ .compatible = "maxim,max5978", .data = &maxim_max5970},
{ .compatible = "maxim,max77705-battery", .data = &maxim_mon_max77705},
{ .compatible = "spacemit,p1", .data = &spacemit_p1, },
{}
};
MODULE_DEVICE_TABLE(of, simple_mfd_i2c_of_match);
Expand Down
13 changes: 13 additions & 0 deletions drivers/regulator/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -1395,6 +1395,19 @@ config REGULATOR_SLG51000
The SLG51000 is seven compact and customizable low dropout
regulators.

config REGULATOR_SPACEMIT_P1
tristate "SpacemiT P1 regulators"
depends on ARCH_SPACEMIT || COMPILE_TEST
depends on I2C
select MFD_SPACEMIT_P1
default ARCH_SPACEMIT
help
Enable support for regulators implemented by the SpacemiT P1
power controller. The P1 implements 6 high-efficiency buck
converters and 12 programmable LDO regulators. To compile this
driver as a module, choose M here. The module will be called
"spacemit-pmic".

config REGULATOR_STM32_BOOSTER
tristate "STMicroelectronics STM32 BOOSTER"
depends on ARCH_STM32 || COMPILE_TEST
Expand Down
1 change: 1 addition & 0 deletions drivers/regulator/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ obj-$(CONFIG_REGULATOR_S5M8767) += s5m8767.o
obj-$(CONFIG_REGULATOR_SC2731) += sc2731-regulator.o
obj-$(CONFIG_REGULATOR_SKY81452) += sky81452-regulator.o
obj-$(CONFIG_REGULATOR_SLG51000) += slg51000-regulator.o
obj-$(CONFIG_REGULATOR_SPACEMIT_P1) += spacemit-p1.o
obj-$(CONFIG_REGULATOR_STM32_BOOSTER) += stm32-booster.o
obj-$(CONFIG_REGULATOR_STM32_VREFBUF) += stm32-vrefbuf.o
obj-$(CONFIG_REGULATOR_STM32_PWR) += stm32-pwr.o
Expand Down
Loading
Loading