From patchwork Wed Dec 3 06:56:19 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heiner Kallweit X-Patchwork-Id: 5427001 Return-Path: X-Original-To: patchwork-linux-spi@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id BD2739F1C5 for ; Wed, 3 Dec 2014 06:56:57 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id CA2D4202B8 for ; Wed, 3 Dec 2014 06:56:56 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id D41E02035C for ; Wed, 3 Dec 2014 06:56:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751088AbaLCG4y (ORCPT ); Wed, 3 Dec 2014 01:56:54 -0500 Received: from mail-wg0-f51.google.com ([74.125.82.51]:47862 "EHLO mail-wg0-f51.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751811AbaLCG4y (ORCPT ); Wed, 3 Dec 2014 01:56:54 -0500 Received: by mail-wg0-f51.google.com with SMTP id k14so18770692wgh.24 for ; Tue, 02 Dec 2014 22:56:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:cc:subject :content-type:content-transfer-encoding; bh=HnoPUnQ9hkTHCtPlFt42qGMXdd3J+HltWvvF0JkLgFk=; b=SaV6MQiW9gHYPeGwE67PJU8XKXrJ0EFJukQyk1VVxgDzXKmePHCyujKRImyHsrD/Pk sB2rK5n61bXqoJBWOQFtkOpAqaABd1SwVsRUwVCe6jaFbL2Xj7FKB3wQTOxEMA26I63v Vvl2yeroi4i1hPIlNaqos8s/NSFouSUlMpldkONwCCAlD6lx3ryIivievsdgNe2kX93W GHOu1gO1Ejh2xjoVO/EOmKaFqnytTggYjwug8bGcEzd0JKIskJ7Z+L7Jbp/QZeZi6Kt7 ANU13+vwKd3ba+Iy3hAsTuCm8sZ2Xc3C9TKQtM1snt+Hf0R6zcVV3zboyH4Sjx6axvSj 856w== X-Received: by 10.180.74.208 with SMTP id w16mr10835791wiv.2.1417589813310; Tue, 02 Dec 2014 22:56:53 -0800 (PST) Received: from ?IPv6:2003:63:2343:500:d97d:be0b:eaa9:cac7? (p2003006323430500D97DBE0BEAA9CAC7.dip0.t-ipconnect.de. [2003:63:2343:500:d97d:be0b:eaa9:cac7]) by mx.google.com with ESMTPSA id 4sm34972944wjs.24.2014.12.02.22.56.52 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 02 Dec 2014 22:56:52 -0800 (PST) Message-ID: <547EB413.8050604@gmail.com> Date: Wed, 03 Dec 2014 07:56:19 +0100 From: Heiner Kallweit User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:31.0) Gecko/20100101 Thunderbird/31.2.0 MIME-Version: 1.0 To: broonie@kernel.org CC: linux-spi@vger.kernel.org Subject: [PATCH 2/2] spi: fsl-espi: add (un)prepare_transfer_hardware calls to save power if SPI is not in use Sender: linux-spi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-spi@vger.kernel.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Use (un)prepare_transfer_hardware calls to set fsl-espi to low-power idle if not in use. Reference manual states: "The eSPI is in a idle state and consumes minimal power. The eSPI BRG is not functioning and the input clock is disabled" Signed-off-by: Heiner Kallweit --- drivers/spi/spi-fsl-espi.c | 46 +++++++++++++++++++++++++++++++++++----------- 1 file changed, 35 insertions(+), 11 deletions(-) diff --git a/drivers/spi/spi-fsl-espi.c b/drivers/spi/spi-fsl-espi.c index e5702c9..d0a73a0 100644 --- a/drivers/spi/spi-fsl-espi.c +++ b/drivers/spi/spi-fsl-espi.c @@ -588,6 +588,38 @@ static void fsl_espi_remove(struct mpc8xxx_spi *mspi) iounmap(mspi->reg_base); } +static int fsl_espi_suspend(struct spi_master *master) +{ + struct mpc8xxx_spi *mpc8xxx_spi; + struct fsl_espi_reg *reg_base; + u32 regval; + + mpc8xxx_spi = spi_master_get_devdata(master); + reg_base = mpc8xxx_spi->reg_base; + + regval = mpc8xxx_spi_read_reg(®_base->mode); + regval &= ~SPMODE_ENABLE; + mpc8xxx_spi_write_reg(®_base->mode, regval); + + return 0; +} + +static int fsl_espi_resume(struct spi_master *master) +{ + struct mpc8xxx_spi *mpc8xxx_spi; + struct fsl_espi_reg *reg_base; + u32 regval; + + mpc8xxx_spi = spi_master_get_devdata(master); + reg_base = mpc8xxx_spi->reg_base; + + regval = mpc8xxx_spi_read_reg(®_base->mode); + regval |= SPMODE_ENABLE; + mpc8xxx_spi_write_reg(®_base->mode, regval); + + return 0; +} + static struct spi_master * fsl_espi_probe(struct device *dev, struct resource *mem, unsigned int irq) { @@ -614,6 +646,8 @@ static struct spi_master * fsl_espi_probe(struct device *dev, master->setup = fsl_espi_setup; master->cleanup = fsl_espi_cleanup; master->transfer_one_message = fsl_espi_do_one_msg; + master->prepare_transfer_hardware = fsl_espi_resume; + master->unprepare_transfer_hardware = fsl_espi_suspend; mpc8xxx_spi = spi_master_get_devdata(master); mpc8xxx_spi->spi_remove = fsl_espi_remove; @@ -761,25 +795,15 @@ static int of_fsl_espi_remove(struct platform_device *dev) static int of_fsl_espi_suspend(struct device *dev) { struct spi_master *master = dev_get_drvdata(dev); - struct mpc8xxx_spi *mpc8xxx_spi; - struct fsl_espi_reg *reg_base; - u32 regval; int ret; - mpc8xxx_spi = spi_master_get_devdata(master); - reg_base = mpc8xxx_spi->reg_base; - ret = spi_master_suspend(master); if (ret) { dev_warn(dev, "cannot suspend master\n"); return ret; } - regval = mpc8xxx_spi_read_reg(®_base->mode); - regval &= ~SPMODE_ENABLE; - mpc8xxx_spi_write_reg(®_base->mode, regval); - - return 0; + return fsl_espi_suspend(master); } static int of_fsl_espi_resume(struct device *dev)