Пример #1
0
static ssize_t version_show(struct device *pdev,
			struct device_attribute *attr, char *buf)
{
	char *s = buf;
	s += sprintf(s, "%d\n", nxp_cpu_version());
	if (s != buf)
		*(s-1) = '\n';
	return (s - buf);
}
Пример #2
0
/*
 * Timer clock source
 */
static void timer_clock_select(struct timer_info *info, long frequency)
{
	struct clk *clk = NULL;
	char name[16] = CORECLK_NAME_PCLK;
	ulong rate, tout = 0;
	int tscl = 0, tmux = 5;
	int vers = nxp_cpu_version();

#if !defined(CONFIG_NXP_DFS_BCLK)
	int smux = 0, pscl = 0;
	ulong mout;
	ulong thz, delt = (-1UL);

	/* PCLK */
	info->clk = clk_get(NULL, name);
   	rate = clk_get_rate(info->clk);
   	for (smux = 0; 5 > smux; smux++) {
   		mout = rate/(1<<smux), pscl = mout/frequency;
   		thz  = mout/(pscl?pscl:1);
   		if (!(mout % frequency) && 256 > pscl) {
   			tout = thz, tmux = smux, tscl = pscl;
   			break;
   		}
		if (pscl > 256)
			continue;
		if (abs(frequency-thz) >= delt)
			continue;
		tout = thz, tmux = smux, tscl = pscl;
		delt = abs(frequency-thz);
   	}
#endif

	/* CLKGEN */
	if (vers && tout != frequency) {
		sprintf(name, "%s.%d", DEV_NAME_TIMER, info->channel);
		clk  = clk_get(NULL, name);
		rate = clk_round_rate(clk, frequency);
		if (abs(frequency-tout) >= abs(frequency-rate)) {
			tout = clk_set_rate(clk, rate);
			tmux = 5, tscl = 1;
			info->clk = clk, info->in_tclk = 1;
			clk_enable(info->clk);
		} else {
			clk_put(clk);
			rate = clk_get_rate(info->clk);	/* PCLK */
		}
	}

	info->tmmux = tmux;
	info->prescale = tscl;
	info->tcount = tout/HZ;
	info->rate = tout;

	pr_debug("%s (ch:%d, mux=%d, scl=%d, rate=%ld, %s)\n",
		__func__, info->channel, tmux, tscl, tout, info->in_tclk?"TCLK":"PCLK");
}
Пример #3
0
void global_data_setup(gd_t *gd, ulong text, ulong sp)
{
	struct stack *stk = &stacks;
	ulong text_start, text_end, heap_end;
	ulong pc, bd;

	/* reconfig stack info */
	gd->relocaddr 	  = text;
	gd->start_addr_sp = sp;
	gd->reloc_off 	  = 0;
	gd->irq_sp = (unsigned long)stk->abt;	/* Abort stack */

	_IRQ_STACK_START_IN_ = gd->irq_sp + 8;
#ifdef CONFIG_USE_IRQ
	_IRQ_STACK_START_ = gd->irq_sp - 4;
	_FIQ_STACK_START_ = _IRQ_STACK_START_ - CONFIG_STACKSIZE_IRQ;
#endif

	/* copy bd info  */
	bd = (unsigned int)gd - sizeof(bd_t);
	memcpy((void *)bd, (void *)gd->bd, sizeof(bd_t));

	/* reset gd->bd */
	gd->bd = (bd_t *)bd;

	/* prevent dataabort, when access enva_addr + data (0x04) */
#if (0)
	gd->env_addr = CONFIG_SYS_SDRAM_BASE;
	*(unsigned int*)CONFIG_SYS_SDRAM_BASE = CONFIG_SYS_SDRAM_BASE;
#else
	gd->env_addr = (ulong)default_environment;
#endif
	/* get cpu info */
	text_start = (unsigned int)(gd->relocaddr);
	text_end = (unsigned int)(gd->relocaddr + _bss_end_ofs);
	heap_end = CONFIG_SYS_MALLOC_END;

#if defined(CONFIG_SYS_GENERIC_BOARD)
	/* refer initr_malloc (common/board_r.c) */
	gd->relocaddr = heap_end;
#endif

	asm("mov %0, pc":"=r" (pc));
	asm("mov %0, sp":"=r" (sp));

	printf("Heap = 0x%08lx~0x%08lx\n", heap_end-TOTAL_MALLOC_LEN, heap_end);
	printf("Code = 0x%08lx~0x%08lx\n", text_start, text_end);
	printf("GLD  = 0x%08lx\n", (ulong)gd);
	printf("GLBD = 0x%08lx\n", (ulong)gd->bd);
	printf("SP   = 0x%08lx,0x%08lx(CURR)\n", gd->start_addr_sp, sp);
	printf("PC   = 0x%08lx\n", pc);

	printf("TAGS = 0x%08lx \n", gd->bd->bi_boot_params);
	#ifdef CONFIG_MMU_ENABLE
	ulong page_tlb =  (text_end & 0xffff0000) + 0x10000;
	printf("PAGE = 0x%08lx~0x%08lx\n", page_tlb, page_tlb + 0xc000 );
	#endif
	printf("MACH = [%ld]   \n", gd->bd->bi_arch_number);
	printf("VER  = %u      \n", nxp_cpu_version());
	printf("BOARD= [%s]    \n", CONFIG_SYS_BOARD);
}