From patchwork Wed Sep 11 15:32:40 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mika Westerberg X-Patchwork-Id: 2873141 Return-Path: X-Original-To: patchwork-linux-acpi@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 353EFBF43F for ; Wed, 11 Sep 2013 15:35:02 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 095402009C for ; Wed, 11 Sep 2013 15:35:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id F0ABE2020E for ; Wed, 11 Sep 2013 15:34:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755166Ab3IKPc7 (ORCPT ); Wed, 11 Sep 2013 11:32:59 -0400 Received: from mga09.intel.com ([134.134.136.24]:46505 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755093Ab3IKPcx (ORCPT ); Wed, 11 Sep 2013 11:32:53 -0400 Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga102.jf.intel.com with ESMTP; 11 Sep 2013 08:29:51 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.90,885,1371106800"; d="scan'208";a="376662253" Received: from blue.fi.intel.com ([10.237.72.156]) by orsmga001.jf.intel.com with ESMTP; 11 Sep 2013 08:32:47 -0700 Received: by blue.fi.intel.com (Postfix, from userid 1004) id 34250E0099; Wed, 11 Sep 2013 18:32:41 +0300 (EEST) From: Mika Westerberg To: linux-i2c@vger.kernel.org Cc: Wolfram Sang , "Rafael J. Wysocki" , linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org, Lv Zheng , Aaron Lu , linux-arm-kernel@lists.infradead.org, Mark Brown , Dmitry Torokhov , Mauro Carvalho Chehab , Samuel Ortiz , Lee Jones , Arnd Bergmann , Greg Kroah-Hartman , Liam Girdwood , Kyungmin Park , Mika Westerberg Subject: [PATCH v2 9/9] spi: attach/detach SPI device to the ACPI power domain Date: Wed, 11 Sep 2013 18:32:40 +0300 Message-Id: <1378913560-2752-10-git-send-email-mika.westerberg@linux.intel.com> X-Mailer: git-send-email 1.8.4.rc3 In-Reply-To: <1378913560-2752-1-git-send-email-mika.westerberg@linux.intel.com> References: <1378913560-2752-1-git-send-email-mika.westerberg@linux.intel.com> Sender: linux-acpi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org X-Spam-Status: No, score=-7.7 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, 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 If the SPI device is enumerated from ACPI namespace (it has an ACPI handle) it might have ACPI methods that needs to be called in order to transition the device to different power states (such as _PSx). We follow what has been done for platform and I2C buses here and attach the SPI device to the ACPI power domain if the device has an ACPI handle. This makes sure that the device is powered on when its ->probe() is called. For non-ACPI devices this patch is a no-op. Signed-off-by: Mika Westerberg Acked-by: Mark Brown --- drivers/spi/spi.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c index 94ebab9..cac0ca2 100644 --- a/drivers/spi/spi.c +++ b/drivers/spi/spi.c @@ -246,6 +246,9 @@ static int spi_drv_probe(struct device *dev) /* Make sure that the master is powered on */ pm_runtime_get_sync(&spi->master->dev); + if (ACPI_HANDLE(&spi->dev)) + acpi_dev_pm_attach(&spi->dev, true); + /* * Enable runtime PM for the SPI device. The SPI device driver can * participate in runtime PM by calling pm_runtime_put() in its @@ -260,6 +263,9 @@ static int spi_drv_probe(struct device *dev) pm_runtime_disable(&spi->dev); pm_runtime_set_suspended(&spi->dev); pm_runtime_put_noidle(&spi->dev); + + if (ACPI_HANDLE(&spi->dev)) + acpi_dev_pm_detach(&spi->dev, true); } pm_runtime_put(&spi->master->dev); @@ -282,6 +288,9 @@ static int spi_drv_remove(struct device *dev) pm_runtime_set_suspended(&spi->dev); pm_runtime_put_noidle(&spi->dev); + if (ACPI_HANDLE(&spi->dev)) + acpi_dev_pm_detach(&spi->dev, true); + pm_runtime_put(&spi->master->dev); return ret;