From patchwork Wed Sep 27 08:35:48 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Romain Izard X-Patchwork-Id: 819044 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="pcYkHZtl"; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="F3lk96+J"; 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 3y2B660wlhz9t4Z for ; Wed, 27 Sep 2017 18:37:50 +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=pcYkHZtldHlZwlKnHxCQravU/x 3u9Jg3+lEIqR51CxcIKJzS96mjpbIlmqyhkEdM9kOtoa3pp+bwlAvGASaFI/50RBsg8VuLwqG85se txjAlLwwPlQOBRvzVU1tdMZth5jKqyGHJysxzdTvJ6ct2QZ7BdJWco+ZoC2pmngW/RWfCRsBksUIS w6wP1dC71P4n5WtWaumbsYU9NqK436toMlFGhlNsa20eCyoSZKxxgs9BYy1Mxmqn8UhmdHoruEH8w WZ3ovooYL5caBYsJYPctRsqdVaZz+AAd0BR0GuGv0Sz3Z0Cz6so2txuf6x2jV0kk3ZubkZdBvYtJN 02+biImg==; 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 1dx7qc-0003yo-8P; Wed, 27 Sep 2017 08:37:38 +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 1dx7pa-0002jJ-Ou for linux-mtd@lists.infradead.org; Wed, 27 Sep 2017 08:36:41 +0000 Received: by mail-wm0-x242.google.com with SMTP id m72so15481192wmc.1 for ; Wed, 27 Sep 2017 01:36:14 -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=F3lk96+JS4bvFaGYoy2MEdUk42Z4fNxTJ+LYRkCeR89A1dDEukmVQJlv8L/fEyV/f1 rWyot8tSq5SNGhUFhiQn07y5UTDFtV79hV2wGTV55deEG8tx7QOp58PHv6dkPHKdcaaP karjnMiPYU5uTTuJtfOouc/BNX+af/DAQriGfvLZb9IlLpqO3Q0Dj3a5GHvlVli1oIeK bJcelXXTDlk0o1qRJoTzUfnxdJk6KrHj+Cj3kFUUAyrx8uPYdOZsUYXfRIq+PBtSALPo CK876vJklL4gUsK7BxGWBRwmsHI4cU3Yq1SA7vtzu+gYTTO7ibTdYXSJcVNV6vsHcOfn AVUw== 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=pjSeAGUMWZMN5JxOyF19GcAHbaQX6wNrdOathFSi+By4AKTHGyYTAKOXfDBwPgy5CV Jtiz/C7q44DxKkGKon/oM8H+rMAKEARC4zXLBdQ71Qlv4gPhXOIgSw97DcXSqapca1EN jbCKkw0OvmfkZIO/mxgTf/9WMrGQAnfQ7CDQRDhvrZ+RF1wbz+MAW5AJr6/jaSJrUXCz DOEuQxE6GsAreiJf+8utxMlmp9swy7r8bMSZMG7PpNQbCZvVAiKKTnmmdWTmbNzVlI5b QX5/WjaMFrroPOEn0R2yrWKWQAUTbbokMORScdKgo9IZmSZjzWJpbeMiAu68lRCIfw/M RI3w== X-Gm-Message-State: AHPjjUhKZcsHyYfid8e+ojELJmoJYvmZGG7NdKOE3LO5ottCGU+R34p1 92C6EK0hP1sUbnZoOR0twno= X-Google-Smtp-Source: AOwi7QC8de/LX7DtKfMfi8SNQ+mtUl0r03rkwEBNWagZeggs51mwGBQraPxvcv6K0Io8et8nDUveUQ== X-Received: by 10.28.174.67 with SMTP id x64mr909409wme.82.1506501373069; Wed, 27 Sep 2017 01:36:13 -0700 (PDT) Received: from localhost.localdomain (146.187.3.109.rev.sfr.net. [109.3.187.146]) by smtp.gmail.com with ESMTPSA id r6sm9699900wrg.40.2017.09.27.01.36.11 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 27 Sep 2017 01:36:12 -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 v3 1/8] clk: at91: pmc: Wait for clocks when resuming Date: Wed, 27 Sep 2017 10:35:48 +0200 Message-Id: <20170927083555.16580-2-romain.izard.pro@gmail.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170927083555.16580-1-romain.izard.pro@gmail.com> References: <20170927083555.16580-1-romain.izard.pro@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170927_013634_964479_E4D5BD21 X-CRM114-Status: GOOD ( 12.90 ) 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 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 Wed Sep 27 08:35:49 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Romain Izard X-Patchwork-Id: 819036 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="Y7Crl69S"; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="VMVZIQ8p"; 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 3y2B4y58lKz9t3x for ; Wed, 27 Sep 2017 18:36:50 +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=Y7Crl69Snt9ZVVgcEVh3N3GE5V LjhmKy7MNAz6czBDeSPT1cS7PPXqGEG45/WrnKIgPdVMp8kdu5QRBG80U0AFxY9hJ1w7RdcZYCd+g h8/eDjt3yuaS/nM/7q0YnNkenr/9nTTxCUyPSZeK/6DX6sdN0L/Gs3bywlOCvHaNW2Bh+cm22D2Qp cNtTDoL091KDANtYuJXTY5A9zOOxAG5e0oRaP9YXwttrYZ8ePtMx0xkGLRfC0Wclqa/McrC7Q8btS NZ0/A80GW0U8UKbbmc1jPjc+pI3G5I6ahYAM9yiLFPoLOeuOkAFbqgOo1V46mFk9hxZLqITwLVnVh pl8w5/CA==; 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 1dx7pd-0002y7-48; Wed, 27 Sep 2017 08:36:37 +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 1dx7pa-0002jn-1q for linux-mtd@lists.infradead.org; Wed, 27 Sep 2017 08:36:35 +0000 Received: by mail-wm0-x243.google.com with SMTP id m72so15481305wmc.1 for ; Wed, 27 Sep 2017 01:36:15 -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=VMVZIQ8pz24rAf20i7VD7Yx6q8OXgegF3SlG2/l5kwPDi1oYRsZwDUsOxeQrjtSHb+ cOIxHwnkY8jhmBAO54j84yXjkhRDwmbySpEOOXH7Zn1QNOsdaOEjidPyGC4qZRnu09Tv z5TDsK/dACqCdmuuto21cYPeI8dBXwRPoNOOEYToLGEg1DQkOPVaHVRW91CzzeS5sZdN Z0bGjC7k320V/gX2UIcyVV7jvH15pPcdmbi8LnJWwdhg5jWr4Emfwd8JMVXhR88LQC7f aVBOw6lXL6KrKtLsm6dIQPuISTAqMW7YTCqg2w23lg/JXL5a4ovAR3ND4wsl5semneE0 v9eQ== 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=SSQCbbAInRvvDuYTUUdrs06YCFFwoOH3TiceRbqxN9mZLOn/wT1Ay6zDbAB+bUmFO/ H+yFgigkFJ0+h8g7tlJSfPQLR9V7p8PN01S+3I9jdkO80BBVw21qpm9C3YtIyffcYDNj 77aYGxzQ+LE1VWNhhZeY1TYDPNj+stdpJwc6CNGjERZYjtgEp8L3o0wu+owSW9b8OQKg AzXJCs+f9jC2pPkuUhzj5TlEkD3KH4vN9NsbDZ5874uCs4hdiVqp81RtldMKtg2G260e uOt5dpb8tTJ3PLR4azsbaP51NFSFOvNQMTWjgjZLO0upfGBKb98eXPKw0j+6wZICfAUJ ycZA== X-Gm-Message-State: AHPjjUiRNoRiYPv5GvaonQzCTiGrnsS796Yn8Mc6p1zUQz1s799T7fJD yJ/2hlhZd4zz3yj9/g/elVA= X-Google-Smtp-Source: AOwi7QD1ghKsWG1bCPnOiOYKdTWvM6QgK0pPRzH9I+TPhUCK2Wp9q2v/boBapy7/WwIJLPgP4a0poQ== X-Received: by 10.28.100.3 with SMTP id y3mr827542wmb.69.1506501373904; Wed, 27 Sep 2017 01:36:13 -0700 (PDT) Received: from localhost.localdomain (146.187.3.109.rev.sfr.net. [109.3.187.146]) by smtp.gmail.com with ESMTPSA id r6sm9699900wrg.40.2017.09.27.01.36.13 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 27 Sep 2017 01:36:13 -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 v3 2/8] clk: at91: pmc: Save SCSR during suspend Date: Wed, 27 Sep 2017 10:35:49 +0200 Message-Id: <20170927083555.16580-3-romain.izard.pro@gmail.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170927083555.16580-1-romain.izard.pro@gmail.com> References: <20170927083555.16580-1-romain.izard.pro@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170927_013634_272098_C7AB1A50 X-CRM114-Status: GOOD ( 11.37 ) 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 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 Wed Sep 27 08:35:50 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Romain Izard X-Patchwork-Id: 819042 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="ln+cmvCc"; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="NFU/Avt1"; 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 3y2B5g6XPRz9t3x for ; Wed, 27 Sep 2017 18:37:27 +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=6aKST+XaqjAQdhsOJKjHpI0UITdCXR+uPv/Z2AOCk7g=; b=ln+cmvCc2pUv2yqlmVB4IRYhg1 LdKQVhjGo5jU8nQ7WUcZa//np4aIA/NHsdckUfayHIRUIB4s3DSnO0Vm4yca41ek6uo6xarSSVHx/ LU18RokpgN4oWWdsKlRSKk4v01Ms6hWC4xpJEt42UDEvGX23L0IsdaXkC4GLzhTSF6T7m8Ycn+MJg oksdKkDH/sdZDPri5Xfe6uyuyb4bSfrOHWCDq0fiKRy74zZWwgwglgA5SJ/pRvBiSSsG3kGmdV6jl BuVQoJ+xdTwY2jNZFCbuZYjCNYiul5Ml1v4IcfcbQqIN/Zbw0aPUO9v5wF1+n8QTBCL6dnNROAtVY 9m/+o9hQ==; 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 1dx7qN-0003iI-63; Wed, 27 Sep 2017 08:37:23 +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 1dx7pa-0002k5-1j for linux-mtd@lists.infradead.org; Wed, 27 Sep 2017 08:36:40 +0000 Received: by mail-wm0-x243.google.com with SMTP id q124so15384010wmb.0 for ; Wed, 27 Sep 2017 01:36:16 -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=iLRDoc1eXp6mQxdaAfv7l1CnPd100UAgbzaexY+m7LI=; b=NFU/Avt1n2OivYNZJLJsv5/BFn3yG9Ye7CUsC8KWJTGRoH7FplTV/4lv/622XzkiQr 1/HDEiS901deqWZVUU3HqLGJ0pdiTIs8cOXETeiQwqgVDao17DpSTR/ZhZfh3AUIEvgY 2UpX8b5sEqlXds0LoPX1hXidYiCjsquFQFYUlD4rzBXITmaZzROZMWp1V5WaT8slOVuE UBEdaZOUFcnnisttBEO3E9UIwnrSz+HDhspZvSIYvgRtj9Fd4a9LTP4/GvV7e33FHvF5 06SJDI6fftp7wjieiAYswrSf/kBkC5V4EZoLqPaDr9QVSHe96vdaup2Pbau658i7hTey B3EQ== 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=iLRDoc1eXp6mQxdaAfv7l1CnPd100UAgbzaexY+m7LI=; b=ESA0ZV29aYmq8Q4worJsDynFAuEoeU2STY8uBroMp4CrSs01UQ2+8VtdUBM6wECBT8 o4Cqk50z0bI385hFVDzPm2p6In3wudDEwZsPJw3xSp+gouogdj47W9FRgbdmpc2gL2cQ ZEBA0BLqIHUyzY+T4qewt3hnFTQlMZNhhwo0Ilett9noC7JbcMpbp+CydGkEw6GqCZEy cR7KNGYWOwU328/Od/6jXNBY7iRG3/xGNUhe+xKoLmqQ0MA//PYU/w2cff/m9zVHaZD4 qRKlVjKS1HzZ9pWChTzoQuMNPwEv2lNCZyhN6MG90aP4/SRmAoHY+Nyr5DCT1Iu6Of8M 6C+A== X-Gm-Message-State: AHPjjUihmxXiyTLv27VoMGubD4o8NH7IKHcKq+Kp5FLETL8xFfeSucg4 Lp7jsYUF9OdnNiW0AnwxIKM= X-Google-Smtp-Source: AOwi7QCo5Db5eKdgcBtRjxCvyj41jUdYPcSQHpB8h1sF5WFR89Zz3ToMSaD8TfcWXwS+n8jypK3ZOQ== X-Received: by 10.28.8.75 with SMTP id 72mr791437wmi.43.1506501374874; Wed, 27 Sep 2017 01:36:14 -0700 (PDT) Received: from localhost.localdomain (146.187.3.109.rev.sfr.net. [109.3.187.146]) by smtp.gmail.com with ESMTPSA id r6sm9699900wrg.40.2017.09.27.01.36.13 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 27 Sep 2017 01:36:14 -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 v3 3/8] clk: at91: pmc: Support backup for programmable clocks Date: Wed, 27 Sep 2017 10:35:50 +0200 Message-Id: <20170927083555.16580-4-romain.izard.pro@gmail.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170927083555.16580-1-romain.izard.pro@gmail.com> References: <20170927083555.16580-1-romain.izard.pro@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170927_013634_290314_C0F93086 X-CRM114-Status: GOOD ( 16.37 ) 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 , 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 Chnages 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 Wed Sep 27 08:35:51 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Romain Izard X-Patchwork-Id: 819045 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="gel5tOUr"; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="jbfL4Wdp"; 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 3y2B6S00yCz9t3x for ; Wed, 27 Sep 2017 18:38:07 +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=J9HaVX40zZZj1QQnN7jog1/FJngBmYyHup3wxrL5mvY=; b=gel5tOUr9XHCJYclZjORv6Pv08 y3BohgN3b/7Whow0CwbVZjRPwdYZ6zaarO+l9q8PimrwCWG6SKIO/yAVcYAkq/Iw5te+p6wlrYdRS osADXfx27+vOREvnV+Np4D521hrMA2avnC9BQrmZkYu0agKl+Wp4z3EMfU73n86Y27bsrUt1nU0tQ xKIGkUHiQA8/Td+JlzHanXua5bbYxxKistfXM+dSz4k9tttPiYcqWV8bUmQ+EdauFt707slhv8Ub0 mtEnqvdL4Lbbv4xFSo0WXamzH6trKqHCQP/f+QpgxIqpbeiY0NlDq+gn9Nh7B4YSdIfEjVR8eO1cj FvH4JPUA==; 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 1dx7qt-0004GM-NY; Wed, 27 Sep 2017 08:37:55 +0000 Received: from mail-wm0-x241.google.com ([2a00:1450:400c:c09::241]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1dx7pd-0002kg-Tf for linux-mtd@lists.infradead.org; Wed, 27 Sep 2017 08:36:48 +0000 Received: by mail-wm0-x241.google.com with SMTP id m72so15481667wmc.1 for ; Wed, 27 Sep 2017 01:36:17 -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=YbTyumyy6P4kge3veVl/A0z9dzATwB6TcaPmHuC1BkA=; b=jbfL4WdpgAFTGIUHTMUkozrT8YPYvH/Qe3M/a3Z1dN3sK3+xHrTKrq1L+GrmSWLvEz IEQ/6/+PQFd3yvhgfCLGF/CMXzebyu+kmOH7AjhZ252ReTObm0W8XnJusQbzpJwFZceK jWVRYuoXPb7F2MnBEIrJD1p0FfRjDaqUWEdPBiFK83vlydVVnh4R94e9klHsbB2n+TZW OaiN+0be9kWZuaRTz5HEdnqMcxpapFAqWeTl8JWbqzWLO9IHakXvH9vJEVFowoa3f4IR XUvT89QoKjeMa/kFSevm66QOsXZ9yfk6pLQTw77vCO4Y4C8sRqMLdcXU3EDFoKxoKV25 IJPw== 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=YbTyumyy6P4kge3veVl/A0z9dzATwB6TcaPmHuC1BkA=; b=jqKFMtOkLQhdx2B2xH0YHimFk/U/Pb2k3gKX609twHUGjsO0vaM8ECsWmbniW0aPZd aHjiHeM7x6uvqm0+X/x+dac8GjL4DAagsfpMcnJilHDh9XZhg1JsHOCWRCjSf2nFmCh2 RXpiYRyIo1NoLQleLFqh6OpZgXCb5I8q6hWvzp0Qoq4po+yWtNmuklqym9QbWQBozf+1 D2Pt7OUIQpSm2sDfpz0N4QZQP8B4bL2IaCselSlFuPyOj2rWTkchW56TcJ2sH4KfO7Dy B8K8Bv4ONvvv/resdoiL0BbTdWvfj0q8DYWJ1S++E0jNw3OhfctY7JvWnXwezBlyI+K9 af7g== X-Gm-Message-State: AHPjjUjb6V8U14eAytmQqAx26pgGqocZxNxCO5KrXZy4lonA/y5k3TFw k0mBXkHijKfUkpuP97hD+6E= X-Google-Smtp-Source: AOwi7QCDvaTM95g9jizq059H+Q/H/WJwHn5cqLxwodS6V9OvQfJiuMBrYNYZfbKgx8so/m+IqdnIRw== X-Received: by 10.28.140.18 with SMTP id o18mr863571wmd.145.1506501376157; Wed, 27 Sep 2017 01:36:16 -0700 (PDT) Received: from localhost.localdomain (146.187.3.109.rev.sfr.net. [109.3.187.146]) by smtp.gmail.com with ESMTPSA id r6sm9699900wrg.40.2017.09.27.01.36.14 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 27 Sep 2017 01:36:15 -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 v3 4/8] mtd: nand: atmel: Avoid ECC errors when leaving backup mode Date: Wed, 27 Sep 2017 10:35:51 +0200 Message-Id: <20170927083555.16580-5-romain.izard.pro@gmail.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170927083555.16580-1-romain.izard.pro@gmail.com> References: <20170927083555.16580-1-romain.izard.pro@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170927_013638_423684_762CAEB4 X-CRM114-Status: GOOD ( 15.56 ) 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:241 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 --- Change 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. drivers/mtd/nand/atmel/nand-controller.c | 3 +++ drivers/mtd/nand/atmel/pmecc.c | 22 ++++++++++++++-------- drivers/mtd/nand/atmel/pmecc.h | 1 + 3 files changed, 18 insertions(+), 8 deletions(-) diff --git a/drivers/mtd/nand/atmel/nand-controller.c b/drivers/mtd/nand/atmel/nand-controller.c index f25eca79f4e5..86c2199380c2 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 (nand->pmecc) + atmel_pmecc_resume(nand->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..ff09c0f25dd4 100644 --- a/drivers/mtd/nand/atmel/pmecc.c +++ b/drivers/mtd/nand/atmel/pmecc.c @@ -765,6 +765,12 @@ 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); +} + int atmel_pmecc_enable(struct atmel_pmecc_user *user, int op) { struct atmel_pmecc *pmecc = user->pmecc; @@ -797,14 +803,17 @@ 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); +void atmel_pmecc_resume(struct atmel_pmecc_user *user) +{ + atmel_pmecc_reset(user->pmecc); +} +EXPORT_SYMBOL_GPL(atmel_pmecc_resume); + int atmel_pmecc_wait_rdy(struct atmel_pmecc_user *user) { struct atmel_pmecc *pmecc = user->pmecc; @@ -855,10 +864,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..488a90f1965d 100644 --- a/drivers/mtd/nand/atmel/pmecc.h +++ b/drivers/mtd/nand/atmel/pmecc.h @@ -63,6 +63,7 @@ void atmel_pmecc_destroy_user(struct atmel_pmecc_user *user); int atmel_pmecc_enable(struct atmel_pmecc_user *user, int op); void atmel_pmecc_disable(struct atmel_pmecc_user *user); +void atmel_pmecc_resume(struct atmel_pmecc_user *user); int atmel_pmecc_wait_rdy(struct atmel_pmecc_user *user); int atmel_pmecc_correct_sector(struct atmel_pmecc_user *user, int sector, void *data, void *ecc); From patchwork Wed Sep 27 08:35:52 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Romain Izard X-Patchwork-Id: 819041 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="sJjF1DYN"; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="oHjLgRSY"; 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 3y2B5V5799z9t3x for ; Wed, 27 Sep 2017 18:37:18 +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=sJjF1DYN2SRzcbP1djOVc7CLcn 1yhYCgqQlnvaHkeC3hHsY3aUMag8KOl+p1SNpoTOLFg1+ehq4fwXDQdTS3mG2Jqyzyx14DXp23MZS D1SH2N/aRn/tHJFFFCOF+oi73adciSpNJhHRYSwaFcS694Lgpd3qHCNxfxUgFjkeWVg5axd2Dr8Wi +Z1HLam3U1uLR2O8IIScO+ZSUHqGkBhlkJqQYtH+ohyXziv+FM1Q/4gT8nus78L0fAFEKga8hNVVC KlKUWb8sdafHcv/qwp+SOw5Jx3VaEd9NAUZ2FLGPnJtGN05uNN0paxvWXxuI41fg5u8tPbGmOn6Xo dmE5j1ag==; 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 1dx7q6-0003RG-Fw; Wed, 27 Sep 2017 08:37:06 +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 1dx7pa-0002lV-Oy for linux-mtd@lists.infradead.org; Wed, 27 Sep 2017 08:36:38 +0000 Received: by mail-wm0-x242.google.com with SMTP id q124so587376wmb.5 for ; Wed, 27 Sep 2017 01:36:18 -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=oHjLgRSYUMqb2Y38wrAll4VRaHsODKgmIZrb5Q6kBxAilAvtnw8If8pPIUm+0OsLHv GbVgmBBAjCtzJ6GGZw4NMTBFxP8GrfsUsiBbPFWRs/PzxN/FDPlcXtM0dNiuqg7tKyed tjD4KSdjSwb/cBanmbCE3+OfnQTA7lIncTEeKyAS0LGBlPwvx4LKbkIM8pFzDY89+/M4 rAt7Xa+JOji2MROOsDAWVQ9eEiPqwmSafW4mroWZHTFgh9bBDeAsxW5d6CV5ugLNVvEb BBHv55s4dvJJWQ+VQwCnrphCZ2+7EWyK9COOPD/R6hgB/K60TaUzfDs7eUZl5oGItEnB 9qsw== 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=MoBKiMzJ9oNrlE5Ph0z2owDBZ+1ahv01WYE+yMJNr0xLjqrwgIqYdNDam4S1uvR9Sn /CrA7Oy/teN9Y/Ajw5qfxZJD8/LuL7PuWXxB0lYyHpcgiA9YmKz89R/hRSSczDphbVwl WimlKZcR07x5VwvNQXfKx9oHyJ13p6rJYEkU2LBMX4p2hlK9HKH5A6YOTAq2QFPNE6NW AP5h+PnOW15zRbgsh0iZY5arw5rU/vgC6L14xa+XtOA/xsXXl6oNJlzzgsucQB9+xjW2 NiyvNmpUt+Aqq46JJZExrILKwOHWo46uXYlzGurF7gPpMgaZV077yNrLlZkNKA0w+2fR hBvw== X-Gm-Message-State: AHPjjUhz9lREH1iMIXx/GIynqHBMCPXCiGLkEmtQSMCXYflbmLy6+DwO Gfo7jIl0flQw7zKJ6Tbr5n8= X-Google-Smtp-Source: AOwi7QAv5KfxFnIFe6PWr5OPEhbTraPZeYD3w8K11cZj+kjpf/6Hv6yuG/jlnsD4822WpD3uiOhaZQ== X-Received: by 10.28.59.133 with SMTP id i127mr782369wma.154.1506501377065; Wed, 27 Sep 2017 01:36:17 -0700 (PDT) Received: from localhost.localdomain (146.187.3.109.rev.sfr.net. [109.3.187.146]) by smtp.gmail.com with ESMTPSA id r6sm9699900wrg.40.2017.09.27.01.36.16 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 27 Sep 2017 01:36:16 -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 v3 5/8] ehci-atmel: Power down during suspend is normal Date: Wed, 27 Sep 2017 10:35:52 +0200 Message-Id: <20170927083555.16580-6-romain.izard.pro@gmail.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170927083555.16580-1-romain.izard.pro@gmail.com> References: <20170927083555.16580-1-romain.izard.pro@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170927_013634_980773_CEB9F091 X-CRM114-Status: GOOD ( 11.29 ) 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 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 Wed Sep 27 08:35:53 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Romain Izard X-Patchwork-Id: 819048 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="I0xSxfj8"; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="dP9VolDM"; 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 3y2B735y7Lz9t3x for ; Wed, 27 Sep 2017 18:38:39 +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=I0xSxfj80EqWEmJOflsVyw2LhU ZxfWsRzq102Go63aD9che6WXr8bprW80fEWfBz4lZP4SMRStGcuixF6W8zZXwW4l/WKaN8wlBeC43 cgSIbLOAV8KvCLzCCRml3VzNcw5z5IzAyPczEMVxDpH1/hDE6HHaUBxt7HbOVp/JO8Bc0XQG5BDkv MYmjP7xOhK4UD9358cVMvI33pmZqyPASC65+KY3Kl4hpySph+lPnzSqxbE20PG+GuJy8cZexihTko I//B1ONIknP2I1PyjGq7XrSppu7jJEs05oLJo+VUPMhqK8cmXL3spCz+fdp5jGnGAkJXvHZ8OUnHs 3I55eaiQ==; 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 1dx7rS-0004nx-7N; Wed, 27 Sep 2017 08:38:30 +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 1dx7pg-0002mB-AB for linux-mtd@lists.infradead.org; Wed, 27 Sep 2017 08:36:50 +0000 Received: by mail-wm0-x244.google.com with SMTP id r136so10793366wmf.3 for ; Wed, 27 Sep 2017 01:36:19 -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=dP9VolDMULRMYAKEEXsxoEy6iO4zQONVJjGo925vK+e2gYELiW6jMXGA8gqbBy6g+b 4kFFpUKOFPmV9Y5HYYL7y6GqHmE0UxYT6ho4R1qPuGErX+03yKIosOizoux1PJnUvw+f 9vG02GMkLwDpr6TWlI88nVmCdklNT0HwPyyc8Ipy6TkS3WBh1QY/sP6K0+h9Rd/AaCeB YllLSDBJOFADzY9N+CMZuSisnb9ggKIZCFXRL/Z1qNs5hYCqEo4lcnt26dRp8K7KO9dc iADZ9Ao81U0qKPpkPCqiaJWRqsULVFz5zo95onBzsOMQMcCaS6Iy1ZCNhtkq9IO3pZFA B39Q== 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=Z879ViiuTjARTaCvyz4Qy10DXg2cg4aWI8TC9J7JjcXaL+sK8+IlurL/jX5cghkE5C RgDWssb/HG8mRVmDJdE0wHI0OtC6cetn+QBS6/0XWJmcmFzT5SDAy/vAjjbpzdK1lWAP Mx7iXkH9JpvLeSvSNTCFk0t8zieADNGhwgR2LpApSfmFE35eMqN8btdtbUAerZyOsPzJ emFMEa5dBHAcTucsA33aYWWtRvf7LchnXxGtaoB9y9+qZuoZWOUhENBMZ5qezoVgsNUM 88lQ/leHsS0IiHL/xuA0ZEWxoawNmWM6wVUrnCvePa6qoQlSqFc0cD0g3YmQmk41vfpH 53nA== X-Gm-Message-State: AHPjjUi0eY/yX5jjPAfl3L7kfxfkQfkvXgwY3QJfaxVs5GkZgIFbbg0R bF8NploK61Ic9ypIvo1bMaY= X-Google-Smtp-Source: AOwi7QB6ORvaLCkSP8eaZfEfR37941IHbSVqmaZraQ+jdyJtvxjw7nSbBVUsSDmRsowiDx2kGd8dig== X-Received: by 10.28.63.134 with SMTP id m128mr895774wma.137.1506501378243; Wed, 27 Sep 2017 01:36:18 -0700 (PDT) Received: from localhost.localdomain (146.187.3.109.rev.sfr.net. [109.3.187.146]) by smtp.gmail.com with ESMTPSA id r6sm9699900wrg.40.2017.09.27.01.36.17 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 27 Sep 2017 01:36:17 -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 v3 6/8] pwm: atmel-tcb: Support backup mode Date: Wed, 27 Sep 2017 10:35:53 +0200 Message-Id: <20170927083555.16580-7-romain.izard.pro@gmail.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170927083555.16580-1-romain.izard.pro@gmail.com> References: <20170927083555.16580-1-romain.izard.pro@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170927_013641_001912_B2EF514D X-CRM114-Status: GOOD ( 16.08 ) 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 Wed Sep 27 08:35:54 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Romain Izard X-Patchwork-Id: 819047 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="cyWBsMim"; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="mwb6mSSg"; 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 3y2B6k6NNmz9t3x for ; Wed, 27 Sep 2017 18:38:22 +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=cyWBsMimtLc1cs/Yh9yjyVVIyo lJHMp8l/McOHj1Efa5F/vXjN4UAhkLNKWYhj4dumuXvpaNxpGV2wwoCFnOyllyElBaRpHtS0N3Mlw dAoIVShD8Tg5A29xSHQzyWl0vFS866g1qak/QIXmsmqSzEJIDHCju/rFv16gmzwYPvzebbDZNgTKe AHyKxktes5x4N8Gz3gTBSiA8PBuNMOYHwf0qoZdxa2kuaBSOrAHrHf1QqKx6UbBY3hXTGeTygo0Ux BIytg1mr2FRaEYbFoiyqUxn42uOF5v3mgH1sG0FgkCDapril/h21OjDtTcdV5dJNyMvABn4oVSx1J x6MRMTxA==; 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 1dx7rA-0004XI-V2; Wed, 27 Sep 2017 08:38:13 +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 1dx7pg-0002mc-A8 for linux-mtd@lists.infradead.org; Wed, 27 Sep 2017 08:36:50 +0000 Received: by mail-wm0-x244.google.com with SMTP id f4so10781649wmh.4 for ; Wed, 27 Sep 2017 01:36:20 -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=mwb6mSSgKFiAKO7X8nbRW4Ox/bVL+xBcVrzHLbT/E4KCvro2+Ad0IqYzdT1ARkEvf1 JPFF5n90wE2p0FZ+MnmPgX2cvqKcNP8Aj6ZX5tc/9BWnPVBaxAAyeUo/PkEQey+Ca+VI 1Md5RJnmbuId3uJQ3569QpBiNvoc8daJHJb+u+ei7gPx2CtEiCDSEes0v2Lvg1Pb+Uo6 8m15y6JieLexqIP2nnyyHUg+V+DUzwEg5Fifp1OQNL+UDWH0ypOTUDp12RK+JijyDCTD +7NZ/Ih1jsC/UIpkZOMTdh/c55lUtUm0ALHxxAtVVPZed2KRYY55S4cYSRgUAHp7C36a bpyQ== 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=pmM7qBGkPBbZu6N0NLq92IgJdJg8B2njbW62QhUVJ/8zd64rjtkpFrPZrhnIHOkpGj +Y8Zc7pGKkNElCm/qUza36JtFLKB5XZj0eI9DIjdIiooPKKmX1skXTY0JWyqq03V9uAD P4K6DJiCRpMw+GiwxIVZGDbxpMdkoFIId1ImL50ckc35wbjspW+gUrIAvh7OcYsS1toC x+DOO79w55rXutEjwmF3auZGHoj53cW3lxnpRs3KMITQArb2QHG6hJWC8QYz7rWn0wik VFYZETzIPKTW2puWKBBMEAtKFW/P99QwSuOdLpTtpa9id9uxfaBmEDYJwkYhJvA6wmc/ +LvQ== X-Gm-Message-State: AHPjjUjWCj1dh/9iTLWqGuYIoNXy5VsSwssWb68ok6XagOjWir9eTqh/ 496VxT5iQduns+qE059cSTk= X-Google-Smtp-Source: AOwi7QBRBgNrQaDn7q8zPqHGoWlSgFrbJmreJ0HILaygFDJQQ0KrUbZgqeY3yB+aHIFmrQqT56jMnA== X-Received: by 10.28.218.209 with SMTP id r200mr785081wmg.97.1506501379493; Wed, 27 Sep 2017 01:36:19 -0700 (PDT) Received: from localhost.localdomain (146.187.3.109.rev.sfr.net. [109.3.187.146]) by smtp.gmail.com with ESMTPSA id r6sm9699900wrg.40.2017.09.27.01.36.18 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 27 Sep 2017 01:36:19 -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 v3 7/8] atmel_flexcom: Support backup mode Date: Wed, 27 Sep 2017 10:35:54 +0200 Message-Id: <20170927083555.16580-8-romain.izard.pro@gmail.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170927083555.16580-1-romain.izard.pro@gmail.com> References: <20170927083555.16580-1-romain.izard.pro@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170927_013641_075011_3CE22639 X-CRM114-Status: GOOD ( 15.16 ) 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 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 Wed Sep 27 08:35:55 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Romain Izard X-Patchwork-Id: 819049 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="GZxTzdn1"; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="Tlz6AXFX"; 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 3y2B7P3LPkz9t3x for ; Wed, 27 Sep 2017 18:38:57 +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=GZxTzdn17AetvcHtyhFCoiP+gQ T4F4hiOnFHGWEF3+6eV12fzB5GIDC6v/+kmrkr+lF8317bYMe85Q11ZfYBZiNil6qKmEIbDIt6qPj etCy4E81hstuzKwxHYuJuikXLEnxbik3JsjLkqUgvdq176Mbs4mXzQPbmuDsA0mKpNJN8xTqSKjC6 sp4qx1lPR7Yqh/wfkVDvXlLoqUQnGvtWV48NuBEQZ6lM4ngR70IhCqreZCsGD+az+88GpcdDIP1Ro k32WfUfvjO3S5/UCaWnZLzue+ufxzGMMVbBiYCSXFmBr3/LU4ZDqpAPmfSApDO7N636NGBBhZWe1Q zglvTptw==; 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 1dx7ri-00055P-Tg; Wed, 27 Sep 2017 08:38:46 +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 1dx7pi-0002nw-H3 for linux-mtd@lists.infradead.org; Wed, 27 Sep 2017 08:36:52 +0000 Received: by mail-wr0-x242.google.com with SMTP id z1so960049wre.1 for ; Wed, 27 Sep 2017 01:36:21 -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=Tlz6AXFXXPMIfqEei+I7ZLa4kEb8LRU1sh26niEIcfwzEkR0oig4yveNiW7THbOc9/ jXK7eEjDISoQPmlg5Hq7o1cCgVpB2w5mMYgCq50NRH4OeIOp+q4YoJ5zpTDMqX1DquBL RWBWsPrWrCppR0QitLvkmvmk3C7MJhmDkTlqLbSrIyw1Ff8oCUwosMvGAaNaqsRkV55y HotMJM7yJMACz2sccGzY9npKDC16YDqe15AjSER2U0nxcOwaI7ZqJOc6Chw6o3qBQylA qfmig/9CelWJb5buRijqP+XzFWm7p/lddxdG1PISWPah8A5bs8BPKTF1EofH7jk1J9CG DgUg== 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=eLyageDrRdu07mw2Yl/iznXCT7YSM6AldpQuQ23ZpNO13rj6DHc1Aa14FCDYKp9D0s 8EyKvoXHIn/NLT8Z2PQd1HEqRewdMSUIn7SwqWPHrX/8xIAk15PWyOfMXxB06UqtwFrw 407Ku1tnfiuNwFcdA1Mqt9Iu8PYrQ1IMqV3dPptxaEiQs/82fiVnBslpNBs295YDJmEr GcU7p8GRh0mJ9Gk3THRSge/dor6ptHSijrJHh/VsXMLFY5BqRTF7LlUfdqFyphxBvaaP LsYXNSIOf1TasVojlauMSQJux1McU9s/PQuZhLcGMl7/SJ+PubEd59AdlyrgROOtEFyM jmAg== X-Gm-Message-State: AHPjjUjG94rN3sG76RE6UjthnT7bHDWI8YBTNXD8Q83wQwneOsK/4cGu Bb2bfKlnI3M0tmSa9tUm468= X-Google-Smtp-Source: AOwi7QCtoqZvxLg5YxbMyt35JhGrsdY+sk7ymi2T0qYjlAwuPZHSNgdCL2CsLOfdOJYe+lkx5Kd8/Q== X-Received: by 10.223.157.11 with SMTP id k11mr721633wre.252.1506501380557; Wed, 27 Sep 2017 01:36:20 -0700 (PDT) Received: from localhost.localdomain (146.187.3.109.rev.sfr.net. [109.3.187.146]) by smtp.gmail.com with ESMTPSA id r6sm9699900wrg.40.2017.09.27.01.36.19 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 27 Sep 2017 01:36:20 -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 v3 8/8] tty/serial: atmel: Prevent a warning on suspend Date: Wed, 27 Sep 2017 10:35:55 +0200 Message-Id: <20170927083555.16580-9-romain.izard.pro@gmail.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170927083555.16580-1-romain.izard.pro@gmail.com> References: <20170927083555.16580-1-romain.izard.pro@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170927_013643_335118_4422645E X-CRM114-Status: GOOD ( 14.87 ) 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 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);