Skip to contentSkip to conversation

power: enable cpufreq-dt support for i.MX23/i.MX28

PATCH Superseded Stefan Wahren 5 participants 20 messages Mar 22, 2015 – Mar 25, 2015

Subsystems (5)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

cover power: enable cpufreq-dt support for i.MX23/i.MX28

This patch series adds cpufreq-dt support to Freescale i.MX23 and i.MX28. It's the result of some discussions since August 2014 [1],[2],[3].

Summary
=======

Patch 1,2 - add driver for mxs power subsystem Patch 3,4,5 - enable regulator support for i.MX23/i.MX28 Patch 6,7 - enable cpufreq-dt support for i.MX23/i.MX28

The main use of mxs_power driver is to trigger probing of the underlying DT child nodes like the on-chip regulators. The mxs-regulator driver provides for instance the voltage scaling support.

A detailed description of the MXS power subsystem is in the reference manual [4],[5].

Known issue
===========

The mxs clock driver provide the clock rate in Hz (454736842), but the operating points must be specified in kHz with less precision (454737).

So we get the following warning on boot [4]:

cpufreq: __cpufreq_add_dev: CPU0: Running at unlisted freq: 454736 KHz
cpufreq: __cpufreq_add_dev: CPU0: Unlisted initial frequency changed to: 454737 KHz

Changes
=======
- rebase on next-20150320
- complete rewrite of regulator ops based on helper functions and imx-bootlets
- move DC-DC handling from mxs_power into mxs-regulator
- make DC-DC switching frequency a device tree property
- fix NULL pointer dereference in mxs_power_remove()
- add i.MX23 support
- add cpufreq-dt support

[1] - http://www.spinics.net/lists/arm-kernel/msg356455.html
[2] - https://lkml.org/lkml/2014/9/26/932
[3] - http://lists.infradead.org/pipermail/linux-arm-kernel/2014-November/304688.html
[4] - http://cache.freescale.com/files/dsp/doc/ref_manual/IMX23RM.pdf
[5] - http://cache.freescale.com/files/dsp/doc/ref_manual/MCIMX28RM.pdf
[6] - http://marc.info/?l=linux-pm&m=141225587213505&w=2

Stefan Wahren (7):
DT: add binding for mxs power subsystem
power: mxs_power: add driver for mxs power subsystem
DT: add binding for MXS regulator
regulator: add mxs regulator driver
ARM: dts: enable regulator support for i.MX23/i.MX28
ARM: mxs: register cpufreq-dt in pm init
ARM: dts: add OPPs for i.MX23/i.MX28

 .../devicetree/bindings/power/mxs_power.txt        |   23 +
 .../bindings/regulator/mxs-regulator.txt           |   70 +++
 arch/arm/boot/dts/imx23.dtsi                       |   82 ++-
 arch/arm/boot/dts/imx28.dtsi                       |   82 ++-
 arch/arm/mach-mxs/pm.c                             |    6 +
 drivers/power/Kconfig                              |    8 +
 drivers/power/Makefile                             |    1 +
 drivers/power/mxs_power.c                          |  146 +++++
 drivers/regulator/Kconfig                          |    8 +
 drivers/regulator/Makefile                         |    1 +
 drivers/regulator/mxs-regulator.c                  |  624 ++++++++++++++++++++
 11 files changed, 1045 insertions(+), 6 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/power/mxs_power.txt
 create mode 100644 Documentation/devicetree/bindings/regulator/mxs-regulator.txt
 create mode 100644 drivers/power/mxs_power.c
 create mode 100644 drivers/regulator/mxs-regulator.c
Signature · 1 line
1.7.9.5
#1 lore raw

PATCH 1/7 DT: add binding for mxs power subsystem

This patch adds the device tree bindings for the Freescale MXS power subsystem.

---
 .../devicetree/bindings/power/mxs_power.txt        |   23 ++++++++++++++++++++
 1 file changed, 23 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/power/mxs_power.txt
Documentation/devicetree/bindings/power/mxs_power.txt new file +23 -0
new file mode 100644
index 0000000..aa9139b
@@ -0,0 +1,23 @@
+Power subsystem for Freescale i.MX23/i.MX28
+
+Required properties:
+- compatible:
+  - "fsl,imx23-power" for i.MX23
+  - "fsl,imx28-power" for i.MX28
+- address-cells, size-cells, ranges: must be present as appropriate to
+  map children
+- reg: Address and length of the register set for the power subsystem.
+
+Optional properties;
+- interrupts: Interrupts used by the power subsystem
+
+Example for i.MX28:
+
+	power: power at 80044000 {
+				compatible = "fsl,imx28-power";
+				#address-cells = <1>;
+				#size-cells = <1>;
+				reg = <0x80044000 0x2000>;
+				interrupts = <6>;
+				ranges;
+	}
Signature · 1 line
1.7.9.5
#2 lore raw

