2019-01-21 07:41:02

by Baolin Wang

[permalink] [raw]
Subject: [PATCH 0/4] Add new device nodes for Spreadtrum SC9860 platform

This patch set adds charger and fuel gauge device nodes for Spreadtrum
SC2731 PMIC, it also removes redundant irq trigger setting for PMIC
devices and adds nvmem cells for ADC to calibrate the ADC channel scales.

Baolin Wang (4):
arm64: dts: sprd: Remove PMIC INTC irq trigger type
arm64: dts: sprd: Add ADC calibration support
arm64: dts: sprd: Add SC2731 charger device
arm64: dts: sprd: Add SC27XX fuel gauge device

arch/arm64/boot/dts/sprd/sc2731.dtsi | 42 ++++++++++++++++++++++++++---
arch/arm64/boot/dts/sprd/sp9860g-1h10.dts | 16 +++++++++++
2 files changed, 54 insertions(+), 4 deletions(-)

--
1.7.9.5



2019-01-21 07:41:15

by Baolin Wang

[permalink] [raw]
Subject: [PATCH 2/4] arm64: dts: sprd: Add ADC calibration support

This patch adds phandles to the calibration cells provided by the Efuse
device, which is used to calibrate the ADC channel scales.

Signed-off-by: Baolin Wang <[email protected]>
---
arch/arm64/boot/dts/sprd/sc2731.dtsi | 10 ++++++++++
1 file changed, 10 insertions(+)

diff --git a/arch/arm64/boot/dts/sprd/sc2731.dtsi b/arch/arm64/boot/dts/sprd/sc2731.dtsi
index f2f2aa5..a2edc25 100644
--- a/arch/arm64/boot/dts/sprd/sc2731.dtsi
+++ b/arch/arm64/boot/dts/sprd/sc2731.dtsi
@@ -63,6 +63,14 @@
#address-cells = <1>;
#size-cells = <1>;
hwlocks = <&hwlock 12>;
+
+ adc_big_scale: calib@24 {
+ reg = <0x24 0x2>;
+ };
+
+ adc_small_scale: calib@26 {
+ reg = <0x26 0x2>;
+ };
};

pmic_adc: adc@480 {
@@ -72,6 +80,8 @@
interrupts = <0>;
#io-channel-cells = <1>;
hwlocks = <&hwlock 4>;
+ nvmem-cell-names = "big_scale_calib", "small_scale_calib";
+ nvmem-cells = <&adc_big_scale>, <&adc_small_scale>;
};

vibrator@ec8 {
--
1.7.9.5


2019-01-21 07:41:27

by Baolin Wang

[permalink] [raw]
Subject: [PATCH 3/4] arm64: dts: sprd: Add SC2731 charger device

Add charger device node and related battery node for SC2731 PMIC.

Signed-off-by: Baolin Wang <[email protected]>
---
arch/arm64/boot/dts/sprd/sc2731.dtsi | 6 ++++++
arch/arm64/boot/dts/sprd/sp9860g-1h10.dts | 16 ++++++++++++++++
2 files changed, 22 insertions(+)

diff --git a/arch/arm64/boot/dts/sprd/sc2731.dtsi b/arch/arm64/boot/dts/sprd/sc2731.dtsi
index a2edc25..b52eaf0 100644
--- a/arch/arm64/boot/dts/sprd/sc2731.dtsi
+++ b/arch/arm64/boot/dts/sprd/sc2731.dtsi
@@ -17,6 +17,12 @@
#address-cells = <1>;
#size-cells = <0>;

+ charger@0 {
+ compatible = "sprd,sc27xx-charger", "sprd,sc2731-charger";
+ reg = <0x0>;
+ monitored-battery = <&bat>;
+ };
+
led-controller@200 {
compatible = "sprd,sc27xx-bltc", "sprd,sc2731-bltc";
reg = <0x200>;
diff --git a/arch/arm64/boot/dts/sprd/sp9860g-1h10.dts b/arch/arm64/boot/dts/sprd/sp9860g-1h10.dts
index 3bd18e3..2a963bd 100644
--- a/arch/arm64/boot/dts/sprd/sp9860g-1h10.dts
+++ b/arch/arm64/boot/dts/sprd/sp9860g-1h10.dts
@@ -41,6 +41,22 @@
#size-cells = <2>;
ranges;
};
+
+ bat: battery {
+ compatible = "simple-battery";
+ charge-full-design-microamp-hours = <1900000>;
+ charge-term-current-microamp = <120000>;
+ constant_charge_voltage_max_microvolt = <4350000>;
+ internal-resistance-micro-ohms = <250000>;
+ ocv-capacity-celsius = <20>;
+ ocv-capacity-table-0 = <4185000 100>, <4113000 95>, <4066000 90>,
+ <4022000 85>, <3983000 80>, <3949000 75>,
+ <3917000 70>, <3889000 65>, <3864000 60>,
+ <3835000 55>, <3805000 50>, <3787000 45>,
+ <3777000 40>, <3773000 35>, <3770000 30>,
+ <3765000 25>, <3752000 20>, <3724000 15>,
+ <3680000 10>, <3605000 5>, <3400000 0>;
+ };
};

