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