cregit-Linux how code gets into the kernel

Release 4.11 arch/arm/plat-omap/dmtimer.c

/*
 * linux/arch/arm/plat-omap/dmtimer.c
 *
 * OMAP Dual-Mode Timers
 *
 * Copyright (C) 2010 Texas Instruments Incorporated - http://www.ti.com/
 * Tarun Kanti DebBarma <tarun.kanti@ti.com>
 * Thara Gopinath <thara@ti.com>
 *
 * dmtimer adaptation to platform_driver.
 *
 * Copyright (C) 2005 Nokia Corporation
 * OMAP2 support by Juha Yrjola
 * API improvements and OMAP2 clock framework support by Timo Teras
 *
 * Copyright (C) 2009 Texas Instruments
 * Added OMAP4 support - Santosh Shilimkar <santosh.shilimkar@ti.com>
 *
 * This program is free software; you can redistribute it and/or modify it
 * under the terms of the GNU General Public License as published by the
 * Free Software Foundation; either version 2 of the License, or (at your
 * option) any later version.
 *
 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
 * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 *
 * You should have received a copy of the  GNU General Public License along
 * with this program; if not, write  to the Free Software Foundation, Inc.,
 * 675 Mass Ave, Cambridge, MA 02139, USA.
 */

#include <linux/clk.h>
#include <linux/clk-provider.h>
#include <linux/module.h>
#include <linux/io.h>
#include <linux/device.h>
#include <linux/err.h>
#include <linux/pm_runtime.h>
#include <linux/of.h>
#include <linux/of_device.h>
#include <linux/platform_device.h>
#include <linux/platform_data/dmtimer-omap.h>

#include <plat/dmtimer.h>


static u32 omap_reserved_systimers;
static LIST_HEAD(omap_timer_list);
static DEFINE_SPINLOCK(dm_timer_lock);

enum {
	
REQUEST_ANY = 0,
	
REQUEST_BY_ID,
	
REQUEST_BY_CAP,
	
REQUEST_BY_NODE,
};

/**
 * omap_dm_timer_read_reg - read timer registers in posted and non-posted mode
 * @timer:      timer pointer over which read operation to perform
 * @reg:        lowest byte holds the register offset
 *
 * The posted mode bit is encoded in reg. Note that in posted mode write
 * pending bit must be checked. Otherwise a read of a non completed write
 * will produce an error.
 */

static inline u32 omap_dm_timer_read_reg(struct omap_dm_timer *timer, u32 reg) { WARN_ON((reg & 0xff) < _OMAP_TIMER_WAKEUP_EN_OFFSET); return __omap_dm_timer_read(timer, reg, timer->posted); }

Contributors

PersonTokensPropCommitsCommitProp
Tony Lindgren2976.32%360.00%
Timo Teräs513.16%120.00%
Richard Woodruff410.53%120.00%
Total38100.00%5100.00%

/** * omap_dm_timer_write_reg - write timer registers in posted and non-posted mode * @timer: timer pointer over which write operation is to perform * @reg: lowest byte holds the register offset * @value: data to write into the register * * The posted mode bit is encoded in reg. Note that in posted mode the write * pending bit must be checked. Otherwise a write on a register which has a * pending write will be lost. */
static void omap_dm_timer_write_reg(struct omap_dm_timer *timer, u32 reg, u32 value) { WARN_ON((reg & 0xff) < _OMAP_TIMER_WAKEUP_EN_OFFSET); __omap_dm_timer_write(timer, reg, value, timer->posted); }

Contributors

PersonTokensPropCommitsCommitProp
Timo Teräs2151.22%120.00%
Tony Lindgren1639.02%360.00%
Richard Woodruff49.76%120.00%
Total41100.00%5100.00%


static void omap_timer_restore_context(struct omap_dm_timer *timer) { omap_dm_timer_write_reg(timer, OMAP_TIMER_WAKEUP_EN_REG, timer->context.twer); omap_dm_timer_write_reg(timer, OMAP_TIMER_COUNTER_REG, timer->context.tcrr); omap_dm_timer_write_reg(timer, OMAP_TIMER_LOAD_REG, timer->context.tldr); omap_dm_timer_write_reg(timer, OMAP_TIMER_MATCH_REG, timer->context.tmar); omap_dm_timer_write_reg(timer, OMAP_TIMER_IF_CTRL_REG, timer->context.tsicr); writel_relaxed(timer->context.tier, timer->irq_ena); omap_dm_timer_write_reg(timer, OMAP_TIMER_CTRL_REG, timer->context.tclr); }

Contributors

PersonTokensPropCommitsCommitProp
Tarun Kanti DebBarma10199.02%150.00%
Victor Kamensky10.98%150.00%
Total102100.00%2100.00%