&uart0 {
--
1.7.9.5


2019-01-21 07:41:37

by Baolin Wang

[permalink] [raw]
Subject: [PATCH 4/4] arm64: dts: sprd: Add SC27XX fuel gauge device

Add Spreadtrum SC27XX fuel gauge device node to calculate the
battery capacity.

Signed-off-by: Baolin Wang <[email protected]>
---
arch/arm64/boot/dts/sprd/sc2731.dtsi | 18 ++++++++++++++++++
1 file changed, 18 insertions(+)

diff --git a/arch/arm64/boot/dts/sprd/sc2731.dtsi b/arch/arm64/boot/dts/sprd/sc2731.dtsi
index b52eaf0..1110d13 100644
--- a/arch/arm64/boot/dts/sprd/sc2731.dtsi
+++ b/arch/arm64/boot/dts/sprd/sc2731.dtsi
@@ -70,6 +70,11 @@
#size-cells = <1>;
hwlocks = <&hwlock 12>;

+ fgu_calib: calib@6 {
+ reg = <0x6 0x2>;
+ bits = <0 9>;
+ };
+
adc_big_scale: calib@24 {
reg = <0x24 0x2>;
};
@@ -90,6 +95,19 @@
nvmem-cells = <&adc_big_scale>, <&adc_small_scale>;
};

+ fgu@a00 {
+ compatible = "sprd,sc27xx-fgu", "sprd,sc2731-fgu";
+ reg = <0xa00>;
+ bat-detect-gpio = <&pmic_eic 9 GPIO_ACTIVE_HIGH>;
+ io-channels = <&pmic_adc 3>, <&pmic_adc 6>;
+ io-channel-names = "bat-temp", "charge-vol";
+ monitored-battery = <&bat>;
+ nvmem-cell-names = "fgu_calib";
+ nvmem-cells = <&fgu_calib>;
+ interrupt-parent = <&sc2731_pmic>;
+ interrupts = <4>;
+ };
+
vibrator@ec8 {
compatible = "sprd,sc27xx-vibrator", "sprd,sc2731-vibrator";
reg = <0xec8>;
--
1.7.9.5


2019-01-21 07:42:00

by Baolin Wang

[permalink] [raw]
Subject: [PATCH 1/4] arm64: dts: sprd: Remove PMIC INTC irq trigger type

The Spreadtrum PMIC INTC controller has no registers to set trigger type,
since it is always high level trigger as default. So remove its child
devices' irq trigger type setting and change #interrupt-cells to 1.

Signed-off-by: Baolin Wang <[email protected]>
---
arch/arm64/boot/dts/sprd/sc2731.dtsi | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/arch/arm64/boot/dts/sprd/sc2731.dtsi b/arch/arm64/boot/dts/sprd/sc2731.dtsi
index 82bd642..f2f2aa5 100644
--- a/arch/arm64/boot/dts/sprd/sc2731.dtsi
+++ b/arch/arm64/boot/dts/sprd/sc2731.dtsi
@@ -13,7 +13,7 @@
spi-max-frequency = <26000000>;
interrupts = <GIC_SPI 31 IRQ_TYPE_LEVEL_HIGH>;
interrupt-controller;
- #interrupt-cells = <2>;
+ #interrupt-cells = <1>;
#address-cells = <1>;
#size-cells = <0>;

@@ -43,14 +43,14 @@
compatible = "sprd,sc27xx-rtc", "sprd,sc2731-rtc";
reg = <0x280>;
interrupt-parent = <&sc2731_pmic>;
- interrupts = <2 IRQ_TYPE_LEVEL_HIGH>;
+ interrupts = <2>;
};