PATCH 2/7 power: mxs_power: add driver for mxs power subsystem

In reply to Stefan Wahren

This patch adds a minimal driver for the Freescale i.MX23, i.MX28 power subsystem. It's required to trigger the probing of the underlying drivers like on-chip regulators.

---
 drivers/power/Kconfig     |    8 +++
 drivers/power/Makefile    |    1 +
 drivers/power/mxs_power.c |  146 +++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 155 insertions(+)
 create mode 100644 drivers/power/mxs_power.c
drivers/power/Kconfig +8 -0
index 4091fb0..b689017 100644
@@ -43,6 +43,14 @@ config MAX8925_POWER
 	  Say Y here to enable support for the battery charger in the Maxim
 	  MAX8925 PMIC.
 
+config MXS_POWER
+	tristate "Freescale MXS power subsystem support"
+	depends on ARCH_MXS
+	help
+	  Say Y here to enable support for the Freescale i.MX23/i.MX28
+	  power subsystem. This is a requirement to get access to on-chip
+	  regulators, battery charger and many more.
+
 config WM831X_BACKUP
 	tristate "WM831X backup battery charger support"
 	depends on MFD_WM831X
drivers/power/Makefile +1 -0
index b7b0181..8edcad7 100644
@@ -10,6 +10,7 @@ obj-$(CONFIG_GENERIC_ADC_BATTERY)	+= generic-adc-battery.o
 obj-$(CONFIG_PDA_POWER)		+= pda_power.o
 obj-$(CONFIG_APM_POWER)		+= apm_power.o
 obj-$(CONFIG_MAX8925_POWER)	+= max8925_power.o
+obj-$(CONFIG_MXS_POWER)		+= mxs_power.o
 obj-$(CONFIG_WM831X_BACKUP)	+= wm831x_backup.o
 obj-$(CONFIG_WM831X_POWER)	+= wm831x_power.o
 obj-$(CONFIG_WM8350_POWER)	+= wm8350_power.o
drivers/power/mxs_power.c new file +146 -0

146 lines not on this page · raw message

Signature · 1 line
1.7.9.5
#3 lore raw

PATCH 2/7 power: mxs_power: add driver for mxs power subsystem

Hi,

drivers/power/Kconfig config MAX8925_POWER · line 48

Quoted 9 lines · Stefan Wahren

This patch adds a minimal driver for the Freescale i.MX23, i.MX28 power subsystem. It's required to trigger the probing of the underlying drivers like on-chip regulators.

[...]

drivers/power/Kconfig +3 -0
+config MXS_POWER
+	tristate "Freescale MXS power subsystem support"
+	depends on ARCH_MXS

please add "|| COMPILE_TEST"

Quoted 25 lines
(quoted diff) +22 -0
+	help
+	  Say Y here to enable support for the Freescale i.MX23/i.MX28
+	  power subsystem. This is a requirement to get access to on-chip
+	  regulators, battery charger and many more.
 
[...]
 
+static int mxs_power_probe(struct platform_device *pdev)
+{
+	struct device *dev = &pdev->dev;
+	struct device_node *np = dev->of_node;
+	struct resource *res;
+	struct mxs_power_data *data;
+	struct power_supply_config psy_cfg = {};
+	void __iomem *v5ctrl_addr;
+
+	if (!np) {
+		dev_err(dev, "missing device tree\n");
+		return -EINVAL;
+	}
+
+	data = devm_kzalloc(dev, sizeof(*data), GFP_KERNEL);
+	if (!data)
+		return -ENOMEM;
+

Review

Quoted 10 lines
(quoted diff) +10 -0
+	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+	data->base_addr = devm_ioremap_resource(dev, res);
+	if (IS_ERR(data->base_addr))
+		return PTR_ERR(data->base_addr);
+
+	psy_cfg.drv_data = data;
+
+	data->ac = power_supply_register(dev, &ac_desc, &psy_cfg);
+	if (IS_ERR(data->ac))
+		return PTR_ERR(data->ac);

You can use devm_power_supply_register to simplify the driver a bit more.

drivers/power/mxs_power.c line 123

Quoted 12 lines
drivers/power/mxs_power.c new file +11 -0
+	platform_set_drvdata(pdev, data);
+
+	v5ctrl_addr = data->base_addr + HW_POWER_5VCTRL_OFFSET;
+
+	/* Make sure the current limit of the linregs are disabled. */
+	writel(BM_POWER_5VCTRL_ENABLE_LINREG_ILIMIT,
+	       v5ctrl_addr + HW_POWER_CTRL_CLR);
+
+	return of_platform_populate(np, NULL, NULL, dev);
+}
+
[...]

-- Sebastian
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20150322/76b83142/attachment.sig>

