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/types.h>
15 #include <linux/kernel.h>
17 #include <linux/interrupt.h>
18 #include <linux/irq.h>
20 #include <asm/setup.h>
21 #include <asm/pgtable.h>
22 #include <asm/machdep.h>
23 #include <asm/m68360.h>
26 #include <asm/bootstd.h>
29 extern void m360_cpm_reset(void);
31 // Mask to select if the PLL prescaler is enabled.
32 #define MCU_PREEN ((unsigned short)(0x0001 << 13))
34 #if defined(CONFIG_UCQUICC)
35 #define OSCILLATOR (unsigned long int)33000000
38 unsigned long int system_clock;
42 /* TODO DON"T Hard Code this */
43 /* calculate properly using the right PLL and prescaller */
44 // unsigned int system_clock = 33000000l;
45 extern unsigned long int system_clock; //In kernel setup.c
48 static irqreturn_t hw_tick(int irq, void *dummy)
53 pquicc->timer_ter1 = 0x0002; /* clear timer event */
55 return arch_timer_interrupt(irq, dummy);
58 static struct irqaction m68360_timer_irq = {
60 .flags = IRQF_DISABLED | IRQF_TIMER,
64 void hw_timer_init(void)
66 unsigned char prescaler;
67 unsigned short tgcr_save;
70 /* Restart mode, Enable int, 32KHz, Enable timer */
71 TCTL = TCTL_OM | TCTL_IRQEN | TCTL_CLKSOURCE_32KHZ | TCTL_TEN;
72 /* Set prescaler (Divide 32KHz by 32)*/
74 /* Set compare register 32Khz / 32 / 10 = 100 */
77 request_irq(IRQ_MACHSPEC | 1, timer_routine, 0, "timer", NULL);
80 /* General purpose quicc timers: MC68360UM p7-20 */
82 /* Set up timer 1 (in [1..4]) to do 100Hz */
83 tgcr_save = pquicc->timer_tgcr & 0xfff0;
84 pquicc->timer_tgcr = tgcr_save; /* stop and reset timer 1 */
85 /* pquicc->timer_tgcr |= 0x4444; */ /* halt timers when FREEZE (ie bdm freeze) */
88 pquicc->timer_tmr1 = 0x001a | /* or=1, frr=1, iclk=01b */
89 (unsigned short)((prescaler - 1) << 8);
91 pquicc->timer_tcn1 = 0x0000; /* initial count */
92 /* calculate interval for 100Hz based on the _system_clock: */
93 pquicc->timer_trr1 = (system_clock/ prescaler) / HZ; /* reference count */
95 pquicc->timer_ter1 = 0x0003; /* clear timer events */
97 /* enable timer 1 interrupt in CIMR */
98 setup_irq(CPMVEC_TIMER1, &m68360_timer_irq);
101 tgcr_save = (pquicc->timer_tgcr & 0xfff0) | 0x0001;
102 pquicc->timer_tgcr = tgcr_save;
105 int BSP_set_clock_mmss(unsigned long nowtime)
108 short real_seconds = nowtime % 60, real_minutes = (nowtime / 60) % 60;
110 tod->second1 = real_seconds / 10;
111 tod->second2 = real_seconds % 10;
112 tod->minute1 = real_minutes / 10;
113 tod->minute2 = real_minutes % 10;
118 void BSP_reset (void)
122 "moveal #_start, %a0;\n"
123 "moveb #0, 0xFFFFF300;\n"
124 "moveal 0(%a0), %sp;\n"
125 "moveal 4(%a0), %a0;\n"
130 unsigned char *scc1_hwaddr;
133 #if defined (CONFIG_UCQUICC)
134 _bsc0(char *, getserialnum)
135 _bsc1(unsigned char *, gethwaddr, int, a)
136 _bsc1(char *, getbenv, char *, a)
140 void config_BSP(char *command, int len)
146 /* Calculate the real system clock value. */
148 unsigned int local_pllcr = (unsigned int)(pquicc->sim_pllcr);
149 if( local_pllcr & MCU_PREEN ) // If the prescaler is dividing by 128
151 int mf = (int)(pquicc->sim_pllcr & 0x0fff);
152 system_clock = (OSCILLATOR / 128) * (mf + 1);
156 int mf = (int)(pquicc->sim_pllcr & 0x0fff);
157 system_clock = (OSCILLATOR) * (mf + 1);
161 printk(KERN_INFO "\n68360 QUICC support (C) 2000 Lineo Inc.\n");
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]);
169 p = getbenv("APPEND");
175 scc1_hwaddr = "\00\01\02\03\04\05";
178 mach_reset = BSP_reset;