pmic_eic: gpio@300 {
compatible = "sprd,sc27xx-eic";
reg = <0x300>;
interrupt-parent = <&sc2731_pmic>;
- interrupts = <5 IRQ_TYPE_LEVEL_HIGH>;
+ interrupts = <5>;
gpio-controller;
#gpio-cells = <2>;
interrupt-controller;
@@ -69,7 +69,7 @@
compatible = "sprd,sc27xx-adc", "sprd,sc2731-adc";
reg = <0x480>;
interrupt-parent = <&sc2731_pmic>;
- interrupts = <0 IRQ_TYPE_LEVEL_HIGH>;
+ interrupts = <0>;
#io-channel-cells = <1>;
hwlocks = <&hwlock 4>;
};
--
1.7.9.5


2019-01-30 16:48:09

by Arnd Bergmann

[permalink] [raw]
Subject: Re: [PATCH 3/4] arm64: dts: sprd: Add SC2731 charger device

On Mon, Jan 21, 2019 at 8:39 AM Baolin Wang <[email protected]> wrote:
>
> Add charger device node and related battery node for SC2731 PMIC.
>
> Signed-off-by: Baolin Wang <[email protected]>
> ---
> arch/arm64/boot/dts/sprd/sc2731.dtsi | 6 ++++++
> arch/arm64/boot/dts/sprd/sp9860g-1h10.dts | 16 ++++++++++++++++
> 2 files changed, 22 insertions(+)
>
> diff --git a/arch/arm64/boot/dts/sprd/sc2731.dtsi b/arch/arm64/boot/dts/sprd/sc2731.dtsi
> index a2edc25..b52eaf0 100644
> --- a/arch/arm64/boot/dts/sprd/sc2731.dtsi
> +++ b/arch/arm64/boot/dts/sprd/sc2731.dtsi
> @@ -17,6 +17,12 @@
> #address-cells = <1>;
> #size-cells = <0>;
>
> + charger@0 {
> + compatible = "sprd,sc27xx-charger", "sprd,sc2731-charger";
> + reg = <0x0>;
> + monitored-battery = <&bat>;
> + };

I see some of these have already slipped through, but we should probably
fix those and not add new ones: "sprd,sc27xx-charger" is not an appropriate
compatible string, because it has a 'xx' wildcard.

What you should have instead is to list compatibility with specific older
models. You also need to have the more generic string as the last one,
not the first.

Arnd

2019-01-30 16:48:09

by Arnd Bergmann

[permalink] [raw]
Subject: Re: [PATCH 0/4] Add new device nodes for Spreadtrum SC9860 platform

On Mon, Jan 21, 2019 at 8:39 AM Baolin Wang <[email protected]> wrote:
>
> This patch set adds charger and fuel gauge device nodes for Spreadtrum
> SC2731 PMIC, it also removes redundant irq trigger setting for PMIC
> devices and adds nvmem cells for ADC to calibrate the ADC channel scales.
>
> Baolin Wang (4):
> arm64: dts: sprd: Remove PMIC INTC irq trigger type
> arm64: dts: sprd: Add ADC calibration support
> arm64: dts: sprd: Add SC2731 charger device
> arm64: dts: sprd: Add SC27XX fuel gauge device

