static inline void resettimer(int count) { tcu_writel(CH_TDFR(CLKEVENT_CH),count); tcu_writel(CH_TCNT(CLKEVENT_CH),0); tcu_writel(TCU_TMCR , (1 << CLKEVENT_CH)); tcu_writel(TCU_TFCR , (1 << CLKEVENT_CH)); tcu_writel(TCU_TESR , (1 << CLKEVENT_CH)); }
void __cpuinit jzcpu_timer_setup(void) { int cpu = smp_processor_id(); struct jz_timerevent *evt = &per_cpu(jzclockevent, cpu); evt->cpu = cpu; evt->state = INIT; switch(cpu) { case 0: evt->state = FINI; evt->ch = 5; evt->irq = IRQ_TCU1; evt->count_addr = TCU_IOBASE + CH_TCNT(evt->ch); evt->latch_addr = TCU_IOBASE + CH_TDFR(evt->ch); evt->ctrl_addr = TCU_IOBASE; evt->config_addr = TCU_IOBASE + CH_TCSR(evt->ch); tcu_writel(CH_TDHR(evt->ch), 0xffff); tcu_writel(TCU_TMSR, ((1 << evt->ch) | (1 << (evt->ch + 16)))); break; case 1: evt->ch = 15; evt->irq = IRQ_TCU0; evt->count_addr = APB_OST_IOBASE + OSTCNTL; evt->latch_addr = APB_OST_IOBASE + OSTDR; evt->ctrl_addr = TCU_IOBASE; evt->config_addr = APB_OST_IOBASE + OSTCSR; apbost_writel(OSTCNTH, 0); break; } #ifdef CONFIG_HOTPLUG_CPU jz_set_cpu_affinity(evt->irq,0); #endif jz_clockevent_init(evt,cpu); }
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)); }
/* @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; }