static int omap_dm_timer_reset(struct omap_dm_timer *timer) { u32 l, timeout = 100000; if (timer->revision != 1) return -EINVAL; omap_dm_timer_write_reg(timer, OMAP_TIMER_IF_CTRL_REG, 0x06); do { l = __omap_dm_timer_read(timer, OMAP_TIMER_V1_SYS_STAT_OFFSET, 0); } while (!l && timeout--); if (!timeout) { dev_err(&timer->pdev->dev, "Timer failed to reset\n"); return -ETIMEDOUT; } /* Configure timer for smart-idle mode */ l = __omap_dm_timer_read(timer, OMAP_TIMER_OCP_CFG_OFFSET, 0); l |= 0x2 << 0x3; __omap_dm_timer_write(timer, OMAP_TIMER_OCP_CFG_OFFSET, l, 0); timer->posted = 0; return 0; }

Contributors

PersonTokensPropCommitsCommitProp
Jon Hunter7964.23%120.00%
Timo Teräs3427.64%120.00%
Tony Lindgren54.07%120.00%
Juha Yrjölä43.25%120.00%
Tarun Kanti DebBarma10.81%120.00%
Total123100.00%5100.00%


static int omap_dm_timer_of_set_source(struct omap_dm_timer *timer) { int ret; struct clk *parent; /* * FIXME: OMAP1 devices do not use the clock framework for dmtimers so * do not call clk_get() for these devices. */ if (!timer->fclk) return -ENODEV; parent = clk_get(&timer->pdev->dev, NULL); if (IS_ERR(parent)) return -ENODEV; ret = clk_set_parent(timer->fclk, parent); if (ret < 0) pr_err("%s: failed to set parent\n", __func__); clk_put(parent); return ret; }

Contributors

PersonTokensPropCommitsCommitProp
Neil Armstrong88100.00%1100.00%
Total88100.00%1100.00%


static int omap_dm_timer_prepare(struct omap_dm_timer *timer) { int rc; /* * FIXME: OMAP1 devices do not use the clock framework for dmtimers so * do not call clk_get() for these devices. */ if (!(timer->capability & OMAP_TIMER_NEEDS_RESET)) { timer->fclk = clk_get(&timer->pdev->dev, "fck"); if (WARN_ON_ONCE(IS_ERR(timer->fclk))) { dev_err(&timer->pdev->dev, ": No fclk handle.\n"); return -EINVAL; } } omap_dm_timer_enable(timer); if (timer->capability & OMAP_TIMER_NEEDS_RESET) { rc = omap_dm_timer_reset(timer); if (rc) { omap_dm_timer_disable(timer); return rc; } } __omap_dm_timer_enable_posted(timer); omap_dm_timer_disable(timer); rc = omap_dm_timer_of_set_source(timer); if (rc == -ENODEV) return omap_dm_timer_set_source(timer, OMAP_TIMER_SRC_32_KHZ); return rc; }

Contributors

PersonTokensPropCommitsCommitProp
Tarun Kanti DebBarma5840.00%19.09%
Jon Hunter5537.93%545.45%
Neil Armstrong1711.72%19.09%
Timo Teräs96.21%218.18%
Tony Lindgren53.45%19.09%
Russell King10.69%19.09%
Total145100.00%11100.00%


static inline u32 omap_dm_timer_reserved_systimer(int id) { return (omap_reserved_systimers & (1 << (id - 1))) ? 1 : 0; }

Contributors

PersonTokensPropCommitsCommitProp
Jon Hunter29100.00%1100.00%
Total29100.00%1100.00%


int omap_dm_timer_reserve_systimer(int id) { if (omap_dm_timer_reserved_systimer(id)) return -ENODEV; omap_reserved_systimers |= (1 << (id - 1)); return 0; }

Contributors

PersonTokensPropCommitsCommitProp
Jon Hunter34100.00%1100.00%
Total34100.00%1100.00%


static struct omap_dm_timer *_omap_dm_timer_request(int req_type, void *data) { struct omap_dm_timer *timer = NULL, *t; struct device_node *np = NULL; unsigned long flags; u32 cap = 0; int id = 0; switch (req_type) { case REQUEST_BY_ID: id = *(int *)data; break; case REQUEST_BY_CAP: cap = *(u32 *)data; break; case REQUEST_BY_NODE: np = (struct device_node *)data; break; default: /* REQUEST_ANY */ break; } spin_lock_irqsave(&dm_timer_lock, flags); list_for_each_entry(t, &omap_timer_list, node) { if (t->reserved) continue; switch (req_type) { case REQUEST_BY_ID: if (id == t->pdev->id) { timer = t; timer->reserved = 1; goto found; } break; case REQUEST_BY_CAP: if (cap == (t->capability & cap)) { /* * If timer is not NULL, we have already found * one timer but it was not an exact match * because it had more capabilites that what * was required. Therefore, unreserve the last * timer found and see if this one is a better * match. */ if (timer) timer->reserved = 0; timer = t; timer->reserved = 1; /* Exit loop early if we find an exact match */ if (t->capability == cap) goto found; } break; case REQUEST_BY_NODE: if (np == t->pdev->dev.of_node) { timer = t; timer->reserved = 1; goto found; } break; default: /* REQUEST_ANY */ timer = t; timer->reserved = 1; goto found; } } found: spin_unlock_irqrestore(&dm_timer_lock, flags); if (timer && omap_dm_timer_prepare(timer)) { timer->reserved = 0; timer = NULL; } if (!timer) pr_debug("%s: timer request failed!\n", __func__); return timer; }

