2 * arch/mips/pmc-sierra/yosemite/setup.c
4 * Copyright (C) 2003 PMC-Sierra Inc.
5 * Author: Manish Lachwani (lachwani@pmc-sierra.com)
7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License as published by the
9 * Free Software Foundation; either version 2 of the License, or (at your
10 * option) any later version.
12 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
13 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
14 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
15 * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
16 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
17 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
18 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
19 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
20 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
21 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23 * You should have received a copy of the GNU General Public License along
24 * with this program; if not, write to the Free Software Foundation, Inc.,
25 * 675 Mass Ave, Cambridge, MA 02139, USA.
28 #include <linux/init.h>
29 #include <linux/kernel.h>
30 #include <linux/types.h>
31 #include <linux/mc146818rtc.h>
33 #include <linux/swap.h>
34 #include <linux/ioport.h>
35 #include <linux/sched.h>
36 #include <linux/interrupt.h>
37 #include <linux/pci.h>
38 #include <linux/timex.h>
39 #include <linux/vmalloc.h>
41 #include <asm/bootinfo.h>
43 #include <asm/bootinfo.h>
46 #include <asm/processor.h>
47 #include <asm/ptrace.h>
48 #include <asm/reboot.h>
49 #include <linux/version.h>
50 #include <linux/bootmem.h>
51 #include <linux/blk.h>
55 unsigned long cpu_clock;
56 unsigned long yosemite_base;
58 void __init bus_error_init(void)
63 unsigned long m48t37y_get_time(void)
65 unsigned char *rtc_base = YOSEMITE_RTC_BASE;
66 unsigned int year, month, day, hour, min, sec;
68 /* Stop the update to the time */
69 rtc_base[0x7ff8] = 0x40;
71 year = CONV_BCD_TO_BIN(rtc_base[0x7fff]);
72 year += CONV_BCD_TO_BIN(rtc_base[0x7fff1]) * 100;
74 month = CONV_BCD_TO_BIN(rtc_base[0x7ffe]);
75 day = CONV_BCD_TO_BIN(rtc_base[0x7ffd]);
76 hour = CONV_BCD_TO_BIN(rtc_base[0x7ffb]);
77 min = CONV_BCD_TO_BIN(rtc_base[0x7ffa]);
78 sec = CONV_BCD_TO_BIN(rtc_base[0x7ff9]);
80 /* Start the update to the time again */
81 rtc_base[0x7ff8] = 0x00;
83 return mktime(year, month, day, hour, min, sec);
86 int m48t37y_set_time(unsigned long sec)
88 unsigned char *rtc_base = YOSEMITE_RTC_BASE;
89 unsigned int year, month, day, hour, min, sec;
93 /* convert to a more useful format -- note months count from 0 */
98 rtc_base[0x7ff8] = 0x80;
101 rtc_base[0x7fff] = CONV_BIN_TO_BCD(tm.tm_year % 100);
102 rtc_base[0x7ff1] = CONV_BIN_TO_BCD(tm.tm_year / 100);
105 rtc_base[0x7ffe] = CONV_BIN_TO_BCD(tm.tm_mon);
108 rtc_base[0x7ffd] = CONV_BIN_TO_BCD(tm.tm_mday);
111 rtc_base[0x7ffb] = CONV_BIN_TO_BCD(tm.tm_hour);
112 rtc_base[0x7ffa] = CONV_BIN_TO_BCD(tm.tm_min);
113 rtc_base[0x7ff9] = CONV_BIN_TO_BCD(tm.tm_sec);
115 /* day of week -- not really used, but let's keep it up-to-date */
116 rtc_base[0x7ffc] = CONV_BIN_TO_BCD(tm.tm_wday + 1);
118 /* disable writing */
119 rtc_base[0x7ff8] = 0x00;
124 void yosemite_timer_setup(struct irqaction *irq)
129 void yosemite_time_init(void)
131 mips_counter_frequency = cpu_clock / 2;
132 board_timer_setup = yosemite_timer_setup;
134 rtc_get_time = m48t37y_get_time;
135 rtc_set_time = m48t37y_set_time;
138 static int __init pmc_yosemite_setup(void)
140 unsigned long val = 0;
142 printk("PMC-Sierra Yosemite Board Setup \n");
143 board_time_init = yosemite_time_init;
145 /* Add memory regions */
146 add_memory_region(0x00000000, 0x10000000, BOOT_MEM_RAM);
147 add_memory_region(0x10000000, 0x10000000, BOOT_MEM_RAM);
149 /* Setup the HT controller */
150 val = *(volatile uint32_t *)(HYPERTRANSPORT_CONFIG_REG);
151 val |= HYPERTRANSPORT_ENABLE;
152 *(volatile uint32_t *)(HYPERTRANSPORT_CONFIG_REG) = val;
154 /* Set the BAR. Shifted mode */
155 *(volatile uint32_t *)(HYPERTRANSPORT_BAR0_REG) = HYPERTRANSPORT_BAR0_ADDR;
156 *(volatile uint32_t *)(HYPERTRANSPORT_SIZE0_REG) = HYPERTRANSPORT_SIZE0;
159 ioport_resource.start = 0xe0000000;
160 ioport_resource.end = 0xe0000000 + 0x20000000 - 1;
161 iomem_resource.start = 0xc0000000;
162 iomem_resource.end = 0xc0000000 + 0x20000000 - 1;
164 pci_scan_bus(0, &titan_pci_ops, NULL);
170 early_initcall(pmc_yosemite_setup);