void tcu_timer_handler(void) { int ctrlbit = 1 << (tcu_channel); if(tcu_readl(TCU_TFR) & ctrlbit) { /* CLEAR INT */ tcu_writel(TCU_TFCR,ctrlbit); tcu_timer_mod(ms_to_count(TCU_TIMER_MS)); } }
static void reset_timer(int count) { unsigned int tcsr = tcu_readl(CH_TCSR(tcu_channel)); /* set count */ tcu_writel(CH_TDFR(tcu_channel),count); tcu_writel(CH_TDHR(tcu_channel),count/2); tcu_writel(TCU_TMCR , (1 << tcu_channel)); start_timer(); }
static void tcu_dump_reg_hex(void) { TCSM_PCHAR('G'); serial_put_hex(tcu_readl(CH_TCSR(tcu_channel))); serial_put_hex(tcu_readl(CH_TCNT(tcu_channel))); serial_put_hex(tcu_readl(TCU_TER)); serial_put_hex(tcu_readl(TCU_TFR)); serial_put_hex(tcu_readl(TCU_TMR)); serial_put_hex(tcu_readl(TCU_TSR)); serial_put_hex(tcu_readl(TCU_TSTR)); TCSM_PCHAR('H'); }
static void tcu_dump_reg(void) { printk("TCU_TCSR:%08x\n", tcu_readl(CH_TCSR(tcu_channel))); printk("TCU_TCNT:%08x\n", tcu_readl(CH_TCNT(tcu_channel))); printk("TCU_TER:%08x\n", tcu_readl(TCU_TER)); printk("TCU_TFR:%08x\n", tcu_readl(TCU_TFR)); printk("TCU_TMR:%08x\n", tcu_readl(TCU_TMR)); printk("TCU_TSR:%08x\n", tcu_readl(TCU_TSR)); printk("TCU_TSTR:%08x\n", tcu_readl(TCU_TSTR)); }
static irqreturn_t jz_timer_interrupt(int irq, void *dev_id) { struct jz_timerevent *evt_dev = dev_id; int ctrlbit = 1 << (CLKEVENT_CH); if(tcu_readl(TCU_TFR) & ctrlbit) { tcu_writel(TCU_TFCR,ctrlbit); if(evt_dev->curmode == CLOCK_EVT_MODE_ONESHOT) { stoptimer(); } evt_dev->clkevt.event_handler(&evt_dev->clkevt); } return IRQ_HANDLED; }
static irqreturn_t jz_cpu1timer_interrupt(int irq, void *dev_id) { struct clock_event_device *cd = dev_id; // int cpu=smp_processor_id(); if(tcu_readl(TCU_TFR) & (1 << OST_TIMER_BIT)) { tcu_writel(TCU_TFCR, (1 << OST_TIMER_BIT)); if(curmode == CLOCK_EVT_MODE_ONESHOT) { tcu_writel(TCU_TECR, (1 << OST_TIMER_BIT)); tcu_writel(TCU_TMSR, (1 << OST_TIMER_BIT)); } } cd->event_handler(cd); return IRQ_HANDLED; }
/* @fn: mod timer. * @timer_cnt: cnt to be written to register. * */ unsigned int tcu_timer_mod(unsigned long timer_cnt) { int count; int current_count; count = timer_cnt; current_count = tcu_readl(CH_TCNT(tcu_channel)); tcu_writel(CH_TCNT(tcu_channel), 0); tcu_writel(TCU_TSCR , (1 << tcu_channel)); tcu_writel(TCU_TECR,(1 << tcu_channel)); reset_timer(count); #ifdef CONFIG_SLEEP_DEBUG if(time >= TIME_1S) { time = 0; TCSM_PCHAR('.'); } time += TCU_TIMER_MS; #endif return current_count; }
static inline void tcu_save(void) { save_tcsr = tcu_readl(CH_TCSR(tcu_channel)); }
static uint64_t get_timer64(void) { uint32_t low = tcu_readl(TCU_OSTCNTL); uint32_t high = tcu_readl(TCU_OSTCNTHBUF); return ((uint64_t)high << 32) | low; }