Contributors

PersonTokensPropCommitsCommitProp
Jon Hunter18060.61%116.67%
Timo Teräs6622.22%233.33%
Tarun Kanti DebBarma4214.14%116.67%
Timo Kokkonen82.69%116.67%
Tony Lindgren10.34%116.67%
Total297100.00%6100.00%


struct omap_dm_timer *omap_dm_timer_request(void) { return _omap_dm_timer_request(REQUEST_ANY, NULL); }

Contributors

PersonTokensPropCommitsCommitProp
Jon Hunter17100.00%1100.00%
Total17100.00%1100.00%

EXPORT_SYMBOL_GPL(omap_dm_timer_request);
struct omap_dm_timer *omap_dm_timer_request_specific(int id) { /* Requesting timer by ID is not supported when device tree is used */ if (of_have_populated_dt()) { pr_warn("%s: Please use omap_dm_timer_request_by_cap/node()\n", __func__); return NULL; } return _omap_dm_timer_request(REQUEST_BY_ID, &id); }

Contributors

PersonTokensPropCommitsCommitProp
Jon Hunter2156.76%228.57%
Timo Teräs1027.03%228.57%
Tony Lindgren410.81%114.29%
Timo Kokkonen12.70%114.29%
Tarun Kanti DebBarma12.70%114.29%
Total37100.00%7100.00%

EXPORT_SYMBOL_GPL(omap_dm_timer_request_specific); /** * omap_dm_timer_request_by_cap - Request a timer by capability * @cap: Bit mask of capabilities to match * * Find a timer based upon capabilities bit mask. Callers of this function * should use the definitions found in the plat/dmtimer.h file under the * comment "timer capabilities used in hwmod database". Returns pointer to * timer handle on success and a NULL pointer on failure. */
struct omap_dm_timer *omap_dm_timer_request_by_cap(u32 cap) { return _omap_dm_timer_request(REQUEST_BY_CAP, &cap); }

Contributors

PersonTokensPropCommitsCommitProp
Jon Hunter19100.00%2100.00%
Total19100.00%2100.00%

EXPORT_SYMBOL_GPL(omap_dm_timer_request_by_cap); /** * omap_dm_timer_request_by_node - Request a timer by device-tree node * @np: Pointer to device-tree timer node * * Request a timer based upon a device node pointer. Returns pointer to * timer handle on success and a NULL pointer on failure. */
struct omap_dm_timer *omap_dm_timer_request_by_node(struct device_node *np) { if (!np) return NULL; return _omap_dm_timer_request(REQUEST_BY_NODE, np); }

Contributors

PersonTokensPropCommitsCommitProp
Jon Hunter28100.00%2100.00%
Total28100.00%2100.00%

EXPORT_SYMBOL_GPL(omap_dm_timer_request_by_node);
int omap_dm_timer_free(struct omap_dm_timer *timer) { if (unlikely(!timer)) return -EINVAL; clk_put(timer->fclk); WARN_ON(!timer->reserved); timer->reserved = 0; return 0; }

Contributors

PersonTokensPropCommitsCommitProp
Timo Teräs2758.70%250.00%
Tarun Kanti DebBarma1941.30%250.00%
Total46100.00%4100.00%

EXPORT_SYMBOL_GPL(omap_dm_timer_free);
void omap_dm_timer_enable(struct omap_dm_timer *timer) { int c; pm_runtime_get_sync(&timer->pdev->dev); if (!(timer->capability & OMAP_TIMER_ALWON)) { if (timer->get_context_loss_count) { c = timer->get_context_loss_count(&timer->pdev->dev); if (c != timer->ctx_loss_count) { omap_timer_restore_context(timer); timer->ctx_loss_count = c; } } else { omap_timer_restore_context(timer); } } }

Contributors

PersonTokensPropCommitsCommitProp
Neil Brown5664.37%114.29%
Timo Teräs1314.94%228.57%
Tarun Kanti DebBarma1112.64%228.57%
Jon Hunter55.75%114.29%
Tony Lindgren22.30%114.29%
Total87100.00%7100.00%

EXPORT_SYMBOL_GPL(omap_dm_timer_enable);
void omap_dm_timer_disable(struct omap_dm_timer *timer) { pm_runtime_put_sync(&timer->pdev->dev); }

Contributors

PersonTokensPropCommitsCommitProp
Timo Teräs1155.00%233.33%
Tarun Kanti DebBarma735.00%233.33%
Tony Lindgren15.00%116.67%
Jon Hunter15.00%116.67%
Total20100.00%6100.00%