#4 lore raw

PATCH 3/7 DT: add binding for MXS regulator

In reply to Stefan Wahren

This patch adds the device tree bindings for the Freescale MXS on-chip regulators.

---
 .../bindings/regulator/mxs-regulator.txt           |   70 ++++++++++++++++++++
 1 file changed, 70 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/regulator/mxs-regulator.txt
Documentation/devicetree/bindings/regulator/mxs-regulator.txt new file +70 -0
new file mode 100644
index 0000000..88452d2
@@ -0,0 +1,70 @@
+Regulators for Freescale i.MX23/i.MX28
+
+Required properties:
+For imx23 regulators
+- compatible:
+  - "fsl,imx23-dcdc" for DC-DC converter
+  - "fsl,imx23-vddd" for VDDD linear regulator
+  - "fsl,imx23-vdda" for VDDA linear regulator
+  - "fsl,imx23-vddio" for VDDIO linear regulator
+For imx28 regulators
+- compatible:
+  - "fsl,imx28-dcdc" for DC-DC converter
+  - "fsl,imx28-vddd" for VDDD linear regulator
+  - "fsl,imx28-vdda" for VDDA linear regulator
+  - "fsl,imx28-vddio" for VDDIO linear regulator
+- reg: Address and length of the register set for the device. It contains
+  the information of registers in the same order as described by reg-names
+- reg-names: Should contain the reg names
+  - "base-address"	- contains base address of regulator
+  - "status-address"	- contains status address of regulator
+  - "v5ctrl-address"	- contains 5V control address of DC-DC converter
+			  (required only for linear regulators)
+  - "misc-address"      - contains misc control address of DC-DC converter
+			  (required only for DC-DC converter)
+
+Optional properties:
+- switching-frequency: switching frequency of the DC-DC converter in Hz.
+  Possible values are <19200000>, <22000000> or <24000000> (default).
+
+Any regulator property defined as part of the core regulator
+binding, defined in regulator.txt, can also be used.
+
+Example for i.MX28:
+
+	power: power at 80044000 {
+		compatible = "fsl,imx28-power";
+		#address-cells = <1>;
+		#size-cells = <1>;
+		reg = <0x80044000 0x2000>;
+		interrupts = <6>;
+		ranges;
+
+		dcdc: regulator at 80044010 {
+			reg = <0x80044010 0x10>,
+			      <0x80044090 0x10>,
+			      <0x800440c0 0x10>;
+			reg-names = "base-address",
+				    "misc-address",
+				    "status-address";
+			compatible = "fsl,imx28-dcdc";
+			regulator-name = "dcdc";
+			regulator-boot-on;
+			regulator-always-on;
+			switching-frequency = <24000000>;
+		};
+
+		reg_vddd: regulator at 80044040 {
+			reg = <0x80044040 0x10>,
+			      <0x80044010 0x10>,
+			      <0x800440c0 0x10>;
+			reg-names = "base-address",
+				    "v5ctrl-address",
+				    "status-address";
+			compatible = "fsl,imx28-vddd";
+			regulator-name = "vddd";
+			regulator-min-microvolt = <1350000>;
+			regulator-max-microvolt = <1550000>;
+		};
+	};
+
Signature · 1 line
1.7.9.5
#5 lore raw

PATCH 4/7 regulator: add mxs regulator driver

In reply to Stefan Wahren

This patch adds driver support for Freescale i.MX23, i.MX28 on-chip regulators. The driver supports the following components:
dcdc, vddd, vdda and vddio.

---
 drivers/regulator/Kconfig         |    8 +
 drivers/regulator/Makefile        |    1 +
 drivers/regulator/mxs-regulator.c |  624 +++++++++++++++++++++++++++++++++++++
 3 files changed, 633 insertions(+)
 create mode 100644 drivers/regulator/mxs-regulator.c
drivers/regulator/Kconfig +8 -0
index a6f116a..85504ab 100644
@@ -450,6 +450,14 @@ config REGULATOR_MT6397
 	  This driver supports the control of different power rails of device
 	  through regulator interface.
 
+config REGULATOR_MXS
+	tristate "Freescale MXS on-chip regulators"
+	depends on MXS_POWER
+	help
+	  Say y here to support Freescale MXS on-chip regulators.
+	  It is recommended that this option be enabled on i.MX23,
+	  i.MX28 platform.
+
 config REGULATOR_PALMAS
 	tristate "TI Palmas PMIC Regulators"
 	depends on MFD_PALMAS
drivers/regulator/Makefile +1 -0
index 2c4da15..a3ebf23 100644
@@ -60,6 +60,7 @@ obj-$(CONFIG_REGULATOR_MC13783) += mc13783-regulator.o
 obj-$(CONFIG_REGULATOR_MC13892) += mc13892-regulator.o
 obj-$(CONFIG_REGULATOR_MC13XXX_CORE) +=  mc13xxx-regulator-core.o
 obj-$(CONFIG_REGULATOR_MT6397)	+= mt6397-regulator.o
