From patchwork Thu Sep 17 08:31:56 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhaoyang Huang X-Patchwork-Id: 53775 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-la0-f70.google.com (mail-la0-f70.google.com [209.85.215.70]) by patches.linaro.org (Postfix) with ESMTPS id AE61522E57 for ; Thu, 17 Sep 2015 08:33:18 +0000 (UTC) Received: by lamp12 with SMTP id p12sf3742627lam.2 for ; Thu, 17 Sep 2015 01:33:17 -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=La2KKPd7UypNfuDxzP/q9pJqDSos8sx4QCkMGbfXPKk=; b=fF7XJx6oB5akYYeW3H8HDxjS7B2LWJWqbZWfCHY64RaNDiPV/gHzO+Hl2ACdqVq+Gl OtxhJyGItRRi1khiH7LhKWmpHalv0H+3e+TTV4I09XW/IwRpIdrP3Zj6bs45WA6Pb3wb 1kxKAsJGG4kKk/f9FL88C7Nwsyt+Dy9a6mtkerG2w1daIbRxpl6xk5EB73vfq5u/molP tsGgAhcn3NhaztyWJPW3vVFR+vURPoRat6edvclBK6cXSTnuXMq4DFSIW9OpiZ4eFppZ 7Towk0s5fE9qPuOJOMeM5AgHlCECtqE125O7w4mi/VFBYgg6p1RHxENUsUwDFWWZ/L61 8V6g== X-Gm-Message-State: ALoCoQlPrQu6dFe2sXdCVEkW33sk5Ba3e9jnWiB7sjG2Orh/H+NSNlaf7sNt7E4EOzL9IMBEEV5c X-Received: by 10.152.163.97 with SMTP id yh1mr1104536lab.10.1442478797582; Thu, 17 Sep 2015 01:33:17 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.29.131 with SMTP id k3ls53025lah.20.gmail; Thu, 17 Sep 2015 01:33:17 -0700 (PDT) X-Received: by 10.112.130.97 with SMTP id od1mr33969269lbb.37.1442478797398; Thu, 17 Sep 2015 01:33:17 -0700 (PDT) Received: from mail-lb0-f172.google.com (mail-lb0-f172.google.com. [209.85.217.172]) by mx.google.com with ESMTPS id j10si1371001lbp.23.2015.09.17.01.33.17 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 17 Sep 2015 01:33:17 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.172 as permitted sender) client-ip=209.85.217.172; Received: by lbbmp1 with SMTP id mp1so5457758lbb.1 for ; Thu, 17 Sep 2015 01:33:17 -0700 (PDT) X-Received: by 10.152.37.162 with SMTP id z2mr29641680laj.117.1442478797283; Thu, 17 Sep 2015 01:33:17 -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 w3csp2925954lbq; Thu, 17 Sep 2015 01:33:16 -0700 (PDT) X-Received: by 10.50.79.166 with SMTP id k6mr23136772igx.24.1442478796263; Thu, 17 Sep 2015 01:33:16 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c13si1544863igo.41.2015.09.17.01.33.15; Thu, 17 Sep 2015 01:33:16 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-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 S1754502AbbIQIdN (ORCPT + 30 others); Thu, 17 Sep 2015 04:33:13 -0400 Received: from mail-pa0-f51.google.com ([209.85.220.51]:33122 "EHLO mail-pa0-f51.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754473AbbIQIdK (ORCPT ); Thu, 17 Sep 2015 04:33:10 -0400 Received: by pacex6 with SMTP id ex6so14576122pac.0 for ; Thu, 17 Sep 2015 01:33:09 -0700 (PDT) X-Received: by 10.66.254.101 with SMTP id ah5mr67564512pad.10.1442478789204; Thu, 17 Sep 2015 01:33:09 -0700 (PDT) Received: from zyhuangubtpc.spreadtrum.com ([175.111.195.49]) by smtp.gmail.com with ESMTPSA id dk2sm2252543pbd.57.2015.09.17.01.33.06 (version=TLSv1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 17 Sep 2015 01:33:08 -0700 (PDT) From: Zhaoyang Huang To: linux-pm@vger.kernel.org, linux@arm.linux.org.uk, gregkh@linuxfoundation.org, jslaby@suse.com, linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org Cc: amit.kucheria@linaro.org, sudeep.holla@arm.com, daniel.lezcano@linaro.org Subject: [PATCH] modify pl011 driver to let it work as wakeup source Date: Thu, 17 Sep 2015 16:31:56 +0800 Message-Id: <1442478716-7377-1-git-send-email-zhaoyang.huang@linaro.org> X-Mailer: git-send-email 1.7.9.5 Sender: linux-kernel-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-kernel@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.217.172 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;