static void mt_gpt_init(void) { int i; unsigned long save_flags; boot_time_value = xgpt_boot_up_time(); /*record the time when init GPT*/ gpt_update_lock(save_flags); gpt_devs_init(); for (i = 0; i < NR_GPTS; i++) { __gpt_reset(&gpt_devs[i]); } setup_clkevt(); setup_clksrc(); #if 1 //fix me after bring up // if (CHIP_SW_VER_01 <= mt_get_chip_sw_ver()) { // setup_syscnt_assist(); //} #endif setup_syscnt(); #if 1 //fix me after bring up // if (CHIP_SW_VER_01 <= mt_get_chip_sw_ver()) { // start_syscnt_assist(); //} #endif gpt_update_unlock(save_flags); }
static void mt_gpt_init(void) { int i; unsigned long save_flags; gpt_update_lock(save_flags); gpt_devs_init(); for (i = 0; i < NR_GPTS; i++) { __gpt_reset(&gpt_devs[i]); } setup_clkevt(); setup_clksrc(); if (CHIP_SW_VER_01 <= mt_get_chip_sw_ver()) { setup_syscnt_assist(); } setup_syscnt(); //if(GPT_SYSCNT_ASSIST_EN == gpt_syscount_assist_en) if (CHIP_SW_VER_01 <= mt_get_chip_sw_ver()) { start_syscnt_assist(); } gpt_update_unlock(save_flags); }
int gpt_get_cmp(unsigned int id, unsigned int *ptr) { unsigned long save_flags; struct gpt_device *dev = id_to_dev(id); if (!dev || !ptr) return -EINVAL; gpt_update_lock(save_flags); __gpt_get_cmp(dev, ptr); gpt_update_unlock(save_flags); return 0; }
int free_gpt(unsigned int id) { unsigned long save_flags; struct gpt_device *dev = id_to_dev(id); if (!dev) return -EINVAL; if (!(dev->flags & GPT_IN_USE)) return 0; gpt_update_lock(save_flags); release_gpt_dev_locked(dev); gpt_update_unlock(save_flags); return 0; }
int gpt_get_cnt(unsigned int id, unsigned int *ptr) { unsigned long save_flags; struct gpt_device *dev = id_to_dev(id); if (!dev || !ptr) return -EINVAL; if (!(dev->features & GPT_FEAT_64_BIT)) { __gpt_get_cnt(dev, ptr); } else { gpt_update_lock(save_flags); __gpt_get_cnt(dev, ptr); gpt_update_unlock(save_flags); } return 0; }
int gpt_set_cmp(unsigned int id, unsigned int val) { unsigned long save_flags; struct gpt_device *dev = id_to_dev(id); if (!dev) return -EINVAL; if (dev->mode == GPT_FREE_RUN) return -EINVAL; gpt_update_lock(save_flags); __gpt_set_cmp(dev, val, 0); gpt_update_unlock(save_flags); return 0; }
int stop_gpt(unsigned int id) { unsigned long save_flags; struct gpt_device *dev = id_to_dev(id); if (!dev) return -EINVAL; if (!(dev->flags & GPT_IN_USE)) { printk(KERN_ERR "%s: GPT%d is not in use!\n", __func__, id); return -EBUSY; } gpt_update_lock(save_flags); __gpt_stop(dev); gpt_update_unlock(save_flags); return 0; }
int gpt_is_counting(unsigned int id) { unsigned long save_flags; int is_counting; struct gpt_device *dev = id_to_dev(id); if (!dev) return -EINVAL; if (!(dev->flags & GPT_IN_USE)) { printk(KERN_ERR "%s: GPT%d is not in use!\n", __func__, id); return -EBUSY; } gpt_update_lock(save_flags); is_counting = __gpt_get_status(dev); gpt_update_unlock(save_flags); return is_counting; }
int request_gpt(unsigned int id, unsigned int mode, unsigned int clksrc, unsigned int clkdiv, unsigned int cmp, void (*func)(unsigned long), unsigned int flags) { unsigned long save_flags; struct gpt_device *dev = id_to_dev(id); if (!dev) return -EINVAL; if (dev->flags & GPT_IN_USE) { printk(KERN_ERR "%s: GPT%d is in use!\n", __func__, (id + 1)); return -EBUSY; } gpt_update_lock(save_flags); setup_gpt_dev_locked(dev, mode, clksrc, clkdiv, cmp, func, flags); gpt_update_unlock(save_flags); return 0; }
static void __init mt_gpt_init(struct device_node *node) { int i; u32 freq; unsigned long save_flags; gpt_update_lock(save_flags); /* freq=SYS_CLK_RATE */ if (of_property_read_u32(node, "clock-frequency", &freq)) pr_err("clock-frequency not set in the .dts file"); /* Setup IRQ numbers */ xgpt_timers.tmr_irq = irq_of_parse_and_map(node, 0); /* Setup IO addresses */ xgpt_timers.tmr_regs = of_iomap(node, 0); boot_time_value = xgpt_boot_up_time(); /*record the time when init GPT*/ pr_alert("mt_gpt_init: tmr_regs=0x%lx, tmr_irq=%d, freq=%d\n", (unsigned long)xgpt_timers.tmr_regs, xgpt_timers.tmr_irq, freq); gpt_devs_init(); for (i = 0; i < NR_GPTS; i++) __gpt_reset(&gpt_devs[i]); setup_clksrc(freq); setup_irq(xgpt_timers.tmr_irq, &gpt_irq); setup_clkevt(freq); /* use cpuxgpt as syscnt */ setup_syscnt(); pr_alert("mt_gpt_init: get_cnt_GPT2=%lld\n", mt_gpt_read(NULL)); /* /TODO: remove */ gpt_update_unlock(save_flags); }