EXPORT_SYMBOL_GPL(omap_dm_timer_disable);
int omap_dm_timer_get_irq(struct omap_dm_timer *timer) { if (timer) return timer->irq; return -EINVAL; }

Contributors

PersonTokensPropCommitsCommitProp
Timo Teräs1460.87%133.33%
Tarun Kanti DebBarma834.78%133.33%
Tony Lindgren14.35%133.33%
Total23100.00%3100.00%

EXPORT_SYMBOL_GPL(omap_dm_timer_get_irq); #if defined(CONFIG_ARCH_OMAP1) #include <mach/hardware.h> /** * omap_dm_timer_modify_idlect_mask - Check if any running timers use ARMXOR * @inputmask: current value of idlect mask */
__u32 omap_dm_timer_modify_idlect_mask(__u32 inputmask) { int i = 0; struct omap_dm_timer *timer = NULL; unsigned long flags; /* If ARMXOR cannot be idled this function call is unnecessary */ if (!(inputmask & (1 << 1))) return inputmask; /* If any active timer is using ARMXOR return modified mask */ spin_lock_irqsave(&dm_timer_lock, flags); list_for_each_entry(timer, &omap_timer_list, node) { u32 l; l = omap_dm_timer_read_reg(timer, OMAP_TIMER_CTRL_REG); if (l & OMAP_TIMER_CTRL_ST) { if (((omap_readl(MOD_CONF_CTRL_1) >> (i * 2)) & 0x03) == 0) inputmask &= ~(1 << 1); else inputmask &= ~(1 << 2); } i++; } spin_unlock_irqrestore(&dm_timer_lock, flags); return inputmask; }

Contributors

PersonTokensPropCommitsCommitProp
Tony Lindgren8059.70%133.33%
Tarun Kanti DebBarma4130.60%133.33%
Timo Teräs139.70%133.33%
Total134100.00%3100.00%

EXPORT_SYMBOL_GPL(omap_dm_timer_modify_idlect_mask); #else
struct clk *omap_dm_timer_get_fclk(struct omap_dm_timer *timer) { if (timer && !IS_ERR(timer->fclk)) return timer->fclk; return NULL; }

Contributors

PersonTokensPropCommitsCommitProp
Tony Lindgren928.12%125.00%
Timo Teräs825.00%125.00%
Russell King825.00%125.00%
Tarun Kanti DebBarma721.88%125.00%
Total32100.00%4100.00%

EXPORT_SYMBOL_GPL(omap_dm_timer_get_fclk);
__u32 omap_dm_timer_modify_idlect_mask(__u32 inputmask) { BUG(); return 0; }

Contributors

PersonTokensPropCommitsCommitProp
Timo Teräs642.86%133.33%
Tony Lindgren535.71%133.33%
Dirk Behme321.43%133.33%
Total14100.00%3100.00%

EXPORT_SYMBOL_GPL(omap_dm_timer_modify_idlect_mask); #endif
int omap_dm_timer_trigger(struct omap_dm_timer *timer) { if (unlikely(!timer || pm_runtime_suspended(&timer->pdev->dev))) { pr_err("%s: timer not available or enabled.\n", __func__); return -EINVAL; } omap_dm_timer_write_reg(timer, OMAP_TIMER_TRIGGER_REG, 0); return 0; }

Contributors

PersonTokensPropCommitsCommitProp
Tarun Kanti DebBarma3566.04%250.00%
Tony Lindgren1222.64%125.00%
Timo Teräs611.32%125.00%
Total53100.00%4100.00%

EXPORT_SYMBOL_GPL(omap_dm_timer_trigger);
int omap_dm_timer_start(struct omap_dm_timer *timer) { u32 l; if (unlikely(!timer)) return -EINVAL; omap_dm_timer_enable(timer); l = omap_dm_timer_read_reg(timer, OMAP_TIMER_CTRL_REG); if (!(l & OMAP_TIMER_CTRL_ST)) { l |= OMAP_TIMER_CTRL_ST; omap_dm_timer_write_reg(timer, OMAP_TIMER_CTRL_REG, l); } /* Save the context */ timer->context.tclr = l; return 0; }

Contributors

PersonTokensPropCommitsCommitProp
Tarun Kanti DebBarma3040.00%250.00%
Timo Teräs2432.00%125.00%
Tony Lindgren2128.00%125.00%
Total75100.00%4100.00%

EXPORT_SYMBOL_GPL(omap_dm_timer_start);
int omap_dm_timer_stop(struct omap_dm_timer *timer) { unsigned long rate = 0; if (unlikely(!timer)) return -EINVAL; if (!(timer->capability & OMAP_TIMER_NEEDS_RESET)) rate = clk_get_rate(timer->fclk); __omap_dm_timer_stop(timer, timer->posted, rate); /* * Since the register values are computed and written within * __omap_dm_timer_stop, we need to use read to retrieve the * context. */ timer->context.tclr = omap_dm_timer_read_reg(timer, OMAP_TIMER_CTRL_REG); omap_dm_timer_disable(timer); return 0; }

