From patchwork Mon Jun 10 14:59:49 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 17733 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-vc0-f197.google.com (mail-vc0-f197.google.com [209.85.220.197]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 0F4A72397B for ; Mon, 10 Jun 2013 15:00:42 +0000 (UTC) Received: by mail-vc0-f197.google.com with SMTP id ha12sf1608263vcb.4 for ; Mon, 10 Jun 2013 08:00:41 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-beenthere:x-forwarded-to:x-forwarded-for:delivered-to:from:to:cc :subject:date:message-id:x-mailer:mime-version:x-gm-message-state :x-original-sender:x-original-authentication-results:precedence :mailing-list:list-id:x-google-group-id:list-post:list-help :list-archive:list-unsubscribe:content-type; bh=9V7Me9AQ4rtZH0+RPiXtWqmTh6+D1pCFI8YGsEa7+oA=; b=kmun5InteLqW8J8+pY11arIBpSy/VTLA6sU061BwkP//oE1+nBJyYSHZ4nZH+qtobH 4PsG92dEqYSDLFGMNITO04VWRRqHHz0Sig9Ct//6315J5HpxY3mQU2SJy/oYgoiQZX3Y nDIokvUWm/P8Co4M7Hh8fmbnA8hMt0ad+RPEPraleDlo/HVUFYomwEe5bffBxvTBPzz6 B9HRGIwwqbvgD5qlxIQPzREL8Iknlye8tGnGVjWP50ewuv3DR9aw+5Mix1uokAiZ/w8o J8i92vZ9GJ6dzQg4ij53NXnN5NSbtsxcK9a+4yOD1W1jPy9Rsu+XlBrUfv2l5MGHF+9T xEPg== X-Received: by 10.58.135.70 with SMTP id pq6mr280482veb.22.1370876441678; Mon, 10 Jun 2013 08:00:41 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.50.197 with SMTP id e5ls2791594qeo.42.gmail; Mon, 10 Jun 2013 08:00:41 -0700 (PDT) X-Received: by 10.52.26.140 with SMTP id l12mr4972623vdg.29.1370876441409; Mon, 10 Jun 2013 08:00:41 -0700 (PDT) Received: from mail-vb0-x232.google.com (mail-vb0-x232.google.com [2607:f8b0:400c:c02::232]) by mx.google.com with ESMTPS id tq4si5034596vdc.131.2013.06.10.08.00.41 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 10 Jun 2013 08:00:41 -0700 (PDT) Received-SPF: neutral (google.com: 2607:f8b0:400c:c02::232 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=2607:f8b0:400c:c02::232; Received: by mail-vb0-f50.google.com with SMTP id w16so4357210vbb.23 for ; Mon, 10 Jun 2013 08:00:41 -0700 (PDT) X-Received: by 10.220.246.8 with SMTP id lw8mr5795304vcb.8.1370876440954; Mon, 10 Jun 2013 08:00:40 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.221.10.206 with SMTP id pb14csp71316vcb; Mon, 10 Jun 2013 08:00:40 -0700 (PDT) X-Received: by 10.14.108.69 with SMTP id p45mr11493800eeg.126.1370876439281; Mon, 10 Jun 2013 08:00:39 -0700 (PDT) Received: from eu1sys200aog112.obsmtp.com (eu1sys200aog112.obsmtp.com [207.126.144.133]) by mx.google.com with SMTP id w8si8468866eep.348.2013.06.10.08.00.10 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Mon, 10 Jun 2013 08:00:39 -0700 (PDT) Received-SPF: neutral (google.com: 207.126.144.133 is neither permitted nor denied by best guess record for domain of linus.walleij@stericsson.com) client-ip=207.126.144.133; Received: from beta.dmz-ap.st.com ([138.198.100.35]) (using TLSv1) by eu1sys200aob112.postini.com ([207.126.147.11]) with SMTP ID DSNKUbXp8mka+9vEa6ZAi+0B4dfWwlfR+9Kc@postini.com; Mon, 10 Jun 2013 15:00:38 UTC Received: from zeta.dmz-ap.st.com (ns6.st.com [138.198.234.13]) by beta.dmz-ap.st.com (STMicroelectronics) with ESMTP id 7DD4E97; Mon, 10 Jun 2013 14:59:57 +0000 (GMT) Received: from relay2.stm.gmessaging.net (unknown [10.230.100.18]) by zeta.dmz-ap.st.com (STMicroelectronics) with ESMTP id D6D95FA9; Mon, 10 Jun 2013 14:59:56 +0000 (GMT) Received: from exdcvycastm004.EQ1STM.local (alteon-source-exch [10.230.100.61]) (using TLSv1 with cipher RC4-MD5 (128/128 bits)) (Client CN "exdcvycastm004", Issuer "exdcvycastm004" (not verified)) by relay2.stm.gmessaging.net (Postfix) with ESMTPS id 153BFA8065; Mon, 10 Jun 2013 16:59:50 +0200 (CEST) Received: from steludxu4075.lud.stericsson.com (10.230.100.153) by smtp.stericsson.com (10.230.100.2) with Microsoft SMTP Server (TLS) id 8.3.279.5; Mon, 10 Jun 2013 16:59:56 +0200 From: Linus Walleij To: Grant Likely , Mark Brown , Cc: Linus Walleij , Hebbar Gururaja , Dmitry Torokhov , Kevin Hilman , Greg Kroah-Hartman , Stephen Warren Subject: [PATCH] spi: pl022: use pinctrl PM helpers Date: Mon, 10 Jun 2013 16:59:49 +0200 Message-ID: <1370876389-24219-1-git-send-email-linus.walleij@stericsson.com> X-Mailer: git-send-email 1.7.11.3 MIME-Version: 1.0 X-Gm-Message-State: ALoCoQkUuyHOU1sT1YF/lTFC41KUIduDDAb7OkQ5dpStB0rg81MUP3Yu/hd15FRPbmpjlRDHKNHS X-Original-Sender: linus.walleij@stericsson.com X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 2607:f8b0:400c:c02::232 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , From: Linus Walleij This utilize the new pinctrl core PM helpers to transition the driver to "sleep" and "idle" states, cutting away some boilerplate code. Cc: Hebbar Gururaja Cc: Mark Brown Cc: Dmitry Torokhov Cc: Kevin Hilman Cc: Greg Kroah-Hartman Cc: Stephen Warren Acked-by: Wolfram Sang Signed-off-by: Linus Walleij --- Mark/Grant: it'd be great if you could ACK this, I'll carry it in the pinctrl tree. --- drivers/spi/spi-pl022.c | 65 ++++++------------------------------------------- 1 file changed, 8 insertions(+), 57 deletions(-) diff --git a/drivers/spi/spi-pl022.c b/drivers/spi/spi-pl022.c index 371cc66f..5b8cd15 100644 --- a/drivers/spi/spi-pl022.c +++ b/drivers/spi/spi-pl022.c @@ -368,11 +368,6 @@ struct pl022 { resource_size_t phybase; void __iomem *virtbase; struct clk *clk; - /* Two optional pin states - default & sleep */ - struct pinctrl *pinctrl; - struct pinctrl_state *pins_default; - struct pinctrl_state *pins_idle; - struct pinctrl_state *pins_sleep; struct spi_master *master; struct pl022_ssp_controller *master_info; /* Message per-transfer pump */ @@ -2133,32 +2128,7 @@ static int pl022_probe(struct amba_device *adev, const struct amba_id *id) pl022->chipselects = devm_kzalloc(dev, num_cs * sizeof(int), GFP_KERNEL); - pl022->pinctrl = devm_pinctrl_get(dev); - if (IS_ERR(pl022->pinctrl)) { - status = PTR_ERR(pl022->pinctrl); - goto err_no_pinctrl; - } - - pl022->pins_default = pinctrl_lookup_state(pl022->pinctrl, - PINCTRL_STATE_DEFAULT); - /* enable pins to be muxed in and configured */ - if (!IS_ERR(pl022->pins_default)) { - status = pinctrl_select_state(pl022->pinctrl, - pl022->pins_default); - if (status) - dev_err(dev, "could not set default pins\n"); - } else - dev_err(dev, "could not get default pinstate\n"); - - pl022->pins_idle = pinctrl_lookup_state(pl022->pinctrl, - PINCTRL_STATE_IDLE); - if (IS_ERR(pl022->pins_idle)) - dev_dbg(dev, "could not get idle pinstate\n"); - - pl022->pins_sleep = pinctrl_lookup_state(pl022->pinctrl, - PINCTRL_STATE_SLEEP); - if (IS_ERR(pl022->pins_sleep)) - dev_dbg(dev, "could not get sleep pinstate\n"); + pinctrl_pm_select_default_state(dev); /* * Bus Number Which has been Assigned to this SSP controller @@ -2308,7 +2278,6 @@ static int pl022_probe(struct amba_device *adev, const struct amba_id *id) amba_release_regions(adev); err_no_ioregion: err_no_gpio: - err_no_pinctrl: spi_master_put(master); return status; } @@ -2353,39 +2322,21 @@ static void pl022_suspend_resources(struct pl022 *pl022, bool runtime) clk_disable(pl022->clk); - pins_state = runtime ? pl022->pins_idle : pl022->pins_sleep; - /* Optionally let pins go into sleep states */ - if (!IS_ERR(pins_state)) { - ret = pinctrl_select_state(pl022->pinctrl, pins_state); - if (ret) - dev_err(&pl022->adev->dev, "could not set %s pins\n", - runtime ? "idle" : "sleep"); - } + if (runtime) + pinctrl_pm_select_idle_state(&pl022->adev->dev); + else + pinctrl_pm_select_sleep_state(&pl022->adev->dev); } static void pl022_resume_resources(struct pl022 *pl022, bool runtime) { int ret; - /* Optionaly enable pins to be muxed in and configured */ /* First go to the default state */ - if (!IS_ERR(pl022->pins_default)) { - ret = pinctrl_select_state(pl022->pinctrl, pl022->pins_default); - if (ret) - dev_err(&pl022->adev->dev, - "could not set default pins\n"); - } - - if (!runtime) { + pinctrl_pm_select_default_state(&pl022->adev->dev); + if (!runtime) /* Then let's idle the pins until the next transfer happens */ - if (!IS_ERR(pl022->pins_idle)) { - ret = pinctrl_select_state(pl022->pinctrl, - pl022->pins_idle); - if (ret) - dev_err(&pl022->adev->dev, - "could not set idle pins\n"); - } - } + pinctrl_pm_select_idle_state(&pl022->adev->dev); clk_enable(pl022->clk); }