Tom Rini | 83d290c | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
wdenk | 5da627a | 2003-10-09 20:09:04 +0000 | [diff] [blame] | 2 | /* |
| 3 | * (C) Copyright 2003 |
| 4 | * Thomas.Lange@corelatus.se |
wdenk | 5da627a | 2003-10-09 20:09:04 +0000 | [diff] [blame] | 5 | */ |
| 6 | |
| 7 | #include <common.h> |
| 8 | #include <command.h> |
Daniel Schwierzeck | 76ada5f | 2015-12-21 16:35:14 +0100 | [diff] [blame] | 9 | #include <mach/au1x00.h> |
wdenk | 5da627a | 2003-10-09 20:09:04 +0000 | [diff] [blame] | 10 | #include <asm/mipsregs.h> |
Jean-Christophe PLAGNIOL-VILLARD | 5c15010 | 2007-11-13 09:11:05 +0100 | [diff] [blame] | 11 | #include <asm/io.h> |
wdenk | 5da627a | 2003-10-09 20:09:04 +0000 | [diff] [blame] | 12 | |
Simon Glass | 088454c | 2017-03-31 08:40:25 -0600 | [diff] [blame] | 13 | DECLARE_GLOBAL_DATA_PTR; |
| 14 | |
Simon Glass | f1683aa | 2017-04-06 12:47:05 -0600 | [diff] [blame] | 15 | int dram_init(void) |
wdenk | 5da627a | 2003-10-09 20:09:04 +0000 | [diff] [blame] | 16 | { |
| 17 | /* Sdram is setup by assembler code */ |
| 18 | /* If memory could be changed, we should return the true value here */ |
Simon Glass | 088454c | 2017-03-31 08:40:25 -0600 | [diff] [blame] | 19 | gd->ram_size = MEM_SIZE * 1024 * 1024; |
| 20 | |
| 21 | return 0; |
wdenk | 5da627a | 2003-10-09 20:09:04 +0000 | [diff] [blame] | 22 | } |
| 23 | |
| 24 | #define BCSR_PCMCIA_PC0DRVEN 0x0010 |
| 25 | #define BCSR_PCMCIA_PC0RST 0x0080 |
| 26 | |
Peter Tyser | 1e3827d | 2010-04-12 22:28:14 -0500 | [diff] [blame] | 27 | /* In arch/mips/cpu/cpu.c */ |
wdenk | 5da627a | 2003-10-09 20:09:04 +0000 | [diff] [blame] | 28 | void write_one_tlb( int index, u32 pagemask, u32 hi, u32 low0, u32 low1 ); |
| 29 | |
| 30 | int checkboard (void) |
| 31 | { |
wdenk | c3d2b4b | 2005-01-22 18:13:04 +0000 | [diff] [blame] | 32 | #ifdef CONFIG_IDE_PCMCIA |
wdenk | 5da627a | 2003-10-09 20:09:04 +0000 | [diff] [blame] | 33 | u16 status; |
wdenk | ff36fd8 | 2005-01-09 22:28:56 +0000 | [diff] [blame] | 34 | volatile u32 *pcmcia_bcsr = (u32*)(DB1XX0_BCSR_ADDR+0x10); |
wdenk | c3d2b4b | 2005-01-22 18:13:04 +0000 | [diff] [blame] | 35 | #endif /* CONFIG_IDE_PCMCIA */ |
wdenk | ff36fd8 | 2005-01-09 22:28:56 +0000 | [diff] [blame] | 36 | volatile u32 *phy = (u32*)(DB1XX0_BCSR_ADDR+0xC); |
wdenk | 5da627a | 2003-10-09 20:09:04 +0000 | [diff] [blame] | 37 | volatile u32 *sys_counter = (volatile u32*)SYS_COUNTER_CNTRL; |
| 38 | u32 proc_id; |
| 39 | |
| 40 | *sys_counter = 0x100; /* Enable 32 kHz oscillator for RTC/TOY */ |
| 41 | |
Shinya Kuribayashi | e2ad842 | 2008-05-30 00:53:38 +0900 | [diff] [blame] | 42 | proc_id = read_c0_prid(); |
wdenk | 5da627a | 2003-10-09 20:09:04 +0000 | [diff] [blame] | 43 | |
wdenk | a2663ea | 2003-12-07 18:32:37 +0000 | [diff] [blame] | 44 | switch (proc_id >> 24) { |
wdenk | 5da627a | 2003-10-09 20:09:04 +0000 | [diff] [blame] | 45 | case 0: |
wdenk | a2663ea | 2003-12-07 18:32:37 +0000 | [diff] [blame] | 46 | puts ("Board: Merlot (DbAu1000)\n"); |
| 47 | printf ("CPU: Au1000 396 MHz, id: 0x%02x, rev: 0x%02x\n", |
| 48 | (proc_id >> 8) & 0xFF, proc_id & 0xFF); |
| 49 | break; |
| 50 | case 1: |
| 51 | puts ("Board: DbAu1500\n"); |
| 52 | printf ("CPU: Au1500, id: 0x%02x, rev: 0x%02x\n", |
| 53 | (proc_id >> 8) & 0xFF, proc_id & 0xFF); |
| 54 | break; |
| 55 | case 2: |
| 56 | puts ("Board: DbAu1100\n"); |
| 57 | printf ("CPU: Au1100, id: 0x%02x, rev: 0x%02x\n", |
| 58 | (proc_id >> 8) & 0xFF, proc_id & 0xFF); |
| 59 | break; |
wdenk | ff36fd8 | 2005-01-09 22:28:56 +0000 | [diff] [blame] | 60 | case 3: |
| 61 | puts ("Board: DbAu1550\n"); |
| 62 | printf ("CPU: Au1550, id: 0x%02x, rev: 0x%02x\n", |
| 63 | (proc_id >> 8) & 0xFF, proc_id & 0xFF); |
| 64 | break; |
wdenk | 5da627a | 2003-10-09 20:09:04 +0000 | [diff] [blame] | 65 | default: |
wdenk | a2663ea | 2003-12-07 18:32:37 +0000 | [diff] [blame] | 66 | printf ("Unsupported cpu %d, proc_id=0x%x\n", proc_id >> 24, proc_id); |
wdenk | 5da627a | 2003-10-09 20:09:04 +0000 | [diff] [blame] | 67 | } |
Jean-Christophe PLAGNIOL-VILLARD | 5c15010 | 2007-11-13 09:11:05 +0100 | [diff] [blame] | 68 | |
| 69 | set_io_port_base(0); |
| 70 | |
wdenk | 5da627a | 2003-10-09 20:09:04 +0000 | [diff] [blame] | 71 | #ifdef CONFIG_IDE_PCMCIA |
| 72 | /* Enable 3.3 V on slot 0 ( VCC ) |
| 73 | No 5V */ |
| 74 | status = 4; |
| 75 | *pcmcia_bcsr = status; |
| 76 | |
| 77 | status |= BCSR_PCMCIA_PC0DRVEN; |
| 78 | *pcmcia_bcsr = status; |
| 79 | au_sync(); |
| 80 | |
| 81 | udelay(300*1000); |
| 82 | |
| 83 | status |= BCSR_PCMCIA_PC0RST; |
| 84 | *pcmcia_bcsr = status; |
| 85 | au_sync(); |
| 86 | |
| 87 | udelay(100*1000); |
| 88 | |
| 89 | /* PCMCIA is on a 36 bit physical address. |
| 90 | We need to map it into a 32 bit addresses */ |
| 91 | |
| 92 | #if 0 |
| 93 | /* We dont need theese unless we run whole pcmcia package */ |
| 94 | write_one_tlb(20, /* index */ |
| 95 | 0x01ffe000, /* Pagemask, 16 MB pages */ |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 96 | CONFIG_SYS_PCMCIA_IO_BASE, /* Hi */ |
wdenk | 5da627a | 2003-10-09 20:09:04 +0000 | [diff] [blame] | 97 | 0x3C000017, /* Lo0 */ |
| 98 | 0x3C200017); /* Lo1 */ |
| 99 | |
| 100 | write_one_tlb(21, /* index */ |
| 101 | 0x01ffe000, /* Pagemask, 16 MB pages */ |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 102 | CONFIG_SYS_PCMCIA_ATTR_BASE, /* Hi */ |
wdenk | 5da627a | 2003-10-09 20:09:04 +0000 | [diff] [blame] | 103 | 0x3D000017, /* Lo0 */ |
| 104 | 0x3D200017); /* Lo1 */ |
wdenk | 697037f | 2004-06-09 15:29:49 +0000 | [diff] [blame] | 105 | #endif /* 0 */ |
wdenk | 5da627a | 2003-10-09 20:09:04 +0000 | [diff] [blame] | 106 | write_one_tlb(22, /* index */ |
| 107 | 0x01ffe000, /* Pagemask, 16 MB pages */ |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 108 | CONFIG_SYS_PCMCIA_MEM_ADDR, /* Hi */ |
wdenk | 5da627a | 2003-10-09 20:09:04 +0000 | [diff] [blame] | 109 | 0x3E000017, /* Lo0 */ |
| 110 | 0x3E200017); /* Lo1 */ |
wdenk | 697037f | 2004-06-09 15:29:49 +0000 | [diff] [blame] | 111 | #endif /* CONFIG_IDE_PCMCIA */ |
wdenk | 5da627a | 2003-10-09 20:09:04 +0000 | [diff] [blame] | 112 | |
| 113 | /* Release reset of ethernet PHY chips */ |
| 114 | /* Always do this, because linux does not know about it */ |
| 115 | *phy = 3; |
| 116 | |
| 117 | return 0; |
wdenk | 5da627a | 2003-10-09 20:09:04 +0000 | [diff] [blame] | 118 | } |