xref: /rk3399_rockchip-uboot/board/pb1x00/pb1x00.c (revision f1683aa73c31db0a025e0254e6ce1ee7e56aad3e)
1265817c7SWolfgang Denk /*
2265817c7SWolfgang Denk  * (C) Copyright 2003
3265817c7SWolfgang Denk  * Thomas.Lange@corelatus.se
4265817c7SWolfgang Denk  *
51a459660SWolfgang Denk  * SPDX-License-Identifier:	GPL-2.0+
6265817c7SWolfgang Denk  */
7265817c7SWolfgang Denk 
8265817c7SWolfgang Denk #include <common.h>
9265817c7SWolfgang Denk #include <command.h>
1076ada5f8SDaniel Schwierzeck #include <mach/au1x00.h>
11265817c7SWolfgang Denk #include <asm/mipsregs.h>
125c15010eSJean-Christophe PLAGNIOL-VILLARD #include <asm/io.h>
13265817c7SWolfgang Denk 
14088454cdSSimon Glass DECLARE_GLOBAL_DATA_PTR;
15088454cdSSimon Glass 
dram_init(void)16*f1683aa7SSimon Glass int dram_init(void)
17265817c7SWolfgang Denk {
18265817c7SWolfgang Denk 	/* Sdram is setup by assembler code */
19265817c7SWolfgang Denk 	/* If memory could be changed, we should return the true value here */
20088454cdSSimon Glass 	gd->ram_size = 64 * 1024 * 1024;
21088454cdSSimon Glass 
22088454cdSSimon Glass 	return 0;
23265817c7SWolfgang Denk }
24265817c7SWolfgang Denk 
25265817c7SWolfgang Denk #define BCSR_PCMCIA_PC0DRVEN		0x0010
26265817c7SWolfgang Denk #define BCSR_PCMCIA_PC0RST		0x0080
27265817c7SWolfgang Denk 
281e3827d9SPeter Tyser /* In arch/mips/cpu/cpu.c */
29265817c7SWolfgang Denk void write_one_tlb( int index, u32 pagemask, u32 hi, u32 low0, u32 low1 );
30265817c7SWolfgang Denk 
checkboard(void)31265817c7SWolfgang Denk int checkboard (void)
32265817c7SWolfgang Denk {
336073f61eSJean-Christophe PLAGNIOL-VILLARD #if defined(CONFIG_IDE_PCMCIA) && 0
34265817c7SWolfgang Denk 	u16 status;
356073f61eSJean-Christophe PLAGNIOL-VILLARD #endif
36265817c7SWolfgang Denk 	/* volatile u32 *pcmcia_bcsr = (u32*)(DB1000_BCSR_ADDR+0x10); */
37265817c7SWolfgang Denk 	volatile u32 *sys_counter = (volatile u32*)SYS_COUNTER_CNTRL;
38265817c7SWolfgang Denk 	u32 proc_id;
39265817c7SWolfgang Denk 
40265817c7SWolfgang Denk 	*sys_counter = 0x100; /* Enable 32 kHz oscillator for RTC/TOY */
41265817c7SWolfgang Denk 
42e2ad8426SShinya Kuribayashi 	proc_id = read_c0_prid();
43265817c7SWolfgang Denk 
44265817c7SWolfgang Denk 	switch (proc_id >> 24) {
45265817c7SWolfgang Denk 	case 0:
46265817c7SWolfgang Denk 		puts ("Board: Pb1000\n");
47265817c7SWolfgang Denk 		printf ("CPU: Au1000 396 MHz, id: 0x%02x, rev: 0x%02x\n",
48265817c7SWolfgang Denk 			(proc_id >> 8) & 0xFF, proc_id & 0xFF);
49265817c7SWolfgang Denk 		break;
50265817c7SWolfgang Denk 	case 1:
51265817c7SWolfgang Denk 		puts ("Board: Pb1500\n");
52265817c7SWolfgang Denk 		printf ("CPU: Au1500, id: 0x%02x, rev: 0x%02x\n",
53265817c7SWolfgang Denk 			(proc_id >> 8) & 0xFF, proc_id & 0xFF);
54265817c7SWolfgang Denk 		break;
55265817c7SWolfgang Denk 	case 2:
56265817c7SWolfgang Denk 		puts ("Board: Pb1100\n");
57265817c7SWolfgang Denk 		printf ("CPU: Au1100, id: 0x%02x, rev: 0x%02x\n",
58265817c7SWolfgang Denk 			(proc_id >> 8) & 0xFF, proc_id & 0xFF);
59265817c7SWolfgang Denk 		break;
60265817c7SWolfgang Denk 	default:
61265817c7SWolfgang Denk 		printf ("Unsupported cpu %d, proc_id=0x%x\n", proc_id >> 24, proc_id);
62265817c7SWolfgang Denk 	}
635c15010eSJean-Christophe PLAGNIOL-VILLARD 
645c15010eSJean-Christophe PLAGNIOL-VILLARD 	set_io_port_base(0);
655c15010eSJean-Christophe PLAGNIOL-VILLARD 
66265817c7SWolfgang Denk #if defined(CONFIG_IDE_PCMCIA) && 0
67265817c7SWolfgang Denk 	/* Enable 3.3 V on slot 0 ( VCC )
68265817c7SWolfgang Denk 	   No 5V */
69265817c7SWolfgang Denk 	status = 4;
70265817c7SWolfgang Denk 	*pcmcia_bcsr = status;
71265817c7SWolfgang Denk 
72265817c7SWolfgang Denk 	status |= BCSR_PCMCIA_PC0DRVEN;
73265817c7SWolfgang Denk 	*pcmcia_bcsr = status;
74265817c7SWolfgang Denk 	au_sync();
75265817c7SWolfgang Denk 
76265817c7SWolfgang Denk 	udelay(300*1000);
77265817c7SWolfgang Denk 
78265817c7SWolfgang Denk 	status |= BCSR_PCMCIA_PC0RST;
79265817c7SWolfgang Denk 	*pcmcia_bcsr = status;
80265817c7SWolfgang Denk 	au_sync();
81265817c7SWolfgang Denk 
82265817c7SWolfgang Denk 	udelay(100*1000);
83265817c7SWolfgang Denk 
84265817c7SWolfgang Denk 	/* PCMCIA is on a 36 bit physical address.
85265817c7SWolfgang Denk 	   We need to map it into a 32 bit addresses */
86265817c7SWolfgang Denk 
87265817c7SWolfgang Denk #if 0
88265817c7SWolfgang Denk 	/* We dont need theese unless we run whole pcmcia package */
89265817c7SWolfgang Denk 	write_one_tlb(20,                 /* index */
90265817c7SWolfgang Denk 		      0x01ffe000,         /* Pagemask, 16 MB pages */
916d0f6bcfSJean-Christophe PLAGNIOL-VILLARD 		      CONFIG_SYS_PCMCIA_IO_BASE, /* Hi */
92265817c7SWolfgang Denk 		      0x3C000017,         /* Lo0 */
93265817c7SWolfgang Denk 		      0x3C200017);        /* Lo1 */
94265817c7SWolfgang Denk 
95265817c7SWolfgang Denk 	write_one_tlb(21,                   /* index */
96265817c7SWolfgang Denk 		      0x01ffe000,           /* Pagemask, 16 MB pages */
976d0f6bcfSJean-Christophe PLAGNIOL-VILLARD 		      CONFIG_SYS_PCMCIA_ATTR_BASE, /* Hi */
98265817c7SWolfgang Denk 		      0x3D000017,           /* Lo0 */
99265817c7SWolfgang Denk 		      0x3D200017);          /* Lo1 */
100265817c7SWolfgang Denk #endif	/* 0 */
101265817c7SWolfgang Denk 	write_one_tlb(22,                   /* index */
102265817c7SWolfgang Denk 		      0x01ffe000,           /* Pagemask, 16 MB pages */
1036d0f6bcfSJean-Christophe PLAGNIOL-VILLARD 		      CONFIG_SYS_PCMCIA_MEM_ADDR,  /* Hi */
104265817c7SWolfgang Denk 		      0x3E000017,           /* Lo0 */
105265817c7SWolfgang Denk 		      0x3E200017);          /* Lo1 */
106265817c7SWolfgang Denk #endif	/* CONFIG_IDE_PCMCIA */
107265817c7SWolfgang Denk 
108265817c7SWolfgang Denk 	return 0;
109265817c7SWolfgang Denk }
110