Songmao Tian | 42d226c | 2007-06-06 14:52:38 +0800 | [diff] [blame] | 1 | /* |
| 2 | * BRIEF MODULE DESCRIPTION |
| 3 | * setup.c - board dependent boot routines |
| 4 | * |
| 5 | * Copyright (C) 2007 Lemote Inc. & Insititute of Computing Technology |
| 6 | * Author: Fuxin Zhang, zhangfx@lemote.com |
| 7 | * |
| 8 | * This program is free software; you can redistribute it and/or modify it |
| 9 | * under the terms of the GNU General Public License as published by the |
| 10 | * Free Software Foundation; either version 2 of the License, or (at your |
| 11 | * option) any later version. |
| 12 | * |
| 13 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED |
| 14 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF |
| 15 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN |
| 16 | * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
| 17 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
| 18 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF |
| 19 | * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON |
| 20 | * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 21 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
| 22 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 23 | * |
| 24 | * You should have received a copy of the GNU General Public License along |
| 25 | * with this program; if not, write to the Free Software Foundation, Inc., |
| 26 | * 675 Mass Ave, Cambridge, MA 02139, USA. |
| 27 | * |
| 28 | */ |
| 29 | #include <linux/bootmem.h> |
| 30 | #include <linux/init.h> |
Songmao Tian | 42d226c | 2007-06-06 14:52:38 +0800 | [diff] [blame] | 31 | #include <linux/irq.h> |
Songmao Tian | 42d226c | 2007-06-06 14:52:38 +0800 | [diff] [blame] | 32 | |
| 33 | #include <asm/bootinfo.h> |
| 34 | #include <asm/mc146818-time.h> |
| 35 | #include <asm/time.h> |
| 36 | #include <asm/wbflush.h> |
| 37 | |
| 38 | #ifdef CONFIG_VT |
| 39 | #include <linux/console.h> |
| 40 | #include <linux/screen_info.h> |
| 41 | #endif |
| 42 | |
| 43 | extern void mips_reboot_setup(void); |
| 44 | |
| 45 | #ifdef CONFIG_64BIT |
| 46 | #define PTR_PAD(p) ((0xffffffff00000000)|((unsigned long long)(p))) |
| 47 | #else |
| 48 | #define PTR_PAD(p) (p) |
| 49 | #endif |
| 50 | |
Ralf Baechle | 348c913 | 2007-07-28 11:46:15 +0100 | [diff] [blame] | 51 | unsigned long cpu_clock_freq; |
Songmao Tian | 42d226c | 2007-06-06 14:52:38 +0800 | [diff] [blame] | 52 | unsigned long bus_clock; |
| 53 | unsigned int memsize; |
| 54 | unsigned int highmemsize = 0; |
| 55 | |
Ralf Baechle | 4b55048 | 2007-10-11 23:46:08 +0100 | [diff] [blame] | 56 | void __init plat_time_init(void) |
Songmao Tian | 42d226c | 2007-06-06 14:52:38 +0800 | [diff] [blame] | 57 | { |
| 58 | /* setup mips r4k timer */ |
Ralf Baechle | 348c913 | 2007-07-28 11:46:15 +0100 | [diff] [blame] | 59 | mips_hpt_frequency = cpu_clock_freq / 2; |
Songmao Tian | 42d226c | 2007-06-06 14:52:38 +0800 | [diff] [blame] | 60 | } |
| 61 | |
Ralf Baechle | 4b55048 | 2007-10-11 23:46:08 +0100 | [diff] [blame] | 62 | unsigned long read_persistent_clock(void) |
Songmao Tian | 42d226c | 2007-06-06 14:52:38 +0800 | [diff] [blame] | 63 | { |
| 64 | return mc146818_get_cmos_time(); |
| 65 | } |
| 66 | |
| 67 | void (*__wbflush)(void); |
| 68 | EXPORT_SYMBOL(__wbflush); |
| 69 | |
| 70 | static void wbflush_loongson2e(void) |
| 71 | { |
| 72 | asm(".set\tpush\n\t" |
| 73 | ".set\tnoreorder\n\t" |
| 74 | ".set mips3\n\t" |
| 75 | "sync\n\t" |
| 76 | "nop\n\t" |
| 77 | ".set\tpop\n\t" |
| 78 | ".set mips0\n\t"); |
| 79 | } |
| 80 | |
| 81 | void __init plat_mem_setup(void) |
| 82 | { |
| 83 | set_io_port_base(PTR_PAD(0xbfd00000)); |
| 84 | |
| 85 | mips_reboot_setup(); |
| 86 | |
Songmao Tian | 42d226c | 2007-06-06 14:52:38 +0800 | [diff] [blame] | 87 | __wbflush = wbflush_loongson2e; |
| 88 | |
| 89 | add_memory_region(0x0, (memsize << 20), BOOT_MEM_RAM); |
| 90 | #ifdef CONFIG_64BIT |
| 91 | if (highmemsize > 0) { |
| 92 | add_memory_region(0x20000000, highmemsize << 20, BOOT_MEM_RAM); |
| 93 | } |
| 94 | #endif |
| 95 | |
| 96 | #ifdef CONFIG_VT |
| 97 | #if defined(CONFIG_VGA_CONSOLE) |
| 98 | conswitchp = &vga_con; |
| 99 | |
| 100 | screen_info = (struct screen_info) { |
| 101 | 0, 25, /* orig-x, orig-y */ |
| 102 | 0, /* unused */ |
| 103 | 0, /* orig-video-page */ |
| 104 | 0, /* orig-video-mode */ |
| 105 | 80, /* orig-video-cols */ |
| 106 | 0, 0, 0, /* ega_ax, ega_bx, ega_cx */ |
| 107 | 25, /* orig-video-lines */ |
| 108 | VIDEO_TYPE_VGAC, /* orig-video-isVGA */ |
| 109 | 16 /* orig-video-points */ |
| 110 | }; |
| 111 | #elif defined(CONFIG_DUMMY_CONSOLE) |
| 112 | conswitchp = &dummy_con; |
| 113 | #endif |
| 114 | #endif |
| 115 | |
| 116 | } |