From patchwork Wed Dec 30 08:30:40 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthias Brugger X-Patchwork-Id: 7932341 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 653969F350 for ; Wed, 30 Dec 2015 08:35:17 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 69769201FE for ; Wed, 30 Dec 2015 08:35:16 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 60C4F20172 for ; Wed, 30 Dec 2015 08:35:15 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1aECAR-00022e-Ei; Wed, 30 Dec 2015 08:31:35 +0000 Received: from mail-wm0-x241.google.com ([2a00:1450:400c:c09::241]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1aECAN-00021u-Dl; Wed, 30 Dec 2015 08:31:32 +0000 Received: by mail-wm0-x241.google.com with SMTP id f206so9371067wmf.2; Wed, 30 Dec 2015 00:31:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=Zz1uEPA1MG4cpvWK9HyhD45lzVOxirth+8Eluhb9e6c=; b=c803jpY3yibUkBSjY/DDdqFedP4UjVtdraZz0Pdr7WQH4NGwydO8ER9OsQ73PCJPEx m3aap6kWODQQhfqFwryukOa1yom7xsSiRftEYMWUC0RU8yGU4k393IhLfhwEWraJ9Q/U Nk5nzjBp3oAtRkbJvlsUibznyTH2xmdvjufnFrraIBnbElJj6/WaaZkAirNiIGgg1CsO S3CBo++pNOC8earSZcMkrhLygCZKOwBP7IkeuxusxjjnZneKjnubApXwmbN8qECNbldd OOzzLDYBxGSbCMSQWghMVkXBWXgW5myR8Vb+jbRZHbSevPqgED7lqDxYtDDeIZwuMriL l0DQ== X-Received: by 10.28.137.135 with SMTP id l129mr16312450wmd.38.1451464268695; Wed, 30 Dec 2015 00:31:08 -0800 (PST) Received: from linux-gy6r.site ([77.231.167.74]) by smtp.gmail.com with ESMTPSA id z127sm8914928wme.2.2015.12.30.00.31.07 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 30 Dec 2015 00:31:07 -0800 (PST) From: Matthias Brugger To: linux-mediatek@lists.infradead.org Subject: [PATCH v2] soc: mediatek: SCPSYS: use builtin_platform_driver Date: Wed, 30 Dec 2015 09:30:40 +0100 Message-Id: <1451464240-5313-1-git-send-email-matthias.bgg@gmail.com> X-Mailer: git-send-email 2.6.2 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20151230_003131_645054_B2A51A98 X-CRM114-Status: GOOD ( 16.73 ) X-Spam-Score: -2.7 (--) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: jamesjj.liao@mediatek.com, arnd@arndb.de, s.hauer@pengutronix.de, linux-kernel@vger.kernel.org, djkurtz@chromium.org, paul.gortmaker@windriver.com, Matthias Brugger , eddie.huang@mediatek.com, linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.1 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP SCPSYS can't be built as module. Use builtin_platform_driver instead. For this probe must not be __init and the data accessed can't be __initconst. Remove this macros. To make the impact as small as possible, fold scp_domain_data into scp_domain via a pointer. Cc: Sascha Hauer Cc: Arnd Bergmann Reported-by: Daniel Kurtz Signed-off-by: Matthias Brugger Reviewed-by: Daniel Kurtz Tested-by: Daniel Kurtz Acked-by: Arnd Bergmann --- Changes for v2: - set suppress_bind_attrs to true drivers/soc/mediatek/mtk-scpsys.c | 49 +++++++++++++++++---------------------- 1 file changed, 21 insertions(+), 28 deletions(-) diff --git a/drivers/soc/mediatek/mtk-scpsys.c b/drivers/soc/mediatek/mtk-scpsys.c index 0221387..837effe 100644 --- a/drivers/soc/mediatek/mtk-scpsys.c +++ b/drivers/soc/mediatek/mtk-scpsys.c @@ -76,7 +76,7 @@ struct scp_domain_data { bool active_wakeup; }; -static const struct scp_domain_data scp_domain_data[] __initconst = { +static const struct scp_domain_data scp_domain_data[] = { [MT8173_POWER_DOMAIN_VDEC] = { .name = "vdec", .sta_mask = PWR_STATUS_VDEC, @@ -174,12 +174,7 @@ struct scp_domain { struct generic_pm_domain genpd; struct scp *scp; struct clk *clk[MAX_CLKS]; - u32 sta_mask; - void __iomem *ctl_addr; - u32 sram_pdn_bits; - u32 sram_pdn_ack_bits; - u32 bus_prot_mask; - bool active_wakeup; + const struct scp_domain_data *data; struct regulator *supply; }; @@ -195,8 +190,9 @@ static int scpsys_domain_is_on(struct scp_domain *scpd) { struct scp *scp = scpd->scp; - u32 status = readl(scp->base + SPM_PWR_STATUS) & scpd->sta_mask; - u32 status2 = readl(scp->base + SPM_PWR_STATUS_2ND) & scpd->sta_mask; + u32 status = readl(scp->base + SPM_PWR_STATUS) & scpd->data->sta_mask; + u32 status2 = readl(scp->base + SPM_PWR_STATUS_2ND) & + scpd->data->sta_mask; /* * A domain is on when both status bits are set. If only one is set @@ -217,8 +213,8 @@ static int scpsys_power_on(struct generic_pm_domain *genpd) struct scp *scp = scpd->scp; unsigned long timeout; bool expired; - void __iomem *ctl_addr = scpd->ctl_addr; - u32 sram_pdn_ack = scpd->sram_pdn_ack_bits; + void __iomem *ctl_addr = scp->base + scpd->data->ctl_offs; + u32 sram_pdn_ack = scpd->data->sram_pdn_ack_bits; u32 val; int ret; int i; @@ -273,7 +269,7 @@ static int scpsys_power_on(struct generic_pm_domain *genpd) val |= PWR_RST_B_BIT; writel(val, ctl_addr); - val &= ~scpd->sram_pdn_bits; + val &= ~scpd->data->sram_pdn_bits; writel(val, ctl_addr); /* wait until SRAM_PDN_ACK all 0 */ @@ -292,9 +288,9 @@ static int scpsys_power_on(struct generic_pm_domain *genpd) expired = true; } - if (scpd->bus_prot_mask) { + if (scpd->data->bus_prot_mask) { ret = mtk_infracfg_clear_bus_protection(scp->infracfg, - scpd->bus_prot_mask); + scpd->data->bus_prot_mask); if (ret) goto err_pwr_ack; } @@ -321,21 +317,21 @@ static int scpsys_power_off(struct generic_pm_domain *genpd) struct scp *scp = scpd->scp; unsigned long timeout; bool expired; - void __iomem *ctl_addr = scpd->ctl_addr; - u32 pdn_ack = scpd->sram_pdn_ack_bits; + void __iomem *ctl_addr = scp->base + scpd->data->ctl_offs; + u32 pdn_ack = scpd->data->sram_pdn_ack_bits; u32 val; int ret; int i; - if (scpd->bus_prot_mask) { + if (scpd->data->bus_prot_mask) { ret = mtk_infracfg_set_bus_protection(scp->infracfg, - scpd->bus_prot_mask); + scpd->data->bus_prot_mask); if (ret) goto out; } val = readl(ctl_addr); - val |= scpd->sram_pdn_bits; + val |= scpd->data->sram_pdn_bits; writel(val, ctl_addr); /* wait until SRAM_PDN_ACK all 1 */ @@ -409,10 +405,10 @@ static bool scpsys_active_wakeup(struct device *dev) genpd = pd_to_genpd(dev->pm_domain); scpd = container_of(genpd, struct scp_domain, genpd); - return scpd->active_wakeup; + return scpd->data->active_wakeup; } -static int __init scpsys_probe(struct platform_device *pdev) +static int scpsys_probe(struct platform_device *pdev) { struct genpd_onecell_data *pd_data; struct resource *res; @@ -485,12 +481,7 @@ static int __init scpsys_probe(struct platform_device *pdev) pd_data->domains[i] = genpd; scpd->scp = scp; - scpd->sta_mask = data->sta_mask; - scpd->ctl_addr = scp->base + data->ctl_offs; - scpd->sram_pdn_bits = data->sram_pdn_bits; - scpd->sram_pdn_ack_bits = data->sram_pdn_ack_bits; - scpd->bus_prot_mask = data->bus_prot_mask; - scpd->active_wakeup = data->active_wakeup; + scpd->data = data; for (j = 0; j < MAX_CLKS && data->clk_id[j]; j++) scpd->clk[j] = clk[data->clk_id[j]]; @@ -542,10 +533,12 @@ static const struct of_device_id of_scpsys_match_tbl[] = { }; static struct platform_driver scpsys_drv = { + .probe = scpsys_probe, .driver = { .name = "mtk-scpsys", + .suppress_bind_attrs = true, .owner = THIS_MODULE, .of_match_table = of_match_ptr(of_scpsys_match_tbl), }, }; -builtin_platform_driver_probe(scpsys_drv, scpsys_probe); +builtin_platform_driver(scpsys_drv);