1
2
3
4
5
6
7
8
9
10
11
12
13#include <stdarg.h>
14#include <linux/types.h>
15#include <linux/kernel.h>
16#include <linux/mm.h>
17#include <linux/interrupt.h>
18#include <linux/irq.h>
19
20#include <asm/setup.h>
21#include <asm/pgtable.h>
22#include <asm/machdep.h>
23#include <asm/m68360.h>
24
25#ifdef CONFIG_UCQUICC
26#include <asm/bootstd.h>
27#endif
28
29extern void m360_cpm_reset(void);
30
31
32#define MCU_PREEN ((unsigned short)(0x0001 << 13))
33
34#if defined(CONFIG_UCQUICC)
35#define OSCILLATOR (unsigned long int)33000000
36#endif
37
38unsigned long int system_clock;
39
40extern QUICC *pquicc;
41
42
43
44
45extern unsigned long int system_clock;
46
47
48static irqreturn_t hw_tick(int irq, void *dummy)
49{
50
51
52
53 pquicc->timer_ter1 = 0x0002;
54
55 return arch_timer_interrupt(irq, dummy);
56}
57
58static struct irqaction m68360_timer_irq = {
59 .name = "timer",
60 .flags = IRQF_DISABLED | IRQF_TIMER,
61 .handler = hw_tick,
62};
63
64void hw_timer_init(void)
65{
66 unsigned char prescaler;
67 unsigned short tgcr_save;
68
69#if 0
70
71 TCTL = TCTL_OM | TCTL_IRQEN | TCTL_CLKSOURCE_32KHZ | TCTL_TEN;
72
73 TPRER = 31;
74
75 TCMP = 10;
76
77 request_irq(IRQ_MACHSPEC | 1, timer_routine, 0, "timer", NULL);
78#endif
79
80
81
82
83 tgcr_save = pquicc->timer_tgcr & 0xfff0;
84 pquicc->timer_tgcr = tgcr_save;
85
86
87 prescaler = 8;
88 pquicc->timer_tmr1 = 0x001a |
89 (unsigned short)((prescaler - 1) << 8);
90
91 pquicc->timer_tcn1 = 0x0000;
92
93 pquicc->timer_trr1 = (system_clock/ prescaler) / HZ;
94
95 pquicc->timer_ter1 = 0x0003;
96
97
98 setup_irq(CPMVEC_TIMER1, &m68360_timer_irq);
99
100
101 tgcr_save = (pquicc->timer_tgcr & 0xfff0) | 0x0001;
102 pquicc->timer_tgcr = tgcr_save;
103}
104
105int BSP_set_clock_mmss(unsigned long nowtime)
106{
107#if 0
108 short real_seconds = nowtime % 60, real_minutes = (nowtime / 60) % 60;
109
110 tod->second1 = real_seconds / 10;
111 tod->second2 = real_seconds % 10;
112 tod->minute1 = real_minutes / 10;
113 tod->minute2 = real_minutes % 10;
114#endif
115 return 0;
116}
117
118void BSP_reset (void)
119{
120 local_irq_disable();
121 asm volatile (
122 "moveal #_start, %a0;\n"
123 "moveb #0, 0xFFFFF300;\n"
124 "moveal 0(%a0), %sp;\n"
125 "moveal 4(%a0), %a0;\n"
126 "jmp (%a0);\n"
127 );
128}
129
130unsigned char *scc1_hwaddr;
131static int errno;
132
133#if defined (CONFIG_UCQUICC)
134_bsc0(char *, getserialnum)
135_bsc1(unsigned char *, gethwaddr, int, a)
136_bsc1(char *, getbenv, char *, a)
137#endif
138
139
140void config_BSP(char *command, int len)
141{
142 unsigned char *p;
143
144 m360_cpm_reset();
145
146
147 {
148 unsigned int local_pllcr = (unsigned int)(pquicc->sim_pllcr);
149 if( local_pllcr & MCU_PREEN )
150 {
151 int mf = (int)(pquicc->sim_pllcr & 0x0fff);
152 system_clock = (OSCILLATOR / 128) * (mf + 1);
153 }
154 else
155 {
156 int mf = (int)(pquicc->sim_pllcr & 0x0fff);
157 system_clock = (OSCILLATOR) * (mf + 1);
158 }
159 }
160
161 printk(KERN_INFO "\n68360 QUICC support (C) 2000 Lineo Inc.\n");
162
163#if defined(CONFIG_UCQUICC) && 0
164 printk(KERN_INFO "uCquicc serial string [%s]\n",getserialnum());
165 p = scc1_hwaddr = gethwaddr(0);
166 printk(KERN_INFO "uCquicc hwaddr %.2x:%.2x:%.2x:%.2x:%.2x:%.2x\n",
167 p[0], p[1], p[2], p[3], p[4], p[5]);
168
169 p = getbenv("APPEND");
170 if (p)
171 strcpy(p,command);
172 else
173 command[0] = 0;
174#else
175 scc1_hwaddr = "\00\01\02\03\04\05";
176#endif
177
178 mach_reset = BSP_reset;
179}
180