From patchwork Mon Sep 7 06:52:03 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhaoyang Huang X-Patchwork-Id: 53211 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wi0-f200.google.com (mail-wi0-f200.google.com [209.85.212.200]) by patches.linaro.org (Postfix) with ESMTPS id 15A3722B05 for ; Mon, 7 Sep 2015 06:52:31 +0000 (UTC) Received: by wicgb1 with SMTP id gb1sf21989401wic.3 for ; Sun, 06 Sep 2015 23:52:30 -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=PDVhamLsHgUKSRg76PvFhnwHV/luoXhNGsgHK9izgfQ=; b=egEo7JC7GXqed4suvJ6sRasy5+tQsW8mdlYisOWkbaC2sdmsuIukd0bOvh+ITPOA17 87AgeIhdZ/46jHnXbcJRnkefbDsZ/XOq708Y7fgvJ/UPx1AhV6zoltKVnN4TsGT6gWh0 XGcQzPJVDSbBZzkXS1QKoJbdYSRh60yg6V9+Ix9aTNeEkcqpb8YpJ814pHK1ZZDkLQoT Kp8TQ8fdNMaflDvaJVjFRNig5Hcq1I+rb5IbS6wY97DiXgloQ8UzY8pgjmrnPk8HLGfK yH+pjqXrwmsdZFg2P5VLzgiuCXjThqMKLaScjFO/awycbm6eGKralfye34HXxIFZsFDk nH3A== X-Gm-Message-State: ALoCoQmBgKijZr7g/1Mg2Krtsf4kUdY0d0sxsAZL7lHWUyDjl8eIKyHPUS+cdgSb/P9CFbNX0OKS X-Received: by 10.112.170.67 with SMTP id ak3mr4505944lbc.6.1441608750302; Sun, 06 Sep 2015 23:52:30 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.153.8.133 with SMTP id dk5ls530373lad.75.gmail; Sun, 06 Sep 2015 23:52:30 -0700 (PDT) X-Received: by 10.152.36.101 with SMTP id p5mr335497laj.123.1441608750158; Sun, 06 Sep 2015 23:52:30 -0700 (PDT) Received: from mail-la0-f42.google.com (mail-la0-f42.google.com. [209.85.215.42]) by mx.google.com with ESMTPS id w6si9595581law.165.2015.09.06.23.52.29 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 06 Sep 2015 23:52:29 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.42 as permitted sender) client-ip=209.85.215.42; Received: by lamp12 with SMTP id p12so45108266lam.0 for ; Sun, 06 Sep 2015 23:52:29 -0700 (PDT) X-Received: by 10.152.18.164 with SMTP id x4mr15901956lad.35.1441608749432; Sun, 06 Sep 2015 23:52:29 -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 w3csp191456lbq; Sun, 6 Sep 2015 23:52:28 -0700 (PDT) X-Received: by 10.50.128.165 with SMTP id np5mr25532731igb.72.1441608748205; Sun, 06 Sep 2015 23:52:28 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 17si18472404pdg.139.2015.09.06.23.52.27; Sun, 06 Sep 2015 23:52:28 -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 S1751257AbbIGGw0 (ORCPT + 13 others); Mon, 7 Sep 2015 02:52:26 -0400 Received: from mail-pa0-f48.google.com ([209.85.220.48]:35819 "EHLO mail-pa0-f48.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751240AbbIGGw0 (ORCPT ); Mon, 7 Sep 2015 02:52:26 -0400 Received: by pacfv12 with SMTP id fv12so89961625pac.2 for ; Sun, 06 Sep 2015 23:52:25 -0700 (PDT) X-Received: by 10.68.244.34 with SMTP id xd2mr41890118pbc.50.1441608745609; Sun, 06 Sep 2015 23:52:25 -0700 (PDT) Received: from zyhuangubtpc.spreadtrum.com ([175.111.195.49]) by smtp.gmail.com with ESMTPSA id xs7sm10707870pab.4.2015.09.06.23.52.23 (version=TLSv1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 06 Sep 2015 23:52:25 -0700 (PDT) From: Zhaoyang Huang To: linux-pm@vger.kernel.org Cc: amit.kucheria@linaro.org Subject: [Resend PATCH v3] modify pl011 driver to work as wakeup source Date: Mon, 7 Sep 2015 14:52:03 +0800 Message-Id: <1441608723-2234-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.42 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 fd27e98..26d2902 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;