From patchwork Thu Sep 28 09:46:20 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Romain Izard X-Patchwork-Id: 819474 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.infradead.org (client-ip=65.50.211.133; helo=bombadil.infradead.org; envelope-from=linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="se0XVSzm"; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="SRLnD8K5"; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3y2qcR2QXtz9t4c for ; Thu, 28 Sep 2017 19:47:51 +1000 (AEST) 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=3dw90dNA4aPy1GDH9odCKvAVcb67guL9zNlBvjkX0Ys=; b=se0XVSzmdtIVYxFqfceY5BgvOb ISHB5n33SMfQup98ch0+3yDk8hv6zxPwQRR9rD/KI28cRsg+7Hp+n1cgFh34M7h+9HTWroRElzhLM b4L/eLQfFuk8HZgxSjRJmbyYeLKz/b0EAD4IIDo7307AVO9TzdN9NHQcsU2tyJD/B1VOtxswLaCu2 AxD3V1LvUSF6n8qgviU26iM4ZomqOOaxdmV9TCVtyHGp1TIveHMzgjV36nOHGmfK0ahThp9FArFwg G2eoVGu3IvN8Zmm4wU86u6MIXZQQS7gLJeCDf1nNHMs54FV8v43eV3XnesJfeEpVKIRd/415ttZ/Y Aq+jawig==; 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 1dxVPz-0003Kk-Tb; Thu, 28 Sep 2017 09:47:43 +0000 Received: from mail-wm0-x243.google.com ([2a00:1450:400c:c09::243]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1dxVPJ-0002Q8-Ux for linux-mtd@lists.infradead.org; Thu, 28 Sep 2017 09:47:08 +0000 Received: by mail-wm0-x243.google.com with SMTP id r74so1045169wme.4 for ; Thu, 28 Sep 2017 02:46:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=SXCU17pSZBd7SdVZm1ZcLIHKqn3I6ldleFFnCs7nces=; b=SRLnD8K5pCMArMDGvBIvj8liP7zplU//N5qwgHFz6d5K1Un7AoehbHni7ga1RSWLOL Yj3mel1Aqtb08aQAJSyhe16FwtvN8naV7DNdxWKHQVZISzR/q8D0L071wJlP2ucR9Fmu 1zPZD8YQxEkC5zG04cHKyN73hWQ8/GAiI7yBaHne1nj1hX+mXnU8UKkzqvaqp8sIxwFu 7SDJ0nzaSM0yYjvxhbHuXgkCef3tZOZVzr1W8zFII4r2XCPt+0baJ22Ngdi/aQRJV00L VZJARAWobjaDU3z9zj5HVAu0Vm8sfSUa/blaE03SDUxoQXoU5Ra2eM5arOWkP9Ng/eEn qaXw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=SXCU17pSZBd7SdVZm1ZcLIHKqn3I6ldleFFnCs7nces=; b=YRUJBDyQAaV690JSe0UgC8TVT6KukSmEc0GVVy06ITcfgD0QYdxBG5gKaZhV34lims axNqlr4lNyCTnfgxGnqvTd/1Jytj1VdcmfjKrvtFGmfmul90NcCu25j7FlLy1zOsmvJ6 iGQ57z5WOPbwUPlg9yIB1Nrt5xl6ZaqOpi1STBo3hI13GPNyydbHxYOOGOz1meYKknoo 6LpCdm71UZODQkICR9HyWcQgLbNQAqAwL/XrA9PUM0EaB40X0yOWILFQzvY68E28ErOj W20tlB/v+LmfqrWwyml6AWNAxw99mWzXJpB2pt6E/s8MKvm7MQDWUBL/fEWinafZD0Fn 16Mg== X-Gm-Message-State: AHPjjUhadCdSkDXPL6mjm2R/IS+Fso8CrWk0iwGQZ96SNAN185GbkrDf KpTD2Ih7QvGbOUvr0gyCx8I= X-Google-Smtp-Source: AOwi7QBI1mqxOdSl/HSyhp0dHdVlrR6Byx8iW7OJK1WslPP1n18aluEMNRGfaoyzsAiv9YdatDMR3A== X-Received: by 10.28.220.85 with SMTP id t82mr497385wmg.95.1506592000442; Thu, 28 Sep 2017 02:46:40 -0700 (PDT) Received: from localhost.localdomain (146.187.3.109.rev.sfr.net. [109.3.187.146]) by smtp.gmail.com with ESMTPSA id z10sm3272395wre.6.2017.09.28.02.46.39 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 28 Sep 2017 02:46:39 -0700 (PDT) From: Romain Izard To: Boris Brezillon , Michael Turquette , Stephen Boyd , Lee Jones , Wenyou Yang , Josh Wu , Richard Weinberger , David Woodhouse , Brian Norris , Marek Vasut , Cyrille Pitchen , Thierry Reding , Richard Genoud , Greg Kroah-Hartman , Jiri Slaby , Alan Stern , Ludovic Desroches , Nicolas Ferre , Alexandre Belloni Subject: [PATCH v4 1/8] clk: at91: pmc: Wait for clocks when resuming Date: Thu, 28 Sep 2017 11:46:20 +0200 Message-Id: <20170928094627.31017-2-romain.izard.pro@gmail.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170928094627.31017-1-romain.izard.pro@gmail.com> References: <20170928094627.31017-1-romain.izard.pro@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170928_024702_251594_9183ED1C X-CRM114-Status: GOOD ( 13.44 ) X-Spam-Score: -2.0 (--) X-Spam-Report: SpamAssassin version 3.4.1 on bombadil.infradead.org summary: Content analysis details: (-2.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at http://www.dnswl.org/, no trust [2a00:1450:400c:c09:0:0:0:243 listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (romain.izard.pro[at]gmail.com) -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-pwm@vger.kernel.org, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mtd@lists.infradead.org, linux-serial@vger.kernel.org, Romain Izard , linux-clk@vger.kernel.org MIME-Version: 1.0 Sender: "linux-mtd" Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org Wait for the syncronization of all clocks when resuming, not only the UPLL clock. Do not use regmap_read_poll_timeout, as it will call BUG() when interrupts are masked, which is the case in here. Signed-off-by: Romain Izard Acked-by: Ludovic Desroches Acked-by: Nicolas Ferre --- drivers/clk/at91/pmc.c | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/drivers/clk/at91/pmc.c b/drivers/clk/at91/pmc.c index 775af473fe11..5c2b26de303e 100644 --- a/drivers/clk/at91/pmc.c +++ b/drivers/clk/at91/pmc.c @@ -107,10 +107,20 @@ static int pmc_suspend(void) return 0; } +static bool pmc_ready(unsigned int mask) +{ + unsigned int status; + + regmap_read(pmcreg, AT91_PMC_SR, &status); + + return ((status & mask) == mask) ? 1 : 0; +} + static void pmc_resume(void) { - int i, ret = 0; + int i; u32 tmp; + u32 mask = AT91_PMC_MCKRDY | AT91_PMC_LOCKA; regmap_read(pmcreg, AT91_PMC_MCKR, &tmp); if (pmc_cache.mckr != tmp) @@ -134,13 +144,11 @@ static void pmc_resume(void) AT91_PMC_PCR_CMD); } - if (pmc_cache.uckr & AT91_PMC_UPLLEN) { - ret = regmap_read_poll_timeout(pmcreg, AT91_PMC_SR, tmp, - !(tmp & AT91_PMC_LOCKU), - 10, 5000); - if (ret) - pr_crit("USB PLL didn't lock when resuming\n"); - } + if (pmc_cache.uckr & AT91_PMC_UPLLEN) + mask |= AT91_PMC_LOCKU; + + while (!pmc_ready(mask)) + cpu_relax(); } static struct syscore_ops pmc_syscore_ops = { From patchwork Thu Sep 28 09:46:21 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Romain Izard X-Patchwork-Id: 819480 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.infradead.org (client-ip=65.50.211.133; helo=bombadil.infradead.org; envelope-from=linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="mEoOGQCy"; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="EDhx9qfs"; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3y2qdd2mXFz9t3v for ; Thu, 28 Sep 2017 19:48:53 +1000 (AEST) 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=soS9/y1xR5kCxM5cAsW3gzxv04FGYoivJOQGwcqiKTI=; b=mEoOGQCyDzet/DPwJJvX73p5P6 BfIiGvaj6FFpT+ysUDeJYjxz8B/LrvJGBFel3998PdSzK4g+TqLB8EDjrUaTdr7nxmQIcE4Zn0NCS hSRCo3sHJ6sQ4LzCim+tG5XEviStKtJLeT5is6aNs2clWcWwPWzurRSCJ4nulunyC4WMJX2HoRYdz G8zdvDDymWst8t/xX4wmXxNuXimnBqi/H2UQK5Xh0rylnO1iTLjFLIXBSwI6IwENYecYWoaXpNeqg rGaFEY8brCGb6s0vcmeg/TjspuJZFRRAEEY9wX5nTC6TVGAKtqENJ8R0+85K71pncwnEKjjow+Yjp oQWfrryQ==; 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 1dxVQw-0004HV-Dp; Thu, 28 Sep 2017 09:48:42 +0000 Received: from mail-wr0-x242.google.com ([2a00:1450:400c:c0c::242]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1dxVPL-0002QG-KM for linux-mtd@lists.infradead.org; Thu, 28 Sep 2017 09:47:12 +0000 Received: by mail-wr0-x242.google.com with SMTP id z1so1491303wre.1 for ; Thu, 28 Sep 2017 02:46:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=d2QPQyjMsXWSkJdc6MMuWv4m8CSK75I6LdWz80n+/Ss=; b=EDhx9qfsL6Kaq78TUPShjev3On4kICLXoJLOyCv0K+jwWP4HqxAshVI8YYM+U11tsV ZDGs30yRjq0SUGWs0YiYJIJdTl69RQDsHo8MHlyzcpwICe06SDWe91HnHDvvUbQyrks9 IfU5uAgsxk89HgPB/yWe6zZOsV2yHLRxwImS1fXe01NHUaiQCY/aFGBcyc1PN1zNd4XY ZfxpDACm0JEehJX5WQE+mheoROQOwyY9uOIL/Vi2vPTKQuiyM5ZqRTXqMHgNak7vT0VD WfkgSvgK/iIaWJ1aFSVRdkKqNb+bM1scwUnp3hq0ArGKlWF1lvV13jklpDl7fEana8Gb 2UqA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=d2QPQyjMsXWSkJdc6MMuWv4m8CSK75I6LdWz80n+/Ss=; b=ZGxybvAj1+cR6mud15V1d8jlTYZAdpExsobV5ak9NIsJrV/el6I2i7M2g3lu7qs3wU GLtpCp/v/X7hUm/OY+2WAjw1kVUg7rIe0CLaa9d/63UkGUDFh6vml3MUqFZxKNcxnGhR s3FqHIPwXDCTstqLfQ4UVxigxhVulQ10nJCVCyT+e0WwjXsp5yye2v0xvMFz9FMAjjUA vhB57UpIjJ/O3779TZj37ctD9rA2GhTHZAlWtevRxoK/0BMXauR2VrCBaCPmqHHacT8H 1M0yDeNT29s/v6tvDEefMAgcjg2dpnIsRJw5LDaojbzhDLuagKc3zjY0XbxDadjEIjAh KUdw== X-Gm-Message-State: AHPjjUgFDlbqrYqBSeuaBkTf47kQGXSqyXIgJaNspiXTEEwUSQdezvNF oSSW7xF018qbkE0vdoZcXzo= X-Google-Smtp-Source: AOwi7QAXSDc62njEovdTIkFyuKejN0KmK1bPS7JliNcU9puaDIJG1GsGL/f+pPJ/C1h7q7r0DNt2NQ== X-Received: by 10.223.185.84 with SMTP id b20mr3983378wrg.87.1506592001509; Thu, 28 Sep 2017 02:46:41 -0700 (PDT) Received: from localhost.localdomain (146.187.3.109.rev.sfr.net. [109.3.187.146]) by smtp.gmail.com with ESMTPSA id z10sm3272395wre.6.2017.09.28.02.46.40 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 28 Sep 2017 02:46:40 -0700 (PDT) From: Romain Izard To: Boris Brezillon , Michael Turquette , Stephen Boyd , Lee Jones , Wenyou Yang , Josh Wu , Richard Weinberger , David Woodhouse , Brian Norris , Marek Vasut , Cyrille Pitchen , Thierry Reding , Richard Genoud , Greg Kroah-Hartman , Jiri Slaby , Alan Stern , Ludovic Desroches , Nicolas Ferre , Alexandre Belloni Subject: [PATCH v4 2/8] clk: at91: pmc: Save SCSR during suspend Date: Thu, 28 Sep 2017 11:46:21 +0200 Message-Id: <20170928094627.31017-3-romain.izard.pro@gmail.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170928094627.31017-1-romain.izard.pro@gmail.com> References: <20170928094627.31017-1-romain.izard.pro@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170928_024703_960985_DBD5AD2B X-CRM114-Status: GOOD ( 11.92 ) X-Spam-Score: -2.0 (--) X-Spam-Report: SpamAssassin version 3.4.1 on bombadil.infradead.org summary: Content analysis details: (-2.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at http://www.dnswl.org/, no trust [2a00:1450:400c:c0c:0:0:0:242 listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (romain.izard.pro[at]gmail.com) -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-pwm@vger.kernel.org, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mtd@lists.infradead.org, linux-serial@vger.kernel.org, Romain Izard , linux-clk@vger.kernel.org MIME-Version: 1.0 Sender: "linux-mtd" Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org The contents of the System Clock Status Register (SCSR) needs to be restored into the System Clock Enable Register (SCER). As the bootloader will restore some clocks by itself, the issue can be missed as only the USB controller, the LCD controller, the Image Sensor controller and the programmable clocks will be impacted. Fix the obvious typo in the suspend/resume code, as the IMR register does not need to be saved twice. Signed-off-by: Romain Izard Acked-by: Nicolas Ferre --- drivers/clk/at91/pmc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/clk/at91/pmc.c b/drivers/clk/at91/pmc.c index 5c2b26de303e..07dc2861ad3f 100644 --- a/drivers/clk/at91/pmc.c +++ b/drivers/clk/at91/pmc.c @@ -86,7 +86,7 @@ static int pmc_suspend(void) { int i; - regmap_read(pmcreg, AT91_PMC_IMR, &pmc_cache.scsr); + regmap_read(pmcreg, AT91_PMC_SCSR, &pmc_cache.scsr); regmap_read(pmcreg, AT91_PMC_PCSR, &pmc_cache.pcsr0); regmap_read(pmcreg, AT91_CKGR_UCKR, &pmc_cache.uckr); regmap_read(pmcreg, AT91_CKGR_MOR, &pmc_cache.mor); @@ -129,7 +129,7 @@ static void pmc_resume(void) if (pmc_cache.pllar != tmp) pr_warn("PLLAR was not configured properly by the firmware\n"); - regmap_write(pmcreg, AT91_PMC_IMR, pmc_cache.scsr); + regmap_write(pmcreg, AT91_PMC_SCER, pmc_cache.scsr); regmap_write(pmcreg, AT91_PMC_PCER, pmc_cache.pcsr0); regmap_write(pmcreg, AT91_CKGR_UCKR, pmc_cache.uckr); regmap_write(pmcreg, AT91_CKGR_MOR, pmc_cache.mor); From patchwork Thu Sep 28 09:46:22 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Romain Izard X-Patchwork-Id: 819483 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.infradead.org (client-ip=65.50.211.133; helo=bombadil.infradead.org; envelope-from=linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="ZnzCov8D"; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="AaVYWqOZ"; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3y2qdw4tfXz9t3v for ; Thu, 28 Sep 2017 19:49:08 +1000 (AEST) 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=1ng4hsT3hhXQk3vkzi8iDFKO1wl94aTWYgwMHG5Hx4Y=; b=ZnzCov8D5Uucrmy05w9qlmAKU5 N6AUym98Bx1RlNN3TVm3GmBE4DCYMrrs7H29D2DfmmUsZvKS2tzE8LTLt5b5qaZ7WRiJCC8/9jWDi +MIUpwjsdAsnTzwGUSGPoGPuRVi6//uA/nvO9RDfe230+G7m8elm970K1sYV3froGlwr9nI4Ghvq2 AKtOk6tcrPfAWTbzwPMcxqJxaUPvTpo6fVYfp0gM5Zj2XoXxi5K+xj2QEcxeF3VJVueLp7pkELlgJ CQLnM6MCrnvNvM2s4cnBKSDE6U7dAuWkW0PjCH/roUWBPOHFJGENw5vxvgcrWnloxfvg5moOps3k/ LRBEquAg==; 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 1dxVRI-0004cu-NV; Thu, 28 Sep 2017 09:49:04 +0000 Received: from mail-wm0-x244.google.com ([2a00:1450:400c:c09::244]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1dxVPM-0002S2-O4 for linux-mtd@lists.infradead.org; Thu, 28 Sep 2017 09:47:13 +0000 Received: by mail-wm0-x244.google.com with SMTP id t69so1049383wmt.2 for ; Thu, 28 Sep 2017 02:46:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=5v5OQvNstnVmbIx9/rItx5KKfRrxeaMxdASdro2SAIU=; b=AaVYWqOZgpYSPJHduUQphRxizm/MZaPT4QHWVxS22dJ8ImjnAyCZgjH/T9pjZn1h9g 12b55Vgrx/GydWKxROh0/Zav4E5XO0MaXAO+k+OEGPmsRZ64eZPDBualdaS+eABvBIu3 tBvO4ie54gZmsAFrUJmy7zbJCaRWho1sJtXKaqIBZutQRxuUId+KDkRMzJmKgmdgVWm1 gh9DrSAq5iwCf9afqhiuNtc3tsBYR4ab5FowWaykGJV1qQPqzAAFIQ6O/SsDhggGXk9S zbkFux5jXGvnDKWfdN4CcpiIR9GuHD8jLMnuKwFAYVsrm+ObZ5THSfbrsLiiz6ykILXK 1Fng== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=5v5OQvNstnVmbIx9/rItx5KKfRrxeaMxdASdro2SAIU=; b=aBOXVBkWDaO0PUqfzIYNoT1hZ4sEGtx4SOs5diqDFfUzJFhAmz+/oPF6IOjCQPFQB/ QEKpsw5A0H/Yr7bft+jR1s5DHWCTIh2f2b0wlUwU6dIJI5qWH3uFizLwNwPAS2EXFTNC 6+zxr2ekwaiOxezj8E/aqo2kBkt2bAZuWSsYqS2iQhmCigWahzmaothqZdbY1DwtN6fX vhnuWASjXoixaDuOPT0TGIUA5GVe8hx0VAtpmHeYMYUsvBkiB4g9f14X7tsFd0YWBYvR xEzRamtrWvB4Jo8dF1LXx8QOkwmLa/YnfQfXKNLQrghkCGVLTvZ+UkPtMR0Y0CTwHmUl Ejtw== X-Gm-Message-State: AMCzsaXDsoCapmn6orvSBQwJtNmvSurycl18ONmLiin7WfTJhGc78Q3u eCcItw306Ei2h1hLJ/BYzD8= X-Google-Smtp-Source: AOwi7QDptAIZ6FV08s0hkDb0KP4Iky1N9uWpZQXNaVwXIQO0s/EB48tfYTNVHvD0phfcwqZmSM5e7Q== X-Received: by 10.28.169.140 with SMTP id s134mr526053wme.36.1506592002690; Thu, 28 Sep 2017 02:46:42 -0700 (PDT) Received: from localhost.localdomain (146.187.3.109.rev.sfr.net. [109.3.187.146]) by smtp.gmail.com with ESMTPSA id z10sm3272395wre.6.2017.09.28.02.46.41 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 28 Sep 2017 02:46:42 -0700 (PDT) From: Romain Izard To: Boris Brezillon , Michael Turquette , Stephen Boyd , Lee Jones , Wenyou Yang , Josh Wu , Richard Weinberger , David Woodhouse , Brian Norris , Marek Vasut , Cyrille Pitchen , Thierry Reding , Richard Genoud , Greg Kroah-Hartman , Jiri Slaby , Alan Stern , Ludovic Desroches , Nicolas Ferre , Alexandre Belloni Subject: [PATCH v4 3/8] clk: at91: pmc: Support backup for programmable clocks Date: Thu, 28 Sep 2017 11:46:22 +0200 Message-Id: <20170928094627.31017-4-romain.izard.pro@gmail.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170928094627.31017-1-romain.izard.pro@gmail.com> References: <20170928094627.31017-1-romain.izard.pro@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170928_024705_043299_1747F08A X-CRM114-Status: GOOD ( 17.10 ) X-Spam-Score: -2.0 (--) X-Spam-Report: SpamAssassin version 3.4.1 on bombadil.infradead.org summary: Content analysis details: (-2.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 SPF_PASS SPF: sender matches SPF record 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (romain.izard.pro[at]gmail.com) -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-pwm@vger.kernel.org, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mtd@lists.infradead.org, linux-serial@vger.kernel.org, Romain Izard , Romain Izard , linux-clk@vger.kernel.org MIME-Version: 1.0 Sender: "linux-mtd" Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org From: Romain Izard When an AT91 programmable clock is declared in the device tree, register it into the Power Management Controller driver. On entering suspend mode, the driver saves and restores the Programmable Clock registers to support the backup mode for these clocks. Signed-off-by: Romain Izard Acked-by: Nicolas Ferre --- Changes in v2: * register PCKs on clock startup Changes in v3: * improve comments on hanling 0 in pmc_register_id and pmc_register_pck * declare local variables earlier for checkpatch drivers/clk/at91/clk-programmable.c | 2 ++ drivers/clk/at91/pmc.c | 35 +++++++++++++++++++++++++++++++++++ drivers/clk/at91/pmc.h | 2 ++ 3 files changed, 39 insertions(+) diff --git a/drivers/clk/at91/clk-programmable.c b/drivers/clk/at91/clk-programmable.c index 85a449cf61e3..0e6aab1252fc 100644 --- a/drivers/clk/at91/clk-programmable.c +++ b/drivers/clk/at91/clk-programmable.c @@ -204,6 +204,8 @@ at91_clk_register_programmable(struct regmap *regmap, if (ret) { kfree(prog); hw = ERR_PTR(ret); + } else { + pmc_register_pck(id); } return hw; diff --git a/drivers/clk/at91/pmc.c b/drivers/clk/at91/pmc.c index 07dc2861ad3f..1fa27f4ea538 100644 --- a/drivers/clk/at91/pmc.c +++ b/drivers/clk/at91/pmc.c @@ -22,6 +22,7 @@ #include "pmc.h" #define PMC_MAX_IDS 128 +#define PMC_MAX_PCKS 8 int of_at91_get_clk_range(struct device_node *np, const char *propname, struct clk_range *range) @@ -50,6 +51,7 @@ EXPORT_SYMBOL_GPL(of_at91_get_clk_range); static struct regmap *pmcreg; static u8 registered_ids[PMC_MAX_IDS]; +static u8 registered_pcks[PMC_MAX_PCKS]; static struct { @@ -66,8 +68,13 @@ static struct u32 pcr[PMC_MAX_IDS]; u32 audio_pll0; u32 audio_pll1; + u32 pckr[PMC_MAX_PCKS]; } pmc_cache; +/* + * As Peripheral ID 0 is invalid on AT91 chips, the identifier is stored + * without alteration in the table, and 0 is for unused clocks. + */ void pmc_register_id(u8 id) { int i; @@ -82,9 +89,28 @@ void pmc_register_id(u8 id) } } +/* + * As Programmable Clock 0 is valid on AT91 chips, there is an offset + * of 1 between the stored value and the real clock ID. + */ +void pmc_register_pck(u8 pck) +{ + int i; + + for (i = 0; i < PMC_MAX_PCKS; i++) { + if (registered_pcks[i] == 0) { + registered_pcks[i] = pck + 1; + break; + } + if (registered_pcks[i] == (pck + 1)) + break; + } +} + static int pmc_suspend(void) { int i; + u8 num; regmap_read(pmcreg, AT91_PMC_SCSR, &pmc_cache.scsr); regmap_read(pmcreg, AT91_PMC_PCSR, &pmc_cache.pcsr0); @@ -103,6 +129,10 @@ static int pmc_suspend(void) regmap_read(pmcreg, AT91_PMC_PCR, &pmc_cache.pcr[registered_ids[i]]); } + for (i = 0; registered_pcks[i]; i++) { + num = registered_pcks[i] - 1; + regmap_read(pmcreg, AT91_PMC_PCKR(num), &pmc_cache.pckr[num]); + } return 0; } @@ -119,6 +149,7 @@ static bool pmc_ready(unsigned int mask) static void pmc_resume(void) { int i; + u8 num; u32 tmp; u32 mask = AT91_PMC_MCKRDY | AT91_PMC_LOCKA; @@ -143,6 +174,10 @@ static void pmc_resume(void) pmc_cache.pcr[registered_ids[i]] | AT91_PMC_PCR_CMD); } + for (i = 0; registered_pcks[i]; i++) { + num = registered_pcks[i] - 1; + regmap_write(pmcreg, AT91_PMC_PCKR(num), pmc_cache.pckr[num]); + } if (pmc_cache.uckr & AT91_PMC_UPLLEN) mask |= AT91_PMC_LOCKU; diff --git a/drivers/clk/at91/pmc.h b/drivers/clk/at91/pmc.h index 858e8ef7e8db..d22b1fa9ecdc 100644 --- a/drivers/clk/at91/pmc.h +++ b/drivers/clk/at91/pmc.h @@ -31,8 +31,10 @@ int of_at91_get_clk_range(struct device_node *np, const char *propname, #ifdef CONFIG_PM void pmc_register_id(u8 id); +void pmc_register_pck(u8 pck); #else static inline void pmc_register_id(u8 id) {} +static inline void pmc_register_pck(u8 pck) {} #endif #endif /* __PMC_H_ */ From patchwork Thu Sep 28 09:46:23 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Romain Izard X-Patchwork-Id: 819470 X-Patchwork-Delegate: boris.brezillon@free-electrons.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.infradead.org (client-ip=65.50.211.133; helo=bombadil.infradead.org; envelope-from=linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="Ci2j1Mpg"; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="VCp6Y1HF"; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3y2qbn3bLcz9t3w for ; Thu, 28 Sep 2017 19:47:16 +1000 (AEST) 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=LM2S+btrxgsoMuZm+v4vPgN8OVkDk5bNT1jLnbi09b4=; b=Ci2j1MpgM1y4ZIm19a8tSlrp2S ahBnsx6ak0PlLHCDDLR7vyyZZM6GaHlnsvFqLG9k65qnj1qu7j/5TEbpvWjTuy/Z3ZdxatwfJ8zPi IE3DrNKMye2wUTn403w4d22VlevsOfEuyXy+B2cTQT/0dSkKpMxPbw51wPHGYoEw/tH14LutDNQrm poQnttU+9h5xoqvU02rHS3N3aNwxrOixWiWyPH7S3IZG5n19zqTiGNg7uzw2ASqWEiK8zw2/b/W1h y1sjm/nE/2YRX+hiaS4dJFhYvEx1GNMVY0ZQ1MnUgIaO3rdtK/Xf920Uqsk0akm0VkuySdSawkbJ1 hhS3EheA==; 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 1dxVPQ-0002ox-7V; Thu, 28 Sep 2017 09:47:08 +0000 Received: from mail-wm0-x243.google.com ([2a00:1450:400c:c09::243]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1dxVPK-0002S3-3L for linux-mtd@lists.infradead.org; Thu, 28 Sep 2017 09:47:05 +0000 Received: by mail-wm0-x243.google.com with SMTP id m72so1067471wmc.1 for ; Thu, 28 Sep 2017 02:46:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=ekmUElve1eO9lFnfDY02U3uv6BFDIO3z+pfaU9Ayz0M=; b=VCp6Y1HFYfdPv1tkjLkFoDDbeVhR+pDtkstWO2bmtRPSGk1sI6w3x3YrFvtcmObHzY 6z4mHrE544OGrIsykpXnM3yNf3+13VySm17/cQTZJN8BJ9TfVWRMz37Z5V4j0tPL773d BesKG7JEqjf2ZlOxKiWW040lelS1aNIrsYSQWUST4cQYGWjv3HbP+QD8qpoTiZUuV05R 0AB1JMWRgUoOVojqVOKcm3zYNDX7VvNHCADitzVszcBCTp8RIGPpr82Kmpi86u9qJGQn 0HypKCfJ5zQb8vCrSa5zk+nJPQvrBAGACWGjxngWsd9yWQbJneIHhfUmh1pt0HYl8ltz rZMA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=ekmUElve1eO9lFnfDY02U3uv6BFDIO3z+pfaU9Ayz0M=; b=o7WDqoVqZipBCQWFB1/s1qxRQYW3Q+F3Mcf9td87uSFK6o9v+5wlpql3D6EyG7Ohm1 KT3P/ed6AY6oVGak4xyuS9YJVNCI8uQIVKOayLrLqsoZj5pdT6CUmrMCJmRGlqJtllj4 uMocaL8FF0M//ka3JmdPPQhAcRhbmOXWMVomD8UBHNdnduIjGfajoRLcizpYEdhvygWD PcsALXVExwJApdoAtaAw3NREcoqXycqDf0jRDnYp2cuGl7yA7QSNmvMuKeiJLFJV1Sb/ nCUYkZO4h+j7TOtLogA/Vkj8kIB0NH7porYMg+8QpI0pcQPDY3q7Xsr0+GDzFnZGCTlu 7ImA== X-Gm-Message-State: AMCzsaWGaIglSVyAuDDKlnL+3ZhBdGu+/wFBXQZVVsYmhzM5ks94PKWZ M8Cdt5hcqydAya6hbGxwly0= X-Google-Smtp-Source: AOwi7QDNJz5hgGMatKKtMkVtKfrygnvWxSRzoM0OykizAp6/p8faG93WHnSN66Dq+U5Y/AcZlRzZIg== X-Received: by 10.28.17.79 with SMTP id 76mr520386wmr.74.1506592003906; Thu, 28 Sep 2017 02:46:43 -0700 (PDT) Received: from localhost.localdomain (146.187.3.109.rev.sfr.net. [109.3.187.146]) by smtp.gmail.com with ESMTPSA id z10sm3272395wre.6.2017.09.28.02.46.42 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 28 Sep 2017 02:46:43 -0700 (PDT) From: Romain Izard To: Boris Brezillon , Michael Turquette , Stephen Boyd , Lee Jones , Wenyou Yang , Josh Wu , Richard Weinberger , David Woodhouse , Brian Norris , Marek Vasut , Cyrille Pitchen , Thierry Reding , Richard Genoud , Greg Kroah-Hartman , Jiri Slaby , Alan Stern , Ludovic Desroches , Nicolas Ferre , Alexandre Belloni Subject: [PATCH v4 4/8] mtd: nand: atmel: Avoid ECC errors when leaving backup mode Date: Thu, 28 Sep 2017 11:46:23 +0200 Message-Id: <20170928094627.31017-5-romain.izard.pro@gmail.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170928094627.31017-1-romain.izard.pro@gmail.com> References: <20170928094627.31017-1-romain.izard.pro@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170928_024702_476930_3084E00F X-CRM114-Status: GOOD ( 16.75 ) X-Spam-Score: -2.0 (--) X-Spam-Report: SpamAssassin version 3.4.1 on bombadil.infradead.org summary: Content analysis details: (-2.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at http://www.dnswl.org/, no trust [2a00:1450:400c:c09:0:0:0:243 listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (romain.izard.pro[at]gmail.com) -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-pwm@vger.kernel.org, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mtd@lists.infradead.org, linux-serial@vger.kernel.org, Romain Izard , linux-clk@vger.kernel.org MIME-Version: 1.0 Sender: "linux-mtd" Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org During backup mode, the contents of all registers will be cleared as the SoC will be completely powered down. For a product that boots on NAND Flash memory, the bootloader will obviously use the related controller to read the Flash and correct any detected error in the memory, before handling back control to the kernel's resuming entry point. But it does not clean the NAND controller registers after use and on its side the kernel driver expects the error locator to be powered down and in a clean state. Add a resume hook for the PMECC error locator, and reset its registers. Signed-off-by: Romain Izard --- Changes in v3: * keep the PMECC disabled when not in use, and use atmel_pmecc_resume to reset the controller after the bootloader has left it enabled. Changes in v4: * export atmel_pmecc_reset instead of atmel_pmecc_resume * use the correct pointer in atmel_nand_controller_resume drivers/mtd/nand/atmel/nand-controller.c | 3 +++ drivers/mtd/nand/atmel/pmecc.c | 17 +++++++++-------- drivers/mtd/nand/atmel/pmecc.h | 1 + 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/drivers/mtd/nand/atmel/nand-controller.c b/drivers/mtd/nand/atmel/nand-controller.c index f25eca79f4e5..8afcff9a66ea 100644 --- a/drivers/mtd/nand/atmel/nand-controller.c +++ b/drivers/mtd/nand/atmel/nand-controller.c @@ -2530,6 +2530,9 @@ static __maybe_unused int atmel_nand_controller_resume(struct device *dev) struct atmel_nand_controller *nc = dev_get_drvdata(dev); struct atmel_nand *nand; + if (nc->pmecc) + atmel_pmecc_reset(nc->pmecc); + list_for_each_entry(nand, &nc->chips, node) { int i; diff --git a/drivers/mtd/nand/atmel/pmecc.c b/drivers/mtd/nand/atmel/pmecc.c index 146af8218314..0a3f12141c45 100644 --- a/drivers/mtd/nand/atmel/pmecc.c +++ b/drivers/mtd/nand/atmel/pmecc.c @@ -765,6 +765,13 @@ void atmel_pmecc_get_generated_eccbytes(struct atmel_pmecc_user *user, } EXPORT_SYMBOL_GPL(atmel_pmecc_get_generated_eccbytes); +void atmel_pmecc_reset(struct atmel_pmecc *pmecc) +{ + writel(PMECC_CTRL_RST, pmecc->regs.base + ATMEL_PMECC_CTRL); + writel(PMECC_CTRL_DISABLE, pmecc->regs.base + ATMEL_PMECC_CTRL); +} +EXPORT_SYMBOL_GPL(atmel_pmecc_reset); + int atmel_pmecc_enable(struct atmel_pmecc_user *user, int op) { struct atmel_pmecc *pmecc = user->pmecc; @@ -797,10 +804,7 @@ EXPORT_SYMBOL_GPL(atmel_pmecc_enable); void atmel_pmecc_disable(struct atmel_pmecc_user *user) { - struct atmel_pmecc *pmecc = user->pmecc; - - writel(PMECC_CTRL_RST, pmecc->regs.base + ATMEL_PMECC_CTRL); - writel(PMECC_CTRL_DISABLE, pmecc->regs.base + ATMEL_PMECC_CTRL); + atmel_pmecc_reset(user->pmecc); mutex_unlock(&user->pmecc->lock); } EXPORT_SYMBOL_GPL(atmel_pmecc_disable); @@ -855,10 +859,7 @@ static struct atmel_pmecc *atmel_pmecc_create(struct platform_device *pdev, /* Disable all interrupts before registering the PMECC handler. */ writel(0xffffffff, pmecc->regs.base + ATMEL_PMECC_IDR); - - /* Reset the ECC engine */ - writel(PMECC_CTRL_RST, pmecc->regs.base + ATMEL_PMECC_CTRL); - writel(PMECC_CTRL_DISABLE, pmecc->regs.base + ATMEL_PMECC_CTRL); + atmel_pmecc_reset(pmecc); return pmecc; } diff --git a/drivers/mtd/nand/atmel/pmecc.h b/drivers/mtd/nand/atmel/pmecc.h index a8ddbfca2ea5..817e0dd9fd15 100644 --- a/drivers/mtd/nand/atmel/pmecc.h +++ b/drivers/mtd/nand/atmel/pmecc.h @@ -61,6 +61,7 @@ atmel_pmecc_create_user(struct atmel_pmecc *pmecc, struct atmel_pmecc_user_req *req); void atmel_pmecc_destroy_user(struct atmel_pmecc_user *user); +void atmel_pmecc_reset(struct atmel_pmecc *pmecc); int atmel_pmecc_enable(struct atmel_pmecc_user *user, int op); void atmel_pmecc_disable(struct atmel_pmecc_user *user); int atmel_pmecc_wait_rdy(struct atmel_pmecc_user *user); From patchwork Thu Sep 28 09:46:24 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Romain Izard X-Patchwork-Id: 819477 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.infradead.org (client-ip=65.50.211.133; helo=bombadil.infradead.org; envelope-from=linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="aFJnzmma"; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="vWx4FWki"; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3y2qcs6yRLz9t3v for ; Thu, 28 Sep 2017 19:48:13 +1000 (AEST) 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=Mhxsf/pbPkI3SJQemZTuZV+K0AWm6ZqioXP3RxgxZgc=; b=aFJnzmmaDxAIzwaNcQ76+pG3eN 1X11SI4GpE+u/srYZAPn9J21aJgQKFCpT/316GJCjCZZ0YBbI03LCnU46fuTlrNotDMBiDyLv8a2z dUc7xF/YjOS1YB4dO/5kK7BAlSDY8FVTw2TJ0Bs5uqLLTmiafLykWajaHRsjvoIl6BlRZqbsBv4eJ oXTc6bUbSpEEBO0u64zt9lxhu7pBFsFc9oa4Z+U1Pb55Jcs1wKIAF0CMjQUc5n7fMk3+lJ+5AGY5K wfL781990/3mBxqbtyfsQfN0i7l4R4RJy0sDpYEgq5DJeHpKzpK3N24GSPYPK9Eo6oba42YxG5E7M f7seD+5Q==; 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 1dxVQJ-0003eH-40; Thu, 28 Sep 2017 09:48:03 +0000 Received: from mail-wm0-x244.google.com ([2a00:1450:400c:c09::244]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1dxVPM-0002SD-O2 for linux-mtd@lists.infradead.org; Thu, 28 Sep 2017 09:47:08 +0000 Received: by mail-wm0-x244.google.com with SMTP id m127so1054489wmm.1 for ; Thu, 28 Sep 2017 02:46:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=eKJJGM2P5nU+uYh8EoUwdBNRZw/Ddz+yhB47PcZ+a/0=; b=vWx4FWkicTubDyGDjpCOulDSm0sWQ2yHje+kJgWMLiCNgdtfCiCPFFArEAJm+lsDsn UmvxoG9+G4KSAL8UadclAzzaBC4Js7DF73N3qf/GmXVcaGdJ+W4+JoAEkg1gDiNiHwyK 5dtXzfnqxWZbqdBaKATu1WwYCMo30+UIvgAh4LE/cE3itUmlQ2udgLBcPaV24o2Q7cNa eb6m2Bi3n0u/P8GZpbdboCSLGsMqimKCotmV17GxgCSFTDV+6UB5C2YA7UhINmOOnF5y vAJT5n2aqHuEQCWo40e01nbkI3hKjILzvsxTngFTCA9MpF722Q/PpH3PwtxoFt81wUx9 eb5g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=eKJJGM2P5nU+uYh8EoUwdBNRZw/Ddz+yhB47PcZ+a/0=; b=M0u4gNbLJvn5Bu3EfKyMeCe0eaF02/Th/IQBZpDtCb4VRrfqSYUdREOMGCAXc3t4OT 5wTKxCtgk7Tos9QeMGVIh+8fVKngQkwnSISoDUSVgyS7rqeOB4qHSBwpnbMSWg5pBZ0c JGGFnnSb2n+uOjlsXUFvEmArAB1KjjIkHxYFzoInG0W7+pXjoqXMxbQM9J0tuWVJ+5/l 43m4zonhLmdf6WbUP7iKEQDkHMtAwpuUJ6gtqhfmFnjv1fbvdNSm8ND6NqzdnCJCFAJN mx2sIDddgIvlJGcU3R4GntedW+UahGFR7WuNmN00n0l3C3u3MLNCI3haZ/H7AYUplx8x oOKQ== X-Gm-Message-State: AHPjjUiV1EztqeJAKIdf4nErjfh+3Tsdmc5vA0eCa+ank/YSX51EfQJg 6BVrHVoxpzJOxMuzcFXSBw8= X-Google-Smtp-Source: AOwi7QCoxtRe7b/1eLS94XTVWGb7k6k8pu8dZyI9lz9BhQH9ZGTTsKPp2nRRiMq7ESBBvT+67BLp+g== X-Received: by 10.28.234.72 with SMTP id i69mr501777wmh.80.1506592004842; Thu, 28 Sep 2017 02:46:44 -0700 (PDT) Received: from localhost.localdomain (146.187.3.109.rev.sfr.net. [109.3.187.146]) by smtp.gmail.com with ESMTPSA id z10sm3272395wre.6.2017.09.28.02.46.43 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 28 Sep 2017 02:46:44 -0700 (PDT) From: Romain Izard To: Boris Brezillon , Michael Turquette , Stephen Boyd , Lee Jones , Wenyou Yang , Josh Wu , Richard Weinberger , David Woodhouse , Brian Norris , Marek Vasut , Cyrille Pitchen , Thierry Reding , Richard Genoud , Greg Kroah-Hartman , Jiri Slaby , Alan Stern , Ludovic Desroches , Nicolas Ferre , Alexandre Belloni Subject: [PATCH v4 5/8] ehci-atmel: Power down during suspend is normal Date: Thu, 28 Sep 2017 11:46:24 +0200 Message-Id: <20170928094627.31017-6-romain.izard.pro@gmail.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170928094627.31017-1-romain.izard.pro@gmail.com> References: <20170928094627.31017-1-romain.izard.pro@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170928_024705_010217_0F6C81B2 X-CRM114-Status: GOOD ( 11.98 ) X-Spam-Score: -2.0 (--) X-Spam-Report: SpamAssassin version 3.4.1 on bombadil.infradead.org summary: Content analysis details: (-2.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 SPF_PASS SPF: sender matches SPF record 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (romain.izard.pro[at]gmail.com) -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-pwm@vger.kernel.org, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mtd@lists.infradead.org, linux-serial@vger.kernel.org, Romain Izard , linux-clk@vger.kernel.org MIME-Version: 1.0 Sender: "linux-mtd" Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org When an Atmel SoC is suspended with the backup mode, the USB bus will be powered down. As this is expected, do not return an error to the driver core when ehci_resume detects it. Signed-off-by: Romain Izard Acked-by: Nicolas Ferre --- drivers/usb/host/ehci-atmel.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/usb/host/ehci-atmel.c b/drivers/usb/host/ehci-atmel.c index 7440722bfbf0..2a8b9bdc0e57 100644 --- a/drivers/usb/host/ehci-atmel.c +++ b/drivers/usb/host/ehci-atmel.c @@ -205,7 +205,8 @@ static int __maybe_unused ehci_atmel_drv_resume(struct device *dev) struct atmel_ehci_priv *atmel_ehci = hcd_to_atmel_ehci_priv(hcd); atmel_start_clock(atmel_ehci); - return ehci_resume(hcd, false); + ehci_resume(hcd, false); + return 0; } #ifdef CONFIG_OF From patchwork Thu Sep 28 09:46:25 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Romain Izard X-Patchwork-Id: 819478 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.infradead.org (client-ip=65.50.211.133; helo=bombadil.infradead.org; envelope-from=linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="NDh6ylwD"; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="KQNnZHMX"; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3y2qd91tsvz9t3v for ; Thu, 28 Sep 2017 19:48:29 +1000 (AEST) 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=Ezvf2ptDvkZ5VHKZI/tWTAPDp+rffgfvXQ5YSGuwj6k=; b=NDh6ylwDTLZumWFKhLMl33hQUY l/sU33ryloIwasLes8SWz517YY5xdiUkxS6haq0UAy89d+3FAIGw7o5JOQqcY0IEdRTPbw3+Y61pc lLTNFJr2ARacfjCHftyOMPTIZnD77zu+IIpkvPEsdBojR6k2rq4v4/ja3matG0cbIiRz0cKLtCrZD bpAJx2iwtArWOEwo29oDi3RtqLCQFjVAHAgIv+7JIu7eCD7nj1weV82eBmCuXOWGC0Pbxk+vka10r pQJQk1rDwe2gCwQTS23mOKsyNdevKq/m6LZ0uUvPUfT2yjnAJia+clvVrphxXmDWZP841WkcJ944M nF57BgQg==; 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 1dxVQb-0003xr-Vz; Thu, 28 Sep 2017 09:48:22 +0000 Received: from mail-wm0-x244.google.com ([2a00:1450:400c:c09::244]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1dxVPM-0002Sl-ON for linux-mtd@lists.infradead.org; Thu, 28 Sep 2017 09:47:09 +0000 Received: by mail-wm0-x244.google.com with SMTP id q132so1043138wmd.2 for ; Thu, 28 Sep 2017 02:46:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=kvPTtPcu5oL0am5aHq/oFFFKcBEH9CL6vhFECh9wHB0=; b=KQNnZHMXDFfOFGJFQEsV0dwlR7PZgrzrwh8LWsui0zuJJbNpBE3w8G4W8ZJIhTx0i/ e/unxACt3ZMmgJMU3q5gZO8a4T047CvWZfyIUhRgQmsqsGFV70IrwejdG1ZD7zTWjNU5 zU12PF0ltN8QdZUMuV3SEIKsVgp/tc6GeEH8mXt51yRzLERm9y5g+ef5W5j0Fg8PBgUB LPX23bbQlW0dwPV7OfbbGfWnCPMJy/QdyU2d/XH+3kIsOhTaF3NciwLTzQwRdcPpOvjp yaG1WmPI6x2syA2R04fvNUt6yW1qQoGUiK8+fKNXoH2QoiDCpwY+KVgiR1cjr+b5REi/ mFsA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=kvPTtPcu5oL0am5aHq/oFFFKcBEH9CL6vhFECh9wHB0=; b=HMXNIqwZPqTbZIvGK+jYeGn8+idxHe5Ga12CBfdyBkdrYqvrF8zz9R/NUFlGg8XITG rhu6+FBjHIrJRpfYv/HYh3yag5m7errSqx3kGRIJXxtTJ5LaD+iqnbVE82WYVLFLKe6E AU4x+UzF8XmbUzpG3payJQ2Y2WXYmIWPLP8h9SGEwRpnDqi8DhCPTtUJhFGu4JWq0v5N gXTWLQgptPzQP42XfjCPubxrxA8c+XJokDiRpIdJWjg+4/d/A+VlACcmnY8029oonIMI Dq0jAQVjUkyvDMoF3/329+HmL7HJPcbrYJ/ujwLrlct8qgD1aWHSXh5GUIFxLmKVtAx7 Rwuw== X-Gm-Message-State: AMCzsaU3otmRBYciw8a1ugoV/mhZy+6sf0HaFOCo4y03W+8q0S9dp9ia YKFGxNW4ktoiYuIpR7iVdQQ= X-Google-Smtp-Source: AOwi7QDQfFREzpem7R3pojsN58sKffhEz2lBu2DmKDIrnGPOMapZIwbbjYgLhKl1xzP9aIMytCj9TQ== X-Received: by 10.28.48.20 with SMTP id w20mr485932wmw.23.1506592006474; Thu, 28 Sep 2017 02:46:46 -0700 (PDT) Received: from localhost.localdomain (146.187.3.109.rev.sfr.net. [109.3.187.146]) by smtp.gmail.com with ESMTPSA id z10sm3272395wre.6.2017.09.28.02.46.44 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 28 Sep 2017 02:46:45 -0700 (PDT) From: Romain Izard To: Boris Brezillon , Michael Turquette , Stephen Boyd , Lee Jones , Wenyou Yang , Josh Wu , Richard Weinberger , David Woodhouse , Brian Norris , Marek Vasut , Cyrille Pitchen , Thierry Reding , Richard Genoud , Greg Kroah-Hartman , Jiri Slaby , Alan Stern , Ludovic Desroches , Nicolas Ferre , Alexandre Belloni Subject: [PATCH v4 6/8] pwm: atmel-tcb: Support backup mode Date: Thu, 28 Sep 2017 11:46:25 +0200 Message-Id: <20170928094627.31017-7-romain.izard.pro@gmail.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170928094627.31017-1-romain.izard.pro@gmail.com> References: <20170928094627.31017-1-romain.izard.pro@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170928_024705_021196_22E8C90B X-CRM114-Status: GOOD ( 16.92 ) X-Spam-Score: -2.0 (--) X-Spam-Report: SpamAssassin version 3.4.1 on bombadil.infradead.org summary: Content analysis details: (-2.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 SPF_PASS SPF: sender matches SPF record 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (romain.izard.pro[at]gmail.com) -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-pwm@vger.kernel.org, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mtd@lists.infradead.org, linux-serial@vger.kernel.org, Romain Izard , linux-clk@vger.kernel.org MIME-Version: 1.0 Sender: "linux-mtd" Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org Save and restore registers for the PWM on suspend and resume, which makes hibernation and backup modes possible. Signed-off-by: Romain Izard Acked-by: Nicolas Ferre --- drivers/pwm/pwm-atmel-tcb.c | 63 +++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 61 insertions(+), 2 deletions(-) diff --git a/drivers/pwm/pwm-atmel-tcb.c b/drivers/pwm/pwm-atmel-tcb.c index 75db585a2a94..acd3ce8ecf3f 100644 --- a/drivers/pwm/pwm-atmel-tcb.c +++ b/drivers/pwm/pwm-atmel-tcb.c @@ -37,11 +37,20 @@ struct atmel_tcb_pwm_device { unsigned period; /* PWM period expressed in clk cycles */ }; +struct atmel_tcb_channel { + u32 enabled; + u32 cmr; + u32 ra; + u32 rb; + u32 rc; +}; + struct atmel_tcb_pwm_chip { struct pwm_chip chip; spinlock_t lock; struct atmel_tc *tc; struct atmel_tcb_pwm_device *pwms[NPWM]; + struct atmel_tcb_channel bkup[NPWM / 2]; }; static inline struct atmel_tcb_pwm_chip *to_tcb_chip(struct pwm_chip *chip) @@ -175,12 +184,15 @@ static void atmel_tcb_pwm_disable(struct pwm_chip *chip, struct pwm_device *pwm) * Use software trigger to apply the new setting. * If both PWM devices in this group are disabled we stop the clock. */ - if (!(cmr & (ATMEL_TC_ACPC | ATMEL_TC_BCPC))) + if (!(cmr & (ATMEL_TC_ACPC | ATMEL_TC_BCPC))) { __raw_writel(ATMEL_TC_SWTRG | ATMEL_TC_CLKDIS, regs + ATMEL_TC_REG(group, CCR)); - else + tcbpwmc->bkup[group].enabled = 1; + } else { __raw_writel(ATMEL_TC_SWTRG, regs + ATMEL_TC_REG(group, CCR)); + tcbpwmc->bkup[group].enabled = 0; + } spin_unlock(&tcbpwmc->lock); } @@ -263,6 +275,7 @@ static int atmel_tcb_pwm_enable(struct pwm_chip *chip, struct pwm_device *pwm) /* Use software trigger to apply the new setting */ __raw_writel(ATMEL_TC_CLKEN | ATMEL_TC_SWTRG, regs + ATMEL_TC_REG(group, CCR)); + tcbpwmc->bkup[group].enabled = 1; spin_unlock(&tcbpwmc->lock); return 0; } @@ -445,10 +458,56 @@ static const struct of_device_id atmel_tcb_pwm_dt_ids[] = { }; MODULE_DEVICE_TABLE(of, atmel_tcb_pwm_dt_ids); +#ifdef CONFIG_PM_SLEEP +static int atmel_tcb_pwm_suspend(struct device *dev) +{ + struct platform_device *pdev = to_platform_device(dev); + struct atmel_tcb_pwm_chip *tcbpwm = platform_get_drvdata(pdev); + void __iomem *base = tcbpwm->tc->regs; + int i; + + for (i = 0; i < (NPWM / 2); i++) { + struct atmel_tcb_channel *chan = &tcbpwm->bkup[i]; + + chan->cmr = readl(base + ATMEL_TC_REG(i, CMR)); + chan->ra = readl(base + ATMEL_TC_REG(i, RA)); + chan->rb = readl(base + ATMEL_TC_REG(i, RB)); + chan->rc = readl(base + ATMEL_TC_REG(i, RC)); + } + return 0; +} + +static int atmel_tcb_pwm_resume(struct device *dev) +{ + struct platform_device *pdev = to_platform_device(dev); + struct atmel_tcb_pwm_chip *tcbpwm = platform_get_drvdata(pdev); + void __iomem *base = tcbpwm->tc->regs; + int i; + + for (i = 0; i < (NPWM / 2); i++) { + struct atmel_tcb_channel *chan = &tcbpwm->bkup[i]; + + writel(chan->cmr, base + ATMEL_TC_REG(i, CMR)); + writel(chan->ra, base + ATMEL_TC_REG(i, RA)); + writel(chan->rb, base + ATMEL_TC_REG(i, RB)); + writel(chan->rc, base + ATMEL_TC_REG(i, RC)); + if (chan->enabled) { + writel(ATMEL_TC_CLKEN | ATMEL_TC_SWTRG, + base + ATMEL_TC_REG(i, CCR)); + } + } + return 0; +} +#endif + +static SIMPLE_DEV_PM_OPS(atmel_tcb_pwm_pm_ops, atmel_tcb_pwm_suspend, + atmel_tcb_pwm_resume); + static struct platform_driver atmel_tcb_pwm_driver = { .driver = { .name = "atmel-tcb-pwm", .of_match_table = atmel_tcb_pwm_dt_ids, + .pm = &atmel_tcb_pwm_pm_ops, }, .probe = atmel_tcb_pwm_probe, .remove = atmel_tcb_pwm_remove, From patchwork Thu Sep 28 09:46:26 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Romain Izard X-Patchwork-Id: 819484 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.infradead.org (client-ip=65.50.211.133; helo=bombadil.infradead.org; envelope-from=linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="kUiS9Vwb"; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="J9GFVGDZ"; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3y2qfQ6hgdz9t3v for ; Thu, 28 Sep 2017 19:49:34 +1000 (AEST) 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=JoqGZu5bsE3ZX0SW+Ioly5S9P9YtABj32SVeof72YFY=; b=kUiS9VwbLsQioHK1Od7jes2lID SOHbzSjSKWfoaZS5kq/JRrXZHsiLAl3cheAIuA0IZYsLA5Thz4RA/+HVtrFrnIYmBw0SIBy1Dj9hx lE3893BYSCNMGyooTeaG/V+/vnYVE68rY2Kuw03EqqCDkRRXpr0A2NEshmSzGlk+P2LIsOCbmW7HM qBsnVscYuYEWVGohHxNJyi9qkWMb0n7QrbUqqAAgAWxecTe5M2lirtVBsqCw1cFE2lkTN2OlgFJek Pya59iexBEs4DPXPqtdz77e8fpqtb4IVeSse+WrZsSiWX46edZl041JpGL3JF69nk2FQJoUCc8sS6 I6yUd6kg==; 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 1dxVRf-0004x6-2Q; Thu, 28 Sep 2017 09:49:27 +0000 Received: from mail-wr0-x242.google.com ([2a00:1450:400c:c0c::242]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1dxVPQ-0002Uu-3a for linux-mtd@lists.infradead.org; Thu, 28 Sep 2017 09:47:16 +0000 Received: by mail-wr0-x242.google.com with SMTP id z1so1491568wre.1 for ; Thu, 28 Sep 2017 02:46:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=DYO+ppTxC9gCfPpg2w/pl8TnhNlCr/mYGjXJz2lkQOQ=; b=J9GFVGDZXnZURnWkSIqp3uXXw+0MZue1tcSe/cxMxwpMPqoRaijKQWkBmXF3BVBRBw xw+aUlubeitymUtgeEqOXCAPS1d56loKhRwAVs65/+3twAfL03mp92ACLqwUOuzyHq4d BtErtxP7W1NrevaUfpwJciZtL4AwLykbTqBsavaiqE3IaYMX/3Zs+bjhh0Q/LroKN17Z QAcTfwZKCwLWQWSmfd7TsGy12kVWdfXEI1R6ujrE0lNj9dhNKIaXogk23dqRMTB9Q5vv ODgVQEazqTFWAh6wTXR0VlNlSxPjgpTwN0n5DPo7xAvM5m2KtFoKLfcm0dTd8qbVZlIq Kg1w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=DYO+ppTxC9gCfPpg2w/pl8TnhNlCr/mYGjXJz2lkQOQ=; b=Ey1R2qDLblw02SrSve2Zw7a8cnYgaWgTYWQIClJxjafr5tEp2AsNervwK71oqzkXDm qGVwAVZjMZoGASBLIIW37yun5TkS29CC+joxyMRKtjexCr1OVD7BrWV/56p6iUe/bjy6 vxqzMOLT+NCa+8987kE9pgV54HN5XKP3hYUOz8RJEo+7zOxrdyWepquvyrcViPyvjVoZ mLVJYwrPJN77HSyKU7X1zsqBPUnYKmIFpzahsmdeveSt4vwd0nThHx3XEmsXGYHGu+dX VPLLpkbYLHLpz8c0UKv4MVHGU+9P/8tXgbtmoEMy+I83jWR5/87d7aiiRSWYk/V/YvTb OxwA== X-Gm-Message-State: AHPjjUien1ei+EyEKDw4feg08mLAEBY0DaDVvBfJzPdWqKtyjSMTKZAd sbjakEhztT+wms6p4NRNf5U= X-Google-Smtp-Source: AOwi7QBn7ngLbKtJg0fnyN1NGRfv5L7NcSHOM/PJY5tqELhSYx+XC0SWV2dK0hJWUJT/v73RKbDstw== X-Received: by 10.223.166.196 with SMTP id t62mr3939653wrc.251.1506592007376; Thu, 28 Sep 2017 02:46:47 -0700 (PDT) Received: from localhost.localdomain (146.187.3.109.rev.sfr.net. [109.3.187.146]) by smtp.gmail.com with ESMTPSA id z10sm3272395wre.6.2017.09.28.02.46.46 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 28 Sep 2017 02:46:46 -0700 (PDT) From: Romain Izard To: Boris Brezillon , Michael Turquette , Stephen Boyd , Lee Jones , Wenyou Yang , Josh Wu , Richard Weinberger , David Woodhouse , Brian Norris , Marek Vasut , Cyrille Pitchen , Thierry Reding , Richard Genoud , Greg Kroah-Hartman , Jiri Slaby , Alan Stern , Ludovic Desroches , Nicolas Ferre , Alexandre Belloni Subject: [PATCH v4 7/8] atmel_flexcom: Support backup mode Date: Thu, 28 Sep 2017 11:46:26 +0200 Message-Id: <20170928094627.31017-8-romain.izard.pro@gmail.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170928094627.31017-1-romain.izard.pro@gmail.com> References: <20170928094627.31017-1-romain.izard.pro@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170928_024708_536756_0135D77C X-CRM114-Status: GOOD ( 15.81 ) X-Spam-Score: -2.0 (--) X-Spam-Report: SpamAssassin version 3.4.1 on bombadil.infradead.org summary: Content analysis details: (-2.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at http://www.dnswl.org/, no trust [2a00:1450:400c:c0c:0:0:0:242 listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (romain.izard.pro[at]gmail.com) -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-pwm@vger.kernel.org, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mtd@lists.infradead.org, linux-serial@vger.kernel.org, Romain Izard , linux-clk@vger.kernel.org MIME-Version: 1.0 Sender: "linux-mtd" Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org The controller used by a flexcom module is configured at boot, and left alone after this. As the configuration will be lost after backup mode, restore the state of the flexcom driver on resume. Signed-off-by: Romain Izard Acked-by: Nicolas Ferre Tested-by: Nicolas Ferre --- drivers/mfd/atmel-flexcom.c | 65 ++++++++++++++++++++++++++++++++++----------- 1 file changed, 50 insertions(+), 15 deletions(-) diff --git a/drivers/mfd/atmel-flexcom.c b/drivers/mfd/atmel-flexcom.c index 064bde9cff5a..ef1235c4a179 100644 --- a/drivers/mfd/atmel-flexcom.c +++ b/drivers/mfd/atmel-flexcom.c @@ -39,34 +39,44 @@ #define FLEX_MR_OPMODE(opmode) (((opmode) << FLEX_MR_OPMODE_OFFSET) & \ FLEX_MR_OPMODE_MASK) +struct atmel_flexcom { + void __iomem *base; + u32 opmode; + struct clk *clk; +}; static int atmel_flexcom_probe(struct platform_device *pdev) { struct device_node *np = pdev->dev.of_node; - struct clk *clk; struct resource *res; - void __iomem *base; - u32 opmode; + struct atmel_flexcom *afc; int err; + u32 val; + + afc = devm_kzalloc(&pdev->dev, sizeof(*afc), GFP_KERNEL); + if (!afc) + return -ENOMEM; - err = of_property_read_u32(np, "atmel,flexcom-mode", &opmode); + platform_set_drvdata(pdev, afc); + + err = of_property_read_u32(np, "atmel,flexcom-mode", &afc->opmode); if (err) return err; - if (opmode < ATMEL_FLEXCOM_MODE_USART || - opmode > ATMEL_FLEXCOM_MODE_TWI) + if (afc->opmode < ATMEL_FLEXCOM_MODE_USART || + afc->opmode > ATMEL_FLEXCOM_MODE_TWI) return -EINVAL; res = platform_get_resource(pdev, IORESOURCE_MEM, 0); - base = devm_ioremap_resource(&pdev->dev, res); - if (IS_ERR(base)) - return PTR_ERR(base); + afc->base = devm_ioremap_resource(&pdev->dev, res); + if (IS_ERR(afc->base)) + return PTR_ERR(afc->base); - clk = devm_clk_get(&pdev->dev, NULL); - if (IS_ERR(clk)) - return PTR_ERR(clk); + afc->clk = devm_clk_get(&pdev->dev, NULL); + if (IS_ERR(afc->clk)) + return PTR_ERR(afc->clk); - err = clk_prepare_enable(clk); + err = clk_prepare_enable(afc->clk); if (err) return err; @@ -76,9 +86,10 @@ static int atmel_flexcom_probe(struct platform_device *pdev) * inaccessible and are read as zero. Also the external I/O lines of the * Flexcom are muxed to reach the selected device. */ - writel(FLEX_MR_OPMODE(opmode), base + FLEX_MR); + val = FLEX_MR_OPMODE(afc->opmode); + writel(val, afc->base + FLEX_MR); - clk_disable_unprepare(clk); + clk_disable_unprepare(afc->clk); return devm_of_platform_populate(&pdev->dev); } @@ -89,10 +100,34 @@ static const struct of_device_id atmel_flexcom_of_match[] = { }; MODULE_DEVICE_TABLE(of, atmel_flexcom_of_match); +#ifdef CONFIG_PM_SLEEP +static int atmel_flexcom_resume(struct device *dev) +{ + struct atmel_flexcom *afc = dev_get_drvdata(dev); + int err; + u32 val; + + err = clk_prepare_enable(afc->clk); + if (err) + return err; + + val = FLEX_MR_OPMODE(afc->opmode), + writel(val, afc->base + FLEX_MR); + + clk_disable_unprepare(afc->clk); + + return 0; +} +#endif + +static SIMPLE_DEV_PM_OPS(atmel_flexcom_pm_ops, NULL, + atmel_flexcom_resume); + static struct platform_driver atmel_flexcom_driver = { .probe = atmel_flexcom_probe, .driver = { .name = "atmel_flexcom", + .pm = &atmel_flexcom_pm_ops, .of_match_table = atmel_flexcom_of_match, }, }; From patchwork Thu Sep 28 09:46:27 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Romain Izard X-Patchwork-Id: 819485 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.infradead.org (client-ip=65.50.211.133; helo=bombadil.infradead.org; envelope-from=linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="Un4Nks2E"; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="ZrMxLN8B"; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3y2qfw068tz9sRq for ; Thu, 28 Sep 2017 19:50:00 +1000 (AEST) 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=95BOGtLjmLLUuYMe82AwExhBEpVtRsLOqLBwb2XvX44=; b=Un4Nks2EloWy1Nm7OYNIfNFiZS Yki69ucH9M6tT771fRSpMAD2j+kLZ7cwcPiX4VOIqFrvMPOMpcTGewBymsoDc22M5LWCNGVNq27C4 JmRx16n1QODveZXJrEpljym2PwNxKJGLoRpQF3x2UVSU3oP49uH+bmZVyDcAw/sQXd6p139NUTFq+ N/JxuhtzL4DGin0cKZbwZvGeNnM4HYBF/oeGGn9G2Mt5Lc+c/1oV5IZ8/qyE76Fmya2uMy8Si8dL3 OQukT6JOxkxT43A31i6JKj4VZVB3JaiVKUBM9LNeG3lOuJzVFywvgm4hlitwCsUKLK5msT5PKpp2X Srk5cb3A==; 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 1dxVS4-0005LR-B1; Thu, 28 Sep 2017 09:49:52 +0000 Received: from mail-wm0-x242.google.com ([2a00:1450:400c:c09::242]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1dxVPS-0002V1-G7 for linux-mtd@lists.infradead.org; Thu, 28 Sep 2017 09:47:21 +0000 Received: by mail-wm0-x242.google.com with SMTP id m127so1045965wmm.3 for ; Thu, 28 Sep 2017 02:46:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=Kb+eYUn6sUr9qLQ2ec5i4R8VU1m7KosNeKaMrwYeb1w=; b=ZrMxLN8BtFMNgwM6gq0gyjxXLz1uKnio23i6+ETlC1ihuBOuO8pbIobUuKvWOOEitS xCQZVxaYSrH6/thLOqWxWEa3UQdLBSbq/6VXQRLZhogP8sf9bEfaZCcMtBdbt14bUyWw eZZNpifmjWIawT5J3NV/byhist9udYfzghe2I/cyqwG7gU77YMH7AOuS1O2yHMpk/1pB zyxuButpfhe4OdN9lyxK1xy25hmSbNkMn6QRbG757tT+SHGRJt+iGznmgVuq2pH0LEyI dEFdfbIqwiXRC+9cRJf4TDVBY+/N3sb2zZPtNqJyZ+SRl3lj2XJ9AZcubzHB6NJqiht9 x/+g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=Kb+eYUn6sUr9qLQ2ec5i4R8VU1m7KosNeKaMrwYeb1w=; b=KS5ouUrZV0NnMwIRV2apBl2UNuaBfveafpaQWJOuBeMLeoVV+wDtLQsTbi1VfLzyXH FeX6fA5uO5KUAOxcjQHut+jIXMSGv2/7z4yWinS9x0Flu4m0k3MWOgX4PypbAq+VwvQg ex1QliTtsmlt1Cm0obWHUvZ3eEZbjIyxVEKUFi0oG8qPADz3m34zoBUZ10W3QFC8X6mH KOfonsNw5qn6O5OqYfQSgGx9AMculUNqzg79AlZk5SrjStEYsFv/El0e5DRB7u/7qxyq KUtw6zSIeYqqEQrxSKwe2u5cUOpaBgfISFOAtdOkvJK6VWsDZwgMEhIuXJvaJQBbDRmM vGrA== X-Gm-Message-State: AHPjjUhwW3MIwmWjwxZSPrXO9IlQxBfNhEo408MHlgNyZLaq2uDDHuJq g5N+J/B+IUS2E03J6sCOBjc= X-Google-Smtp-Source: AOwi7QC8vtaGUT5ewGdVT4EJVssaapRUL6wbggMzzHoqiMw1ugTolj+A97gc6o5HBWanf4OaX4sWjQ== X-Received: by 10.28.147.199 with SMTP id v190mr509569wmd.24.1506592008445; Thu, 28 Sep 2017 02:46:48 -0700 (PDT) Received: from localhost.localdomain (146.187.3.109.rev.sfr.net. [109.3.187.146]) by smtp.gmail.com with ESMTPSA id z10sm3272395wre.6.2017.09.28.02.46.47 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 28 Sep 2017 02:46:47 -0700 (PDT) From: Romain Izard To: Boris Brezillon , Michael Turquette , Stephen Boyd , Lee Jones , Wenyou Yang , Josh Wu , Richard Weinberger , David Woodhouse , Brian Norris , Marek Vasut , Cyrille Pitchen , Thierry Reding , Richard Genoud , Greg Kroah-Hartman , Jiri Slaby , Alan Stern , Ludovic Desroches , Nicolas Ferre , Alexandre Belloni Subject: [PATCH v4 8/8] tty/serial: atmel: Prevent a warning on suspend Date: Thu, 28 Sep 2017 11:46:27 +0200 Message-Id: <20170928094627.31017-9-romain.izard.pro@gmail.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170928094627.31017-1-romain.izard.pro@gmail.com> References: <20170928094627.31017-1-romain.izard.pro@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170928_024711_054741_D40E8F8F X-CRM114-Status: GOOD ( 15.43 ) X-Spam-Score: -2.0 (--) X-Spam-Report: SpamAssassin version 3.4.1 on bombadil.infradead.org summary: Content analysis details: (-2.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at http://www.dnswl.org/, no trust [2a00:1450:400c:c09:0:0:0:242 listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (romain.izard.pro[at]gmail.com) -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-pwm@vger.kernel.org, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mtd@lists.infradead.org, linux-serial@vger.kernel.org, Romain Izard , linux-clk@vger.kernel.org MIME-Version: 1.0 Sender: "linux-mtd" Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org The atmel serial port driver reported the following warning on suspend: atmel_usart f8020000.serial: ttyS1: Unable to drain transmitter As the ATMEL_US_TXEMPTY status bit in ATMEL_US_CSR is always cleared when the transmitter is disabled, we need to know the transmitter's state to return the real fifo state. And as ATMEL_US_CR is write-only, it is necessary to save the state of the transmitter in a local variable, and update the variable when TXEN and TXDIS is written in ATMEL_US_CR. After those changes, atmel_tx_empty can return "empty" on suspend, the warning in uart_suspend_port disappears, and suspending is 20ms shorter for each enabled Atmel serial port. Signed-off-by: Romain Izard Tested-by: Nicolas Ferre Acked-by: Nicolas Ferre Acked-by: Richard Genoud --- drivers/tty/serial/atmel_serial.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/drivers/tty/serial/atmel_serial.c b/drivers/tty/serial/atmel_serial.c index 7551cab438ff..ce45b4ada0bf 100644 --- a/drivers/tty/serial/atmel_serial.c +++ b/drivers/tty/serial/atmel_serial.c @@ -171,6 +171,7 @@ struct atmel_uart_port { bool has_hw_timer; struct timer_list uart_timer; + bool tx_stopped; bool suspended; unsigned int pending; unsigned int pending_status; @@ -380,6 +381,10 @@ static int atmel_config_rs485(struct uart_port *port, */ static u_int atmel_tx_empty(struct uart_port *port) { + struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); + + if (atmel_port->tx_stopped) + return TIOCSER_TEMT; return (atmel_uart_readl(port, ATMEL_US_CSR) & ATMEL_US_TXEMPTY) ? TIOCSER_TEMT : 0; @@ -485,6 +490,7 @@ static void atmel_stop_tx(struct uart_port *port) * is fully transmitted. */ atmel_uart_writel(port, ATMEL_US_CR, ATMEL_US_TXDIS); + atmel_port->tx_stopped = true; /* Disable interrupts */ atmel_uart_writel(port, ATMEL_US_IDR, atmel_port->tx_done_mask); @@ -521,6 +527,7 @@ static void atmel_start_tx(struct uart_port *port) /* re-enable the transmitter */ atmel_uart_writel(port, ATMEL_US_CR, ATMEL_US_TXEN); + atmel_port->tx_stopped = false; } /* @@ -1866,6 +1873,7 @@ static int atmel_startup(struct uart_port *port) atmel_uart_writel(port, ATMEL_US_CR, ATMEL_US_RSTSTA | ATMEL_US_RSTRX); /* enable xmit & rcvr */ atmel_uart_writel(port, ATMEL_US_CR, ATMEL_US_TXEN | ATMEL_US_RXEN); + atmel_port->tx_stopped = false; setup_timer(&atmel_port->uart_timer, atmel_uart_timer_callback, @@ -2122,6 +2130,7 @@ static void atmel_set_termios(struct uart_port *port, struct ktermios *termios, /* disable receiver and transmitter */ atmel_uart_writel(port, ATMEL_US_CR, ATMEL_US_TXDIS | ATMEL_US_RXDIS); + atmel_port->tx_stopped = true; /* mode */ if (port->rs485.flags & SER_RS485_ENABLED) { @@ -2207,6 +2216,7 @@ static void atmel_set_termios(struct uart_port *port, struct ktermios *termios, atmel_uart_writel(port, ATMEL_US_BRGR, quot); atmel_uart_writel(port, ATMEL_US_CR, ATMEL_US_RSTSTA | ATMEL_US_RSTRX); atmel_uart_writel(port, ATMEL_US_CR, ATMEL_US_TXEN | ATMEL_US_RXEN); + atmel_port->tx_stopped = false; /* restore interrupts */ atmel_uart_writel(port, ATMEL_US_IER, imr); @@ -2450,6 +2460,7 @@ static void atmel_console_write(struct console *co, const char *s, u_int count) /* Make sure that tx path is actually able to send characters */ atmel_uart_writel(port, ATMEL_US_CR, ATMEL_US_TXEN); + atmel_port->tx_stopped = false; uart_console_write(port, s, count, atmel_console_putchar); @@ -2511,6 +2522,7 @@ static int __init atmel_console_setup(struct console *co, char *options) { int ret; struct uart_port *port = &atmel_ports[co->index].uart; + struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); int baud = 115200; int bits = 8; int parity = 'n'; @@ -2528,6 +2540,7 @@ static int __init atmel_console_setup(struct console *co, char *options) atmel_uart_writel(port, ATMEL_US_IDR, -1); atmel_uart_writel(port, ATMEL_US_CR, ATMEL_US_RSTSTA | ATMEL_US_RSTRX); atmel_uart_writel(port, ATMEL_US_CR, ATMEL_US_TXEN | ATMEL_US_RXEN); + atmel_port->tx_stopped = false; if (options) uart_parse_options(options, &baud, &parity, &bits, &flow);