+obj-$(CONFIG_REGULATOR_MXS) += mxs-regulator.o
 obj-$(CONFIG_REGULATOR_QCOM_RPM) += qcom_rpm-regulator.o
 obj-$(CONFIG_REGULATOR_PALMAS) += palmas-regulator.o
 obj-$(CONFIG_REGULATOR_PFUZE100) += pfuze100-regulator.o
drivers/regulator/mxs-regulator.c new file +624 -0

624 lines not on this page · raw message

Signature · 1 line
1.7.9.5
maintainer
#6 lore raw

PATCH 4/7 regulator: add mxs regulator driver

Quoted 7 lines · Stefan Wahren
drivers/regulator/mxs-regulator.c new file +7 -0
+	/* Accept only values recommend by Freescale */
+	switch (khz) {
+	case 19200:
+		val |= HW_POWER_MISC_FREQSEL_19200_KHZ << SHIFT_FREQSEL;
+		break;
+	case 20000:
+		val |= HW_POWER_MISC_FREQSEL_20000_KHZ << SHIFT_FREQSEL;

drivers/regulator/mxs-regulator.c line 244

Quoted 10 lines
drivers/regulator/mxs-regulator.c new file +10 -0
+		break;
+	case 24000:
+		val |= HW_POWER_MISC_FREQSEL_24000_KHZ << SHIFT_FREQSEL;
+		break;
+	default:
+		ret = -EINVAL;
+		break;
+	}
+	if (ret)
+		return ret;

Just return directly, it'd be a bit easier to follow. It'd also be better to print an error message saying we're rejecting the value - that will make it easier for someone writing a DT to figure out that they have made a typo or whatever.

drivers/regulator/mxs-regulator.c line 264

