Received: by 2002:a25:824b:0:0:0:0:0 with SMTP id d11csp813190ybn; Tue, 24 Sep 2019 09:54:20 -0700 (PDT) X-Google-Smtp-Source: APXvYqxO4dneFp1DozefP7RxxjT4hweesI1pPyVstzhp92m7OEbo9h2/E9UTPf6lLVvEB8ztxaTW X-Received: by 2002:a17:906:4a5a:: with SMTP id a26mr3455687ejv.154.1569344060452; Tue, 24 Sep 2019 09:54:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1569344060; cv=none; d=google.com; s=arc-20160816; b=kk2iKpHPTQj+awLiDvM1MBSFIbM0hZICZcU6Vwbo9hzVlfp4WuP+nWZbde0k3aT+ee 21nTtw5gs1De0lxtPVfe0IFyO3qdSqLOF0wytF9yN8vKuhr26yeQHrPak1rJSaV++KS1 eXEOkT9gm60UN193BKAh3+MyiBHXFpLq0Uzu5Rvvo1yDndGBmFL1KYgaDL92EbPeh3ML fWEpvR/AwLtAygBjb5hMUjFFNKnFbn5Zg6mMw5YM3KpMVvq/oRGQtfHG19Hu0zbK+a/s gPXtih4TE9kdGRiDW5tp0RRLCvxfgckS1CgH/W/0VE+wUWHVqlhZvtjYqPn+ea7lfpMk 6j6w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from; bh=4zp9k1D4SO/itRBEI0aIYRW5Dh4HVP6EoDkVy9hR3cI=; b=jyTmWf7ix9UeNbiaUGzaYUAIORkSGlal38fTW62nYY0wM/RJt96+CQCi7MFQ0UfkZa qmL0l3lsyq0zuUf3xceeoP73/HZAbwGJtjn7IsZSS83xYrMNtQU7UkgfatXQGYI5vEE/ rQ/Ntd1zFj/FZa/+r9e0+aAOhzeNHmItvdVjASzNEmk/0Xz9W3gjLGRndmOcwW3/xUJq Cz6LLZSpKfacXFllwGjUJX2U3Zi8/smPn3LL04pleTDth9uXXx07ub4nSlGd2gVZxMBe wS7e+qRtcztbAWW7+iMntFcOxiC5s8YwdBD6aq9x/KeVx/9no+6lSDVhiTLC1jXWSwE2 oQpA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q12si1196097ejr.187.2019.09.24.09.53.57; Tue, 24 Sep 2019 09:54:20 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2438683AbfIWIec (ORCPT + 99 others); Mon, 23 Sep 2019 04:34:32 -0400 Received: from mail-sz.amlogic.com ([211.162.65.117]:17196 "EHLO mail-sz.amlogic.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2438235AbfIWIe3 (ORCPT ); Mon, 23 Sep 2019 04:34:29 -0400 Received: from droid12-sz.software.amlogic (10.28.8.22) by mail-sz.amlogic.com (10.28.11.5) with Microsoft SMTP Server id 15.1.1591.10; Mon, 23 Sep 2019 16:35:23 +0800 From: Xingyu Chen To: Philipp Zabel , Kevin Hilman , Neil Armstrong CC: Xingyu Chen , Jianxin Pan , Rob Herring , Jerome Brunet , Hanjie Lin , , , Subject: [PATCH v2 3/3] reset: add support for the Meson-A1 SoC Reset Controller Date: Mon, 23 Sep 2019 16:34:21 +0800 Message-ID: <1569227661-4261-4-git-send-email-xingyu.chen@amlogic.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1569227661-4261-1-git-send-email-xingyu.chen@amlogic.com> References: <1569227661-4261-1-git-send-email-xingyu.chen@amlogic.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.28.8.22] Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The number of RESET registers and offset of RESET_LEVEL register for Meson-A1 are different from previous SoCs, In order to describe these differences, we introduce the struct meson_reset_param. Signed-off-by: Xingyu Chen Signed-off-by: Jianxin Pan Reviewed-by: Neil Armstrong --- drivers/reset/reset-meson.c | 35 ++++++++++++++++++++++++++++------- 1 file changed, 28 insertions(+), 7 deletions(-) diff --git a/drivers/reset/reset-meson.c b/drivers/reset/reset-meson.c index 7d05d76..94d7ba8 100644 --- a/drivers/reset/reset-meson.c +++ b/drivers/reset/reset-meson.c @@ -15,12 +15,16 @@ #include #include -#define REG_COUNT 8 #define BITS_PER_REG 32 -#define LEVEL_OFFSET 0x7c + +struct meson_reset_param { + int reg_count; + int level_offset; +}; struct meson_reset { void __iomem *reg_base; + const struct meson_reset_param *param; struct reset_controller_dev rcdev; spinlock_t lock; }; @@ -46,10 +50,12 @@ static int meson_reset_level(struct reset_controller_dev *rcdev, container_of(rcdev, struct meson_reset, rcdev); unsigned int bank = id / BITS_PER_REG; unsigned int offset = id % BITS_PER_REG; - void __iomem *reg_addr = data->reg_base + LEVEL_OFFSET + (bank << 2); + void __iomem *reg_addr; unsigned long flags; u32 reg; + reg_addr = data->reg_base + data->param->level_offset + (bank << 2); + spin_lock_irqsave(&data->lock, flags); reg = readl(reg_addr); @@ -81,10 +87,21 @@ static const struct reset_control_ops meson_reset_ops = { .deassert = meson_reset_deassert, }; +static const struct meson_reset_param meson8b_param = { + .reg_count = 8, + .level_offset = 0x7c, +}; + +static const struct meson_reset_param meson_a1_param = { + .reg_count = 3, + .level_offset = 0x40, +}; + static const struct of_device_id meson_reset_dt_ids[] = { - { .compatible = "amlogic,meson8b-reset" }, - { .compatible = "amlogic,meson-gxbb-reset" }, - { .compatible = "amlogic,meson-axg-reset" }, + { .compatible = "amlogic,meson8b-reset", .data = &meson8b_param}, + { .compatible = "amlogic,meson-gxbb-reset", .data = &meson8b_param}, + { .compatible = "amlogic,meson-axg-reset", .data = &meson8b_param}, + { .compatible = "amlogic,meson-a1-reset", .data = &meson_a1_param}, { /* sentinel */ }, }; @@ -102,12 +119,16 @@ static int meson_reset_probe(struct platform_device *pdev) if (IS_ERR(data->reg_base)) return PTR_ERR(data->reg_base); + data->param = of_device_get_match_data(&pdev->dev); + if (!data->param) + return -ENODEV; + platform_set_drvdata(pdev, data); spin_lock_init(&data->lock); data->rcdev.owner = THIS_MODULE; - data->rcdev.nr_resets = REG_COUNT * BITS_PER_REG; + data->rcdev.nr_resets = data->param->reg_count * BITS_PER_REG; data->rcdev.ops = &meson_reset_ops; data->rcdev.of_node = pdev->dev.of_node; -- 2.7.4