Contributors

PersonTokensPropCommitsCommitProp
Tarun Kanti DebBarma4049.38%337.50%
Tony Lindgren1923.46%225.00%
Tero Kristo1316.05%112.50%
Jon Hunter67.41%112.50%
Timo Teräs33.70%112.50%
Total81100.00%8100.00%

EXPORT_SYMBOL_GPL(omap_dm_timer_stop);
int omap_dm_timer_set_source(struct omap_dm_timer *timer, int source) { int ret; char *parent_name = NULL; struct clk *parent; struct dmtimer_platform_data *pdata; if (unlikely(!timer)) return -EINVAL; pdata = timer->pdev->dev.platform_data; if (source < 0 || source >= 3) return -EINVAL; /* * FIXME: Used for OMAP1 devices only because they do not currently * use the clock framework to set the parent clock. To be removed * once OMAP1 migrated to using clock framework for dmtimers */ if (pdata && pdata->set_timer_src) return pdata->set_timer_src(timer->pdev, source); if (IS_ERR(timer->fclk)) return -EINVAL; #if defined(CONFIG_COMMON_CLK) /* Check if the clock has configurable parents */ if (clk_hw_get_num_parents(__clk_get_hw(timer->fclk)) < 2) return 0; #endif switch (source) { case OMAP_TIMER_SRC_SYS_CLK: parent_name = "timer_sys_ck"; break; case OMAP_TIMER_SRC_32_KHZ: parent_name = "timer_32k_ck"; break; case OMAP_TIMER_SRC_EXT_CLK: parent_name = "timer_ext_ck"; break; } parent = clk_get(&timer->pdev->dev, parent_name); if (IS_ERR(parent)) { pr_err("%s: %s not found\n", __func__, parent_name); return -EINVAL; } ret = clk_set_parent(timer->fclk, parent); if (ret < 0) pr_err("%s: failed to set %s as parent\n", __func__, parent_name); clk_put(parent); return ret; }

Contributors

PersonTokensPropCommitsCommitProp
Jon Hunter12655.26%428.57%
Tarun Kanti DebBarma3917.11%321.43%
Suman Anna2611.40%17.14%
Timo Teräs156.58%214.29%
Tony Lindgren114.82%17.14%
Russell King62.63%214.29%
Paul Walmsley52.19%17.14%
Total228100.00%14100.00%

EXPORT_SYMBOL_GPL(omap_dm_timer_set_source);
int omap_dm_timer_set_load(struct omap_dm_timer *timer, int autoreload, unsigned int load) { u32 l; if (unlikely(!timer)) return -EINVAL; omap_dm_timer_enable(timer); l = omap_dm_timer_read_reg(timer, OMAP_TIMER_CTRL_REG); if (autoreload) l |= OMAP_TIMER_CTRL_AR; else l &= ~OMAP_TIMER_CTRL_AR; omap_dm_timer_write_reg(timer, OMAP_TIMER_CTRL_REG, l); omap_dm_timer_write_reg(timer, OMAP_TIMER_LOAD_REG, load); omap_dm_timer_write_reg(timer, OMAP_TIMER_TRIGGER_REG, 0); /* Save the context */ timer->context.tclr = l; timer->context.tldr = load; omap_dm_timer_disable(timer); return 0; }

Contributors

PersonTokensPropCommitsCommitProp
Tarun Kanti DebBarma4338.39%250.00%
Tony Lindgren4237.50%125.00%
Timo Teräs2724.11%125.00%
Total112100.00%4100.00%

EXPORT_SYMBOL_GPL(omap_dm_timer_set_load); /* Optimized set_load which removes costly spin wait in timer_start */
int omap_dm_timer_set_load_start(struct omap_dm_timer *timer, int autoreload, unsigned int load) { u32 l; if (unlikely(!timer)) return -EINVAL; omap_dm_timer_enable(timer); l = omap_dm_timer_read_reg(timer, OMAP_TIMER_CTRL_REG); if (autoreload) { l |= OMAP_TIMER_CTRL_AR; omap_dm_timer_write_reg(timer, OMAP_TIMER_LOAD_REG, load); } else { l &= ~OMAP_TIMER_CTRL_AR; } l |= OMAP_TIMER_CTRL_ST; __omap_dm_timer_load_start(timer, l, load, timer->posted); /* Save the context */ timer->context.tclr = l; timer->context.tldr = load; timer->context.tcrr = load; return 0; }

Contributors

PersonTokensPropCommitsCommitProp
Richard Woodruff5445.76%120.00%
Tarun Kanti DebBarma4638.98%240.00%
Paul Walmsley1311.02%120.00%
Tony Lindgren54.24%120.00%
Total118100.00%5100.00%

EXPORT_SYMBOL_GPL(omap_dm_timer_set_load_start);
int omap_dm_timer_set_match(struct omap_dm_timer *timer, int enable, unsigned int match) { u32 l; if (unlikely(!timer)) return -EINVAL; omap_dm_timer_enable(timer); l = omap_dm_timer_read_reg(timer, OMAP_TIMER_CTRL_REG); if (enable) l |= OMAP_TIMER_CTRL_CE; else l &= ~OMAP_TIMER_CTRL_CE; omap_dm_timer_write_reg(timer, OMAP_TIMER_MATCH_REG, match); omap_dm_timer_write_reg(timer, OMAP_TIMER_CTRL_REG, l); /* Save the context */ timer->context.tclr = l; timer->context.tmar = match; omap_dm_timer_disable(timer); return 0; }

Contributors

PersonTokensPropCommitsCommitProp
Tarun Kanti DebBarma4341.75%240.00%
Tony Lindgren3332.04%120.00%
Timo Teräs2322.33%120.00%
Jon Hunter43.88%120.00%
Total103100.00%5100.00%

EXPORT_SYMBOL_GPL(omap_dm_timer_set_match);
int omap_dm_timer_set_pwm(struct omap_dm_timer *timer, int def_on, int toggle, int trigger) { 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_GPOCFG | OMAP_TIMER_CTRL_SCPWM | OMAP_TIMER_CTRL_PT | (0x03 << 10)); if (def_on) l |= OMAP_TIMER_CTRL_SCPWM; if (toggle) l |= OMAP_TIMER_CTRL_PT; l |= trigger << 10; 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; }