Quoted 10 lines
drivers/regulator/mxs-regulator.c new file +10 -0
+static int mxs_ldo_set_voltage_sel(struct regulator_dev *reg, unsigned sel)
+{
+	struct mxs_ldo *ldo = rdev_get_drvdata(reg);
+	struct regulator_desc *desc = &ldo->desc;
+	unsigned long start;
+	u32 regs;
+	int uV;
+	u8 power_source = HW_POWER_UNKNOWN_SOURCE;
+
+	uV = regulator_list_voltage_linear(reg, sel);

This would be strange execpt uV doesn't seem to be referenced at all so it could be removed instead.

drivers/regulator/mxs-regulator.c line 278

Quoted 10 lines
drivers/regulator/mxs-regulator.c new file +10 -0
+	if (ldo->get_power_source)
+		power_source = ldo->get_power_source(reg);
+
+	switch (power_source) {
+	case HW_POWER_LINREG_DCDC_OFF:
+	case HW_POWER_LINREG_DCDC_READY:
+	case HW_POWER_EXTERNAL_SOURCE_5V:
+		usleep_range(1000, 2000);
+		return 0;
+	}

I'd expect the switch to be in the if here?

drivers/regulator/mxs-regulator.c line 290

Quoted 12 lines
drivers/regulator/mxs-regulator.c new file +12 -0
+
+	usleep_range(15, 20);
+	start = jiffies;
+	while (1) {
+		if (readl(ldo->status_addr) & BM_POWER_STS_DC_OK)
+			return 0;
+
+		if (time_after(jiffies, start +	msecs_to_jiffies(20)))
+			break;
+
+		schedule();
+	}

So, this isn't actually quite a busy wait because we do a schedule() rather than a cpu_relax() but still it could devolve into that - 20ms seems a long time to burn doing that. If we're expecting this to finish very quickly can we do an initial busy wait then fall back to something with an actual sleep or soemthing?

drivers/regulator/mxs-regulator.c line 308

Quoted 11 lines
drivers/regulator/mxs-regulator.c new file +11 -0
+static int mxs_ldo_get_voltage_sel(struct regulator_dev *reg)
+{
+	struct mxs_ldo *ldo = rdev_get_drvdata(reg);
+	struct regulator_desc *desc = &ldo->desc;
+	int ret, uV;
+
+	ret = readl(ldo->base_addr) & desc->vsel_mask;
+	uV = regulator_list_voltage_linear(reg, ret);
+
+	return ret;
+}

Again with the uV lookup...

Quoted 7 lines
drivers/regulator/mxs-regulator.c new file +7 -0
+static int mxs_ldo_is_enabled(struct regulator_dev *reg)
+{
+	struct mxs_ldo *ldo = rdev_get_drvdata(reg);
+	u8 power_source = HW_POWER_UNKNOWN_SOURCE;
+
+	if (ldo->get_power_source)
+		power_source = ldo->get_power_source(reg);

drivers/regulator/mxs-regulator.c line 336

Quoted 10 lines
drivers/regulator/mxs-regulator.c new file +10 -0
+
+	switch (power_source) {
+	case HW_POWER_LINREG_DCDC_OFF:
+	case HW_POWER_LINREG_DCDC_READY:
+	case HW_POWER_DCDC_LINREG_ON:
+		return 1;
+	}
+
+	return 0;
+}

Some comments explaining what the logic here is might be helpful, it's
all a bit surprising.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 473 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20150322/ff18cbbb/attachment.sig>

#7 lore raw

PATCH 4/7 regulator: add mxs regulator driver

Hi Mark,

Quoted 12 lines
Quoted 11 lines

+ if (ldo->get_power_source)
+ power_source = ldo->get_power_source(reg);
+
+ switch (power_source) {
+ case HW_POWER_LINREG_DCDC_OFF:
+ case HW_POWER_LINREG_DCDC_READY:
+ case HW_POWER_EXTERNAL_SOURCE_5V:
+ usleep_range(1000, 2000);
+ return 0;
+ }

Quoted 1 line

I'd expect the switch to be in the if here?

yes, that's possible too.

Quoted 11 lines
Quoted 11 lines
drivers/regulator/mxs-regulator.c new file +10 -0
+
+ usleep_range(15, 20);
+ start = jiffies;
+ while (1) {
+ if (readl(ldo->status_addr) & BM_POWER_STS_DC_OK)
+ return 0;
+
+ if (time_after(jiffies, start + msecs_to_jiffies(20)))
+ break;
+
Quoted 8 lines
Quoted 2 lines

+ schedule();
+ }

So, this isn't actually quite a busy wait because we do a schedule() rather than a cpu_relax() but still it could devolve into that - 20ms seems a long time to burn doing that. If we're expecting this to finish very quickly can we do an initial busy wait then fall back to something with an actual sleep or soemthing?

We will need to keep the initial usleep_range(). So do you think of the following:

1. usleep_range
2. busy_wait for BM_POWER_STS_DC_OK
3. msleep (for the timeout case)

Stefan

maintainer
#8 lore raw

PATCH 4/7 regulator: add mxs regulator driver

Quoted 6 lines · Stefan Wahren
Quoted 5 lines

So, this isn't actually quite a busy wait because we do a schedule() rather than a cpu_relax() but still it could devolve into that - 20ms seems a long time to burn doing that. If we're expecting this to finish very quickly can we do an initial busy wait then fall back to something with an actual sleep or soemthing?

Quoted 6 lines

We will need to keep the initial usleep_range(). So do you think of the following:

1. usleep_range
2. busy_wait for BM_POWER_STS_DC_OK
3. msleep (for the timeout case)

That's what I'm suggesting - do the initial busy wait for a reasonably
short time period and then fall back to something that sleeps.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 473 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20150323/d00b8429/attachment.sig>

#9 lore raw

PATCH 5/7 ARM: dts: enable regulator support for i.MX23/i.MX28

In reply to Stefan Wahren

This patch enables the on-chip regulator support for all i.MX23 and i.MX28 boards.

---
 arch/arm/boot/dts/imx23.dtsi |   67 +++++++++++++++++++++++++++++++++++++++++-
 arch/arm/boot/dts/imx28.dtsi |   67 +++++++++++++++++++++++++++++++++++++++++-
 2 files changed, 132 insertions(+), 2 deletions(-)
arch/arm/boot/dts/imx23.dtsi +66 -1
index bbcfb5a..be0aee8 100644
@@ -404,8 +404,73 @@
 			};
 
 			power at 80044000 {
+				compatible = "fsl,imx23-power";
+				#address-cells = <1>;
+				#size-cells = <1>;
 				reg = <0x80044000 0x2000>;
-				status = "disabled";
+				interrupts = <3>;
+				ranges;
+
+				dcdc: regulator at 80044010 {
+					reg = <0x80044010 0x10>,
+					      <0x80044090 0x10>,
+					      <0x800440c0 0x10>;
+					reg-names = "base-address",
+						    "misc-address",
+						    "status-address";
+					compatible = "fsl,imx23-dcdc";
+					regulator-name = "dcdc";
+					regulator-boot-on;
+					regulator-always-on;
+				};
+
+				reg_vddd: regulator at 80044040 {
+					reg = <0x80044040 0x10>,
+					      <0x80044010 0x10>,
+					      <0x800440c0 0x10>;
+					reg-names = "base-address",
+						    "v5ctrl-address",
+						    "status-address";
+					compatible = "fsl,imx23-vddd";
+					regulator-name = "vddd";
+					regulator-min-microvolt = <1350000>;
+					regulator-max-microvolt = <1550000>;
+					vddd-supply = <&reg_vdda>;
+					regulator-boot-on;
+					regulator-always-on;
+				};
+
+				reg_vdda: regulator at 80044050 {
+					reg = <0x80044050 0x10>,
+					      <0x80044010 0x10>,
+					      <0x800440c0 0x10>;
+					reg-names = "base-address",
+						    "v5ctrl-address",
+						    "status-address";
+					compatible = "fsl,imx23-vdda";
+					regulator-name = "vdda";
+					regulator-min-microvolt = <1725000>;
+					regulator-max-microvolt = <1950000>;
+					vdda-supply = <&reg_vddio>;
+					regulator-boot-on;
+					regulator-always-on;
+				};
+
+				reg_vddio: regulator at 80044060 {
+					reg = <0x80044060 0x10>,
+					      <0x80044010 0x10>,
+					      <0x800440c0 0x10>;
+					reg-names = "base-address",
+						    "v5ctrl-address",
+						    "status-address";
+					compatible = "fsl,imx23-vddio";
+					regulator-name = "vddio";
+					regulator-min-microvolt = <3000000>;
+					regulator-max-microvolt = <3575000>;
+					regulator-microvolt-offset = <80000>;
+					regulator-boot-on;
+					regulator-always-on;
+				};
 			};
 
 			saif1: saif at 80046000 {
arch/arm/boot/dts/imx28.dtsi +66 -1

74 lines not on this page · raw message

Signature · 1 line
1.7.9.5
maintainer
#10 lore raw

PATCH 5/7 ARM: dts: enable regulator support for i.MX23/i.MX28

Quoted 27 lines · Stefan Wahren

This patch enables the on-chip regulator support for all i.MX23 and i.MX28 boards.

---
 arch/arm/boot/dts/imx23.dtsi |   67 +++++++++++++++++++++++++++++++++++++++++-
 arch/arm/boot/dts/imx28.dtsi |   67 +++++++++++++++++++++++++++++++++++++++++-
 2 files changed, 132 insertions(+), 2 deletions(-)
arch/arm/boot/dts/imx23.dtsi +8 -1
index bbcfb5a..be0aee8 100644
@@ -404,8 +404,73 @@
 			};
 
 			power at 80044000 {
+				compatible = "fsl,imx23-power";
+				#address-cells = <1>;
+				#size-cells = <1>;
 				reg = <0x80044000 0x2000>;
-				status = "disabled";
+				interrupts = <3>;
+				ranges;
+
+				dcdc: regulator at 80044010 {
+					reg = <0x80044010 0x10>,

arch/arm/boot/dts/imx23.dtsi line 425

Quoted 10 lines
arch/arm/boot/dts/imx23.dtsi +10 -0
+					      <0x80044090 0x10>,
+					      <0x800440c0 0x10>;
+					reg-names = "base-address",
+						    "misc-address",
+						    "status-address";
+					compatible = "fsl,imx23-dcdc";
+					regulator-name = "dcdc";
+					regulator-boot-on;
+					regulator-always-on;
+				};

It is very unusual to describe the regulators of a device on a register level like this and to iomemap each register individually. I think you should drop the registers here and put this knowledge into the driver like (nearly?) all others do.

Sascha

Signature · 4 lines
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |
#11 lore raw

PATCH 5/7 ARM: dts: enable regulator support for i.MX23/i.MX28

Hi Sascha,

Quoted 39 lines

Sascha Hauer <[email protected]> hat am 23. M?rz 2015 um 07:07 geschrieben:

Quoted 34 lines · Stefan Wahren

This patch enables the on-chip regulator support for all i.MX23 and i.MX28 boards.

---
arch/arm/boot/dts/imx23.dtsi | 67 +++++++++++++++++++++++++++++++++++++++++- arch/arm/boot/dts/imx28.dtsi | 67 +++++++++++++++++++++++++++++++++++++++++-

2 files changed, 132 insertions(+), 2 deletions(-)
arch/arm/boot/dts/imx23.dtsi +15 -1
index bbcfb5a..be0aee8 100644
@@ -404,8 +404,73 @@
 };
 
 power at 80044000 {
+ compatible = "fsl,imx23-power";
+ #address-cells = <1>;
+ #size-cells = <1>;
 reg = <0x80044000 0x2000>;
- status = "disabled";
+ interrupts = <3>;
+ ranges;
+
+ dcdc: regulator at 80044010 {
+ reg = <0x80044010 0x10>,
+ <0x80044090 0x10>,
+ <0x800440c0 0x10>;
+ reg-names = "base-address",
+ "misc-address",
+ "status-address";
+ compatible = "fsl,imx23-dcdc";
+ regulator-name = "dcdc";
Quoted 8 lines

arch/arm/boot/dts/imx23.dtsi line 425

Quoted 3 lines
arch/arm/boot/dts/imx23.dtsi +3 -0
+ regulator-boot-on;
+ regulator-always-on;
+ };

It is very unusual to describe the regulators of a device on a register level like this and to iomemap each register individually. I think you should drop the registers here and put this knowledge into the driver like (nearly?) all others do.

do mean dropping the base address of the regulator, too?

How would you implement it (bare register address or regmap or syscon), since there
are overlapping register regions for different driver?

@Mark: What's your opinion?

Stefan

Quoted 8 lines

Sascha

--
Pengutronix e.K. | |
Industrial Linux Solutions | http://www.pengutronix.de/ | Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |

maintainer
#12 lore raw

PATCH 5/7 ARM: dts: enable regulator support for i.MX23/i.MX28

Quoted 7 lines · Stefan Wahren
Quoted 6 lines

Sascha Hauer <[email protected]> hat am 23. M?rz 2015 um 07:07

It is very unusual to describe the regulators of a device on a register level like this and to iomemap each register individually. I think you should drop the registers here and put this knowledge into the driver like (nearly?) all others do.

Quoted 7 lines

do mean dropping the base address of the regulator, too?

How would you implement it (bare register address or regmap or syscon), since there
are overlapping register regions for different driver?

@Mark: What's your opinion?

This might be the sort of thing normally handled by a system controller,
I have to say I had assumed this had all been discussed in the previous
iterations of this seriee.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 473 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20150323/9c3f8374/attachment.sig>

#13 lore raw

PATCH 5/7 ARM: dts: enable regulator support for i.MX23/i.MX28

Hi Mark,

Am 23.03.2015 um 19:37 schrieb Mark Brown:

Quoted 6 lines · Stefan Wahren
Quoted 5 lines
Quoted 5 lines

Sascha Hauer <[email protected]> hat am 23. M?rz 2015 um 07:07 It is very unusual to describe the regulators of a device on a register level like this and to iomemap each register individually. I think you should drop the registers here and put this knowledge into the driver like (nearly?) all others do.

Quoted 8 lines
Quoted 5 lines

do mean dropping the base address of the regulator, too?
How would you implement it (bare register address or regmap or syscon), since there
are overlapping register regions for different driver?
@Mark: What's your opinion?

This might be the sort of thing normally handled by a system controller, I have to say I had assumed this had all been discussed in the previous iterations of this seriee.

sorry, but i missed this important fact.

If you speak of system controller, do you mean the usage of drivers/mfd/syscon.c ?

Stefan

maintainer
#14 lore raw

PATCH 5/7 ARM: dts: enable regulator support for i.MX23/i.MX28

Quoted 10 lines · Stefan Wahren

Am 23.03.2015 um 19:37 schrieb Mark Brown:

Quoted 3 lines

This might be the sort of thing normally handled by a system controller, I have to say I had assumed this had all been discussed in the previous iterations of this seriee.

sorry, but i missed this important fact.

If you speak of system controller, do you mean the usage of drivers/mfd/syscon.c ?

Yes.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 473 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20150324/14a7e477/attachment.sig>

maintainer
#15 lore raw

PATCH 5/7 ARM: dts: enable regulator support for i.MX23/i.MX28

In reply to Stefan Wahren
Quoted 8 lines · Stefan Wahren

Hi Sascha,

Quoted 4 lines

It is very unusual to describe the regulators of a device on a register level like this and to iomemap each register individually. I think you should drop the registers here and put this knowledge into the driver like (nearly?) all others do.

do mean dropping the base address of the regulator, too?

Yes.

Sascha

Signature · 4 lines
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |
#16 lore raw

PATCH 6/7 ARM: mxs: register cpufreq-dt in pm init

In reply to Stefan Wahren

This patch adds the registration of cpufreq-dt into pm init to get cpufreq support for MXS platform.

---
 arch/arm/mach-mxs/pm.c |    6 ++++++
 1 file changed, 6 insertions(+)
arch/arm/mach-mxs/pm.c +6 -0
index 0170e99..23c52e0 100644
@@ -15,6 +15,7 @@
 #include <linux/kernel.h>
 #include <linux/suspend.h>
 #include <linux/io.h>
+#include <linux/platform_device.h>
 #include "pm.h"
 
 static int mxs_suspend_enter(suspend_state_t state)
@@ -35,7 +36,12 @@ static struct platform_suspend_ops mxs_suspend_ops = {
 	.valid = suspend_valid_only_mem,
 };
 
+static struct platform_device mxs_cpufreq_pdev = {
+	.name = "cpufreq-dt",
+};
+
 void __init mxs_pm_init(void)
 {
 	suspend_set_ops(&mxs_suspend_ops);
+	platform_device_register(&mxs_cpufreq_pdev);
 }
Signature · 1 line
1.7.9.5
#17 lore raw

PATCH 7/7 ARM: dts: add OPPs for i.MX23/i.MX28

In reply to Stefan Wahren

This patch adds the OPPs for i.MX23/i.MX28 which are necessary for cpufreq support.

---
 arch/arm/boot/dts/imx23.dtsi |   15 +++++++++++++--
 arch/arm/boot/dts/imx28.dtsi |   15 +++++++++++++--
 2 files changed, 26 insertions(+), 4 deletions(-)
arch/arm/boot/dts/imx23.dtsi +13 -2
index be0aee8..885c79c 100644
@@ -27,12 +27,23 @@
 	};
 
 	cpus {
-		#address-cells = <0>;
+		#address-cells = <1>;
 		#size-cells = <0>;
 
-		cpu {
+		cpu at 0 {
 			compatible = "arm,arm926ej-s";
 			device_type = "cpu";
+			reg = <0x0>;
+			operating-points = <
+				/* kHz	uV */
+				261819  1350000
+				360000  1350000
+				392728  1450000
+				454737  1550000
+			>;
+			clocks = <&clks 2>;
+			clock-latency = <61036>; /* two CLK32 periods */
+			cpu-supply = <&reg_vddd>;
 		};
 	};
 
arch/arm/boot/dts/imx28.dtsi +13 -2
index 98c1be6..21c1921 100644
@@ -38,12 +38,23 @@
 	};
 
 	cpus {
-		#address-cells = <0>;
+		#address-cells = <1>;
 		#size-cells = <0>;
 
-		cpu {
+		cpu at 0 {
 			compatible = "arm,arm926ej-s";
 			device_type = "cpu";
+			reg = <0x0>;
+			operating-points = <
+				/* kHz	uV */
+				261819  1350000
+				360000  1350000
+				392728  1450000
+				454737  1550000
+			>;
+			clocks = <&clks 4>;
+			clock-latency = <61036>; /* two CLK32 periods */
+			cpu-supply = <&reg_vddd>;
 		};
 	};
 
Signature · 1 line
1.7.9.5
#18 lore raw

PATCH 7/7 ARM: dts: add OPPs for i.MX23/i.MX28

Quoted 20 lines · Stefan Wahren

[...]

arch/arm/boot/dts/imx28.dtsi +5 -2
index 98c1be6..21c1921 100644
@@ -38,12 +38,23 @@
 	};
 
 	cpus {
-		#address-cells = <0>;
+		#address-cells = <1>;
 		#size-cells = <0>;
 
-		cpu {
+		cpu at 0 {
 			compatible = "arm,arm926ej-s";
 			device_type = "cpu";
+			reg = <0x0>;
+			operating-points = <
+				/* kHz	uV */

arch/arm/boot/dts/imx28.dtsi line 59

Quoted 10 lines
arch/arm/boot/dts/imx28.dtsi +8 -0
+				261819  1350000
+				360000  1350000
+				392728  1450000
+				454737  1550000
+			>;
+			clocks = <&clks 4>;
+			clock-latency = <61036>; /* two CLK32 periods */
+			cpu-supply = <&reg_vddd>;
 		};
 	};

Maybe you should take into account not to reduce VDD below 1.55 V if the SDRAM controller runs above 196 MHz. The i.MX28 datasheet[1] lists these restrictions. VDD powers the SDRAM controller as well. From the datasheet the table "Frequency versus Voltage for EMICLK" shows:

EMICLK Fmax (MHz)
VDDD (V) DDR2 mDDR
--------------------------------

 1.550       205.71     205.71
 1.450       196.36     196.36
 1.350       196.36     196.36

jbe

[1]
i.MX28 Applications
Processors for Consumer
Products
Silicon Version 1.2

Document Number: IMX28CEC
Rev. 3, 07/2012

#19 lore raw

PATCH 7/7 ARM: dts: add OPPs for i.MX23/i.MX28

Hi Juergen,

Quoted 21 lines

Juergen Borleis <[email protected]> hat am 24. M?rz 2015 um 21:45 geschrieben:

Quoted 1 line · Stefan Wahren

[...]

Maybe you should take into account not to reduce VDD below 1.55 V if the SDRAM controller runs above 196 MHz. The i.MX28 datasheet[1] lists these restrictions. VDD powers the SDRAM controller as well. From the datasheet the table "Frequency versus Voltage for EMICLK" shows:

EMICLK Fmax (MHz)
VDDD (V) DDR2 mDDR
--------------------------------
1.550 205.71 205.71
1.450 196.36 196.36
1.350 196.36 196.36

jbe

Quoted 8 lines

[1]
i.MX28 Applications
Processors for Consumer
Products
Silicon Version 1.2

Document Number: IMX28CEC
Rev. 3, 07/2012

thanks for pointing out. I will take care of it.

Stefan