I did not apply these because of the 'sc27xx' wildcard matching.

Please fix those up and resend.

Arnd

2019-02-01 12:10:40

by Baolin Wang

[permalink] [raw]
Subject: Re: [PATCH 0/4] Add new device nodes for Spreadtrum SC9860 platform

Hi Arnd,

On Thu, 31 Jan 2019 at 00:46, Arnd Bergmann <[email protected]> wrote:
>
> On Mon, Jan 21, 2019 at 8:39 AM Baolin Wang <[email protected]> wrote:
> >
> > This patch set adds charger and fuel gauge device nodes for Spreadtrum
> > SC2731 PMIC, it also removes redundant irq trigger setting for PMIC
> > devices and adds nvmem cells for ADC to calibrate the ADC channel scales.
> >
> > Baolin Wang (4):
> > arm64: dts: sprd: Remove PMIC INTC irq trigger type
> > arm64: dts: sprd: Add ADC calibration support
> > arm64: dts: sprd: Add SC2731 charger device
> > arm64: dts: sprd: Add SC27XX fuel gauge device
>
> I did not apply these because of the 'sc27xx' wildcard matching.
>
> Please fix those up and resend.
>

On Spreadtrum platform, we use one mfd driver [1] to populate the
SC27XX series PMICs including SC2731, SC2721, SC2720 and SC2730. So we
use sc27xx to be compatible with different PMICs' devices, otherwise
it will be difficult to define the mfd cell arrays in mfd driver. Do
you have any good suggestion? Thanks.

https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/mfd/sprd-sc27xx-spi.c

--
Baolin Wang
Best Regards

2019-02-01 13:13:15

by Mark Brown

[permalink] [raw]
Subject: Re: [PATCH 0/4] Add new device nodes for Spreadtrum SC9860 platform

On Fri, Feb 01, 2019 at 08:05:30PM +0800, Baolin Wang wrote:

> On Spreadtrum platform, we use one mfd driver [1] to populate the
> SC27XX series PMICs including SC2731, SC2721, SC2720 and SC2730. So we
> use sc27xx to be compatible with different PMICs' devices, otherwise
> it will be difficult to define the mfd cell arrays in mfd driver. Do
> you have any good suggestion? Thanks.

You can just list all the individual device names in the of_match_table
for the MFD and then it can bind to any of them. You can always map
them onto the same behaviour in the MFD driver if they are identical
from a software point of view.


Attachments:
(No filename) (639.00 B)
signature.asc (499.00 B)
Download all attachments

2019-02-12 08:40:51

by Baolin Wang

[permalink] [raw]
Subject: Re: [PATCH 0/4] Add new device nodes for Spreadtrum SC9860 platform

Hi Mark,

Sorry for late reply.

On Fri, 1 Feb 2019 at 21:05, Mark Brown <[email protected]> wrote:
>
> On Fri, Feb 01, 2019 at 08:05:30PM +0800, Baolin Wang wrote:
>
> > On Spreadtrum platform, we use one mfd driver [1] to populate the
> > SC27XX series PMICs including SC2731, SC2721, SC2720 and SC2730. So we
> > use sc27xx to be compatible with different PMICs' devices, otherwise
> > it will be difficult to define the mfd cell arrays in mfd driver. Do
> > you have any good suggestion? Thanks.
>
> You can just list all the individual device names in the of_match_table
> for the MFD and then it can bind to any of them. You can always map
> them onto the same behaviour in the MFD driver if they are identical
> from a software point of view.

If I understood correctly, as you suggested, we should add new
mfd_cell groups to list all different PMICs' device names. Something
like:

static const struct mfd_cell sprd_pmic_sc2731_devs[] = {
{
.name = "sc27xx-wdt",
.of_compatible = "sprd,sc2731-wdt",
}, {
.name = "sc27xx-rtc",
.of_compatible = "sprd,sc2731-rtc",
}, {
.name = "sc27xx-charger",
.of_compatible = "sprd,sc2731-charger",
}, {
.name = "sc27xx-fast-chg",
.of_compatible = "sprd,sc2731-fast-chg",
}, {
.name = "sc27xx-typec",
.of_compatible = "sprd,sc2731-typec",
}, {
.name = "sc27xx-eic",
.of_compatible = "sprd,sc2731-eic",
},

.......

};