Contributors

PersonTokensPropCommitsCommitProp
Timo Teräs5346.90%125.00%
Tarun Kanti DebBarma3530.97%250.00%
Tony Lindgren2522.12%125.00%
Total113100.00%4100.00%

EXPORT_SYMBOL_GPL(omap_dm_timer_set_pwm);
int omap_dm_timer_set_prescaler(struct omap_dm_timer *timer, int prescaler) { 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_PRE | (0x07 << 2)); if (prescaler >= 0x00 && prescaler <= 0x07) { l |= OMAP_TIMER_CTRL_PRE; l |= prescaler << 2; } 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; }

Contributors

PersonTokensPropCommitsCommitProp
Timo Teräs3533.98%125.00%
Tarun Kanti DebBarma3533.98%250.00%
Tony Lindgren3332.04%125.00%
Total103100.00%4100.00%

EXPORT_SYMBOL_GPL(omap_dm_timer_set_prescaler);
int omap_dm_timer_set_int_enable(struct omap_dm_timer *timer, unsigned int value) { if (unlikely(!timer)) return -EINVAL; omap_dm_timer_enable(timer); __omap_dm_timer_int_enable(timer, value); /* Save the context */ timer->context.tier = value; timer->context.twer = value; omap_dm_timer_disable(timer); return 0; }

Contributors

PersonTokensPropCommitsCommitProp
Tarun Kanti DebBarma4368.25%233.33%
Tony Lindgren1117.46%233.33%
Timo Teräs57.94%116.67%
Juha Yrjölä46.35%116.67%
Total63100.00%6100.00%

EXPORT_SYMBOL_GPL(omap_dm_timer_set_int_enable); /** * omap_dm_timer_set_int_disable - disable timer interrupts * @timer: pointer to timer handle * @mask: bit mask of interrupts to be disabled * * Disables the specified timer interrupts for a timer. */
int omap_dm_timer_set_int_disable(struct omap_dm_timer *timer, u32 mask) { u32 l = mask; if (unlikely(!timer)) return -EINVAL; omap_dm_timer_enable(timer); if (timer->revision == 1) l = readl_relaxed(timer->irq_ena) & ~mask; writel_relaxed(l, timer->irq_dis); l = omap_dm_timer_read_reg(timer, OMAP_TIMER_WAKEUP_EN_REG) & ~mask; omap_dm_timer_write_reg(timer, OMAP_TIMER_WAKEUP_EN_REG, l); /* Save the context */ timer->context.tier &= ~mask; timer->context.twer &= ~mask; omap_dm_timer_disable(timer); return 0; }

Contributors

PersonTokensPropCommitsCommitProp
Jon Hunter11098.21%150.00%
Victor Kamensky21.79%150.00%
Total112100.00%2100.00%

EXPORT_SYMBOL_GPL(omap_dm_timer_set_int_disable);
unsigned int omap_dm_timer_read_status(struct omap_dm_timer *timer) { unsigned int l; if (unlikely(!timer || pm_runtime_suspended(&timer->pdev->dev))) { pr_err("%s: timer not available or enabled.\n", __func__); return 0; } l = readl_relaxed(timer->irq_stat); return l; }

Contributors

PersonTokensPropCommitsCommitProp
Tarun Kanti DebBarma3052.63%228.57%
Tony Lindgren1322.81%228.57%
Timo Teräs1322.81%228.57%
Victor Kamensky11.75%114.29%
Total57100.00%7100.00%

EXPORT_SYMBOL_GPL(omap_dm_timer_read_status);
int omap_dm_timer_write_status(struct omap_dm_timer *timer, unsigned int value) { if (unlikely(!timer || pm_runtime_suspended(&timer->pdev->dev))) return -EINVAL; __omap_dm_timer_write_status(timer, value); return 0; }

Contributors

PersonTokensPropCommitsCommitProp
Tarun Kanti DebBarma2656.52%125.00%
Tony Lindgren1736.96%250.00%
Timo Teräs36.52%125.00%
Total46100.00%4100.00%

EXPORT_SYMBOL_GPL(omap_dm_timer_write_status);
unsigned int omap_dm_timer_read_counter(struct omap_dm_timer *timer) { if (unlikely(!timer || pm_runtime_suspended(&timer->pdev->dev))) { pr_err("%s: timer not iavailable or enabled.\n", __func__); return 0; } return __omap_dm_timer_read_counter(timer, timer->posted); }

Contributors

PersonTokensPropCommitsCommitProp
Tarun Kanti DebBarma3058.82%240.00%
Tony Lindgren1733.33%240.00%
Timo Teräs47.84%120.00%
Total51100.00%5100.00%

EXPORT_SYMBOL_GPL(omap_dm_timer_read_counter);
int omap_dm_timer_write_counter(struct omap_dm_timer *timer, unsigned int value) { if (unlikely(!timer || pm_runtime_suspended(&timer->pdev->dev))) { pr_err("%s: timer not available or enabled.\n", __func__); return -EINVAL; } omap_dm_timer_write_reg(timer, OMAP_TIMER_COUNTER_REG, value); /* Save the context */ timer->context.tcrr = value; return 0; }

Contributors

PersonTokensPropCommitsCommitProp
Tarun Kanti DebBarma4466.67%250.00%
Timo Teräs2233.33%250.00%
Total66100.00%4100.00%

EXPORT_SYMBOL_GPL(omap_dm_timer_write_counter);
int omap_dm_timers_active(void) { struct omap_dm_timer *timer; list_for_each_entry(timer, &omap_timer_list, node) { if (!timer->reserved) continue; if (omap_dm_timer_read_reg(timer, OMAP_TIMER_CTRL_REG) & OMAP_TIMER_CTRL_ST) { return 1; } } return 0; }

Contributors

PersonTokensPropCommitsCommitProp
Timo Teräs2346.94%350.00%
Tarun Kanti DebBarma1530.61%233.33%
Tony Lindgren1122.45%116.67%
Total49100.00%6100.00%

EXPORT_SYMBOL_GPL(omap_dm_timers_active); static const struct of_device_id omap_timer_match[]; /** * omap_dm_timer_probe - probe function called for every registered device * @pdev: pointer to current timer platform device * * Called by driver framework at the end of device registration for all * timer devices. */
static int omap_dm_timer_probe(struct platform_device *pdev) { unsigned long flags; struct omap_dm_timer *timer; struct resource *mem, *irq; struct device *dev = &pdev->dev; const struct of_device_id *match; const struct dmtimer_platform_data *pdata; int ret; match = of_match_device(of_match_ptr(omap_timer_match), dev); pdata = match ? match->data : dev->platform_data; if (!pdata && !dev->of_node) { dev_err(dev, "%s: no platform data.\n", __func__); return -ENODEV; } irq = platform_get_resource(pdev, IORESOURCE_IRQ, 0); if (unlikely(!irq)) { dev_err(dev, "%s: no IRQ resource.\n", __func__); return -ENODEV; } mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); if (unlikely(!mem)) { dev_err(dev, "%s: no memory resource.\n", __func__); return -ENODEV; } timer = devm_kzalloc(dev, sizeof(struct omap_dm_timer), GFP_KERNEL); if (!timer) { dev_err(dev, "%s: memory alloc failed!\n", __func__); return -ENOMEM; } timer->fclk = ERR_PTR(-ENODEV); timer->io_base = devm_ioremap_resource(dev, mem); if (IS_ERR(timer->io_base)) return PTR_ERR(timer->io_base); if (dev->of_node) { if (of_find_property(dev->of_node, "ti,timer-alwon", NULL)) timer->capability |= OMAP_TIMER_ALWON; if (of_find_property(dev->of_node, "ti,timer-dsp", NULL)) timer->capability |= OMAP_TIMER_HAS_DSP_IRQ; if (of_find_property(dev->of_node, "ti,timer-pwm", NULL)) timer->capability |= OMAP_TIMER_HAS_PWM; if (of_find_property(dev->of_node, "ti,timer-secure", NULL)) timer->capability |= OMAP_TIMER_SECURE; } else { timer->id = pdev->id; timer->capability = pdata->timer_capability; timer->reserved = omap_dm_timer_reserved_systimer(timer->id); timer->get_context_loss_count = pdata->get_context_loss_count; } if (pdata) timer->errata = pdata->timer_errata; timer->irq = irq->start; timer->pdev = pdev; /* Skip pm_runtime_enable for OMAP1 */ if (!(timer->capability & OMAP_TIMER_NEEDS_RESET)) { pm_runtime_enable(dev); pm_runtime_irq_safe(dev); } if (!timer->reserved) { ret = pm_runtime_get_sync(dev); if (ret < 0) { dev_err(dev, "%s: pm_runtime_get_sync failed!\n", __func__); goto err_get_sync; } __omap_dm_timer_init_regs(timer); pm_runtime_put(dev); } /* add the timer element to the list */ spin_lock_irqsave(&dm_timer_lock, flags); list_add_tail(&timer->node, &omap_timer_list); spin_unlock_irqrestore(&dm_timer_lock, flags); dev_dbg(dev, "Device Probed.\n"); return 0; err_get_sync: pm_runtime_put_noidle(dev); pm_runtime_disable(dev); return ret; }

