Exemplo n.º 1
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;
}
Exemplo n.º 2
0
static cycle_t mt_gpt_read(struct clocksource *cs)
{
    cycle_t cycles;
    unsigned int cnt[2] = {0, 0};
    struct gpt_device *dev = id_to_dev(GPT_CLKSRC_ID);
    __gpt_get_cnt(dev, cnt);

    cycles = ((cycle_t)(cnt[1])) << 32 | (cycle_t)(cnt[0]);

	return cycles;
}
Exemplo n.º 3
0
static void syscnt_assist_resume(void)
{
    unsigned int old_loop;
    unsigned int assist_cnt1, assist_cnt2;
    unsigned int syscnt_cnt[2] = {0};

    struct gpt_device *assist_dev = id_to_dev(GPT_SYSCNT_ASSIST_ID);
    struct gpt_device *syscnt_dev = id_to_dev(GPT_SYSCNT_ID);

    do {
        __gpt_get_cnt(assist_dev, &assist_cnt1);
        __gpt_get_cnt(syscnt_dev, syscnt_cnt);
        __gpt_ack_irq(assist_dev);
        __gpt_get_cnt(assist_dev, &assist_cnt2);
    } while (assist_cnt1 > assist_cnt2);

    old_loop = loop;
    loop = syscnt_cnt[1];

    printk("[%s]assist(0x%08x, 0x%08x),syscnt(0x%08x,0x%08x),loop(%u->%u)\n",
            __func__, assist_cnt1, assist_cnt2, syscnt_cnt[0], syscnt_cnt[1],
            old_loop, loop);
}
Exemplo n.º 4
0
static void syscnt_assist_handler(unsigned long data)
{
    unsigned int assist_cnt;
    unsigned int syscnt_cnt[2] = {0};

    unsigned int cnth;
    unsigned int pct_lo, pct_hi;

    int cnt = 0;

    struct gpt_device *assist_dev = id_to_dev(GPT_SYSCNT_ASSIST_ID);
    struct gpt_device *syscnt_dev = id_to_dev(GPT_SYSCNT_ID);

    __gpt_get_cnt(assist_dev, &assist_cnt);
    __gpt_get_cnt(syscnt_dev, syscnt_cnt);
    
    loop++;

    do {
        cnt++;
        cnth = DRV_Reg32(syscnt_dev->base_addr + GPT_CNTH);
        if ((cnt / CHECK_WARNING_TIMERS) && !(cnt % CHECK_WARNING_TIMERS)) {
            printk("[%s]WARNING: fail to sync GPT_CNTH!! assist(0x%08x),"
                    "syscnt(0x%08x,0x%08x),cnth(0x%08x),loop(0x%08x),cnt(%d)\n", 
                    __func__, assist_cnt, syscnt_cnt[0], syscnt_cnt[1], 
                    cnth, loop, cnt);
        } 
    } while (cnth != loop);

    read_cntpct(pct_lo, pct_hi);
    WARN_ON(pct_hi != loop);

    printk("[%s]syscnt assist IRQ!! assist(0x%08x),syscnt(0x%08x,0x%08x),"  
            "cnth:pct_hi:loop(0x%08x,0x%08x,0x%08x),cnt(%d)\n", __func__,   
            assist_cnt, syscnt_cnt[0], syscnt_cnt[1], cnth, pct_hi, loop, cnt);
}
Exemplo n.º 5
0
static cycle_t mt_gpt_read(struct clocksource *cs)
{
	cycle_t cycles;
	unsigned int cnt[2] = {0, 0};
	struct gpt_device *dev = id_to_dev(GPT_CLKSRC_ID);

	__gpt_get_cnt(dev, cnt);

	if (GPT_CLKSRC_ID != GPT6) {
		/*
		* force do mask for high 32-bit to avoid unpredicted alignment
		*/
		cycles = (GPT_BIT_MASK_L & (cycle_t) (cnt[0]));
	} else {
		cycles = (GPT_BIT_MASK_H & (((cycle_t) (cnt[1])) << 32)) | (GPT_BIT_MASK_L&((cycle_t) (cnt[0])));
	}

	return cycles;
}