From patchwork Tue Oct 3 06:55:40 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joel Stanley X-Patchwork-Id: 9981851 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 74C5260365 for ; Tue, 3 Oct 2017 07:13:36 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 66A002870C for ; Tue, 3 Oct 2017 07:13:36 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5B25F28878; Tue, 3 Oct 2017 07:13:36 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_MED autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id C4C542870C for ; Tue, 3 Oct 2017 07:13:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=TPKI0Okq4mQJy4Tr9WO9N1/iM4N5+b2N2UdqqbLkySI=; b=U5woDh1tGBIv+2YFGymWts7T7Q Ym/6aR+9JOQtZ5jQ5KrFkRHL7UsGIembNcoVadHCiKgaTl7qriirM0hyNNuqpYfNkMVCMdrlafHcD +s+lCNb2V3dMEjahthgdYMccYnwGniVHftn33mJbhh012VwGYM01bNnWID3VH+EoqiS7hNsEtFvGt YwhHNZP5R8OEc3i7j5CRf902GSy1gDLLHJck8wsFaxYf5MlFMNFDaWsHilw4dKALheOCSex94V7i/ Lb5t803WIiWj7d9Igy4h/nhbLpBCTQmmuTaDH254PJrt2cEm544ViEdtRZH60qy9Bnf/sdVYf1I1G SxZPUbJg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1dzHOR-0004GK-Hc; Tue, 03 Oct 2017 07:13:27 +0000 Received: from casper.infradead.org ([2001:8b0:10b:1236::1]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1dzHOB-0003wy-OH for linux-arm-kernel@bombadil.infradead.org; Tue, 03 Oct 2017 07:13:11 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=References:In-Reply-To:Message-Id:Date: Subject:Cc:To:From:Sender:Reply-To:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=dXWfK5cgpGP1CPVj7BnVdmt3eO24FuR7QXjlsRClvBQ=; b=vEZoDbo6JyvaA2s0fWWsRrYrk KxlUHluAjZaBbqn8nBQR1aED8dempXKzTSCd/d9gR6xRcTxtaczCyLoTAezv8sKan5ag1zbwPlL6I tT9ceie2gdqcDTrzoZDaFUuoJX7tMVGulK9KymRT3b7REqtWIs0MOytNC8p/M1GbQn/B57qeK6To5 Rc6YWdnnY1XRS6vNO/4fUM4+2SSnkMyJR486NndsDCMwyfK7V0oHPu2Tzv7tJmmqWOH9eVvavE0iA 1dP7hHeRlC7q/qBl5/ShYcBuVA6UT3DulTRdNWPjN3wdakTQ3kDUW6zAbwDUORAV+Q4POq4wHW08e aisK9/uvw==; Received: from mail-pf0-x243.google.com ([2607:f8b0:400e:c00::243]) by casper.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1dzH8m-0007ao-B4 for linux-arm-kernel@lists.infradead.org; Tue, 03 Oct 2017 06:57:18 +0000 Received: by mail-pf0-x243.google.com with SMTP id e69so8120176pfg.4 for ; Mon, 02 Oct 2017 23:56:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=dXWfK5cgpGP1CPVj7BnVdmt3eO24FuR7QXjlsRClvBQ=; b=OsrErUm/s/MHHWta2ekFfGQZOyKvr3oVBvLEFLUWvSLVVZuZhvv0SRVLTRH+L9Mgmy uTgDpO5KI8k5jWKYb7yIIRTiJ+THzN04+Z6qCOQX7xLN0QU2FPD25gYY7LnAaU8fS1Jp F29/N6QfiuJqFP7v6LkllEVTdcmm/1kSsejHV22pvXvTGJGDqeQJfuE7HYz5JJqn7fr0 h0GCna5n/VUxH5EflvDhIRnHwn3NR+7CKPvnmdFx2tfoG71MXkhbvyV4Od05d/selXVT xW4uQp7Zh5F5FMAePec+0j8qh+30vj2bw6daDcTDb9MutLA7AcwDctA0dx45LN3Zhaap W4SQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=dXWfK5cgpGP1CPVj7BnVdmt3eO24FuR7QXjlsRClvBQ=; b=XbRAJJwEeQzKEY5RwJ3YgF2eQystMhi2Z3pzf3ey1+8V2ipnI/XeolvyCm1pcyhVsD IkNKunLSBYifZT7CtjejqM10K5SfsXA8Qe6modboClwswEp9dy3IES8Q7WYBbClA1Z/g T1tG6QgO+Nd1n9715UiFamx+OVve2H89iUmHUjwEFbOCIvzjl/oROL+C/KaBFXolDUok Pjzvtml8Gk3yl+Mu6mrCKbQhUnhhgprZ6gbvFvhHcepQMX0KDczCWYbNdHq2arbYga2f wOKOT52rB7Df8T15WSFxEWMTKaYRaZsnoutcNTJu1wlLBsYUWYzny9hSI/iQBU8lBhYE haYg== X-Gm-Message-State: AMCzsaWm9We4uIlG88rMLkhl9rCwA8zCOYbhS0HOJ3evG0mlSvi6P2ss q9m+HSUo/d5afjIVVnw4DlA= X-Google-Smtp-Source: AOwi7QALQCoFdXZpF0DUF0kIEu5G2BxethJ+S73JVuMloGctV5BN3mlBxcvKuKp+1yZ97RBcm9lm8g== X-Received: by 10.84.131.111 with SMTP id 102mr4846960pld.178.1507013814418; Mon, 02 Oct 2017 23:56:54 -0700 (PDT) Received: from aurora.jms.id.au ([203.0.153.9]) by smtp.gmail.com with ESMTPSA id s27sm19667356pgo.59.2017.10.02.23.56.48 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 02 Oct 2017 23:56:53 -0700 (PDT) Received: by aurora.jms.id.au (sSMTP sendmail emulation); Tue, 03 Oct 2017 17:26:45 +1030 From: Joel Stanley To: Lee Jones , Michael Turquette , Stephen Boyd Subject: [PATCH v4 5/5] clk: aspeed: Add reset controller Date: Tue, 3 Oct 2017 17:25:40 +1030 Message-Id: <20171003065540.11722-6-joel@jms.id.au> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20171003065540.11722-1-joel@jms.id.au> References: <20171003065540.11722-1-joel@jms.id.au> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20171003_075716_574864_4E19D0C5 X-CRM114-Status: GOOD ( 20.09 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Ryan Chen , Arnd Bergmann , Andrew Jeffery , Benjamin Herrenschmidt , linux-kernel@vger.kernel.org, Rick Altherr , Jeremy Kerr , linux-clk@vger.kernel.org, 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-Virus-Scanned: ClamAV using ClamSMTP There are some resets that are not associated with gates. These are represented by a reset controller. Signed-off-by: Joel Stanley Reviewed-by: Andrew Jeffery --- v3: - Add named initalisers for the reset defines - Add define for ADC --- drivers/clk/clk-aspeed.c | 82 +++++++++++++++++++++++++++++++- include/dt-bindings/clock/aspeed-clock.h | 10 ++++ 2 files changed, 91 insertions(+), 1 deletion(-) diff --git a/drivers/clk/clk-aspeed.c b/drivers/clk/clk-aspeed.c index a424b056e767..de491dc7f955 100644 --- a/drivers/clk/clk-aspeed.c +++ b/drivers/clk/clk-aspeed.c @@ -17,6 +17,7 @@ #include #include #include +#include #include #include @@ -292,6 +293,68 @@ static const struct clk_ops aspeed_clk_gate_ops = { .is_enabled = aspeed_clk_is_enabled, }; +/** + * struct aspeed_reset - Aspeed reset controller + * @map: regmap to access the containing system controller + * @rcdev: reset controller device + */ +struct aspeed_reset { + struct regmap *map; + struct reset_controller_dev rcdev; +}; + +#define to_aspeed_reset(p) container_of((p), struct aspeed_reset, rcdev) + +static const u8 aspeed_resets[] = { + [ASPEED_RESET_XDMA] = 25, + [ASPEED_RESET_MCTP] = 24, + [ASPEED_RESET_ADC] = 23, + [ASPEED_RESET_JTAG_MASTER] = 22, + [ASPEED_RESET_MIC] = 18, + [ASPEED_RESET_PWM] = 9, + [ASPEED_RESET_PCIVGA] = 8, + [ASPEED_RESET_I2C] = 2, + [ASPEED_RESET_AHB] = 1, +}; + +static int aspeed_reset_deassert(struct reset_controller_dev *rcdev, + unsigned long id) +{ + struct aspeed_reset *ar = to_aspeed_reset(rcdev); + u32 rst = BIT(aspeed_resets[id]); + + return regmap_update_bits(ar->map, ASPEED_RESET_CTRL, rst, 0); +} + +static int aspeed_reset_assert(struct reset_controller_dev *rcdev, + unsigned long id) +{ + struct aspeed_reset *ar = to_aspeed_reset(rcdev); + u32 rst = BIT(aspeed_resets[id]); + + return regmap_update_bits(ar->map, ASPEED_RESET_CTRL, rst, rst); +} + +static int aspeed_reset_status(struct reset_controller_dev *rcdev, + unsigned long id) +{ + struct aspeed_reset *ar = to_aspeed_reset(rcdev); + u32 val, rst = BIT(aspeed_resets[id]); + int ret; + + ret = regmap_read(ar->map, ASPEED_RESET_CTRL, &val); + if (ret) + return ret; + + return !!(val & rst); +} + +static const struct reset_control_ops aspeed_reset_ops = { + .assert = aspeed_reset_assert, + .deassert = aspeed_reset_deassert, + .status = aspeed_reset_status, +}; + static struct clk_hw *aspeed_clk_hw_register_gate(struct device *dev, const char *name, const char *parent_name, unsigned long flags, struct regmap *map, u8 clock_idx, u8 reset_idx, @@ -333,10 +396,11 @@ static int aspeed_clk_probe(struct platform_device *pdev) { const struct aspeed_clk_soc_data *soc_data; struct device *dev = &pdev->dev; + struct aspeed_reset *ar; struct regmap *map; struct clk_hw *hw; u32 val, rate; - int i; + int i, ret; map = syscon_node_to_regmap(dev->of_node); if (IS_ERR(map)) { @@ -344,6 +408,22 @@ static int aspeed_clk_probe(struct platform_device *pdev) return PTR_ERR(map); } + ar = devm_kzalloc(dev, sizeof(*ar), GFP_KERNEL); + if (!ar) + return -ENOMEM; + + ar->map = map; + ar->rcdev.owner = THIS_MODULE; + ar->rcdev.nr_resets = ARRAY_SIZE(aspeed_resets); + ar->rcdev.ops = &aspeed_reset_ops; + ar->rcdev.of_node = dev->of_node; + + ret = devm_reset_controller_register(dev, &ar->rcdev); + if (ret) { + dev_err(dev, "could not register reset controller\n"); + return ret; + } + /* SoC generations share common layouts but have different divisors */ soc_data = of_device_get_match_data(dev); if (!soc_data) { diff --git a/include/dt-bindings/clock/aspeed-clock.h b/include/dt-bindings/clock/aspeed-clock.h index 4a99421d77c8..8e19646d8025 100644 --- a/include/dt-bindings/clock/aspeed-clock.h +++ b/include/dt-bindings/clock/aspeed-clock.h @@ -39,4 +39,14 @@ #define ASPEED_NUM_CLKS 35 +#define ASPEED_RESET_XDMA 0 +#define ASPEED_RESET_MCTP 1 +#define ASPEED_RESET_ADC 2 +#define ASPEED_RESET_JTAG_MASTER 3 +#define ASPEED_RESET_MIC 4 +#define ASPEED_RESET_PWM 5 +#define ASPEED_RESET_PCIVGA 6 +#define ASPEED_RESET_I2C 7 +#define ASPEED_RESET_AHB 8 + #endif