Contributors

PersonTokensPropCommitsCommitProp
Tarun Kanti DebBarma26451.36%428.57%
Jon Hunter15530.16%535.71%
Suman Anna407.78%17.14%
Tony Lindgren367.00%214.29%
Russell King101.95%17.14%
Thierry Reding91.75%17.14%
Total514100.00%14100.00%

/** * omap_dm_timer_remove - cleanup a registered timer device * @pdev: pointer to current timer platform device * * Called by driver framework whenever a timer device is unregistered. * In addition to freeing platform resources it also deletes the timer * entry from the local list. */
static int omap_dm_timer_remove(struct platform_device *pdev) { struct omap_dm_timer *timer; unsigned long flags; int ret = -EINVAL; spin_lock_irqsave(&dm_timer_lock, flags); list_for_each_entry(timer, &omap_timer_list, node) if (!strcmp(dev_name(&timer->pdev->dev), dev_name(&pdev->dev))) { list_del(&timer->node); ret = 0; break; } spin_unlock_irqrestore(&dm_timer_lock, flags); pm_runtime_disable(&pdev->dev); return ret; }

Contributors

PersonTokensPropCommitsCommitProp
Tarun Kanti DebBarma7777.00%133.33%
Jon Hunter1515.00%133.33%
Suman Anna88.00%133.33%
Total100100.00%3100.00%

static const struct dmtimer_platform_data omap3plus_pdata = { .timer_errata = OMAP_TIMER_ERRATA_I103_I767, }; static const struct of_device_id omap_timer_match[] = { { .compatible = "ti,omap2420-timer", }, { .compatible = "ti,omap3430-timer", .data = &omap3plus_pdata, }, { .compatible = "ti,omap4430-timer", .data = &omap3plus_pdata, }, { .compatible = "ti,omap5430-timer", .data = &omap3plus_pdata, }, { .compatible = "ti,am335x-timer", .data = &omap3plus_pdata, }, { .compatible = "ti,am335x-timer-1ms", .data = &omap3plus_pdata, }, { .compatible = "ti,dm816-timer", .data = &omap3plus_pdata, }, {}, }; MODULE_DEVICE_TABLE(of, omap_timer_match); static struct platform_driver omap_dm_timer_driver = { .probe = omap_dm_timer_probe, .remove = omap_dm_timer_remove, .driver = { .name = "omap_timer", .of_match_table = of_match_ptr(omap_timer_match), }, }; early_platform_init("earlytimer", &omap_dm_timer_driver); module_platform_driver(omap_dm_timer_driver); MODULE_DESCRIPTION("OMAP Dual-Mode Timer Driver"); MODULE_LICENSE("GPL"); MODULE_ALIAS("platform:" DRIVER_NAME); MODULE_AUTHOR("Texas Instruments Inc");

Overall Contributors

PersonTokensPropCommitsCommitProp
Tarun Kanti DebBarma125832.99%812.70%
Jon Hunter105227.59%2133.33%
Timo Teräs50113.14%46.35%
Tony Lindgren47412.43%914.29%
Timo Kokkonen1293.38%23.17%
Neil Armstrong1183.09%23.17%
Suman Anna772.02%34.76%
Richard Woodruff631.65%23.17%
Neil Brown561.47%11.59%
Russell King250.66%23.17%
Paul Walmsley180.47%23.17%
Tero Kristo130.34%11.59%
Thierry Reding90.24%11.59%
Juha Yrjölä80.21%11.59%
Victor Kamensky40.10%11.59%
Axel Lin30.08%11.59%
Dirk Behme30.08%11.59%
Srinivas Kandagatla20.05%11.59%
Total3813100.00%63100.00%
Information contained on this website is for historical information purposes only and does not indicate or represent copyright ownership.
Created with cregit.