public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: "Lothar Waßmann" <LW@KARO-electronics.de>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH V4 24/32] power: Add power domain driver for i.MX8
Date: Thu, 13 Sep 2018 17:59:25 +0200	[thread overview]
Message-ID: <20180913175925.1abffa84@karo-electronics.de> (raw)
In-Reply-To: <20180905021219.12828-25-peng.fan@nxp.com>

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 = "nxp,imx8-pd";"
> 
> When power on one PD device, the driver will power on its ancestor PD
> devices in power domain tree.
> 
> 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.
> 
> 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.
> 
> 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.
> 
> Signed-off-by: Ye Li <ye.li@nxp.com>
> Signed-off-by: Peng Fan <peng.fan@nxp.com>
> Cc: Stefano Babic <sbabic@denx.de>
> ---
>  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
> 
> diff --git a/arch/arm/include/asm/arch-imx8/power-domain.h b/arch/arm/include/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 <asm/arch/sci/types.h>
> +
> +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).
>  
> +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) += bcm6328-power-domain.o
>  obj-$(CONFIG_SANDBOX_POWER_DOMAIN) += sandbox-power-domain.o
>  obj-$(CONFIG_SANDBOX_POWER_DOMAIN) += sandbox-power-domain-test.o
>  obj-$(CONFIG_TEGRA186_POWER_DOMAIN) += tegra186-power-domain.o
> +obj-$(CONFIG_IMX8_POWER_DOMAIN) += imx8-power-domain.o
> diff --git a/drivers/power/domain/imx8-power-domain.c b/drivers/power/domain/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 <common.h>
> +#include <dm.h>
> +#include <power-domain-uclass.h>
> +#include <asm/io.h>
> +#include <asm/arch/power-domain.h>
> +#include <dm/device-internal.h>
> +#include <dm/device.h>
> +#include <asm/arch/sci/sci.h>
> +
> +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=%p)\n", __func__, power_domain);
> +
> +	return 0;
> +}
> +
> +static int imx8_power_domain_free(struct power_domain *power_domain)
> +{
> +	debug("%s(power_domain=%p)\n", __func__, power_domain);
> +
> +	return 0;
> +}
> +
> +static int imx8_power_domain_on(struct power_domain *power_domain)
> +{
> +	struct udevice *dev = 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 = dev_get_parent(dev);
> +
> +	/* Need to power on parent node first */
> +	if (device_get_uclass_id(parent) == UCLASS_POWER_DOMAIN) {
> +		parent_domain.dev = 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 = (struct imx8_power_domain_platdata *)dev_get_platdata(dev);
> +	ppriv = (struct imx8_power_domain_priv *)dev_get_priv(dev);
> +
useless type casts.


Lothar Waßmann

  reply	other threads:[~2018-09-13 15:59 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-09-05  2:11 [U-Boot] [PATCH V4 00/32] i.MX: Add i.MX8QXP support Peng Fan
2018-09-05  2:11 ` [U-Boot] [PATCH V4 01/32] dt-bindings: pinctrl: add i.MX8QXP pads definition Peng Fan
2018-09-05  2:11 ` [U-Boot] [PATCH V4 02/32] dt-bindings: clock: dt-bindings: pinctrl: add i.MX8QXP clocks definition Peng Fan
2018-09-05  2:11 ` [U-Boot] [PATCH V4 03/32] dt-bindings: soc: add i.MX8QXP pm and rsrc definition Peng Fan
2018-09-05  2:11 ` [U-Boot] [PATCH V4 04/32] imx8: add scfw macro definition Peng Fan
2018-09-05  2:11 ` [U-Boot] [PATCH V4 05/32] imx: add Kconfig entry for i.MX8QXP Peng Fan
2018-09-05  2:11 ` [U-Boot] [PATCH V4 06/32] arm: build mach-imx for i.MX8 Peng Fan
2018-09-05  2:11 ` [U-Boot] [PATCH V4 07/32] arm: global_data: add scu_dev " Peng Fan
2018-09-05  2:11 ` [U-Boot] [PATCH V4 08/32] misc: add i.MX8 misc driver Peng Fan
2018-09-05  2:11 ` [U-Boot] [PATCH V4 09/32] misc: imx8: add scfw api impementation Peng Fan
2018-09-05  2:11 ` [U-Boot] [PATCH V4 10/32] imx: boot_mode: Add FLEXSPI boot entry Peng Fan
2018-09-05  2:11 ` [U-Boot] [PATCH V4 11/32] imx8: add imx-regs header file Peng Fan
2018-09-05  2:11 ` [U-Boot] [PATCH V4 12/32] imx8: pins: include i.MX8QXP pin header when CONFIG_IMX8QXP defined Peng Fan
2018-09-05  2:12 ` [U-Boot] [PATCH V4 13/32] imx: add i.MX8 cpu type Peng Fan
2018-09-05  2:12 ` [U-Boot] [PATCH V4 14/32] armv8: add cpu core helper functions Peng Fan
2018-09-05  2:12 ` [U-Boot] [PATCH V4 15/32] imx8: add basic cpu support Peng Fan
2018-09-05  2:12 ` [U-Boot] [PATCH V4 16/32] imx8: add boot device detection Peng Fan
2018-09-05  2:12 ` [U-Boot] [PATCH V4 17/32] imx8: implement mmc_get_env_dev Peng Fan
2018-09-05  2:12 ` [U-Boot] [PATCH V4 18/32] imx8: add mmu and dram related functiions Peng Fan
2018-09-05  2:12 ` [U-Boot] [PATCH V4 19/32] imx8: add arch_cpu_init arch_cpu_init_dm Peng Fan
2018-09-05  2:12 ` [U-Boot] [PATCH V4 20/32] imx8: add iomux configuration api Peng Fan
2018-09-05  2:12 ` [U-Boot] [PATCH V4 21/32] imx8: add dummy clock Peng Fan
2018-09-05  2:12 ` [U-Boot] [PATCH V4 22/32] gpio: mxc_gpio: add support for i.MX8 Peng Fan
2018-09-05  2:12 ` [U-Boot] [PATCH V4 23/32] pinctrl: Add pinctrl driver " Peng Fan
2018-09-05  2:12 ` [U-Boot] [PATCH V4 24/32] power: Add power domain " Peng Fan
2018-09-13 15:59   ` Lothar Waßmann [this message]
2018-09-14  0:57     ` Peng Fan
2018-09-05  2:12 ` [U-Boot] [PATCH V4 25/32] clk: imx: add clk driver for i.MX8QXP Peng Fan
2018-09-05  2:12 ` [U-Boot] [PATCH V4 26/32] serial_lpuart: Update lpuart driver to support i.MX8 Peng Fan
2018-09-05  2:12 ` [U-Boot] [PATCH V4 27/32] serial: lpuart: Enable RX and TX FIFO Peng Fan
2018-09-05  2:12 ` [U-Boot] [PATCH V4 28/32] serial: lpuart: support uclass clk api Peng Fan
2018-09-05  2:12 ` [U-Boot] [PATCH V4 29/32] fsl_esdhc: Update usdhc driver to support i.MX8 Peng Fan
2018-09-05  2:12 ` [U-Boot] [PATCH V4 30/32] mmc: fsl_esdhc: add uclass clk support Peng Fan
2018-09-05  2:12 ` [U-Boot] [PATCH V4 31/32] arm: dts: introduce dtsi for i.MX8QXP Peng Fan
2018-09-05  2:12 ` [U-Boot] [PATCH V4 32/32] imx: add i.MX8QXP MEK board support Peng Fan
2018-09-13 15:55   ` Lothar Waßmann
2018-09-14  1:01     ` Peng Fan

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180913175925.1abffa84@karo-electronics.de \
    --to=lw@karo-electronics.de \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox