* [PATCH v4 1/3] soc: zte: pm_domains: Prepare for supporting ARMv8 zx2967 family @ 2017-01-03 6:56 ` Baoyou Xie 0 siblings, 0 replies; 12+ messages in thread From: Baoyou Xie @ 2017-01-03 6:56 UTC (permalink / raw) To: linux-arm-kernel The ARMv8 zx2967 family (296718, 296716 etc) uses different value for controlling the power domain on/off registers, Choose the value depending on the compatible. Multiple domains are prepared for the family, this patch prepares the common functions. Signed-off-by: Baoyou Xie <baoyou.xie@linaro.org> --- drivers/soc/Kconfig | 1 + drivers/soc/Makefile | 1 + drivers/soc/zte/Kconfig | 13 ++++ drivers/soc/zte/Makefile | 4 ++ drivers/soc/zte/zx2967_pm_domains.c | 138 ++++++++++++++++++++++++++++++++++++ drivers/soc/zte/zx2967_pm_domains.h | 45 ++++++++++++ 6 files changed, 202 insertions(+) create mode 100644 drivers/soc/zte/Kconfig create mode 100644 drivers/soc/zte/Makefile create mode 100644 drivers/soc/zte/zx2967_pm_domains.c create mode 100644 drivers/soc/zte/zx2967_pm_domains.h diff --git a/drivers/soc/Kconfig b/drivers/soc/Kconfig index f31bceb..f09023f 100644 --- a/drivers/soc/Kconfig +++ b/drivers/soc/Kconfig @@ -11,5 +11,6 @@ source "drivers/soc/tegra/Kconfig" source "drivers/soc/ti/Kconfig" source "drivers/soc/ux500/Kconfig" source "drivers/soc/versatile/Kconfig" +source "drivers/soc/zte/Kconfig" endmenu diff --git a/drivers/soc/Makefile b/drivers/soc/Makefile index 50c23d0..05eae52 100644 --- a/drivers/soc/Makefile +++ b/drivers/soc/Makefile @@ -16,3 +16,4 @@ obj-$(CONFIG_ARCH_TEGRA) += tegra/ obj-$(CONFIG_SOC_TI) += ti/ obj-$(CONFIG_ARCH_U8500) += ux500/ obj-$(CONFIG_PLAT_VERSATILE) += versatile/ +obj-$(CONFIG_ARCH_ZX) += zte/ diff --git a/drivers/soc/zte/Kconfig b/drivers/soc/zte/Kconfig new file mode 100644 index 0000000..20bde38 --- /dev/null +++ b/drivers/soc/zte/Kconfig @@ -0,0 +1,13 @@ +# +# ZTE SoC drivers +# +menuconfig SOC_ZTE + bool "ZTE SoC driver support" + +if SOC_ZTE + +config ZX2967_PM_DOMAINS + bool "ZX2967 PM domains" + depends on PM_GENERIC_DOMAINS + +endif diff --git a/drivers/soc/zte/Makefile b/drivers/soc/zte/Makefile new file mode 100644 index 0000000..8a37f2f --- /dev/null +++ b/drivers/soc/zte/Makefile @@ -0,0 +1,4 @@ +# +# ZTE SOC drivers +# +obj-$(CONFIG_ZX2967_PM_DOMAINS) += zx2967_pm_domains.o diff --git a/drivers/soc/zte/zx2967_pm_domains.c b/drivers/soc/zte/zx2967_pm_domains.c new file mode 100644 index 0000000..98b3b5f --- /dev/null +++ b/drivers/soc/zte/zx2967_pm_domains.c @@ -0,0 +1,138 @@ +/* + * Copyright (C) 2015 ZTE Ltd. + * + * Author: Baoyou Xie <baoyou.xie@linaro.org> + * License terms: GNU General Public License (GPL) version 2 + */ +#include <linux/delay.h> +#include <linux/err.h> +#include <linux/io.h> +#include <linux/of.h> +#include "zx2967_pm_domains.h" + +#define PCU_DM_CLKEN(zpd) ((zpd)->reg_offset[REG_CLKEN]) +#define PCU_DM_ISOEN(zpd) ((zpd)->reg_offset[REG_ISOEN]) +#define PCU_DM_RSTEN(zpd) ((zpd)->reg_offset[REG_RSTEN]) +#define PCU_DM_PWREN(zpd) ((zpd)->reg_offset[REG_PWREN]) +#define PCU_DM_PWRDN(zpd) ((zpd)->reg_offset[REG_PWRDN]) +#define PCU_DM_ACK_SYNC(zpd) ((zpd)->reg_offset[REG_ACK_SYNC]) + +static void __iomem *pcubase; + +int zx2967_power_on(struct generic_pm_domain *domain) +{ + struct zx2967_pm_domain *zpd = (struct zx2967_pm_domain *)domain; + unsigned long loop = 1000; + u32 val; + + val = readl_relaxed(pcubase + PCU_DM_PWREN(zpd)); + if (zpd->polarity == PWREN) + val |= BIT(zpd->bit); + else + val &= ~BIT(zpd->bit); + writel_relaxed(val, pcubase + PCU_DM_PWRDN(zpd)); + + do { + udelay(1); + val = readl_relaxed(pcubase + PCU_DM_ACK_SYNC(zpd)) + & BIT(zpd->bit); + } while (--loop && !val); + + if (!loop) { + pr_err("Error: %s %s fail\n", __func__, domain->name); + return -EIO; + } + + val = readl_relaxed(pcubase + PCU_DM_RSTEN(zpd)); + val |= BIT(zpd->bit); + writel_relaxed(val, pcubase + PCU_DM_RSTEN(zpd)); + udelay(5); + + val = readl_relaxed(pcubase + PCU_DM_ISOEN(zpd)); + val &= ~BIT(zpd->bit); + writel_relaxed(val, pcubase + PCU_DM_ISOEN(zpd)); + udelay(5); + + val = readl_relaxed(pcubase + PCU_DM_CLKEN(zpd)); + val |= BIT(zpd->bit); + writel_relaxed(val, pcubase + PCU_DM_CLKEN(zpd)); + udelay(5); + + pr_debug("normal poweron %s\n", domain->name); + + return 0; +} + +int zx2967_power_off(struct generic_pm_domain *domain) +{ + struct zx2967_pm_domain *zpd = (struct zx2967_pm_domain *)domain; + unsigned long loop = 1000; + u32 val; + + val = readl_relaxed(pcubase + PCU_DM_CLKEN(zpd)); + val &= ~BIT(zpd->bit); + writel_relaxed(val, pcubase + PCU_DM_CLKEN(zpd)); + udelay(5); + + val = readl_relaxed(pcubase + PCU_DM_ISOEN(zpd)); + val |= BIT(zpd->bit); + writel_relaxed(val, pcubase + PCU_DM_ISOEN(zpd)); + udelay(5); + + val = readl_relaxed(pcubase + PCU_DM_RSTEN(zpd)); + val &= ~BIT(zpd->bit); + writel_relaxed(val, pcubase + PCU_DM_RSTEN(zpd)); + udelay(5); + + val = readl_relaxed(pcubase + PCU_DM_PWREN(zpd)); + if (zpd->polarity == PWREN) + val &= ~BIT(zpd->bit); + else + val |= BIT(zpd->bit); + writel_relaxed(val, pcubase + PCU_DM_PWRDN(zpd)); + + do { + udelay(1); + val = readl_relaxed(pcubase + PCU_DM_ACK_SYNC(zpd)) + & BIT(zpd->bit); + } while (--loop && val); + + if (!loop) { + pr_err("Error: %s %s fail\n", __func__, domain->name); + return -EIO; + } + + pr_debug("normal poweroff %s\n", domain->name); + + return 0; +} + +int zx2967_pd_probe(struct platform_device *pdev, + struct generic_pm_domain **zx_pm_domains, + int domain_num) +{ + struct genpd_onecell_data *genpd_data; + struct resource *res; + int i; + + genpd_data = devm_kzalloc(&pdev->dev, sizeof(*genpd_data), GFP_KERNEL); + if (!genpd_data) + return -ENOMEM; + + genpd_data->domains = zx_pm_domains; + genpd_data->num_domains = domain_num; + + res = platform_get_resource(pdev, IORESOURCE_MEM, 0); + pcubase = devm_ioremap_resource(&pdev->dev, res); + if (IS_ERR(pcubase)) { + dev_err(&pdev->dev, "ioremap fail.\n"); + return PTR_ERR(pcubase); + } + + for (i = 0; i < domain_num; ++i) + pm_genpd_init(zx_pm_domains[i], NULL, false); + + of_genpd_add_provider_onecell(pdev->dev.of_node, genpd_data); + dev_info(&pdev->dev, "powerdomain init ok\n"); + return 0; +} diff --git a/drivers/soc/zte/zx2967_pm_domains.h b/drivers/soc/zte/zx2967_pm_domains.h new file mode 100644 index 0000000..35938c3 --- /dev/null +++ b/drivers/soc/zte/zx2967_pm_domains.h @@ -0,0 +1,45 @@ +/* + * Header for ZTE's Power Domain Driver support + * + * Copyright (C) 2015 ZTE Ltd. + * + * Author: Baoyou Xie <baoyou.xie@linaro.org> + * License terms: GNU General Public License (GPL) version 2 + */ + +#ifndef __ZTE_ZX2967_PM_DOMAIN_H +#define __ZTE_ZX2967_PM_DOMAIN_H + +#include <linux/platform_device.h> +#include <linux/pm_domain.h> + +enum { + REG_CLKEN, + REG_ISOEN, + REG_RSTEN, + REG_PWREN, + REG_PWRDN, + REG_ACK_SYNC, + + /* The size of the array - must be last */ + REG_ARRAY_SIZE, +}; + +enum zx2967_power_polarity { + PWREN, + PWRDN, +}; + +struct zx2967_pm_domain { + struct generic_pm_domain dm; + const u16 bit; + const enum zx2967_power_polarity polarity; + const u16 *reg_offset; +}; + +extern int zx2967_power_on(struct generic_pm_domain *domain); +extern int zx2967_power_off(struct generic_pm_domain *domain); +extern int zx2967_pd_probe(struct platform_device *pdev, + struct generic_pm_domain **zx_pm_domains, + int domain_num); +#endif /* __ZTE_ZX2967_PM_DOMAIN_H */ -- 2.7.4 ^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH v4 1/3] soc: zte: pm_domains: Prepare for supporting ARMv8 zx2967 family @ 2017-01-03 6:56 ` Baoyou Xie 0 siblings, 0 replies; 12+ messages in thread From: Baoyou Xie @ 2017-01-03 6:56 UTC (permalink / raw) To: jun.nie, krzk, arnd, roy.pledge, ulf.hansson, yangbo.lu, claudiu.manoil, pankaj.dubey, f.fainelli, scott.branden, horms+renesas, laurent.pinchart, amitdanielk, geert+renesas, shawnguo Cc: baoyou.xie, xie.baoyou, chen.chaokai, wang.qiang01, linux-kernel, linux-arm-kernel The ARMv8 zx2967 family (296718, 296716 etc) uses different value for controlling the power domain on/off registers, Choose the value depending on the compatible. Multiple domains are prepared for the family, this patch prepares the common functions. Signed-off-by: Baoyou Xie <baoyou.xie@linaro.org> --- drivers/soc/Kconfig | 1 + drivers/soc/Makefile | 1 + drivers/soc/zte/Kconfig | 13 ++++ drivers/soc/zte/Makefile | 4 ++ drivers/soc/zte/zx2967_pm_domains.c | 138 ++++++++++++++++++++++++++++++++++++ drivers/soc/zte/zx2967_pm_domains.h | 45 ++++++++++++ 6 files changed, 202 insertions(+) create mode 100644 drivers/soc/zte/Kconfig create mode 100644 drivers/soc/zte/Makefile create mode 100644 drivers/soc/zte/zx2967_pm_domains.c create mode 100644 drivers/soc/zte/zx2967_pm_domains.h diff --git a/drivers/soc/Kconfig b/drivers/soc/Kconfig index f31bceb..f09023f 100644 --- a/drivers/soc/Kconfig +++ b/drivers/soc/Kconfig @@ -11,5 +11,6 @@ source "drivers/soc/tegra/Kconfig" source "drivers/soc/ti/Kconfig" source "drivers/soc/ux500/Kconfig" source "drivers/soc/versatile/Kconfig" +source "drivers/soc/zte/Kconfig" endmenu diff --git a/drivers/soc/Makefile b/drivers/soc/Makefile index 50c23d0..05eae52 100644 --- a/drivers/soc/Makefile +++ b/drivers/soc/Makefile @@ -16,3 +16,4 @@ obj-$(CONFIG_ARCH_TEGRA) += tegra/ obj-$(CONFIG_SOC_TI) += ti/ obj-$(CONFIG_ARCH_U8500) += ux500/ obj-$(CONFIG_PLAT_VERSATILE) += versatile/ +obj-$(CONFIG_ARCH_ZX) += zte/ diff --git a/drivers/soc/zte/Kconfig b/drivers/soc/zte/Kconfig new file mode 100644 index 0000000..20bde38 --- /dev/null +++ b/drivers/soc/zte/Kconfig @@ -0,0 +1,13 @@ +# +# ZTE SoC drivers +# +menuconfig SOC_ZTE + bool "ZTE SoC driver support" + +if SOC_ZTE + +config ZX2967_PM_DOMAINS + bool "ZX2967 PM domains" + depends on PM_GENERIC_DOMAINS + +endif diff --git a/drivers/soc/zte/Makefile b/drivers/soc/zte/Makefile new file mode 100644 index 0000000..8a37f2f --- /dev/null +++ b/drivers/soc/zte/Makefile @@ -0,0 +1,4 @@ +# +# ZTE SOC drivers +# +obj-$(CONFIG_ZX2967_PM_DOMAINS) += zx2967_pm_domains.o diff --git a/drivers/soc/zte/zx2967_pm_domains.c b/drivers/soc/zte/zx2967_pm_domains.c new file mode 100644 index 0000000..98b3b5f --- /dev/null +++ b/drivers/soc/zte/zx2967_pm_domains.c @@ -0,0 +1,138 @@ +/* + * Copyright (C) 2015 ZTE Ltd. + * + * Author: Baoyou Xie <baoyou.xie@linaro.org> + * License terms: GNU General Public License (GPL) version 2 + */ +#include <linux/delay.h> +#include <linux/err.h> +#include <linux/io.h> +#include <linux/of.h> +#include "zx2967_pm_domains.h" + +#define PCU_DM_CLKEN(zpd) ((zpd)->reg_offset[REG_CLKEN]) +#define PCU_DM_ISOEN(zpd) ((zpd)->reg_offset[REG_ISOEN]) +#define PCU_DM_RSTEN(zpd) ((zpd)->reg_offset[REG_RSTEN]) +#define PCU_DM_PWREN(zpd) ((zpd)->reg_offset[REG_PWREN]) +#define PCU_DM_PWRDN(zpd) ((zpd)->reg_offset[REG_PWRDN]) +#define PCU_DM_ACK_SYNC(zpd) ((zpd)->reg_offset[REG_ACK_SYNC]) + +static void __iomem *pcubase; + +int zx2967_power_on(struct generic_pm_domain *domain) +{ + struct zx2967_pm_domain *zpd = (struct zx2967_pm_domain *)domain; + unsigned long loop = 1000; + u32 val; + + val = readl_relaxed(pcubase + PCU_DM_PWREN(zpd)); + if (zpd->polarity == PWREN) + val |= BIT(zpd->bit); + else + val &= ~BIT(zpd->bit); + writel_relaxed(val, pcubase + PCU_DM_PWRDN(zpd)); + + do { + udelay(1); + val = readl_relaxed(pcubase + PCU_DM_ACK_SYNC(zpd)) + & BIT(zpd->bit); + } while (--loop && !val); + + if (!loop) { + pr_err("Error: %s %s fail\n", __func__, domain->name); + return -EIO; + } + + val = readl_relaxed(pcubase + PCU_DM_RSTEN(zpd)); + val |= BIT(zpd->bit); + writel_relaxed(val, pcubase + PCU_DM_RSTEN(zpd)); + udelay(5); + + val = readl_relaxed(pcubase + PCU_DM_ISOEN(zpd)); + val &= ~BIT(zpd->bit); + writel_relaxed(val, pcubase + PCU_DM_ISOEN(zpd)); + udelay(5); + + val = readl_relaxed(pcubase + PCU_DM_CLKEN(zpd)); + val |= BIT(zpd->bit); + writel_relaxed(val, pcubase + PCU_DM_CLKEN(zpd)); + udelay(5); + + pr_debug("normal poweron %s\n", domain->name); + + return 0; +} + +int zx2967_power_off(struct generic_pm_domain *domain) +{ + struct zx2967_pm_domain *zpd = (struct zx2967_pm_domain *)domain; + unsigned long loop = 1000; + u32 val; + + val = readl_relaxed(pcubase + PCU_DM_CLKEN(zpd)); + val &= ~BIT(zpd->bit); + writel_relaxed(val, pcubase + PCU_DM_CLKEN(zpd)); + udelay(5); + + val = readl_relaxed(pcubase + PCU_DM_ISOEN(zpd)); + val |= BIT(zpd->bit); + writel_relaxed(val, pcubase + PCU_DM_ISOEN(zpd)); + udelay(5); + + val = readl_relaxed(pcubase + PCU_DM_RSTEN(zpd)); + val &= ~BIT(zpd->bit); + writel_relaxed(val, pcubase + PCU_DM_RSTEN(zpd)); + udelay(5); + + val = readl_relaxed(pcubase + PCU_DM_PWREN(zpd)); + if (zpd->polarity == PWREN) + val &= ~BIT(zpd->bit); + else + val |= BIT(zpd->bit); + writel_relaxed(val, pcubase + PCU_DM_PWRDN(zpd)); + + do { + udelay(1); + val = readl_relaxed(pcubase + PCU_DM_ACK_SYNC(zpd)) + & BIT(zpd->bit); + } while (--loop && val); + + if (!loop) { + pr_err("Error: %s %s fail\n", __func__, domain->name); + return -EIO; + } + + pr_debug("normal poweroff %s\n", domain->name); + + return 0; +} + +int zx2967_pd_probe(struct platform_device *pdev, + struct generic_pm_domain **zx_pm_domains, + int domain_num) +{ + struct genpd_onecell_data *genpd_data; + struct resource *res; + int i; + + genpd_data = devm_kzalloc(&pdev->dev, sizeof(*genpd_data), GFP_KERNEL); + if (!genpd_data) + return -ENOMEM; + + genpd_data->domains = zx_pm_domains; + genpd_data->num_domains = domain_num; + + res = platform_get_resource(pdev, IORESOURCE_MEM, 0); + pcubase = devm_ioremap_resource(&pdev->dev, res); + if (IS_ERR(pcubase)) { + dev_err(&pdev->dev, "ioremap fail.\n"); + return PTR_ERR(pcubase); + } + + for (i = 0; i < domain_num; ++i) + pm_genpd_init(zx_pm_domains[i], NULL, false); + + of_genpd_add_provider_onecell(pdev->dev.of_node, genpd_data); + dev_info(&pdev->dev, "powerdomain init ok\n"); + return 0; +} diff --git a/drivers/soc/zte/zx2967_pm_domains.h b/drivers/soc/zte/zx2967_pm_domains.h new file mode 100644 index 0000000..35938c3 --- /dev/null +++ b/drivers/soc/zte/zx2967_pm_domains.h @@ -0,0 +1,45 @@ +/* + * Header for ZTE's Power Domain Driver support + * + * Copyright (C) 2015 ZTE Ltd. + * + * Author: Baoyou Xie <baoyou.xie@linaro.org> + * License terms: GNU General Public License (GPL) version 2 + */ + +#ifndef __ZTE_ZX2967_PM_DOMAIN_H +#define __ZTE_ZX2967_PM_DOMAIN_H + +#include <linux/platform_device.h> +#include <linux/pm_domain.h> + +enum { + REG_CLKEN, + REG_ISOEN, + REG_RSTEN, + REG_PWREN, + REG_PWRDN, + REG_ACK_SYNC, + + /* The size of the array - must be last */ + REG_ARRAY_SIZE, +}; + +enum zx2967_power_polarity { + PWREN, + PWRDN, +}; + +struct zx2967_pm_domain { + struct generic_pm_domain dm; + const u16 bit; + const enum zx2967_power_polarity polarity; + const u16 *reg_offset; +}; + +extern int zx2967_power_on(struct generic_pm_domain *domain); +extern int zx2967_power_off(struct generic_pm_domain *domain); +extern int zx2967_pd_probe(struct platform_device *pdev, + struct generic_pm_domain **zx_pm_domains, + int domain_num); +#endif /* __ZTE_ZX2967_PM_DOMAIN_H */ -- 2.7.4 ^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH v4 2/3] soc: zte: pm_domains: Add support for zx296718 board 2017-01-03 6:56 ` Baoyou Xie @ 2017-01-03 6:56 ` Baoyou Xie -1 siblings, 0 replies; 12+ messages in thread From: Baoyou Xie @ 2017-01-03 6:56 UTC (permalink / raw) To: linux-arm-kernel This patch introduces the power domain driver of zx296718 which belongs to zte's zx2967 family. Signed-off-by: Baoyou Xie <baoyou.xie@linaro.org> --- drivers/soc/zte/Makefile | 2 +- drivers/soc/zte/zx296718_pm_domains.c | 194 ++++++++++++++++++++++++++++++++++ 2 files changed, 195 insertions(+), 1 deletion(-) create mode 100644 drivers/soc/zte/zx296718_pm_domains.c diff --git a/drivers/soc/zte/Makefile b/drivers/soc/zte/Makefile index 8a37f2f..f399553 100644 --- a/drivers/soc/zte/Makefile +++ b/drivers/soc/zte/Makefile @@ -1,4 +1,4 @@ # # ZTE SOC drivers # -obj-$(CONFIG_ZX2967_PM_DOMAINS) += zx2967_pm_domains.o +obj-$(CONFIG_ZX2967_PM_DOMAINS) += zx2967_pm_domains.o zx296718_pm_domains.o diff --git a/drivers/soc/zte/zx296718_pm_domains.c b/drivers/soc/zte/zx296718_pm_domains.c new file mode 100644 index 0000000..7d0bce6 --- /dev/null +++ b/drivers/soc/zte/zx296718_pm_domains.c @@ -0,0 +1,194 @@ +/* + * Copyright (C) 2015 ZTE Ltd. + * + * Author: Baoyou Xie <baoyou.xie@linaro.org> + * License terms: GNU General Public License (GPL) version 2 + */ +#include <dt-bindings/soc/zx2967,pm_domains.h> +#include "zx2967_pm_domains.h" + +static u16 zx296718_offsets[REG_ARRAY_SIZE] = { + [REG_CLKEN] = 0x18, + [REG_ISOEN] = 0x1c, + [REG_RSTEN] = 0x20, + [REG_PWREN] = 0x24, + [REG_ACK_SYNC] = 0x28, +}; + +enum { + PCU_DM_VOU = 0, + PCU_DM_SAPPU, + PCU_DM_VDE, + PCU_DM_VCE, + PCU_DM_HDE, + PCU_DM_VIU, + PCU_DM_USB20, + PCU_DM_USB21, + PCU_DM_USB30, + PCU_DM_HSIC, + PCU_DM_GMAC, + PCU_DM_TS, +}; + +static struct zx2967_pm_domain vou_domain = { + .dm = { + .name = "vou_domain", + .power_off = zx2967_power_off, + .power_on = zx2967_power_on, + }, + .bit = PCU_DM_VOU, + .polarity = PWREN, + .reg_offset = zx296718_offsets, +}; +static struct zx2967_pm_domain sappu_domain = { + .dm = { + .name = "sappu_domain", + .power_off = zx2967_power_off, + .power_on = zx2967_power_on, + }, + .bit = PCU_DM_SAPPU, + .polarity = PWREN, + .reg_offset = zx296718_offsets, +}; +static struct zx2967_pm_domain vde_domain = { + .dm = { + .name = "vde_domain", + .power_off = zx2967_power_off, + .power_on = zx2967_power_on, + }, + .bit = PCU_DM_VDE, + .polarity = PWREN, + .reg_offset = zx296718_offsets, +}; +static struct zx2967_pm_domain vce_domain = { + .dm = { + .name = "vce_domain", + .power_off = zx2967_power_off, + .power_on = zx2967_power_on, + }, + .bit = PCU_DM_VCE, + .polarity = PWREN, + .reg_offset = zx296718_offsets, +}; +static struct zx2967_pm_domain hde_domain = { + .dm = { + .name = "hde_domain", + .power_off = zx2967_power_off, + .power_on = zx2967_power_on, + }, + .bit = PCU_DM_HDE, + .polarity = PWREN, + .reg_offset = zx296718_offsets, +}; + +static struct zx2967_pm_domain viu_domain = { + .dm = { + .name = "viu_domain", + .power_off = zx2967_power_off, + .power_on = zx2967_power_on, + }, + .bit = PCU_DM_VIU, + .polarity = PWREN, + .reg_offset = zx296718_offsets, +}; +static struct zx2967_pm_domain usb20_domain = { + .dm = { + .name = "usb20_domain", + .power_off = zx2967_power_off, + .power_on = zx2967_power_on, + }, + .bit = PCU_DM_USB20, + .polarity = PWREN, + .reg_offset = zx296718_offsets, +}; +static struct zx2967_pm_domain usb21_domain = { + .dm = { + .name = "usb21_domain", + .power_off = zx2967_power_off, + .power_on = zx2967_power_on, + }, + .bit = PCU_DM_USB21, + .polarity = PWREN, + .reg_offset = zx296718_offsets, +}; +static struct zx2967_pm_domain usb30_domain = { + .dm = { + .name = "usb30_domain", + .power_off = zx2967_power_off, + .power_on = zx2967_power_on, + }, + .bit = PCU_DM_USB30, + .polarity = PWREN, + .reg_offset = zx296718_offsets, +}; +static struct zx2967_pm_domain hsic_domain = { + .dm = { + .name = "hsic_domain", + .power_off = zx2967_power_off, + .power_on = zx2967_power_on, + }, + .bit = PCU_DM_HSIC, + .polarity = PWREN, + .reg_offset = zx296718_offsets, +}; +static struct zx2967_pm_domain gmac_domain = { + .dm = { + .name = "gmac_domain", + .power_off = zx2967_power_off, + .power_on = zx2967_power_on, + }, + .bit = PCU_DM_GMAC, + .polarity = PWREN, + .reg_offset = zx296718_offsets, +}; +static struct zx2967_pm_domain ts_domain = { + .dm = { + .name = "ts_domain", + .power_off = zx2967_power_off, + .power_on = zx2967_power_on, + }, + .bit = PCU_DM_TS, + .polarity = PWREN, + .reg_offset = zx296718_offsets, +}; +struct generic_pm_domain *zx296718_pm_domains[] = { + [DM_ZX296718_SAPPU] = &sappu_domain.dm, + [DM_ZX296718_VDE] = &vde_domain.dm, + [DM_ZX296718_VCE] = &vce_domain.dm, + [DM_ZX296718_HDE] = &hde_domain.dm, + [DM_ZX296718_VIU] = &viu_domain.dm, + [DM_ZX296718_USB20] = &usb20_domain.dm, + [DM_ZX296718_USB21] = &usb21_domain.dm, + [DM_ZX296718_USB30] = &usb30_domain.dm, + [DM_ZX296718_HSIC] = &hsic_domain.dm, + [DM_ZX296718_GMAC] = &gmac_domain.dm, + [DM_ZX296718_TS] = &ts_domain.dm, + [DM_ZX296718_VOU] = &vou_domain.dm, +}; + +static int zx296718_pd_probe(struct platform_device *pdev) +{ + return zx2967_pd_probe(pdev, + zx296718_pm_domains, + ARRAY_SIZE(zx296718_pm_domains)); +} + +static const struct of_device_id zx296718_pm_domain_matches[] = { + { .compatible = "zte,zx296718-pcu", }, + { }, +}; + +static struct platform_driver zx296718_pd_driver = { + .driver = { + .name = "zx-powerdomain", + .owner = THIS_MODULE, + .of_match_table = zx296718_pm_domain_matches, + }, + .probe = zx296718_pd_probe, +}; + +static int __init zx296718_pd_init(void) +{ + return platform_driver_register(&zx296718_pd_driver); +} +subsys_initcall(zx296718_pd_init); -- 2.7.4 ^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH v4 2/3] soc: zte: pm_domains: Add support for zx296718 board @ 2017-01-03 6:56 ` Baoyou Xie 0 siblings, 0 replies; 12+ messages in thread From: Baoyou Xie @ 2017-01-03 6:56 UTC (permalink / raw) To: jun.nie, krzk, arnd, roy.pledge, ulf.hansson, yangbo.lu, claudiu.manoil, pankaj.dubey, f.fainelli, scott.branden, horms+renesas, laurent.pinchart, amitdanielk, geert+renesas, shawnguo Cc: baoyou.xie, xie.baoyou, chen.chaokai, wang.qiang01, linux-kernel, linux-arm-kernel This patch introduces the power domain driver of zx296718 which belongs to zte's zx2967 family. Signed-off-by: Baoyou Xie <baoyou.xie@linaro.org> --- drivers/soc/zte/Makefile | 2 +- drivers/soc/zte/zx296718_pm_domains.c | 194 ++++++++++++++++++++++++++++++++++ 2 files changed, 195 insertions(+), 1 deletion(-) create mode 100644 drivers/soc/zte/zx296718_pm_domains.c diff --git a/drivers/soc/zte/Makefile b/drivers/soc/zte/Makefile index 8a37f2f..f399553 100644 --- a/drivers/soc/zte/Makefile +++ b/drivers/soc/zte/Makefile @@ -1,4 +1,4 @@ # # ZTE SOC drivers # -obj-$(CONFIG_ZX2967_PM_DOMAINS) += zx2967_pm_domains.o +obj-$(CONFIG_ZX2967_PM_DOMAINS) += zx2967_pm_domains.o zx296718_pm_domains.o diff --git a/drivers/soc/zte/zx296718_pm_domains.c b/drivers/soc/zte/zx296718_pm_domains.c new file mode 100644 index 0000000..7d0bce6 --- /dev/null +++ b/drivers/soc/zte/zx296718_pm_domains.c @@ -0,0 +1,194 @@ +/* + * Copyright (C) 2015 ZTE Ltd. + * + * Author: Baoyou Xie <baoyou.xie@linaro.org> + * License terms: GNU General Public License (GPL) version 2 + */ +#include <dt-bindings/soc/zx2967,pm_domains.h> +#include "zx2967_pm_domains.h" + +static u16 zx296718_offsets[REG_ARRAY_SIZE] = { + [REG_CLKEN] = 0x18, + [REG_ISOEN] = 0x1c, + [REG_RSTEN] = 0x20, + [REG_PWREN] = 0x24, + [REG_ACK_SYNC] = 0x28, +}; + +enum { + PCU_DM_VOU = 0, + PCU_DM_SAPPU, + PCU_DM_VDE, + PCU_DM_VCE, + PCU_DM_HDE, + PCU_DM_VIU, + PCU_DM_USB20, + PCU_DM_USB21, + PCU_DM_USB30, + PCU_DM_HSIC, + PCU_DM_GMAC, + PCU_DM_TS, +}; + +static struct zx2967_pm_domain vou_domain = { + .dm = { + .name = "vou_domain", + .power_off = zx2967_power_off, + .power_on = zx2967_power_on, + }, + .bit = PCU_DM_VOU, + .polarity = PWREN, + .reg_offset = zx296718_offsets, +}; +static struct zx2967_pm_domain sappu_domain = { + .dm = { + .name = "sappu_domain", + .power_off = zx2967_power_off, + .power_on = zx2967_power_on, + }, + .bit = PCU_DM_SAPPU, + .polarity = PWREN, + .reg_offset = zx296718_offsets, +}; +static struct zx2967_pm_domain vde_domain = { + .dm = { + .name = "vde_domain", + .power_off = zx2967_power_off, + .power_on = zx2967_power_on, + }, + .bit = PCU_DM_VDE, + .polarity = PWREN, + .reg_offset = zx296718_offsets, +}; +static struct zx2967_pm_domain vce_domain = { + .dm = { + .name = "vce_domain", + .power_off = zx2967_power_off, + .power_on = zx2967_power_on, + }, + .bit = PCU_DM_VCE, + .polarity = PWREN, + .reg_offset = zx296718_offsets, +}; +static struct zx2967_pm_domain hde_domain = { + .dm = { + .name = "hde_domain", + .power_off = zx2967_power_off, + .power_on = zx2967_power_on, + }, + .bit = PCU_DM_HDE, + .polarity = PWREN, + .reg_offset = zx296718_offsets, +}; + +static struct zx2967_pm_domain viu_domain = { + .dm = { + .name = "viu_domain", + .power_off = zx2967_power_off, + .power_on = zx2967_power_on, + }, + .bit = PCU_DM_VIU, + .polarity = PWREN, + .reg_offset = zx296718_offsets, +}; +static struct zx2967_pm_domain usb20_domain = { + .dm = { + .name = "usb20_domain", + .power_off = zx2967_power_off, + .power_on = zx2967_power_on, + }, + .bit = PCU_DM_USB20, + .polarity = PWREN, + .reg_offset = zx296718_offsets, +}; +static struct zx2967_pm_domain usb21_domain = { + .dm = { + .name = "usb21_domain", + .power_off = zx2967_power_off, + .power_on = zx2967_power_on, + }, + .bit = PCU_DM_USB21, + .polarity = PWREN, + .reg_offset = zx296718_offsets, +}; +static struct zx2967_pm_domain usb30_domain = { + .dm = { + .name = "usb30_domain", + .power_off = zx2967_power_off, + .power_on = zx2967_power_on, + }, + .bit = PCU_DM_USB30, + .polarity = PWREN, + .reg_offset = zx296718_offsets, +}; +static struct zx2967_pm_domain hsic_domain = { + .dm = { + .name = "hsic_domain", + .power_off = zx2967_power_off, + .power_on = zx2967_power_on, + }, + .bit = PCU_DM_HSIC, + .polarity = PWREN, + .reg_offset = zx296718_offsets, +}; +static struct zx2967_pm_domain gmac_domain = { + .dm = { + .name = "gmac_domain", + .power_off = zx2967_power_off, + .power_on = zx2967_power_on, + }, + .bit = PCU_DM_GMAC, + .polarity = PWREN, + .reg_offset = zx296718_offsets, +}; +static struct zx2967_pm_domain ts_domain = { + .dm = { + .name = "ts_domain", + .power_off = zx2967_power_off, + .power_on = zx2967_power_on, + }, + .bit = PCU_DM_TS, + .polarity = PWREN, + .reg_offset = zx296718_offsets, +}; +struct generic_pm_domain *zx296718_pm_domains[] = { + [DM_ZX296718_SAPPU] = &sappu_domain.dm, + [DM_ZX296718_VDE] = &vde_domain.dm, + [DM_ZX296718_VCE] = &vce_domain.dm, + [DM_ZX296718_HDE] = &hde_domain.dm, + [DM_ZX296718_VIU] = &viu_domain.dm, + [DM_ZX296718_USB20] = &usb20_domain.dm, + [DM_ZX296718_USB21] = &usb21_domain.dm, + [DM_ZX296718_USB30] = &usb30_domain.dm, + [DM_ZX296718_HSIC] = &hsic_domain.dm, + [DM_ZX296718_GMAC] = &gmac_domain.dm, + [DM_ZX296718_TS] = &ts_domain.dm, + [DM_ZX296718_VOU] = &vou_domain.dm, +}; + +static int zx296718_pd_probe(struct platform_device *pdev) +{ + return zx2967_pd_probe(pdev, + zx296718_pm_domains, + ARRAY_SIZE(zx296718_pm_domains)); +} + +static const struct of_device_id zx296718_pm_domain_matches[] = { + { .compatible = "zte,zx296718-pcu", }, + { }, +}; + +static struct platform_driver zx296718_pd_driver = { + .driver = { + .name = "zx-powerdomain", + .owner = THIS_MODULE, + .of_match_table = zx296718_pm_domain_matches, + }, + .probe = zx296718_pd_probe, +}; + +static int __init zx296718_pd_init(void) +{ + return platform_driver_register(&zx296718_pd_driver); +} +subsys_initcall(zx296718_pd_init); -- 2.7.4 ^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH v4 2/3] soc: zte: pm_domains: Add support for zx296718 board 2017-01-03 6:56 ` Baoyou Xie @ 2017-01-03 11:08 ` Shawn Guo -1 siblings, 0 replies; 12+ messages in thread From: Shawn Guo @ 2017-01-03 11:08 UTC (permalink / raw) To: linux-arm-kernel On Tue, Jan 03, 2017 at 02:56:16PM +0800, Baoyou Xie wrote: > This patch introduces the power domain driver of zx296718 > which belongs to zte's zx2967 family. > > Signed-off-by: Baoyou Xie <baoyou.xie@linaro.org> It seems that none of the review comments I put on v3 [1] gets addressed in this version. You missed them? Shawn [1] http://www.spinics.net/lists/arm-kernel/msg547691.html ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH v4 2/3] soc: zte: pm_domains: Add support for zx296718 board @ 2017-01-03 11:08 ` Shawn Guo 0 siblings, 0 replies; 12+ messages in thread From: Shawn Guo @ 2017-01-03 11:08 UTC (permalink / raw) To: Baoyou Xie Cc: jun.nie, krzk, arnd, roy.pledge, ulf.hansson, yangbo.lu, claudiu.manoil, pankaj.dubey, f.fainelli, scott.branden, horms+renesas, laurent.pinchart, amitdanielk, geert+renesas, xie.baoyou, chen.chaokai, wang.qiang01, linux-kernel, linux-arm-kernel On Tue, Jan 03, 2017 at 02:56:16PM +0800, Baoyou Xie wrote: > This patch introduces the power domain driver of zx296718 > which belongs to zte's zx2967 family. > > Signed-off-by: Baoyou Xie <baoyou.xie@linaro.org> It seems that none of the review comments I put on v3 [1] gets addressed in this version. You missed them? Shawn [1] http://www.spinics.net/lists/arm-kernel/msg547691.html ^ permalink raw reply [flat|nested] 12+ messages in thread
* [PATCH v4 2/3] soc: zte: pm_domains: Add support for zx296718 board 2017-01-03 6:56 ` Baoyou Xie @ 2017-01-03 12:26 ` kbuild test robot -1 siblings, 0 replies; 12+ messages in thread From: kbuild test robot @ 2017-01-03 12:26 UTC (permalink / raw) To: linux-arm-kernel Hi Baoyou, [auto build test ERROR on linus/master] [also build test ERROR on v4.10-rc2 next-20161224] [if your patch is applied to the wrong git tree, please drop us a note to help improve the system] url: https://github.com/0day-ci/linux/commits/Baoyou-Xie/soc-zte-pm_domains-Prepare-for-supporting-ARMv8-zx2967-family/20170103-181714 config: arm-allmodconfig (attached as .config) compiler: arm-linux-gnueabi-gcc (Debian 6.1.1-9) 6.1.1 20160705 reproduce: wget https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross # save the attached .config to linux build tree make.cross ARCH=arm All errors (new ones prefixed by >>): >> drivers/soc/zte/zx296718_pm_domains.c:7:47: fatal error: dt-bindings/soc/zx2967,pm_domains.h: No such file or directory #include <dt-bindings/soc/zx2967,pm_domains.h> ^ compilation terminated. vim +7 drivers/soc/zte/zx296718_pm_domains.c 1 /* 2 * Copyright (C) 2015 ZTE Ltd. 3 * 4 * Author: Baoyou Xie <baoyou.xie@linaro.org> 5 * License terms: GNU General Public License (GPL) version 2 6 */ > 7 #include <dt-bindings/soc/zx2967,pm_domains.h> 8 #include "zx2967_pm_domains.h" 9 10 static u16 zx296718_offsets[REG_ARRAY_SIZE] = { --- 0-DAY kernel test infrastructure Open Source Technology Center https://lists.01.org/pipermail/kbuild-all Intel Corporation -------------- next part -------------- A non-text attachment was scrubbed... Name: .config.gz Type: application/gzip Size: 60343 bytes Desc: not available URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20170103/2d453a38/attachment-0001.gz> ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH v4 2/3] soc: zte: pm_domains: Add support for zx296718 board @ 2017-01-03 12:26 ` kbuild test robot 0 siblings, 0 replies; 12+ messages in thread From: kbuild test robot @ 2017-01-03 12:26 UTC (permalink / raw) To: Baoyou Xie Cc: kbuild-all, jun.nie, krzk, arnd, roy.pledge, ulf.hansson, yangbo.lu, claudiu.manoil, pankaj.dubey, f.fainelli, scott.branden, horms+renesas, laurent.pinchart, amitdanielk, geert+renesas, shawnguo, baoyou.xie, xie.baoyou, chen.chaokai, wang.qiang01, linux-kernel, linux-arm-kernel [-- Attachment #1: Type: text/plain, Size: 1546 bytes --] Hi Baoyou, [auto build test ERROR on linus/master] [also build test ERROR on v4.10-rc2 next-20161224] [if your patch is applied to the wrong git tree, please drop us a note to help improve the system] url: https://github.com/0day-ci/linux/commits/Baoyou-Xie/soc-zte-pm_domains-Prepare-for-supporting-ARMv8-zx2967-family/20170103-181714 config: arm-allmodconfig (attached as .config) compiler: arm-linux-gnueabi-gcc (Debian 6.1.1-9) 6.1.1 20160705 reproduce: wget https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross # save the attached .config to linux build tree make.cross ARCH=arm All errors (new ones prefixed by >>): >> drivers/soc/zte/zx296718_pm_domains.c:7:47: fatal error: dt-bindings/soc/zx2967,pm_domains.h: No such file or directory #include <dt-bindings/soc/zx2967,pm_domains.h> ^ compilation terminated. vim +7 drivers/soc/zte/zx296718_pm_domains.c 1 /* 2 * Copyright (C) 2015 ZTE Ltd. 3 * 4 * Author: Baoyou Xie <baoyou.xie@linaro.org> 5 * License terms: GNU General Public License (GPL) version 2 6 */ > 7 #include <dt-bindings/soc/zx2967,pm_domains.h> 8 #include "zx2967_pm_domains.h" 9 10 static u16 zx296718_offsets[REG_ARRAY_SIZE] = { --- 0-DAY kernel test infrastructure Open Source Technology Center https://lists.01.org/pipermail/kbuild-all Intel Corporation [-- Attachment #2: .config.gz --] [-- Type: application/gzip, Size: 60343 bytes --] ^ permalink raw reply [flat|nested] 12+ messages in thread
* [PATCH v4 3/3] MAINTAINERS: add zx2967 SoC drivers to ARM ZTE architecture 2017-01-03 6:56 ` Baoyou Xie @ 2017-01-03 6:56 ` Baoyou Xie -1 siblings, 0 replies; 12+ messages in thread From: Baoyou Xie @ 2017-01-03 6:56 UTC (permalink / raw) To: linux-arm-kernel Add the ZTE SoC drivers as maintained by ARM ZTE architecture maintainers, as they're parts of the core IP. By the way, this patch adds the maintainer for ARM ZTE architecture to Baoyou Xie. Signed-off-by: Baoyou Xie <baoyou.xie@linaro.org> --- MAINTAINERS | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/MAINTAINERS b/MAINTAINERS index ad199da..64f04df 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -1975,12 +1975,16 @@ F: arch/arm/mach-pxa/include/mach/z2.h ARM/ZTE ARCHITECTURE M: Jun Nie <jun.nie@linaro.org> +M: Baoyou Xie <baoyou.xie@linaro.org> L: linux-arm-kernel at lists.infradead.org (moderated for non-subscribers) S: Maintained F: arch/arm/mach-zx/ F: drivers/clk/zte/ +F: drivers/soc/zte/ F: Documentation/devicetree/bindings/arm/zte.txt F: Documentation/devicetree/bindings/clock/zx296702-clk.txt +F: Documentation/devicetree/bindings/soc/zte/ +F: include/dt-bindings/soc/zx*.h ARM/ZYNQ ARCHITECTURE M: Michal Simek <michal.simek@xilinx.com> -- 2.7.4 ^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH v4 3/3] MAINTAINERS: add zx2967 SoC drivers to ARM ZTE architecture @ 2017-01-03 6:56 ` Baoyou Xie 0 siblings, 0 replies; 12+ messages in thread From: Baoyou Xie @ 2017-01-03 6:56 UTC (permalink / raw) To: jun.nie, krzk, arnd, roy.pledge, ulf.hansson, yangbo.lu, claudiu.manoil, pankaj.dubey, f.fainelli, scott.branden, horms+renesas, laurent.pinchart, amitdanielk, geert+renesas, shawnguo Cc: baoyou.xie, xie.baoyou, chen.chaokai, wang.qiang01, linux-kernel, linux-arm-kernel Add the ZTE SoC drivers as maintained by ARM ZTE architecture maintainers, as they're parts of the core IP. By the way, this patch adds the maintainer for ARM ZTE architecture to Baoyou Xie. Signed-off-by: Baoyou Xie <baoyou.xie@linaro.org> --- MAINTAINERS | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/MAINTAINERS b/MAINTAINERS index ad199da..64f04df 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -1975,12 +1975,16 @@ F: arch/arm/mach-pxa/include/mach/z2.h ARM/ZTE ARCHITECTURE M: Jun Nie <jun.nie@linaro.org> +M: Baoyou Xie <baoyou.xie@linaro.org> L: linux-arm-kernel@lists.infradead.org (moderated for non-subscribers) S: Maintained F: arch/arm/mach-zx/ F: drivers/clk/zte/ +F: drivers/soc/zte/ F: Documentation/devicetree/bindings/arm/zte.txt F: Documentation/devicetree/bindings/clock/zx296702-clk.txt +F: Documentation/devicetree/bindings/soc/zte/ +F: include/dt-bindings/soc/zx*.h ARM/ZYNQ ARCHITECTURE M: Michal Simek <michal.simek@xilinx.com> -- 2.7.4 ^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH v4 1/3] soc: zte: pm_domains: Prepare for supporting ARMv8 zx2967 family 2017-01-03 6:56 ` Baoyou Xie @ 2017-01-03 11:32 ` Shawn Guo -1 siblings, 0 replies; 12+ messages in thread From: Shawn Guo @ 2017-01-03 11:32 UTC (permalink / raw) To: linux-arm-kernel On Tue, Jan 03, 2017 at 02:56:15PM +0800, Baoyou Xie wrote: > The ARMv8 zx2967 family (296718, 296716 etc) uses different value > for controlling the power domain on/off registers, Choose the > value depending on the compatible. > > Multiple domains are prepared for the family, this patch prepares > the common functions. > > Signed-off-by: Baoyou Xie <baoyou.xie@linaro.org> > --- > drivers/soc/Kconfig | 1 + > drivers/soc/Makefile | 1 + > drivers/soc/zte/Kconfig | 13 ++++ > drivers/soc/zte/Makefile | 4 ++ > drivers/soc/zte/zx2967_pm_domains.c | 138 ++++++++++++++++++++++++++++++++++++ > drivers/soc/zte/zx2967_pm_domains.h | 45 ++++++++++++ > 6 files changed, 202 insertions(+) > create mode 100644 drivers/soc/zte/Kconfig > create mode 100644 drivers/soc/zte/Makefile > create mode 100644 drivers/soc/zte/zx2967_pm_domains.c > create mode 100644 drivers/soc/zte/zx2967_pm_domains.h > > diff --git a/drivers/soc/Kconfig b/drivers/soc/Kconfig > index f31bceb..f09023f 100644 > --- a/drivers/soc/Kconfig > +++ b/drivers/soc/Kconfig > @@ -11,5 +11,6 @@ source "drivers/soc/tegra/Kconfig" > source "drivers/soc/ti/Kconfig" > source "drivers/soc/ux500/Kconfig" > source "drivers/soc/versatile/Kconfig" > +source "drivers/soc/zte/Kconfig" > > endmenu > diff --git a/drivers/soc/Makefile b/drivers/soc/Makefile > index 50c23d0..05eae52 100644 > --- a/drivers/soc/Makefile > +++ b/drivers/soc/Makefile > @@ -16,3 +16,4 @@ obj-$(CONFIG_ARCH_TEGRA) += tegra/ > obj-$(CONFIG_SOC_TI) += ti/ > obj-$(CONFIG_ARCH_U8500) += ux500/ > obj-$(CONFIG_PLAT_VERSATILE) += versatile/ > +obj-$(CONFIG_ARCH_ZX) += zte/ > diff --git a/drivers/soc/zte/Kconfig b/drivers/soc/zte/Kconfig > new file mode 100644 > index 0000000..20bde38 > --- /dev/null > +++ b/drivers/soc/zte/Kconfig > @@ -0,0 +1,13 @@ > +# > +# ZTE SoC drivers > +# > +menuconfig SOC_ZTE > + bool "ZTE SoC driver support" > + > +if SOC_ZTE > + > +config ZX2967_PM_DOMAINS > + bool "ZX2967 PM domains" > + depends on PM_GENERIC_DOMAINS > + > +endif > diff --git a/drivers/soc/zte/Makefile b/drivers/soc/zte/Makefile > new file mode 100644 > index 0000000..8a37f2f > --- /dev/null > +++ b/drivers/soc/zte/Makefile > @@ -0,0 +1,4 @@ > +# > +# ZTE SOC drivers > +# > +obj-$(CONFIG_ZX2967_PM_DOMAINS) += zx2967_pm_domains.o > diff --git a/drivers/soc/zte/zx2967_pm_domains.c b/drivers/soc/zte/zx2967_pm_domains.c > new file mode 100644 > index 0000000..98b3b5f > --- /dev/null > +++ b/drivers/soc/zte/zx2967_pm_domains.c > @@ -0,0 +1,138 @@ > +/* > + * Copyright (C) 2015 ZTE Ltd. What about year 2017? > + * > + * Author: Baoyou Xie <baoyou.xie@linaro.org> > + * License terms: GNU General Public License (GPL) version 2 > + */ > +#include <linux/delay.h> > +#include <linux/err.h> > +#include <linux/io.h> > +#include <linux/of.h> Can we have a newline between system and local includes? > +#include "zx2967_pm_domains.h" > + > +#define PCU_DM_CLKEN(zpd) ((zpd)->reg_offset[REG_CLKEN]) > +#define PCU_DM_ISOEN(zpd) ((zpd)->reg_offset[REG_ISOEN]) > +#define PCU_DM_RSTEN(zpd) ((zpd)->reg_offset[REG_RSTEN]) > +#define PCU_DM_PWREN(zpd) ((zpd)->reg_offset[REG_PWREN]) > +#define PCU_DM_PWRDN(zpd) ((zpd)->reg_offset[REG_PWRDN]) > +#define PCU_DM_ACK_SYNC(zpd) ((zpd)->reg_offset[REG_ACK_SYNC]) > + > +static void __iomem *pcubase; > + > +int zx2967_power_on(struct generic_pm_domain *domain) > +{ > + struct zx2967_pm_domain *zpd = (struct zx2967_pm_domain *)domain; > + unsigned long loop = 1000; > + u32 val; > + > + val = readl_relaxed(pcubase + PCU_DM_PWREN(zpd)); > + if (zpd->polarity == PWREN) > + val |= BIT(zpd->bit); > + else > + val &= ~BIT(zpd->bit); > + writel_relaxed(val, pcubase + PCU_DM_PWRDN(zpd)); Hmm, do you really want to read val from PCU_DM_PWREN and then write back to PCU_DM_PWRDN? They are two different registers or same one? A bit confused here. > + > + do { > + udelay(1); > + val = readl_relaxed(pcubase + PCU_DM_ACK_SYNC(zpd)) > + & BIT(zpd->bit); > + } while (--loop && !val); > + > + if (!loop) { > + pr_err("Error: %s %s fail\n", __func__, domain->name); > + return -EIO; > + } > + > + val = readl_relaxed(pcubase + PCU_DM_RSTEN(zpd)); > + val |= BIT(zpd->bit); > + writel_relaxed(val, pcubase + PCU_DM_RSTEN(zpd)); > + udelay(5); > + > + val = readl_relaxed(pcubase + PCU_DM_ISOEN(zpd)); > + val &= ~BIT(zpd->bit); > + writel_relaxed(val, pcubase + PCU_DM_ISOEN(zpd)); > + udelay(5); > + > + val = readl_relaxed(pcubase + PCU_DM_CLKEN(zpd)); > + val |= BIT(zpd->bit); > + writel_relaxed(val, pcubase + PCU_DM_CLKEN(zpd)); > + udelay(5); > + > + pr_debug("normal poweron %s\n", domain->name); > + > + return 0; > +} > + > +int zx2967_power_off(struct generic_pm_domain *domain) > +{ > + struct zx2967_pm_domain *zpd = (struct zx2967_pm_domain *)domain; > + unsigned long loop = 1000; > + u32 val; > + > + val = readl_relaxed(pcubase + PCU_DM_CLKEN(zpd)); > + val &= ~BIT(zpd->bit); > + writel_relaxed(val, pcubase + PCU_DM_CLKEN(zpd)); > + udelay(5); > + > + val = readl_relaxed(pcubase + PCU_DM_ISOEN(zpd)); > + val |= BIT(zpd->bit); > + writel_relaxed(val, pcubase + PCU_DM_ISOEN(zpd)); > + udelay(5); > + > + val = readl_relaxed(pcubase + PCU_DM_RSTEN(zpd)); > + val &= ~BIT(zpd->bit); > + writel_relaxed(val, pcubase + PCU_DM_RSTEN(zpd)); > + udelay(5); > + > + val = readl_relaxed(pcubase + PCU_DM_PWREN(zpd)); > + if (zpd->polarity == PWREN) > + val &= ~BIT(zpd->bit); > + else > + val |= BIT(zpd->bit); > + writel_relaxed(val, pcubase + PCU_DM_PWRDN(zpd)); Ditto > + > + do { > + udelay(1); > + val = readl_relaxed(pcubase + PCU_DM_ACK_SYNC(zpd)) > + & BIT(zpd->bit); > + } while (--loop && val); > + > + if (!loop) { > + pr_err("Error: %s %s fail\n", __func__, domain->name); > + return -EIO; > + } > + > + pr_debug("normal poweroff %s\n", domain->name); > + > + return 0; > +} > + > +int zx2967_pd_probe(struct platform_device *pdev, > + struct generic_pm_domain **zx_pm_domains, > + int domain_num) Please fix the indentation as below. int zx2967_pd_probe(struct platform_device *pdev, struct generic_pm_domain **zx_pm_domains, int domain_num) > +{ > + struct genpd_onecell_data *genpd_data; > + struct resource *res; > + int i; > + > + genpd_data = devm_kzalloc(&pdev->dev, sizeof(*genpd_data), GFP_KERNEL); > + if (!genpd_data) > + return -ENOMEM; > + > + genpd_data->domains = zx_pm_domains; > + genpd_data->num_domains = domain_num; > + > + res = platform_get_resource(pdev, IORESOURCE_MEM, 0); > + pcubase = devm_ioremap_resource(&pdev->dev, res); > + if (IS_ERR(pcubase)) { > + dev_err(&pdev->dev, "ioremap fail.\n"); > + return PTR_ERR(pcubase); > + } > + > + for (i = 0; i < domain_num; ++i) > + pm_genpd_init(zx_pm_domains[i], NULL, false); > + > + of_genpd_add_provider_onecell(pdev->dev.of_node, genpd_data); > + dev_info(&pdev->dev, "powerdomain init ok\n"); > + return 0; > +} > diff --git a/drivers/soc/zte/zx2967_pm_domains.h b/drivers/soc/zte/zx2967_pm_domains.h > new file mode 100644 > index 0000000..35938c3 > --- /dev/null > +++ b/drivers/soc/zte/zx2967_pm_domains.h > @@ -0,0 +1,45 @@ > +/* > + * Header for ZTE's Power Domain Driver support > + * > + * Copyright (C) 2015 ZTE Ltd. > + * > + * Author: Baoyou Xie <baoyou.xie@linaro.org> > + * License terms: GNU General Public License (GPL) version 2 > + */ > + > +#ifndef __ZTE_ZX2967_PM_DOMAIN_H > +#define __ZTE_ZX2967_PM_DOMAIN_H > + > +#include <linux/platform_device.h> > +#include <linux/pm_domain.h> > + > +enum { > + REG_CLKEN, > + REG_ISOEN, > + REG_RSTEN, > + REG_PWREN, > + REG_PWRDN, > + REG_ACK_SYNC, > + > + /* The size of the array - must be last */ > + REG_ARRAY_SIZE, > +}; > + > +enum zx2967_power_polarity { > + PWREN, > + PWRDN, > +}; > + > +struct zx2967_pm_domain { > + struct generic_pm_domain dm; > + const u16 bit; > + const enum zx2967_power_polarity polarity; > + const u16 *reg_offset; > +}; > + > +extern int zx2967_power_on(struct generic_pm_domain *domain); > +extern int zx2967_power_off(struct generic_pm_domain *domain); > +extern int zx2967_pd_probe(struct platform_device *pdev, > + struct generic_pm_domain **zx_pm_domains, > + int domain_num); Have a newline here. Shawn > +#endif /* __ZTE_ZX2967_PM_DOMAIN_H */ > -- > 2.7.4 > ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH v4 1/3] soc: zte: pm_domains: Prepare for supporting ARMv8 zx2967 family @ 2017-01-03 11:32 ` Shawn Guo 0 siblings, 0 replies; 12+ messages in thread From: Shawn Guo @ 2017-01-03 11:32 UTC (permalink / raw) To: Baoyou Xie Cc: jun.nie, krzk, arnd, roy.pledge, ulf.hansson, yangbo.lu, claudiu.manoil, pankaj.dubey, f.fainelli, scott.branden, horms+renesas, laurent.pinchart, amitdanielk, geert+renesas, xie.baoyou, chen.chaokai, wang.qiang01, linux-kernel, linux-arm-kernel On Tue, Jan 03, 2017 at 02:56:15PM +0800, Baoyou Xie wrote: > The ARMv8 zx2967 family (296718, 296716 etc) uses different value > for controlling the power domain on/off registers, Choose the > value depending on the compatible. > > Multiple domains are prepared for the family, this patch prepares > the common functions. > > Signed-off-by: Baoyou Xie <baoyou.xie@linaro.org> > --- > drivers/soc/Kconfig | 1 + > drivers/soc/Makefile | 1 + > drivers/soc/zte/Kconfig | 13 ++++ > drivers/soc/zte/Makefile | 4 ++ > drivers/soc/zte/zx2967_pm_domains.c | 138 ++++++++++++++++++++++++++++++++++++ > drivers/soc/zte/zx2967_pm_domains.h | 45 ++++++++++++ > 6 files changed, 202 insertions(+) > create mode 100644 drivers/soc/zte/Kconfig > create mode 100644 drivers/soc/zte/Makefile > create mode 100644 drivers/soc/zte/zx2967_pm_domains.c > create mode 100644 drivers/soc/zte/zx2967_pm_domains.h > > diff --git a/drivers/soc/Kconfig b/drivers/soc/Kconfig > index f31bceb..f09023f 100644 > --- a/drivers/soc/Kconfig > +++ b/drivers/soc/Kconfig > @@ -11,5 +11,6 @@ source "drivers/soc/tegra/Kconfig" > source "drivers/soc/ti/Kconfig" > source "drivers/soc/ux500/Kconfig" > source "drivers/soc/versatile/Kconfig" > +source "drivers/soc/zte/Kconfig" > > endmenu > diff --git a/drivers/soc/Makefile b/drivers/soc/Makefile > index 50c23d0..05eae52 100644 > --- a/drivers/soc/Makefile > +++ b/drivers/soc/Makefile > @@ -16,3 +16,4 @@ obj-$(CONFIG_ARCH_TEGRA) += tegra/ > obj-$(CONFIG_SOC_TI) += ti/ > obj-$(CONFIG_ARCH_U8500) += ux500/ > obj-$(CONFIG_PLAT_VERSATILE) += versatile/ > +obj-$(CONFIG_ARCH_ZX) += zte/ > diff --git a/drivers/soc/zte/Kconfig b/drivers/soc/zte/Kconfig > new file mode 100644 > index 0000000..20bde38 > --- /dev/null > +++ b/drivers/soc/zte/Kconfig > @@ -0,0 +1,13 @@ > +# > +# ZTE SoC drivers > +# > +menuconfig SOC_ZTE > + bool "ZTE SoC driver support" > + > +if SOC_ZTE > + > +config ZX2967_PM_DOMAINS > + bool "ZX2967 PM domains" > + depends on PM_GENERIC_DOMAINS > + > +endif > diff --git a/drivers/soc/zte/Makefile b/drivers/soc/zte/Makefile > new file mode 100644 > index 0000000..8a37f2f > --- /dev/null > +++ b/drivers/soc/zte/Makefile > @@ -0,0 +1,4 @@ > +# > +# ZTE SOC drivers > +# > +obj-$(CONFIG_ZX2967_PM_DOMAINS) += zx2967_pm_domains.o > diff --git a/drivers/soc/zte/zx2967_pm_domains.c b/drivers/soc/zte/zx2967_pm_domains.c > new file mode 100644 > index 0000000..98b3b5f > --- /dev/null > +++ b/drivers/soc/zte/zx2967_pm_domains.c > @@ -0,0 +1,138 @@ > +/* > + * Copyright (C) 2015 ZTE Ltd. What about year 2017? > + * > + * Author: Baoyou Xie <baoyou.xie@linaro.org> > + * License terms: GNU General Public License (GPL) version 2 > + */ > +#include <linux/delay.h> > +#include <linux/err.h> > +#include <linux/io.h> > +#include <linux/of.h> Can we have a newline between system and local includes? > +#include "zx2967_pm_domains.h" > + > +#define PCU_DM_CLKEN(zpd) ((zpd)->reg_offset[REG_CLKEN]) > +#define PCU_DM_ISOEN(zpd) ((zpd)->reg_offset[REG_ISOEN]) > +#define PCU_DM_RSTEN(zpd) ((zpd)->reg_offset[REG_RSTEN]) > +#define PCU_DM_PWREN(zpd) ((zpd)->reg_offset[REG_PWREN]) > +#define PCU_DM_PWRDN(zpd) ((zpd)->reg_offset[REG_PWRDN]) > +#define PCU_DM_ACK_SYNC(zpd) ((zpd)->reg_offset[REG_ACK_SYNC]) > + > +static void __iomem *pcubase; > + > +int zx2967_power_on(struct generic_pm_domain *domain) > +{ > + struct zx2967_pm_domain *zpd = (struct zx2967_pm_domain *)domain; > + unsigned long loop = 1000; > + u32 val; > + > + val = readl_relaxed(pcubase + PCU_DM_PWREN(zpd)); > + if (zpd->polarity == PWREN) > + val |= BIT(zpd->bit); > + else > + val &= ~BIT(zpd->bit); > + writel_relaxed(val, pcubase + PCU_DM_PWRDN(zpd)); Hmm, do you really want to read val from PCU_DM_PWREN and then write back to PCU_DM_PWRDN? They are two different registers or same one? A bit confused here. > + > + do { > + udelay(1); > + val = readl_relaxed(pcubase + PCU_DM_ACK_SYNC(zpd)) > + & BIT(zpd->bit); > + } while (--loop && !val); > + > + if (!loop) { > + pr_err("Error: %s %s fail\n", __func__, domain->name); > + return -EIO; > + } > + > + val = readl_relaxed(pcubase + PCU_DM_RSTEN(zpd)); > + val |= BIT(zpd->bit); > + writel_relaxed(val, pcubase + PCU_DM_RSTEN(zpd)); > + udelay(5); > + > + val = readl_relaxed(pcubase + PCU_DM_ISOEN(zpd)); > + val &= ~BIT(zpd->bit); > + writel_relaxed(val, pcubase + PCU_DM_ISOEN(zpd)); > + udelay(5); > + > + val = readl_relaxed(pcubase + PCU_DM_CLKEN(zpd)); > + val |= BIT(zpd->bit); > + writel_relaxed(val, pcubase + PCU_DM_CLKEN(zpd)); > + udelay(5); > + > + pr_debug("normal poweron %s\n", domain->name); > + > + return 0; > +} > + > +int zx2967_power_off(struct generic_pm_domain *domain) > +{ > + struct zx2967_pm_domain *zpd = (struct zx2967_pm_domain *)domain; > + unsigned long loop = 1000; > + u32 val; > + > + val = readl_relaxed(pcubase + PCU_DM_CLKEN(zpd)); > + val &= ~BIT(zpd->bit); > + writel_relaxed(val, pcubase + PCU_DM_CLKEN(zpd)); > + udelay(5); > + > + val = readl_relaxed(pcubase + PCU_DM_ISOEN(zpd)); > + val |= BIT(zpd->bit); > + writel_relaxed(val, pcubase + PCU_DM_ISOEN(zpd)); > + udelay(5); > + > + val = readl_relaxed(pcubase + PCU_DM_RSTEN(zpd)); > + val &= ~BIT(zpd->bit); > + writel_relaxed(val, pcubase + PCU_DM_RSTEN(zpd)); > + udelay(5); > + > + val = readl_relaxed(pcubase + PCU_DM_PWREN(zpd)); > + if (zpd->polarity == PWREN) > + val &= ~BIT(zpd->bit); > + else > + val |= BIT(zpd->bit); > + writel_relaxed(val, pcubase + PCU_DM_PWRDN(zpd)); Ditto > + > + do { > + udelay(1); > + val = readl_relaxed(pcubase + PCU_DM_ACK_SYNC(zpd)) > + & BIT(zpd->bit); > + } while (--loop && val); > + > + if (!loop) { > + pr_err("Error: %s %s fail\n", __func__, domain->name); > + return -EIO; > + } > + > + pr_debug("normal poweroff %s\n", domain->name); > + > + return 0; > +} > + > +int zx2967_pd_probe(struct platform_device *pdev, > + struct generic_pm_domain **zx_pm_domains, > + int domain_num) Please fix the indentation as below. int zx2967_pd_probe(struct platform_device *pdev, struct generic_pm_domain **zx_pm_domains, int domain_num) > +{ > + struct genpd_onecell_data *genpd_data; > + struct resource *res; > + int i; > + > + genpd_data = devm_kzalloc(&pdev->dev, sizeof(*genpd_data), GFP_KERNEL); > + if (!genpd_data) > + return -ENOMEM; > + > + genpd_data->domains = zx_pm_domains; > + genpd_data->num_domains = domain_num; > + > + res = platform_get_resource(pdev, IORESOURCE_MEM, 0); > + pcubase = devm_ioremap_resource(&pdev->dev, res); > + if (IS_ERR(pcubase)) { > + dev_err(&pdev->dev, "ioremap fail.\n"); > + return PTR_ERR(pcubase); > + } > + > + for (i = 0; i < domain_num; ++i) > + pm_genpd_init(zx_pm_domains[i], NULL, false); > + > + of_genpd_add_provider_onecell(pdev->dev.of_node, genpd_data); > + dev_info(&pdev->dev, "powerdomain init ok\n"); > + return 0; > +} > diff --git a/drivers/soc/zte/zx2967_pm_domains.h b/drivers/soc/zte/zx2967_pm_domains.h > new file mode 100644 > index 0000000..35938c3 > --- /dev/null > +++ b/drivers/soc/zte/zx2967_pm_domains.h > @@ -0,0 +1,45 @@ > +/* > + * Header for ZTE's Power Domain Driver support > + * > + * Copyright (C) 2015 ZTE Ltd. > + * > + * Author: Baoyou Xie <baoyou.xie@linaro.org> > + * License terms: GNU General Public License (GPL) version 2 > + */ > + > +#ifndef __ZTE_ZX2967_PM_DOMAIN_H > +#define __ZTE_ZX2967_PM_DOMAIN_H > + > +#include <linux/platform_device.h> > +#include <linux/pm_domain.h> > + > +enum { > + REG_CLKEN, > + REG_ISOEN, > + REG_RSTEN, > + REG_PWREN, > + REG_PWRDN, > + REG_ACK_SYNC, > + > + /* The size of the array - must be last */ > + REG_ARRAY_SIZE, > +}; > + > +enum zx2967_power_polarity { > + PWREN, > + PWRDN, > +}; > + > +struct zx2967_pm_domain { > + struct generic_pm_domain dm; > + const u16 bit; > + const enum zx2967_power_polarity polarity; > + const u16 *reg_offset; > +}; > + > +extern int zx2967_power_on(struct generic_pm_domain *domain); > +extern int zx2967_power_off(struct generic_pm_domain *domain); > +extern int zx2967_pd_probe(struct platform_device *pdev, > + struct generic_pm_domain **zx_pm_domains, > + int domain_num); Have a newline here. Shawn > +#endif /* __ZTE_ZX2967_PM_DOMAIN_H */ > -- > 2.7.4 > ^ permalink raw reply [flat|nested] 12+ messages in thread
end of thread, other threads:[~2017-01-03 12:26 UTC | newest] Thread overview: 12+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2017-01-03 6:56 [PATCH v4 1/3] soc: zte: pm_domains: Prepare for supporting ARMv8 zx2967 family Baoyou Xie 2017-01-03 6:56 ` Baoyou Xie 2017-01-03 6:56 ` [PATCH v4 2/3] soc: zte: pm_domains: Add support for zx296718 board Baoyou Xie 2017-01-03 6:56 ` Baoyou Xie 2017-01-03 11:08 ` Shawn Guo 2017-01-03 11:08 ` Shawn Guo 2017-01-03 12:26 ` kbuild test robot 2017-01-03 12:26 ` kbuild test robot 2017-01-03 6:56 ` [PATCH v4 3/3] MAINTAINERS: add zx2967 SoC drivers to ARM ZTE architecture Baoyou Xie 2017-01-03 6:56 ` Baoyou Xie 2017-01-03 11:32 ` [PATCH v4 1/3] soc: zte: pm_domains: Prepare for supporting ARMv8 zx2967 family Shawn Guo 2017-01-03 11:32 ` Shawn Guo
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.