From patchwork Sat Jan 30 12:01:45 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Wu X-Patchwork-Id: 8170841 Return-Path: X-Original-To: patchwork-linux-rockchip@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 EA6EF9F9A0 for ; Sat, 30 Jan 2016 12:18:41 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 05EAE20398 for ; Sat, 30 Jan 2016 12:18:41 +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 DE75820392 for ; Sat, 30 Jan 2016 12:18:39 +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 1aPUU9-0000eV-VN; Sat, 30 Jan 2016 12:18:37 +0000 Received: from lucky1.263xmail.com ([211.157.147.132]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1aPUU0-0000bw-Me; Sat, 30 Jan 2016 12:18:29 +0000 Received: from david.wu?rock-chips.com (unknown [192.168.167.11]) by lucky1.263xmail.com (Postfix) with SMTP id 4A9135DE84; Sat, 30 Jan 2016 20:18:04 +0800 (CST) X-263anti-spam: KSV:0; X-MAIL-GRAY: 1 X-MAIL-DELIVERY: 0 X-KSVirus-check: 0 X-ABS-CHECKED: 4 X-ADDR-CHECKED: 0 Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.263.net (Postfix) with ESMTP id 2F4B0432; Sat, 30 Jan 2016 20:18:02 +0800 (CST) X-RL-SENDER: david.wu@rock-chips.com X-FST-TO: heiko@sntech.de X-SENDER-IP: 58.22.7.114 X-LOGIN-NAME: david.wu@rock-chips.com X-UNIQUE-TAG: <6feafcf4c2d4762a50632974ac522890> X-ATTACHMENT-NUM: 0 X-SENDER: wdc@rock-chips.com X-DNS-TYPE: 0 Received: from localhost.localdomain (unknown [58.22.7.114]) by smtp.263.net (Postfix) whith ESMTP id 12091A2THY3; Sat, 30 Jan 2016 20:18:03 +0800 (CST) From: David Wu To: heiko@sntech.de Subject: [PATCH] PM / AVS: rockchip-io: add GRF and PMUGRF types to distinguish Date: Sat, 30 Jan 2016 20:01:45 +0800 Message-Id: <1454155305-55516-1-git-send-email-david.wu@rock-chips.com> X-Mailer: git-send-email 1.9.1 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160130_041829_090506_F4D90965 X-CRM114-Status: GOOD ( 11.53 ) X-Spam-Score: -1.9 (-) X-BeenThere: linux-rockchip@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: Upstream kernel work for Rockchip platforms List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: nm@ti.com, huangtao@rock-chips.com, khilman@kernel.org, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, zyw@rock-chips.com, xjq@rock-chips.com, David Wu , cf@rock-chips.com, linux-rockchip@lists.infradead.org, linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "Linux-rockchip" Errors-To: linux-rockchip-bounces+patchwork-linux-rockchip=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, 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 As rk3368 contained two separated iodomain areas, this was determined to use which regmap base address. Signed-off-by: David Wu --- drivers/power/avs/rockchip-io-domain.c | 32 ++++++++++++++++++++++++-------- 1 file changed, 24 insertions(+), 8 deletions(-) diff --git a/drivers/power/avs/rockchip-io-domain.c b/drivers/power/avs/rockchip-io-domain.c index 8099456..b17aeb7 100644 --- a/drivers/power/avs/rockchip-io-domain.c +++ b/drivers/power/avs/rockchip-io-domain.c @@ -47,6 +47,11 @@ #define RK3368_SOC_CON15_FLASH0 BIT(14) #define RK3368_SOC_FLASH_SUPPLY_NUM 2 +enum rockchip_iodomain_grf_type { + GRF, + PMUGRF +}; + struct rockchip_iodomain; /** @@ -54,6 +59,7 @@ struct rockchip_iodomain; */ struct rockchip_iodomain_soc_data { int grf_offset; + enum rockchip_iodomain_grf_type type; const char *supply_names[MAX_SUPPLIES]; void (*init)(struct rockchip_iodomain *iod); }; @@ -67,7 +73,7 @@ struct rockchip_iodomain_supply { struct rockchip_iodomain { struct device *dev; - struct regmap *grf; + struct regmap *base; struct rockchip_iodomain_soc_data *soc_data; struct rockchip_iodomain_supply supplies[MAX_SUPPLIES]; }; @@ -86,7 +92,7 @@ static int rockchip_iodomain_write(struct rockchip_iodomain_supply *supply, /* apply hiword-mask */ val |= (BIT(supply->idx) << 16); - ret = regmap_write(iod->grf, iod->soc_data->grf_offset, val); + ret = regmap_write(iod->base, iod->soc_data->grf_offset, val); if (ret) dev_err(iod->dev, "Couldn't write to GRF\n"); @@ -157,7 +163,7 @@ static void rk3288_iodomain_init(struct rockchip_iodomain *iod) * instead of a special gpio. */ val = RK3288_SOC_CON2_FLASH0 | (RK3288_SOC_CON2_FLASH0 << 16); - ret = regmap_write(iod->grf, RK3288_SOC_CON2, val); + ret = regmap_write(iod->base, RK3288_SOC_CON2, val); if (ret < 0) dev_warn(iod->dev, "couldn't update flash0 ctrl\n"); } @@ -176,7 +182,7 @@ static void rk3368_iodomain_init(struct rockchip_iodomain *iod) * instead of a special gpio. */ val = RK3368_SOC_CON15_FLASH0 | (RK3368_SOC_CON15_FLASH0 << 16); - ret = regmap_write(iod->grf, RK3368_SOC_CON15, val); + ret = regmap_write(iod->base, RK3368_SOC_CON15, val); if (ret < 0) dev_warn(iod->dev, "couldn't update flash0 ctrl\n"); } @@ -187,6 +193,7 @@ static void rk3368_iodomain_init(struct rockchip_iodomain *iod) */ static const struct rockchip_iodomain_soc_data soc_data_rk3188 = { .grf_offset = 0x104, + .type = GRF, .supply_names = { NULL, NULL, @@ -209,6 +216,7 @@ static const struct rockchip_iodomain_soc_data soc_data_rk3188 = { static const struct rockchip_iodomain_soc_data soc_data_rk3288 = { .grf_offset = 0x380, + .type = GRF, .supply_names = { "lcdc", /* LCDC_VDD */ "dvp", /* DVPIO_VDD */ @@ -226,6 +234,7 @@ static const struct rockchip_iodomain_soc_data soc_data_rk3288 = { static const struct rockchip_iodomain_soc_data soc_data_rk3368 = { .grf_offset = 0x900, + .type = GRF, .supply_names = { NULL, /* reserved */ "dvp", /* DVPIO_VDD */ @@ -242,6 +251,7 @@ static const struct rockchip_iodomain_soc_data soc_data_rk3368 = { static const struct rockchip_iodomain_soc_data soc_data_rk3368_pmu = { .grf_offset = 0x100, + .type = PMUGRF, .supply_names = { NULL, NULL, @@ -293,10 +303,16 @@ static int rockchip_iodomain_probe(struct platform_device *pdev) match = of_match_node(rockchip_iodomain_match, np); iod->soc_data = (struct rockchip_iodomain_soc_data *)match->data; - iod->grf = syscon_regmap_lookup_by_phandle(np, "rockchip,grf"); - if (IS_ERR(iod->grf)) { - dev_err(&pdev->dev, "couldn't find grf regmap\n"); - return PTR_ERR(iod->grf); + if (iod->soc_data->type == PMUGRF) + iod->base = syscon_regmap_lookup_by_phandle( + np, "rockchip,pmugrf"); + else + iod->base = syscon_regmap_lookup_by_phandle( + np, "rockchip,grf"); + if (IS_ERR(iod->base)) { + dev_err(&pdev->dev, "couldn't find %s regmap\n", + (iod->soc_data->type == PMUGRF) ? "pmugrf" : "grf"); + return PTR_ERR(iod->base); } for (i = 0; i < MAX_SUPPLIES; i++) {