From mboxrd@z Thu Jan 1 00:00:00 1970 From: Lothar =?UTF-8?B?V2HDn21hbm4=?= Date: Thu, 13 Sep 2018 17:59:25 +0200 Subject: [U-Boot] [PATCH V4 24/32] power: Add power domain driver for i.MX8 In-Reply-To: <20180905021219.12828-25-peng.fan@nxp.com> References: <20180905021219.12828-1-peng.fan@nxp.com> <20180905021219.12828-25-peng.fan@nxp.com> Message-ID: <20180913175925.1abffa84@karo-electronics.de> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="windows-1252" Content-Transfer-Encoding: quoted-printable To: u-boot@lists.denx.de Hi, On Wed, 5 Sep 2018 10:12:11 +0800 Peng Fan wrote: > Add the power domain DM driver for i.MX8, that it depends on the DTB > power domain trees to generate the power domain provider devices. Users > needs add power domain trees with property "compatible =3D "nxp,imx8-pd";" >=20 > When power on one PD device, the driver will power on its ancestor PD > devices in power domain tree. >=20 > When power off on PD device, the driver will check its child PD devices > first, only all child PD devices are off, then power off the current PD > device. Then the driver checks sibling PD devices. If sibling PD devices > are off, then it will power off parent PD device. >=20 > There is no counter maintained in this driver, but a state to hold current > on/off state. So the request and free functions are empty. >=20 > The power domain implementation in i.MX8 DTB set the "#power-domain-cells" > to 0, so there is no ID binding with each PD device. We don't use "id" > variable in struct power_domain. At same time, we have to set of_xlate to > empty to bypass standard of_xlate in uclass driver. >=20 > Signed-off-by: Ye Li > Signed-off-by: Peng Fan > Cc: Stefano Babic > --- > arch/arm/include/asm/arch-imx8/power-domain.h | 15 ++ > drivers/power/domain/Kconfig | 6 + > drivers/power/domain/Makefile | 1 + > drivers/power/domain/imx8-power-domain.c | 312 ++++++++++++++++++++= ++++++ > 4 files changed, 334 insertions(+) > create mode 100644 arch/arm/include/asm/arch-imx8/power-domain.h > create mode 100644 drivers/power/domain/imx8-power-domain.c >=20 > diff --git a/arch/arm/include/asm/arch-imx8/power-domain.h b/arch/arm/inc= lude/asm/arch-imx8/power-domain.h > new file mode 100644 > index 0000000000..1396008877 > --- /dev/null > +++ b/arch/arm/include/asm/arch-imx8/power-domain.h > @@ -0,0 +1,15 @@ > +/* SPDX-License-Identifier: GPL-2.0 */ > +/* > + * Copyright 2017 NXP > + */ > + > +#ifndef _ASM_ARCH_IMX8_POWER_DOMAIN_H > +#define _ASM_ARCH_IMX8_POWER_DOMAIN_H > + > +#include > + > +struct imx8_power_domain_platdata { > + sc_rsrc_t resource_id; > +}; > + > +#endif > diff --git a/drivers/power/domain/Kconfig b/drivers/power/domain/Kconfig > index 7cfa761498..2a72642a26 100644 > --- a/drivers/power/domain/Kconfig > +++ b/drivers/power/domain/Kconfig > @@ -31,4 +31,10 @@ config TEGRA186_POWER_DOMAIN > Enable support for manipulating Tegra's on-SoC power domains via IPC > requests to the BPMP (Boot and Power Management Processor). > =20 > +config IMX8_POWER_DOMAIN > + bool "Enable i.MX8 power domain driver" > + depends on ARCH_IMX8 > + help > + Enable support for manipulating NXP i.MX8 on-SoC power domains= via IPC > + requests to the SCU. > endmenu > diff --git a/drivers/power/domain/Makefile b/drivers/power/domain/Makefile > index 020eee2378..1ef4844c0b 100644 > --- a/drivers/power/domain/Makefile > +++ b/drivers/power/domain/Makefile > @@ -7,3 +7,4 @@ obj-$(CONFIG_BCM6328_POWER_DOMAIN) +=3D bcm6328-power-dom= ain.o > obj-$(CONFIG_SANDBOX_POWER_DOMAIN) +=3D sandbox-power-domain.o > obj-$(CONFIG_SANDBOX_POWER_DOMAIN) +=3D sandbox-power-domain-test.o > obj-$(CONFIG_TEGRA186_POWER_DOMAIN) +=3D tegra186-power-domain.o > +obj-$(CONFIG_IMX8_POWER_DOMAIN) +=3D imx8-power-domain.o > diff --git a/drivers/power/domain/imx8-power-domain.c b/drivers/power/dom= ain/imx8-power-domain.c > new file mode 100644 > index 0000000000..be91d626ad > --- /dev/null > +++ b/drivers/power/domain/imx8-power-domain.c > @@ -0,0 +1,312 @@ > +// SPDX-License-Identifier: GPL-2.0 > +/* > + * Copyright 2017 NXP > + */ > + > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > + > +DECLARE_GLOBAL_DATA_PTR; > + > +struct imx8_power_domain_priv { > + bool state_on; > +}; > + > +static int imx8_power_domain_request(struct power_domain *power_domain) > +{ > + debug("%s(power_domain=3D%p)\n", __func__, power_domain); > + > + return 0; > +} > + > +static int imx8_power_domain_free(struct power_domain *power_domain) > +{ > + debug("%s(power_domain=3D%p)\n", __func__, power_domain); > + > + return 0; > +} > + > +static int imx8_power_domain_on(struct power_domain *power_domain) > +{ > + struct udevice *dev =3D power_domain->dev; > + struct imx8_power_domain_platdata *pdata; > + struct imx8_power_domain_priv *ppriv; > + sc_err_t ret; > + > + struct power_domain parent_domain; > + struct udevice *parent =3D dev_get_parent(dev); > + > + /* Need to power on parent node first */ > + if (device_get_uclass_id(parent) =3D=3D UCLASS_POWER_DOMAIN) { > + parent_domain.dev =3D parent; > + imx8_power_domain_on(&parent_domain); > What if this fails? Is it actually sensible to continue enabling the power domain, when its parent domain could not be enabled? > + > + pdata =3D (struct imx8_power_domain_platdata *)dev_get_platdata(dev); > + ppriv =3D (struct imx8_power_domain_priv *)dev_get_priv(dev); > + useless type casts. Lothar Wa=C3=9Fmann