From: Andrey Smirnov <andrew.smirnov@gmail.com>
To: barebox@lists.infradead.org
Cc: Andrey Smirnov <andrew.smirnov@gmail.com>
Subject: [PATCH 04/15] soc: imx: gpcv2: make pgc driver more generic for other i.MX platforms
Date: Thu, 31 Jan 2019 18:31:22 -0800 [thread overview]
Message-ID: <20190201023133.1078-5-andrew.smirnov@gmail.com> (raw)
In-Reply-To: <20190201023133.1078-1-andrew.smirnov@gmail.com>
Port of a Linux commit 73f59712a1a3e532a2cbfe582ecfdbf56c33297d
i.MX8MQ and i.MX8MM share same gpc module with i.MX7D, they
can reuse gpcv2 pgc driver for power domain control, this
patch renames all functions and structure definitions started
with "imx7" to "imx", and use .data in imx_gpcv2_dt_ids[] to
pass platform specific power domain data for power domain
driver, thus make gpcv2 pgc driver more generic for i.MX
platforms.
Signed-off-by: Anson Huang <Anson.Huang@nxp.com>
Acked-by: Andrey Smirnov <andrew.smirnov@gmail.com>
Signed-off-by: Shawn Guo <shawnguo@kernel.org>
Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
---
drivers/soc/imx/gpcv2.c | 68 +++++++++++++++++++++++++----------------
1 file changed, 41 insertions(+), 27 deletions(-)
diff --git a/drivers/soc/imx/gpcv2.c b/drivers/soc/imx/gpcv2.c
index a48f6d9a7..0b428bfc1 100644
--- a/drivers/soc/imx/gpcv2.c
+++ b/drivers/soc/imx/gpcv2.c
@@ -14,6 +14,7 @@
* http://www.gnu.org/copyleft/gpl.html
*/
+#include <of_device.h>
#include <common.h>
#include <clock.h>
#include <abort.h>
@@ -59,7 +60,7 @@
#define GPC_PGC_CTRL_PCR BIT(0)
-struct imx7_pgc_domain {
+struct imx_pgc_domain {
struct generic_pm_domain genpd;
void __iomem *base;
struct regulator *regulator;
@@ -75,12 +76,17 @@ struct imx7_pgc_domain {
struct device_d *dev;
};
-static int imx7_gpc_pu_pgc_sw_pxx_req(struct generic_pm_domain *genpd,
+struct imx_pgc_domain_data {
+ const struct imx_pgc_domain *domains;
+ size_t domains_num;
+};
+
+static int imx_gpc_pu_pgc_sw_pxx_req(struct generic_pm_domain *genpd,
bool on)
{
- struct imx7_pgc_domain *domain = container_of(genpd,
- struct imx7_pgc_domain,
- genpd);
+ struct imx_pgc_domain *domain = container_of(genpd,
+ struct imx_pgc_domain,
+ genpd);
unsigned int offset = on ?
GPC_PU_PGC_SW_PUP_REQ : GPC_PU_PGC_SW_PDN_REQ;
const bool enable_power_control = !on;
@@ -150,17 +156,17 @@ unmap:
return ret;
}
-static int imx7_gpc_pu_pgc_sw_pup_req(struct generic_pm_domain *genpd)
+static int imx_gpc_pu_pgc_sw_pup_req(struct generic_pm_domain *genpd)
{
- return imx7_gpc_pu_pgc_sw_pxx_req(genpd, true);
+ return imx_gpc_pu_pgc_sw_pxx_req(genpd, true);
}
-static int imx7_gpc_pu_pgc_sw_pdn_req(struct generic_pm_domain *genpd)
+static int imx_gpc_pu_pgc_sw_pdn_req(struct generic_pm_domain *genpd)
{
- return imx7_gpc_pu_pgc_sw_pxx_req(genpd, false);
+ return imx_gpc_pu_pgc_sw_pxx_req(genpd, false);
}
-static const struct imx7_pgc_domain imx7_pgc_domains[] = {
+static const struct imx_pgc_domain imx7_pgc_domains[] = {
[IMX7_POWER_DOMAIN_MIPI_PHY] = {
.genpd = {
.name = "mipi-phy",
@@ -198,9 +204,14 @@ static const struct imx7_pgc_domain imx7_pgc_domains[] = {
},
};
-static int imx7_pgc_domain_probe(struct device_d *dev)
+static const struct imx_pgc_domain_data imx7_pgc_domain_data = {
+ .domains = imx7_pgc_domains,
+ .domains_num = ARRAY_SIZE(imx7_pgc_domains),
+};
+
+static int imx_pgc_domain_probe(struct device_d *dev)
{
- struct imx7_pgc_domain *domain = dev->priv;
+ struct imx_pgc_domain *domain = dev->priv;
int ret;
domain->dev = dev;
@@ -232,24 +243,25 @@ static int imx7_pgc_domain_probe(struct device_d *dev)
return ret;
}
-static const struct platform_device_id imx7_pgc_domain_id[] = {
- { "imx7-pgc-domain", },
+static const struct platform_device_id imx_pgc_domain_id[] = {
+ { "imx-pgc-domain", },
{ },
};
-static struct driver_d imx7_pgc_domain_driver = {
+static struct driver_d imx_pgc_domain_driver = {
.name = "imx-pgc",
- .probe = imx7_pgc_domain_probe,
- .id_table = imx7_pgc_domain_id,
+ .probe = imx_pgc_domain_probe,
+ .id_table = imx_pgc_domain_id,
};
-coredevice_platform_driver(imx7_pgc_domain_driver);
+coredevice_platform_driver(imx_pgc_domain_driver);
static int imx_gpcv2_probe(struct device_d *dev)
{
+ static const struct imx_pgc_domain_data *domain_data;
struct device_node *pgc_np, *np;
struct resource *res;
void __iomem *base;
- int ret;
+ int ret;
pgc_np = of_get_child_by_name(dev->device_node, "pgc");
if (!pgc_np) {
@@ -263,9 +275,11 @@ static int imx_gpcv2_probe(struct device_d *dev)
base = IOMEM(res->start);
+ domain_data = of_device_get_match_data(dev);
+
for_each_child_of_node(pgc_np, np) {
struct device_d *pd_dev;
- struct imx7_pgc_domain *domain;
+ struct imx_pgc_domain *domain;
u32 domain_index;
ret = of_property_read_u32(np, "reg", &domain_index);
if (ret) {
@@ -273,18 +287,18 @@ static int imx_gpcv2_probe(struct device_d *dev)
return ret;
}
- if (domain_index >= ARRAY_SIZE(imx7_pgc_domains)) {
+ if (domain_index >= domain_data->domains_num) {
dev_warn(dev,
"Domain index %d is out of bounds\n",
domain_index);
continue;
}
- domain = xmemdup(&imx7_pgc_domains[domain_index],
- sizeof(imx7_pgc_domains[domain_index]));
+ domain = xmemdup(&domain_data->domains[domain_index],
+ sizeof(domain_data->domains[domain_index]));
domain->base = base;
- domain->genpd.power_on = imx7_gpc_pu_pgc_sw_pup_req;
- domain->genpd.power_off = imx7_gpc_pu_pgc_sw_pdn_req;
+ domain->genpd.power_on = imx_gpc_pu_pgc_sw_pup_req;
+ domain->genpd.power_off = imx_gpc_pu_pgc_sw_pdn_req;
pd_dev = xzalloc(sizeof(*pd_dev));
pd_dev->device_node = np;
@@ -292,7 +306,7 @@ static int imx_gpcv2_probe(struct device_d *dev)
pd_dev->parent = dev;
pd_dev->priv = domain;
pd_dev->device_node = np;
- dev_set_name(pd_dev, imx7_pgc_domain_id[0].name);
+ dev_set_name(pd_dev, imx_pgc_domain_id[0].name);
ret = platform_device_register(pd_dev);
if (ret)
@@ -303,7 +317,7 @@ static int imx_gpcv2_probe(struct device_d *dev)
}
static const struct of_device_id imx_gpcv2_dt_ids[] = {
- { .compatible = "fsl,imx7d-gpc" },
+ { .compatible = "fsl,imx7d-gpc", .data = &imx7_pgc_domain_data },
{ }
};
--
2.20.1
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
next prev parent reply other threads:[~2019-02-01 2:31 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-02-01 2:31 [PATCH 00/15] PCIE support for i.MX8MQ Andrey Smirnov
2019-02-01 2:31 ` [PATCH 01/15] PCI: dwc: Fix pointer width cast problem Andrey Smirnov
2019-02-01 2:31 ` [PATCH 02/15] ARM: aarch64: Add PCI fixups section to linker script Andrey Smirnov
2019-02-01 2:31 ` [PATCH 03/15] soc: imx: gpcv2: use A_CORE instread of A7 for more i.MX platforms Andrey Smirnov
2019-02-01 2:31 ` Andrey Smirnov [this message]
2019-02-01 2:31 ` [PATCH 05/15] soc: imx: gpcv2: Switch to SPDX identifier Andrey Smirnov
2019-02-01 2:31 ` [PATCH 06/15] soc: imx: gpcv2: prefix i.MX7 specific defines Andrey Smirnov
2019-02-01 2:31 ` [PATCH 07/15] soc: imx: gpcv2: add support for i.MX8MQ SoC Andrey Smirnov
2019-02-01 2:31 ` [PATCH 08/15] reset: Constify "ops" in struct reset_controller_dev Andrey Smirnov
2019-02-01 2:31 ` [PATCH 09/15] reset: imx7: Add plubming to support multiple IP variants Andrey Smirnov
2019-02-01 2:31 ` [PATCH 10/15] include: Import dt-bindings/reset/imx8mq-reset.h Andrey Smirnov
2019-02-01 2:31 ` [PATCH 11/15] reset: imx7: Add support for i.MX8MQ IP block variant Andrey Smirnov
2019-02-01 2:31 ` [RFC 12/15] PCI: imx6: Introduce drvdata Andrey Smirnov
2019-02-01 2:31 ` [RFC 13/15] PCI: imx6: Mark PHY functions as i.MX6 specific Andrey Smirnov
2019-02-01 2:31 ` [RFC 14/15] PCI: imx6: Convert DIRECT_SPEED_CHANGE quirk code to use a flag Andrey Smirnov
2019-02-01 2:31 ` [RFC 15/15] PCI: imx6: Add support for i.MX8MQ Andrey Smirnov
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=20190201023133.1078-5-andrew.smirnov@gmail.com \
--to=andrew.smirnov@gmail.com \
--cc=barebox@lists.infradead.org \
/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