From patchwork Mon Jan 8 15:42:17 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ladislav Michl X-Patchwork-Id: 10149791 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 A3638602CA for ; Mon, 8 Jan 2018 15:47:32 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EB6CC285B9 for ; Mon, 8 Jan 2018 15:47:24 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E01EE286EE; Mon, 8 Jan 2018 15:47:24 +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, UNPARSEABLE_RELAY autolearn=ham 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 CB8D5285B9 for ; Mon, 8 Jan 2018 15:47:23 +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:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=sQ/bVgn0quWrMedb8CtRzYmHWkK2cG07EUFpUCVyt3s=; b=ZyREmiuanjtdwS WsKfQ9K3CexutLNKCHXL8o04A7s+s+HQ2AYFbdt6BrKlUDIDfoLBhggYfgkbOK9y1TRVN3KwtEc6O 1kg1iho+VCpqarlZ5dKvi8tLYJ+PIbu4qWA1c955Pl0OEv9sG5RwZbT4kDY05gp3dwI5J4VE5pee+ caroDqzNlEwVrihNkUk3VcyMJJmxV7biti/RS3UacfeC1R9s5E34XsRGAFzZd1Ti11cUynklvJ40r vVa9GqpTUwNE+6NwkV/5AJufEDicQ8iWuqW+k/RaZjDjiD1xBvwjUK+h7SQ4uJbqvGe3C9rKi7q6I 9OXz0ISf50IlYodk54Bg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.89 #1 (Red Hat Linux)) id 1eYZdu-0000d6-0i; Mon, 08 Jan 2018 15:47:18 +0000 Received: from eddie.linux-mips.org ([148.251.95.138] helo=cvs.linux-mips.org) by bombadil.infradead.org with esmtp (Exim 4.89 #1 (Red Hat Linux)) id 1eYZZo-0001Xf-8I for linux-arm-kernel@lists.infradead.org; Mon, 08 Jan 2018 15:44:42 +0000 Received: (from localhost user: 'ladis' uid#1021 fake: STDIN (ladis@eddie.linux-mips.org)) by eddie.linux-mips.org id S23992391AbeAHPmVK5M5T (ORCPT ); Mon, 8 Jan 2018 16:42:21 +0100 Date: Mon, 8 Jan 2018 16:42:17 +0100 From: Ladislav Michl To: Keerthy , tony@atomide.com, aaro.koskinen@iki.fi, thierry.reding@gmail.com, daniel.lezcano@linaro.org Subject: [PATCH 4/5] clocksource: timer-dm: Add event capture Message-ID: <20180108154217.GD4077@lenoch> References: <20180108153926.GA3916@lenoch> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20180108153926.GA3916@lenoch> User-Agent: Mutt/1.9.2 (2017-12-15) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180108_074304_904615_A80AB876 X-CRM114-Status: GOOD ( 10.60 ) 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: linux-pwm@vger.kernel.org, grygorii.strashko@ti.com, t-kristo@ti.com, robh+dt@kernel.org, sebastian.reichel@collabora.co.uk, linux-omap@vger.kernel.org, linux-arm-kernel@lists.infradead.org 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 Implement event capture functions. Signed-off-by: Ladislav Michl diff --git a/drivers/clocksource/timer-dm.c b/drivers/clocksource/timer-dm.c index bde1014308f9..dbf2b1f6a941 100644 --- a/drivers/clocksource/timer-dm.c +++ b/drivers/clocksource/timer-dm.c @@ -633,6 +633,30 @@ static int omap_dm_timer_set_match(struct omap_dm_timer *timer, int enable, return 0; } +static int omap_dm_timer_set_capture(struct omap_dm_timer *timer, + int captmode, int edges) +{ + u32 l; + + if (unlikely(!timer)) + return -EINVAL; + + omap_dm_timer_enable(timer); + l = omap_dm_timer_read_reg(timer, OMAP_TIMER_CTRL_REG); + l &= ~(OMAP_TIMER_CTRL_CAPTMODE | OMAP_TIMER_CTRL_SCPWM | + OMAP_TIMER_CTRL_PT | OMAP_TIMER_CTRL_TCM_BOTHEDGES); + l |= OMAP_TIMER_CTRL_GPOCFG; + if (captmode) + l |= OMAP_TIMER_CTRL_CAPTMODE; + l |= edges << 8; + omap_dm_timer_write_reg(timer, OMAP_TIMER_CTRL_REG, l); + + /* Save the context */ + timer->context.tclr = l; + omap_dm_timer_disable(timer); + return 0; +} + static int omap_dm_timer_set_pwm(struct omap_dm_timer *timer, int def_on, int toggle, int trigger) { @@ -791,6 +815,22 @@ int omap_dm_timers_active(void) return 0; } +static int omap_dm_timer_read_capture(struct omap_dm_timer *timer, + unsigned int *reg, + unsigned int *reg2) +{ + if (unlikely(!timer || pm_runtime_suspended(&timer->pdev->dev))) { + pr_err("%s: timer not available or enabled.\n", __func__); + return -EINVAL; + } + + *reg = omap_dm_timer_read_reg(timer, OMAP_TIMER_CAPTURE_REG); + if (reg2) + *reg2 = omap_dm_timer_read_reg(timer, OMAP_TIMER_CAPTURE2_REG); + + return 0; +} + static const struct of_device_id omap_timer_match[]; /** @@ -939,11 +979,14 @@ static struct omap_dm_timer_ops dmtimer_ops = { .start = omap_dm_timer_start, .stop = omap_dm_timer_stop, .set_load = omap_dm_timer_set_load, + .set_load_start = omap_dm_timer_set_load_start, .set_match = omap_dm_timer_set_match, + .set_capture = omap_dm_timer_set_capture, .set_pwm = omap_dm_timer_set_pwm, .set_prescaler = omap_dm_timer_set_prescaler, .read_counter = omap_dm_timer_read_counter, .write_counter = omap_dm_timer_write_counter, + .read_capture = omap_dm_timer_read_capture, .read_status = omap_dm_timer_read_status, .write_status = omap_dm_timer_write_status, }; diff --git a/include/linux/platform_data/dmtimer-omap.h b/include/linux/platform_data/dmtimer-omap.h index a3e17945a0e9..ad247d45bc08 100644 --- a/include/linux/platform_data/dmtimer-omap.h +++ b/include/linux/platform_data/dmtimer-omap.h @@ -43,8 +43,12 @@ struct omap_dm_timer_ops { int (*set_load)(struct omap_dm_timer *timer, int autoreload, unsigned int value); + int (*set_load_start)(struct omap_dm_timer *timer, int autoreload, + unsigned int value); int (*set_match)(struct omap_dm_timer *timer, int enable, unsigned int match); + int (*set_capture)(struct omap_dm_timer *timer, int captmode, + int edges); int (*set_pwm)(struct omap_dm_timer *timer, int def_on, int toggle, int trigger); int (*set_prescaler)(struct omap_dm_timer *timer, int prescaler); @@ -52,6 +56,10 @@ struct omap_dm_timer_ops { unsigned int (*read_counter)(struct omap_dm_timer *timer); int (*write_counter)(struct omap_dm_timer *timer, unsigned int value); + + int (*read_capture)(struct omap_dm_timer *timer, unsigned int *reg, + unsigned int *reg2); + unsigned int (*read_status)(struct omap_dm_timer *timer); int (*write_status)(struct omap_dm_timer *timer, unsigned int value);