From patchwork Wed Sep 16 06:46:59 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhaoyang Huang X-Patchwork-Id: 53711 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-lb0-f199.google.com (mail-lb0-f199.google.com [209.85.217.199]) by patches.linaro.org (Postfix) with ESMTPS id 3402322DB2 for ; Wed, 16 Sep 2015 06:47:16 +0000 (UTC) Received: by lbcao8 with SMTP id ao8sf65532322lbc.1 for ; Tue, 15 Sep 2015 23:47:15 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:sender:precedence:list-id:x-original-sender :x-original-authentication-results:mailing-list:list-post:list-help :list-archive:list-unsubscribe; bh=riLZ+XlSE1/ENghEZXWmfV6ya8ARfq0o+vRrFjsMW3M=; b=MwiyqDIojqggNQUlQYD7P2Hz5jpzE3J1bgioY579Xs+STDEjntUtu6guNOY+HqSGtu xjD3W6bBQjrq8jNsstiq7kgu8MuphJv1DnOYBgGNv+KTnXMAYVoIDnXhKal/v6GqAPlX kYIjxeSWPZmk4onvug1tT3yXJf/XLbPSewNkoNGJalzclay/vyaWFdzE191qHJwWAbz4 Of2aisGAY6KuF1WvFXVYaMrGMzxrcC67y6W8X6P2uiH/S6yNIRCbua7JbfkpebMBrlxP JCfLn55oD/ZF8RxwYkVcPeb8+uEGyldKndmmZ1xcQ6hJ2vEyw4aJAALyRnJuUFAs9nP4 2B0A== X-Gm-Message-State: ALoCoQmj0h6gVMMB/0ZGmcB4f8b1iRLroN+5GjsE7kTEoOYhFRW3hiBYPyNmyzDq64XbgshSr1CC X-Received: by 10.112.63.165 with SMTP id h5mr5181224lbs.18.1442386035142; Tue, 15 Sep 2015 23:47:15 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.203.196 with SMTP id ks4ls819733lac.64.gmail; Tue, 15 Sep 2015 23:47:15 -0700 (PDT) X-Received: by 10.152.19.228 with SMTP id i4mr26432750lae.47.1442386034997; Tue, 15 Sep 2015 23:47:14 -0700 (PDT) Received: from mail-la0-f51.google.com (mail-la0-f51.google.com. [209.85.215.51]) by mx.google.com with ESMTPS id g6si17171116lae.163.2015.09.15.23.47.14 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 15 Sep 2015 23:47:14 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.51 as permitted sender) client-ip=209.85.215.51; Received: by lanb10 with SMTP id b10so121884044lan.3 for ; Tue, 15 Sep 2015 23:47:14 -0700 (PDT) X-Received: by 10.152.28.9 with SMTP id x9mr18213494lag.73.1442386034526; Tue, 15 Sep 2015 23:47:14 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.59.35 with SMTP id w3csp2242965lbq; Tue, 15 Sep 2015 23:47:13 -0700 (PDT) X-Received: by 10.107.8.212 with SMTP id h81mr39651005ioi.89.1442386033531; Tue, 15 Sep 2015 23:47:13 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h16si16322804iod.111.2015.09.15.23.47.12; Tue, 15 Sep 2015 23:47:13 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-pm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752412AbbIPGrK (ORCPT + 12 others); Wed, 16 Sep 2015 02:47:10 -0400 Received: from mail-pa0-f54.google.com ([209.85.220.54]:33224 "EHLO mail-pa0-f54.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752294AbbIPGrI (ORCPT ); Wed, 16 Sep 2015 02:47:08 -0400 Received: by pacex6 with SMTP id ex6so200669238pac.0 for ; Tue, 15 Sep 2015 23:47:07 -0700 (PDT) X-Received: by 10.68.69.98 with SMTP id d2mr55336366pbu.137.1442386027498; Tue, 15 Sep 2015 23:47:07 -0700 (PDT) Received: from zyhuangubtpc.spreadtrum.com ([175.111.195.49]) by smtp.gmail.com with ESMTPSA id ey17sm25835075pac.26.2015.09.15.23.47.05 (version=TLSv1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 15 Sep 2015 23:47:07 -0700 (PDT) From: Zhaoyang Huang To: linux-pm@vger.kernel.org Cc: amit.kucheria@linaro.org, sudeep.holla@arm.com Subject: [PATCH v4 1/2] modify pl011 driver to let it work as wakeup source Date: Wed, 16 Sep 2015 14:46:59 +0800 Message-Id: <1442386021-5113-1-git-send-email-zhaoyang.huang@linaro.org> X-Mailer: git-send-email 1.7.9.5 Sender: linux-pm-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: zhaoyang.huang@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.51 as permitted sender) smtp.mailfrom=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , the commit use the latest dev_pm_set_wake_irq API instead of the enable_irq_wake and IRQF_NO_SUSPEND to configure the ttyAMA device to work as the wakeup source Signed-off-by: Zhaoyang Huang --- drivers/tty/serial/amba-pl011.c | 47 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 46 insertions(+), 1 deletion(-) diff --git a/drivers/tty/serial/amba-pl011.c b/drivers/tty/serial/amba-pl011.c index fd27e98..1923b94 100644 --- a/drivers/tty/serial/amba-pl011.c +++ b/drivers/tty/serial/amba-pl011.c @@ -59,6 +59,11 @@ #include #include #include +#include +#include +#include + +static struct device *uart_dev; #define UART_NR 14 @@ -2353,11 +2358,29 @@ static int pl011_register_port(struct uart_amba_port *uap) return ret; } +struct uart_match { + struct uart_port *port; + struct uart_driver *driver; +}; + +static int match_uart_port(struct device *dev, void *data) +{ + struct uart_match *match = data; + + dev_t devt = MKDEV(match->driver->major, match->driver->minor) + + match->port->line; + + pr_info("the match data of ttyAMA0 is %d %d\n", + (int)devt, (int)dev->devt); + + return dev->devt == devt; /* Actually, only one tty per port */ +} static int pl011_probe(struct amba_device *dev, const struct amba_id *id) { struct uart_amba_port *uap; struct vendor_data *vendor = id->data; int portnr, ret; + struct uart_match match; portnr = pl011_find_free_port(); if (portnr < 0) @@ -2387,13 +2410,35 @@ static int pl011_probe(struct amba_device *dev, const struct amba_id *id) amba_set_drvdata(dev, uap); - return pl011_register_port(uap); + ret = pl011_register_port(uap); + + if (!of_find_property(dev->dev.of_node, "linux,wakeup", NULL)) { + uart_dev = NULL; + return ret; + } + + match.port = &uap->port; + match.driver = &amba_reg; + + uart_dev = device_find_child(&dev->dev, &match, match_uart_port); + + if (uart_dev) { + device_init_wakeup(uart_dev, true); + dev_pm_set_wake_irq(uart_dev, uap->port.irq); + } + + return ret; } static int pl011_remove(struct amba_device *dev) { struct uart_amba_port *uap = amba_get_drvdata(dev); + if (uart_dev) { + dev_pm_clear_wake_irq(uart_dev); + device_init_wakeup(uart_dev, false); + } + uart_remove_one_port(&amba_reg, &uap->port); pl011_unregister_port(uap); return 0;