From patchwork Tue Sep 1 09:35:49 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhaoyang Huang X-Patchwork-Id: 52917 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wi0-f197.google.com (mail-wi0-f197.google.com [209.85.212.197]) by patches.linaro.org (Postfix) with ESMTPS id 433832127E for ; Tue, 1 Sep 2015 09:36:23 +0000 (UTC) Received: by wicmn1 with SMTP id mn1sf105334wic.1 for ; Tue, 01 Sep 2015 02:36:22 -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=7XbmEIoP7BHaNtuNndh3hdV1HcOoD0I+uuZK2RgZprA=; b=YBu4kh98xFA33B7eUpvstAzdYc2BxnOndII7JWQFf3iuuB+f0GMhLGC29uKnKdS66X zrpEnJf76pzd3OA9MWCVhckbkAebBd5el3hhV3Tl0/pXe0XkbKTnygld82hDGO6RzrNe nnv2oPFx2Dr9kfN7zcNjJkJVP4S4aNjc7Z96eV8RjPDXAxgtoIpJDWnznhZtJxgq6nxp o8eVIbyl/3coRnTsOmxtxs51RtzDIaLgrfDuiCHvJWLRdb3pmxK4Fe9AfA/faAya9Pz8 Xs3c62fA9zI/sQMa60YBY+mkpIZM5Za0v2SyKqgL6VuQzG5vZLF3qKOvEYSLzfnadED9 KDXw== X-Gm-Message-State: ALoCoQkHSSG0cYG90duVkb1fYIdWLXvItNkgam6v2vfsk5aMQuqcoe/LNP5oXsZfj5ZvnH9khj9o X-Received: by 10.180.12.203 with SMTP id a11mr548130wic.3.1441100182390; Tue, 01 Sep 2015 02:36:22 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.234.103 with SMTP id ud7ls209096lac.89.gmail; Tue, 01 Sep 2015 02:36:22 -0700 (PDT) X-Received: by 10.152.22.133 with SMTP id d5mr12364935laf.112.1441100182108; Tue, 01 Sep 2015 02:36:22 -0700 (PDT) Received: from mail-la0-f54.google.com (mail-la0-f54.google.com. [209.85.215.54]) by mx.google.com with ESMTPS id i12si15922942lbl.12.2015.09.01.02.36.22 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 01 Sep 2015 02:36:22 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.54 as permitted sender) client-ip=209.85.215.54; Received: by laboe4 with SMTP id oe4so62480617lab.0 for ; Tue, 01 Sep 2015 02:36:22 -0700 (PDT) X-Received: by 10.152.21.196 with SMTP id x4mr12110977lae.117.1441100181974; Tue, 01 Sep 2015 02:36:21 -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 yn10csp400817lbb; Tue, 1 Sep 2015 02:36:20 -0700 (PDT) X-Received: by 10.67.22.169 with SMTP id ht9mr45225213pad.35.1441100180599; Tue, 01 Sep 2015 02:36:20 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id vx5si28893520pab.143.2015.09.01.02.36.16; Tue, 01 Sep 2015 02:36:20 -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 S1755214AbbIAJgL (ORCPT + 13 others); Tue, 1 Sep 2015 05:36:11 -0400 Received: from mail-pa0-f45.google.com ([209.85.220.45]:35415 "EHLO mail-pa0-f45.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754318AbbIAJgB (ORCPT ); Tue, 1 Sep 2015 05:36:01 -0400 Received: by pacdd16 with SMTP id dd16so171099645pac.2 for ; Tue, 01 Sep 2015 02:36:01 -0700 (PDT) X-Received: by 10.66.185.231 with SMTP id ff7mr45863284pac.48.1441100161126; Tue, 01 Sep 2015 02:36:01 -0700 (PDT) Received: from zyhuangubtpc.spreadtrum.com ([175.111.195.49]) by smtp.gmail.com with ESMTPSA id dh9sm17429931pdb.67.2015.09.01.02.35.59 (version=TLSv1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 01 Sep 2015 02:36:00 -0700 (PDT) From: Zhaoyang Huang To: linux-pm@vger.kernel.org Cc: amit.kucheria@linaro.org Subject: [PATCH v2] modify the pl011 driver to let it work as wakeup source Date: Tue, 1 Sep 2015 17:35:49 +0800 Message-Id: <1441100149-28071-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.54 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 | 55 ++++++++++++++++++++++++++++++++++++--- 1 file changed, 52 insertions(+), 3 deletions(-) diff --git a/drivers/tty/serial/amba-pl011.c b/drivers/tty/serial/amba-pl011.c index 50cf5b1..33a479a 100644 --- a/drivers/tty/serial/amba-pl011.c +++ b/drivers/tty/serial/amba-pl011.c @@ -59,6 +59,10 @@ #include #include #include +#include +#include +#include "../../base/power/power.h" +#include #define UART_NR 14 @@ -127,6 +131,7 @@ static struct vendor_data vendor_st = { .get_fifosize = get_fifosize_st, }; +static int is_suspended = 0; /* Deals with DMA transactions */ struct pl011_sgbuf { @@ -1376,6 +1381,10 @@ static irqreturn_t pl011_int(int irq, void *dev_id) pl011_dma_rx_irq(uap); else pl011_rx_chars(uap); + + if(is_suspended) + pm_system_wakeup(); + } if (status & (UART011_DSRMIS|UART011_DCDMIS| UART011_CTSMIS|UART011_RIMIS)) @@ -2353,11 +2362,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 device * uart_dev; + struct uart_match match; portnr = pl011_find_free_port(); if (portnr < 0) @@ -2387,7 +2414,17 @@ 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); + + 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) @@ -2403,21 +2440,33 @@ static int pl011_remove(struct amba_device *dev) static int pl011_suspend(struct device *dev) { struct uart_amba_port *uap = dev_get_drvdata(dev); + int ret = 0; if (!uap) return -EINVAL; - return uart_suspend_port(&amba_reg, &uap->port); + ret =uart_suspend_port(&amba_reg, &uap->port); + + if(!ret) + is_suspended = 1; + + return ret; } static int pl011_resume(struct device *dev) { struct uart_amba_port *uap = dev_get_drvdata(dev); + int ret = 0; if (!uap) return -EINVAL; - return uart_resume_port(&amba_reg, &uap->port); + ret = uart_resume_port(&amba_reg, &uap->port); + + if(!ret) + is_suspended = 0; + + return ret; } #endif