2 * linux/arch/m68knommu/platform/68360/config.c
4 * Copyright (c) 2000 Michael Leslie <mleslie@lineo.com>
5 * Copyright (C) 1993 Hamish Macdonald
6 * Copyright (C) 1999 D. Jeff Dionne <jeff@uclinux.org>
8 * This file is subject to the terms and conditions of the GNU General Public
9 * License. See the file COPYING in the main directory of this archive
14 #include <linux/init.h>
15 #include <linux/types.h>
16 #include <linux/kernel.h>
18 #include <linux/interrupt.h>
19 #include <linux/irq.h>
21 #include <asm/setup.h>
22 #include <asm/pgtable.h>
23 #include <asm/machdep.h>
24 #include <asm/m68360.h>
27 #include <asm/bootstd.h>
30 extern void m360_cpm_reset(void);
32 // Mask to select if the PLL prescaler is enabled.
33 #define MCU_PREEN ((unsigned short)(0x0001 << 13))
35 #if defined(CONFIG_UCQUICC)
36 #define OSCILLATOR (unsigned long int)33000000
39 static irq_handler_t timer_interrupt
;
40 unsigned long int system_clock
;
44 /* TODO DON"T Hard Code this */
45 /* calculate properly using the right PLL and prescaller */
46 // unsigned int system_clock = 33000000l;
47 extern unsigned long int system_clock
; //In kernel setup.c
50 static irqreturn_t
hw_tick(int irq
, void *dummy
)
55 pquicc
->timer_ter1
= 0x0002; /* clear timer event */
57 return timer_interrupt(irq
, dummy
);
60 static struct irqaction m68360_timer_irq
= {
66 void hw_timer_init(irq_handler_t handler
)
68 unsigned char prescaler
;
69 unsigned short tgcr_save
;
72 /* Restart mode, Enable int, 32KHz, Enable timer */
73 TCTL
= TCTL_OM
| TCTL_IRQEN
| TCTL_CLKSOURCE_32KHZ
| TCTL_TEN
;
74 /* Set prescaler (Divide 32KHz by 32)*/
76 /* Set compare register 32Khz / 32 / 10 = 100 */
79 request_irq(IRQ_MACHSPEC
| 1, timer_routine
, 0, "timer", NULL
);
82 /* General purpose quicc timers: MC68360UM p7-20 */
84 /* Set up timer 1 (in [1..4]) to do 100Hz */
85 tgcr_save
= pquicc
->timer_tgcr
& 0xfff0;
86 pquicc
->timer_tgcr
= tgcr_save
; /* stop and reset timer 1 */
87 /* pquicc->timer_tgcr |= 0x4444; */ /* halt timers when FREEZE (ie bdm freeze) */
90 pquicc
->timer_tmr1
= 0x001a | /* or=1, frr=1, iclk=01b */
91 (unsigned short)((prescaler
- 1) << 8);
93 pquicc
->timer_tcn1
= 0x0000; /* initial count */
94 /* calculate interval for 100Hz based on the _system_clock: */
95 pquicc
->timer_trr1
= (system_clock
/ prescaler
) / HZ
; /* reference count */
97 pquicc
->timer_ter1
= 0x0003; /* clear timer events */
99 timer_interrupt
= handler
;
101 /* enable timer 1 interrupt in CIMR */
102 setup_irq(CPMVEC_TIMER1
, &m68360_timer_irq
);
105 tgcr_save
= (pquicc
->timer_tgcr
& 0xfff0) | 0x0001;
106 pquicc
->timer_tgcr
= tgcr_save
;
109 int BSP_set_clock_mmss(unsigned long nowtime
)
112 short real_seconds
= nowtime
% 60, real_minutes
= (nowtime
/ 60) % 60;
114 tod
->second1
= real_seconds
/ 10;
115 tod
->second2
= real_seconds
% 10;
116 tod
->minute1
= real_minutes
/ 10;
117 tod
->minute2
= real_minutes
% 10;
122 void BSP_reset (void)
126 "moveal #_start, %a0;\n"
127 "moveb #0, 0xFFFFF300;\n"
128 "moveal 0(%a0), %sp;\n"
129 "moveal 4(%a0), %a0;\n"
134 unsigned char *scc1_hwaddr
;
137 #if defined (CONFIG_UCQUICC)
138 _bsc0(char *, getserialnum
)
139 _bsc1(unsigned char *, gethwaddr
, int, a
)
140 _bsc1(char *, getbenv
, char *, a
)
144 void __init
config_BSP(char *command
, int len
)
150 /* Calculate the real system clock value. */
152 unsigned int local_pllcr
= (unsigned int)(pquicc
->sim_pllcr
);
153 if( local_pllcr
& MCU_PREEN
) // If the prescaler is dividing by 128
155 int mf
= (int)(pquicc
->sim_pllcr
& 0x0fff);
156 system_clock
= (OSCILLATOR
/ 128) * (mf
+ 1);
160 int mf
= (int)(pquicc
->sim_pllcr
& 0x0fff);
161 system_clock
= (OSCILLATOR
) * (mf
+ 1);
165 printk(KERN_INFO
"\n68360 QUICC support (C) 2000 Lineo Inc.\n");
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]);
173 p
= getbenv("APPEND");
179 scc1_hwaddr
= "\00\01\02\03\04\05";
182 mach_reset
= BSP_reset
;