From patchwork Wed Sep 2 01:58:08 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhaoyang Huang X-Patchwork-Id: 52948 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wi0-f199.google.com (mail-wi0-f199.google.com [209.85.212.199]) by patches.linaro.org (Postfix) with ESMTPS id 7EF4422E23 for ; Wed, 2 Sep 2015 01:58:24 +0000 (UTC) Received: by wicuu12 with SMTP id uu12sf812202wic.2 for ; Tue, 01 Sep 2015 18:58:23 -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=36ELZCPsHVhDJZxt4MvSCzeKWgjUc4IRZe9d2392YNo=; b=f64xsa2rayPLN+YXj5M8KX34oW56I26yvhoMKSkOW7ArYDwEFjAvuNTS7QZEj2tQ/G 5dtb2A49u8FG5D3HPRR0NgsQyy8pUTL9yDtDlzcrX1pt2H6fMb4UjAqGHauH7fVDaBn7 MFCkCKqrtkm1r6eStIK0HiSb8yxhq1/dI3WCGEpFm60qzy+/G5qPHatP3D2+KukUP+1Q NHlxi8qP4pv/G74ZrzjpW9CwyDMom/oH4i8IhcY7RZ7DQNCTOXN+KziS3ZxQJ4WULXUW X5UlRSpXtrHgIsufL3Rr4oFbA2vfddTnmbP0r2KU+HK8l/22+iF4A9SZYD18aFojmp/b VuaA== X-Gm-Message-State: ALoCoQmQvjvnJ25/ZaT0ig1YoF1wu0Luf6yxfDUV5D7cmdojrBgiDFIf98prNlClpdLNPaaqfupa X-Received: by 10.180.100.71 with SMTP id ew7mr319769wib.0.1441159103599; Tue, 01 Sep 2015 18:58:23 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.36.135 with SMTP id q7ls14919laj.77.gmail; Tue, 01 Sep 2015 18:58:23 -0700 (PDT) X-Received: by 10.112.181.162 with SMTP id dx2mr14155860lbc.75.1441159103445; Tue, 01 Sep 2015 18:58:23 -0700 (PDT) Received: from mail-lb0-f177.google.com (mail-lb0-f177.google.com. [209.85.217.177]) by mx.google.com with ESMTPS id h9si18242769lbc.56.2015.09.01.18.58.23 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 01 Sep 2015 18:58:23 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.177 as permitted sender) client-ip=209.85.217.177; Received: by lbbmp1 with SMTP id mp1so9828736lbb.1 for ; Tue, 01 Sep 2015 18:58:23 -0700 (PDT) X-Received: by 10.112.198.202 with SMTP id je10mr2545650lbc.86.1441159103152; Tue, 01 Sep 2015 18:58:23 -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.164.42 with SMTP id yn10csp227966lbb; Tue, 1 Sep 2015 18:58:21 -0700 (PDT) X-Received: by 10.68.193.169 with SMTP id hp9mr52284801pbc.39.1441159101824; Tue, 01 Sep 2015 18:58:21 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id aq3si32787757pbc.190.2015.09.01.18.58.20; Tue, 01 Sep 2015 18:58:21 -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 S1751240AbbIBB6T (ORCPT + 13 others); Tue, 1 Sep 2015 21:58:19 -0400 Received: from mail-pa0-f49.google.com ([209.85.220.49]:35224 "EHLO mail-pa0-f49.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751169AbbIBB6T (ORCPT ); Tue, 1 Sep 2015 21:58:19 -0400 Received: by pacfv12 with SMTP id fv12so14693334pac.2 for ; Tue, 01 Sep 2015 18:58:19 -0700 (PDT) X-Received: by 10.66.164.98 with SMTP id yp2mr50725475pab.58.1441159098940; Tue, 01 Sep 2015 18:58:18 -0700 (PDT) Received: from zyhuangubtpc.spreadtrum.com ([175.111.195.49]) by smtp.gmail.com with ESMTPSA id sl7sm19578050pbc.54.2015.09.01.18.58.17 (version=TLSv1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 01 Sep 2015 18:58:18 -0700 (PDT) From: Zhaoyang Huang To: linux-pm@vger.kernel.org Cc: amit.kucheria@linaro.org Subject: [PATCH v3] modify pl011 driver to work as wakeup source Date: Wed, 2 Sep 2015 09:58:08 +0800 Message-Id: <1441159088-7446-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.217.177 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 | 42 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 41 insertions(+), 1 deletion(-) diff --git a/drivers/tty/serial/amba-pl011.c b/drivers/tty/serial/amba-pl011.c index 50cf5b1..98d2015 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,30 @@ 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); + + 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;