From patchwork Fri Dec 1 07:49:38 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "H. Nikolaus Schaller" X-Patchwork-Id: 10086455 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 9AD0B6037E for ; Fri, 1 Dec 2017 07:59:32 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 85CAD2A4EA for ; Fri, 1 Dec 2017 07:59:32 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 79FA72A50A; Fri, 1 Dec 2017 07:59:32 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_MED autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id EEB622A4EA for ; Fri, 1 Dec 2017 07:59:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=EBBBzpTkMWOFrDS0d6J2MK3IvTz6R78gHUbKP56EJlc=; b=DT6/kcePDqJreROPbbCKh0NDMU JbuhqRVrKqxCEDa6mbFuq66KzVRtd+v+4cBlUmm7LdzGIN1jkhas9nzC0hP0gFOM4GCrv3PuK5eU7 Nke1oYsx6vnLQmggZ9hApCM8i0HQhZFKiqsYnrD9/4Dyic1VdWVWM4S2l14dIf4YVELBTZ/JN7x5v CaURtnMAWS6mTd7Tu35tvOiUfZLOdiGSoP3tgxxf+gMoQwx0t0XkQssPrZFgeVTcYdxR/6U1/8lGL FJwI1k6/noJ6moF5/RfWDuOtReRtd2WQf3UljGgKdLL34yvdnCQ/tR13beNm5pjVz3JZforSqI21I gVk+cg+w==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1eKgEI-0003Zx-F7; Fri, 01 Dec 2017 07:59:26 +0000 Received: from mo6-p00-ob.smtp.rzone.de ([2a01:238:20a:202:5300::11]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1eKg5D-0006K5-A7 for linux-arm-kernel@lists.infradead.org; Fri, 01 Dec 2017 07:50:13 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; t=1512114581; s=domk; d=goldelico.com; h=References:In-Reply-To:References:In-Reply-To:Message-Id:Date: Subject:Cc:To:From:X-RZG-CLASS-ID:X-RZG-AUTH:Accept-Language: Auto-Submitted:Cc:Date:From:Message-ID:References:Reply-To:Resent-Cc: Resent-Date:Resent-From:Resent-To:Sender:Subject:To: Content-Alternative:Content-Description:Content-Disposition: Content-Duration:Content-Features:Content-ID:Content-Language: Content-Location:Content-MD5:Content-Transfer-Encoding:Content-Type: MIME-Version; bh=kaPk+E+ViEWEYI3tXcytpZMQ/gKZmFeBiEf0N2Et8vU=; b=Hziz8L7DqdURoJrTpkHAtE/qMupoIYKrdo/nrgcu9RvAbQVnQpTue8HB3dLtLEIO6x 3ZjFPRqT9DAoLH3nc9DuhcyPhjMELGDR0Cqd97s5VaCuYG8z9Jx42QO8Zk6/q8S7sZsc 4adObN4jQxoxhcpPooCSDHh1c1sOhO1WvwTCk= X-RZG-AUTH: :JGIXVUS7cutRB/49FwqZ7WcJeFKiMgPgp8VKxflSZ1P34KBj4Qpw87WiuNN2FDaY X-RZG-CLASS-ID: mo00 Received: from localhost.localdomain (p57AE00F8.dip0.t-ipconnect.de [87.174.0.248]) by smtp.strato.de (RZmta 42.10 DYNA|AUTH) with ESMTPSA id V027catB17nfHRz (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (curve secp521r1 with 521 ECDH bits, eq. 15360 bits RSA)) (Client did not present a certificate); Fri, 1 Dec 2017 08:49:41 +0100 (CET) From: "H. Nikolaus Schaller" To: Rob Herring , Mark Rutland , =?UTF-8?q?Beno=C3=AEt=20Cousson?= , Tony Lindgren , Russell King , Arnd Bergmann , Greg Kroah-Hartman , "H. Nikolaus Schaller" , Kevin Hilman , =?UTF-8?q?Andreas=20F=C3=A4rber?= , Thierry Reding , Jonathan Cameron Subject: [PATCH v5 5/5] misc serdev: w2sg0004: add debugging code and Kconfig Date: Fri, 1 Dec 2017 08:49:38 +0100 Message-Id: <5816bfb9e7cab68591c133e20696d6188ebe70de.1512114577.git.hns@goldelico.com> X-Mailer: git-send-email 2.12.2 In-Reply-To: References: In-Reply-To: References: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20171130_235004_019372_0B34FF4A X-CRM114-Status: GOOD ( 13.63 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: devicetree@vger.kernel.org, linux-omap@vger.kernel.org, linux-kernel@vger.kernel.org, kernel@pyra-handheld.com, letux-kernel@openphoenux.org, linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP This allows to set CONFIG_W2SG0004_DEBUG which will make the driver report more activities and it will turn on the GPS module during boot while the driver assumes that it is off. This can be used to debug the correct functioning of the hardware. Therefore we add it as an option to the driver because we think it is of general use (and a little tricky to add by system testers). Normally it should be off. Signed-off-by: H. Nikolaus Schaller --- drivers/misc/Kconfig | 8 ++++++++ drivers/misc/w2sg0004.c | 37 +++++++++++++++++++++++++++++++++++++ 2 files changed, 45 insertions(+) diff --git a/drivers/misc/Kconfig b/drivers/misc/Kconfig index a3b11016ed2b..ad6e60f0cc8c 100644 --- a/drivers/misc/Kconfig +++ b/drivers/misc/Kconfig @@ -518,4 +518,12 @@ config W2SG0004 is opened/closed. It also provides a rfkill gps name to control the LNA power. +config W2SG0004_DEBUG + bool "W2SG0004 on/off debugging" + depends on W2SG0004 + help + Enable driver debugging mode of W2SG0004 GPS. If you say y here + this will turn on the module and you can check if it is turned + off by the driver. + endmenu diff --git a/drivers/misc/w2sg0004.c b/drivers/misc/w2sg0004.c index 6bfd12eb8e02..82c708fce510 100644 --- a/drivers/misc/w2sg0004.c +++ b/drivers/misc/w2sg0004.c @@ -26,6 +26,10 @@ * */ +#ifdef CONFIG_W2SG0004_DEBUG +#define DEBUG 1 +#endif + #include #include #include @@ -256,6 +260,7 @@ static int w2sg_tty_install(struct tty_driver *driver, struct tty_struct *tty) pr_debug("%s() tty = %p\n", __func__, tty); data = w2sg_get_by_minor(tty->index); + pr_debug("%s() data = %p\n", __func__, data); if (!data) return -ENODEV; @@ -342,6 +347,8 @@ static int w2sg_probe(struct serdev_device *serdev) if (data == NULL) return -ENOMEM; + pr_debug("w2sg serdev_device_set_drvdata\n"); + serdev_device_set_drvdata(serdev, data); data->on_off_gpio = of_get_named_gpio_flags(serdev->dev.of_node, @@ -375,6 +382,8 @@ static int w2sg_probe(struct serdev_device *serdev) INIT_DELAYED_WORK(&data->work, toggle_work); + pr_debug("w2sg devm_gpio_request\n"); + err = devm_gpio_request(&serdev->dev, data->on_off_gpio, "w2sg0004-on-off"); if (err < 0) @@ -388,6 +397,8 @@ static int w2sg_probe(struct serdev_device *serdev) serdev_device_set_baudrate(data->uart, 9600); serdev_device_set_flow_control(data->uart, false); + pr_debug("w2sg rfkill_alloc\n"); + rf_kill = rfkill_alloc("GPS", &serdev->dev, RFKILL_TYPE_GPS, &w2sg0004_rfkill_ops, data); if (rf_kill == NULL) { @@ -395,6 +406,8 @@ static int w2sg_probe(struct serdev_device *serdev) goto err_rfkill; } + pr_debug("w2sg register rfkill\n"); + err = rfkill_register(rf_kill); if (err) { dev_err(&serdev->dev, "Cannot register rfkill device\n"); @@ -403,6 +416,8 @@ static int w2sg_probe(struct serdev_device *serdev) data->rf_kill = rf_kill; + pr_debug("w2sg alloc_tty_driver\n"); + /* allocate the tty driver */ data->tty_drv = alloc_tty_driver(1); if (!data->tty_drv) @@ -428,6 +443,8 @@ static int w2sg_probe(struct serdev_device *serdev) */ tty_set_operations(data->tty_drv, &w2sg_serial_ops); + pr_debug("w2sg tty_register_driver\n"); + /* register the tty driver */ err = tty_register_driver(data->tty_drv); if (err) { @@ -443,9 +460,27 @@ static int w2sg_probe(struct serdev_device *serdev) tty_port_init(&data->port); data->port.ops = &w2sg_port_ops; + pr_debug("w2sg call tty_port_register_device\n"); + data->dev = tty_port_register_device(&data->port, data->tty_drv, minor, &serdev->dev); + pr_debug("w2sg tty_port_register_device -> %p\n", data->dev); + pr_debug("w2sg port.tty = %p\n", data->port.tty); + + pr_debug("w2sg probed\n"); + +#ifdef CONFIG_W2SG0004_DEBUG + pr_debug("w2sg DEBUGGING MODE enabled\n"); + /* turn on for debugging rx notifications */ + pr_debug("w2sg power gpio ON\n"); + gpio_set_value_cansleep(data->on_off_gpio, 1); + mdelay(100); + pr_debug("w2sg power gpio OFF\n"); + gpio_set_value_cansleep(data->on_off_gpio, 0); + mdelay(300); +#endif + /* keep off until user space requests the device */ w2sg_set_power(data, false); @@ -455,6 +490,8 @@ static int w2sg_probe(struct serdev_device *serdev) rfkill_destroy(rf_kill); serdev_device_close(data->uart); out: + pr_debug("w2sg error %d\n", err); + return err; }