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