#include <linux/clk.h>
#include <linux/clk-provider.h>
#include <linux/cpu_pm.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/platform_device.h>
#include <linux/platform_data/dmtimer-omap.h>
#include <clocksource/timer-ti-dm.h>
#define OMAP_TIMER_ERRATA_I103_I767 …
#define OMAP_TIMER_NONPOSTED …
#define OMAP_TIMER_POSTED …
#define WPSHIFT …
#define OMAP_TIMER_WAKEUP_EN_REG …
#define OMAP_TIMER_CTRL_REG …
#define OMAP_TIMER_COUNTER_REG …
#define OMAP_TIMER_LOAD_REG …
#define OMAP_TIMER_TRIGGER_REG …
#define OMAP_TIMER_WRITE_PEND_REG …
#define OMAP_TIMER_MATCH_REG …
#define OMAP_TIMER_CAPTURE_REG …
#define OMAP_TIMER_IF_CTRL_REG …
#define OMAP_TIMER_CAPTURE2_REG …
#define OMAP_TIMER_TICK_POS_REG …
#define OMAP_TIMER_TICK_NEG_REG …
#define OMAP_TIMER_TICK_COUNT_REG …
#define OMAP_TIMER_TICK_INT_MASK_SET_REG …
#define OMAP_TIMER_TICK_INT_MASK_COUNT_REG …
struct timer_regs { … };
struct dmtimer { … };
static u32 omap_reserved_systimers;
static LIST_HEAD(omap_timer_list);
static DEFINE_SPINLOCK(dm_timer_lock);
enum { … };
static inline u32 dmtimer_read(struct dmtimer *timer, u32 reg)
{ … }
static inline void dmtimer_write(struct dmtimer *timer, u32 reg, u32 val)
{ … }
static inline void __omap_dm_timer_init_regs(struct dmtimer *timer)
{ … }
static inline void __omap_dm_timer_enable_posted(struct dmtimer *timer)
{ … }
static inline void __omap_dm_timer_stop(struct dmtimer *timer)
{ … }
static inline void __omap_dm_timer_int_enable(struct dmtimer *timer,
unsigned int value)
{ … }
static inline unsigned int
__omap_dm_timer_read_counter(struct dmtimer *timer)
{ … }
static inline void __omap_dm_timer_write_status(struct dmtimer *timer,
unsigned int value)
{ … }
static void omap_timer_restore_context(struct dmtimer *timer)
{ … }
static void omap_timer_save_context(struct dmtimer *timer)
{ … }
static int omap_timer_context_notifier(struct notifier_block *nb,
unsigned long cmd, void *v)
{ … }
static int omap_timer_fclk_notifier(struct notifier_block *nb,
unsigned long event, void *data)
{ … }
static int omap_dm_timer_reset(struct dmtimer *timer)
{ … }
static struct dmtimer *to_dmtimer(struct omap_dm_timer *cookie)
{ … }
static int omap_dm_timer_set_source(struct omap_dm_timer *cookie, int source)
{ … }
static void omap_dm_timer_enable(struct omap_dm_timer *cookie)
{ … }
static void omap_dm_timer_disable(struct omap_dm_timer *cookie)
{ … }
static int omap_dm_timer_prepare(struct dmtimer *timer)
{ … }
static inline u32 omap_dm_timer_reserved_systimer(int id)
{ … }
static struct dmtimer *_omap_dm_timer_request(int req_type, void *data)
{ … }
static struct omap_dm_timer *omap_dm_timer_request(void)
{ … }
static struct omap_dm_timer *omap_dm_timer_request_specific(int id)
{ … }
static struct omap_dm_timer *omap_dm_timer_request_by_node(struct device_node *np)
{ … }
static int omap_dm_timer_free(struct omap_dm_timer *cookie)
{ … }
static int omap_dm_timer_get_irq(struct omap_dm_timer *cookie)
{ … }
#if defined(CONFIG_ARCH_OMAP1)
#include <linux/soc/ti/omap1-io.h>
static struct clk *omap_dm_timer_get_fclk(struct omap_dm_timer *cookie)
{
return NULL;
}
__u32 omap_dm_timer_modify_idlect_mask(__u32 inputmask)
{
int i = 0;
struct dmtimer *timer = NULL;
unsigned long flags;
if (!(inputmask & (1 << 1)))
return inputmask;
spin_lock_irqsave(&dm_timer_lock, flags);
list_for_each_entry(timer, &omap_timer_list, node) {
u32 l;
l = dmtimer_read(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;
}
#else
static struct clk *omap_dm_timer_get_fclk(struct omap_dm_timer *cookie)
{ … }
__u32 omap_dm_timer_modify_idlect_mask(__u32 inputmask)
{ … }
#endif
static int omap_dm_timer_start(struct omap_dm_timer *cookie)
{ … }
static int omap_dm_timer_stop(struct omap_dm_timer *cookie)
{ … }
static int omap_dm_timer_set_load(struct omap_dm_timer *cookie,
unsigned int load)
{ … }
static int omap_dm_timer_set_match(struct omap_dm_timer *cookie, int enable,
unsigned int match)
{ … }
static int omap_dm_timer_set_pwm(struct omap_dm_timer *cookie, int def_on,
int toggle, int trigger, int autoreload)
{ … }
static int omap_dm_timer_get_pwm_status(struct omap_dm_timer *cookie)
{ … }
static int omap_dm_timer_set_prescaler(struct omap_dm_timer *cookie,
int prescaler)
{ … }
static int omap_dm_timer_set_int_enable(struct omap_dm_timer *cookie,
unsigned int value)
{ … }
static int omap_dm_timer_set_int_disable(struct omap_dm_timer *cookie, u32 mask)
{ … }
static unsigned int omap_dm_timer_read_status(struct omap_dm_timer *cookie)
{ … }
static int omap_dm_timer_write_status(struct omap_dm_timer *cookie, unsigned int value)
{ … }
static unsigned int omap_dm_timer_read_counter(struct omap_dm_timer *cookie)
{ … }
static int omap_dm_timer_write_counter(struct omap_dm_timer *cookie, unsigned int value)
{ … }
static int __maybe_unused omap_dm_timer_runtime_suspend(struct device *dev)
{ … }
static int __maybe_unused omap_dm_timer_runtime_resume(struct device *dev)
{ … }
static const struct dev_pm_ops omap_dm_timer_pm_ops = …;
static const struct of_device_id omap_timer_match[];
static int omap_dm_timer_probe(struct platform_device *pdev)
{ … }
static void omap_dm_timer_remove(struct platform_device *pdev)
{ … }
static const struct omap_dm_timer_ops dmtimer_ops = …;
static const struct dmtimer_platform_data omap3plus_pdata = …;
static const struct dmtimer_platform_data am6_pdata = …;
static const struct of_device_id omap_timer_match[] = …;
MODULE_DEVICE_TABLE(of, omap_timer_match);
static struct platform_driver omap_dm_timer_driver = …;
module_platform_driver(…) …;
MODULE_DESCRIPTION(…) …;
MODULE_AUTHOR(…) …;