static const struct mfd_cell sprd_pmic_sc2730_devs[] = {
{
.name = "sc27xx-wdt",
.of_compatible = "sprd,sc2730-wdt",
}, {
.name = "sc27xx-rtc",
.of_compatible = "sprd,sc2730-rtc",
}, {
.name = "sc27xx-charger",
.of_compatible = "sprd,sc2730-charger",
}, {
.name = "sc27xx-fast-chg",
.of_compatible = "sprd,sc2730-fast-chg",
}, {
.name = "sc27xx-typec",
.of_compatible = "sprd,sc2730-typec",
}, {
.name = "sc27xx-eic",
.of_compatible = "sprd,sc2730-eic",
},

.......

};

......

But from my point, they are just some meaningless duplication, and
will waste lots of code there.

--
Baolin Wang
Best Regards

2019-02-12 12:22:12

by Mark Brown

[permalink] [raw]
Subject: Re: [PATCH 0/4] Add new device nodes for Spreadtrum SC9860 platform

On Tue, Feb 12, 2019 at 04:40:10PM +0800, Baolin Wang wrote:
> On Fri, 1 Feb 2019 at 21:05, Mark Brown <[email protected]> wrote:

> > You can just list all the individual device names in the of_match_table
> > for the MFD and then it can bind to any of them. You can always map
> > them onto the same behaviour in the MFD driver if they are identical
> > from a software point of view.

> If I understood correctly, as you suggested, we should add new
> mfd_cell groups to list all different PMICs' device names. Something
> like:

I do think this is a good idea (registering the components of the MFD
using mfd_cell), though it wasn't quite the point I was making. Having
individual device names matters less for Linux-internal names like this.

> But from my point, they are just some meaningless duplication, and
> will waste lots of code there.

I was more thinking of the of_match table that has the IDs that appear
in DT - they're the one that's the ABI. Look at something like wm8994
where the driver has several IDs listed in the main table then selects
function drivers based on that.


Attachments:
(No filename) (1.10 kB)
signature.asc (499.00 B)
Download all attachments

2019-02-13 09:31:00

by Baolin Wang

[permalink] [raw]
Subject: Re: [PATCH 0/4] Add new device nodes for Spreadtrum SC9860 platform

On Tue, 12 Feb 2019 at 20:20, Mark Brown <[email protected]> wrote:
>
> On Tue, Feb 12, 2019 at 04:40:10PM +0800, Baolin Wang wrote:
> > On Fri, 1 Feb 2019 at 21:05, Mark Brown <[email protected]> wrote:
>
> > > You can just list all the individual device names in the of_match_table
> > > for the MFD and then it can bind to any of them. You can always map
> > > them onto the same behaviour in the MFD driver if they are identical
> > > from a software point of view.
>
> > If I understood correctly, as you suggested, we should add new
> > mfd_cell groups to list all different PMICs' device names. Something
> > like:
>
> I do think this is a good idea (registering the components of the MFD
> using mfd_cell), though it wasn't quite the point I was making. Having
> individual device names matters less for Linux-internal names like this.
>
> > But from my point, they are just some meaningless duplication, and
> > will waste lots of code there.
>
> I was more thinking of the of_match table that has the IDs that appear
> in DT - they're the one that's the ABI. Look at something like wm8994
> where the driver has several IDs listed in the main table then selects
> function drivers based on that.

Yes, we can use id_table to populate the PMIC child devices, but some
child devices need use the device node to get some resources which are
described in DT, so we must specify the of_compabible member of
mfd_cell. That means we should use compatible string of the
of_match_table to populate the child devices.

So the problem is still there, we should expand the mfd_cell groups to
list all device names, but just some meaningless duplication.




--
Baolin Wang
Best Regards