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: 7203451 Return-Path: X-Original-To: patchwork-linux-pm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id CB49DBEEC1 for ; Thu, 17 Sep 2015 08:33:34 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id DEF0D207E8 for ; Thu, 17 Sep 2015 08:33:33 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id E9C0E207D7 for ; Thu, 17 Sep 2015 08:33:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754483AbbIQIdM (ORCPT ); Thu, 17 Sep 2015 04:33:12 -0400 Received: from mail-pa0-f47.google.com ([209.85.220.47]:34857 "EHLO mail-pa0-f47.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754471AbbIQIdJ (ORCPT ); Thu, 17 Sep 2015 04:33:09 -0400 Received: by pacfv12 with SMTP id fv12so14628850pac.2 for ; Thu, 17 Sep 2015 01:33:09 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=gvyFgZVjUMJLNPIqa7fT71p1VjCAY2LVvVSyS7LIxEM=; b=EKiVhK3bTECIarG14uVNRhWZ7lcreuiTBpCnUKBkUUOyNCAslDotloXYLUtJBy1jfM 1OGRaYj7aNfXaGXUxdA5v+58cN4d9VG78LAyStedZnugB/0Xp01xn2QpcSDhlY+fny9D 7kfe3QJcQsau+Xa+VWesndzZ68OWK+Hz/DiAWbSxPZX6Q5qX6zDMQArlihv4ycKdMRqd NWOHVKNtwNqoMC7lY6WiLpbEbbgfMXBonqSY6n+I+mqplG8FZ04K8xw7SVUTsbT7WJ70 AN9+SMLqZ/44aTyK8xWQeFYLUbzbIoqEopasl00v7Fm2JaD0d9Dm8O6La69oyLo9B8Yh Kovg== X-Gm-Message-State: ALoCoQlZFcW6DOpxXm0URpfwNw+CTxLvha9Smk5wJ81ZgUAZ44+NUGMPkK4hN4U6+5vsUufuWQl5 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-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, 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 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;