[PATCH 2/2] soc: zte: pm_domains: Add support for zx296718 driver

Jun Nie jun.nie at linaro.org
Sun Dec 4 19:27:09 PST 2016


2016-12-03 22:11 GMT+08:00 Baoyou Xie <baoyou.xie at linaro.org>:
> This patch introduces the power domain driver of zx296718
> which belongs to zte's 2967 family.
>
> Signed-off-by: Baoyou Xie <baoyou.xie at linaro.org>
> ---
>  drivers/soc/zte/Makefile              |   3 +
>  drivers/soc/zte/zx296718_pm_domains.c | 162 ++++++++++++++++++++++++++++++++++
>  2 files changed, 165 insertions(+)
>  create mode 100644 drivers/soc/zte/zx296718_pm_domains.c
>
> diff --git a/drivers/soc/zte/Makefile b/drivers/soc/zte/Makefile
> index 97ac8ea..a6e7bfe 100644
> --- a/drivers/soc/zte/Makefile
> +++ b/drivers/soc/zte/Makefile
> @@ -2,3 +2,6 @@
>  # zx SOC drivers
>  #
>  obj-$(CONFIG_ZX_PM_DOMAINS) += pm_domains.o
> +ifeq ($(CONFIG_ZX_PM_DOMAINS), y)
> +       obj-y += zx296718_pm_domains.o
> +endif

Follow unified style for Makefile:
obj-$(CONFIG_ZX_PM_DOMAINS) += 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..fc16dfd
> --- /dev/null
> +++ b/drivers/soc/zte/zx296718_pm_domains.c
> @@ -0,0 +1,162 @@
> +/*
> + * Copyright (C) 2015 ZTE Ltd.
> + *
> + * Author: Baoyou Xie <baoyou.xie at linaro.org>
> + * License terms: GNU General Public License (GPL) version 2
> + */
> +#include "pm_domains.h"
> +
> +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 zx_pm_domain vou_domain = {
> +       .dm = {
> +               .name           = "vou_domain",
> +               .power_off      = zx_normal_power_off,
> +               .power_on       = zx_normal_power_on,
> +       },
> +       .bit = PCU_DM_VOU,
> +};
> +static struct zx_pm_domain sappu_domain = {
> +       .dm = {
> +               .name           = "sappu_domain",
> +               .power_off      = zx_normal_power_off,
> +               .power_on       = zx_normal_power_on,
> +       },
> +       .bit = PCU_DM_SAPPU,
> +};
> +static struct zx_pm_domain vde_domain = {
> +       .dm = {
> +               .name           = "vde_domain",
> +               .power_off      = zx_normal_power_off,
> +               .power_on       = zx_normal_power_on,
> +       },
> +       .bit = PCU_DM_VDE,
> +};
> +static struct zx_pm_domain vce_domain = {
> +       .dm = {
> +               .name           = "vce_domain",
> +               .power_off      = zx_normal_power_off,
> +               .power_on       = zx_normal_power_on,
> +       },
> +       .bit = PCU_DM_VCE,
> +};
> +static struct zx_pm_domain hde_domain = {
> +       .dm = {
> +               .name           = "hde_domain",
> +               .power_off      = zx_normal_power_off,
> +               .power_on       = zx_normal_power_on,
> +       },
> +       .bit = PCU_DM_HDE,
> +};
> +
> +static struct zx_pm_domain viu_domain = {
> +       .dm = {
> +               .name           = "viu_domain",
> +               .power_off      = zx_normal_power_off,
> +               .power_on       = zx_normal_power_on,
> +       },
> +       .bit = PCU_DM_VIU,
> +};
> +static struct zx_pm_domain usb20_domain = {
> +       .dm = {
> +               .name           = "usb20_domain",
> +               .power_off      = zx_normal_power_off,
> +               .power_on       = zx_normal_power_on,
> +       },
> +       .bit = PCU_DM_USB20,
> +};
> +static struct zx_pm_domain usb21_domain = {
> +       .dm = {
> +               .name           = "usb21_domain",
> +               .power_off      = zx_normal_power_off,
> +               .power_on       = zx_normal_power_on,
> +       },
> +       .bit = PCU_DM_USB21,
> +};
> +static struct zx_pm_domain usb30_domain = {
> +       .dm = {
> +               .name           = "usb30_domain",
> +               .power_off      = zx_normal_power_off,
> +               .power_on       = zx_normal_power_on,
> +       },
> +       .bit = PCU_DM_USB30,
> +};
> +static struct zx_pm_domain hsic_domain = {
> +       .dm = {
> +               .name           = "hsic_domain",
> +               .power_off      = zx_normal_power_off,
> +               .power_on       = zx_normal_power_on,
> +       },
> +       .bit = PCU_DM_HSIC,
> +};
> +static struct zx_pm_domain gmac_domain = {
> +       .dm = {
> +               .name           = "gmac_domain",
> +               .power_off      = zx_normal_power_off,
> +               .power_on       = zx_normal_power_on,
> +       },
> +       .bit = PCU_DM_GMAC,
> +};
> +static struct zx_pm_domain ts_domain = {
> +       .dm = {
> +               .name           = "ts_domain",
> +               .power_off      = zx_normal_power_off,
> +               .power_on       = zx_normal_power_on,
> +       },
> +       .bit = PCU_DM_TS,
> +};
> +struct generic_pm_domain *zx296718_pm_domains[] = {
> +       //&vou_domain.dm,
Remove this line.

> +       &sappu_domain.dm,

If you can add an index and add the index definition in devicetree
header file, it will be more convenient when binding power domain to
device in DT file. such as
         [ZX296718_PM_VDE] = &vde_domain.dm,

> +       &vde_domain.dm,
> +       &vce_domain.dm,
> +       &hde_domain.dm,
> +       &viu_domain.dm,
> +       &usb20_domain.dm,
> +       &usb21_domain.dm,
> +       &usb30_domain.dm,
> +       &hsic_domain.dm,
> +       &gmac_domain.dm,
> +       &ts_domain.dm,
> +       &vou_domain.dm,
> +};
> +
> +static int zx296718_pd_probe(struct platform_device *pdev)
> +{
> +       return zx_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", },

Suggest to rename probe function and of_device_id to a generic zx
name, then add compatible data so that probe function can be shared.
Probe function can find SoC specific data via comparing compatible
string and initialize device accordingly.

> +       { },
> +};
> +
> +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
>



More information about the linux-arm-kernel mailing list