Path: blob/master/arch/m68k/platform/68360/config.c
10819 views
/*1* linux/arch/m68knommu/platform/68360/config.c2*3* Copyright (c) 2000 Michael Leslie <[email protected]>4* Copyright (C) 1993 Hamish Macdonald5* Copyright (C) 1999 D. Jeff Dionne <[email protected]>6*7* This file is subject to the terms and conditions of the GNU General Public8* License. See the file COPYING in the main directory of this archive9* for more details.10*/1112#include <stdarg.h>13#include <linux/types.h>14#include <linux/kernel.h>15#include <linux/mm.h>16#include <linux/interrupt.h>17#include <linux/irq.h>1819#include <asm/setup.h>20#include <asm/system.h>21#include <asm/pgtable.h>22#include <asm/machdep.h>23#include <asm/m68360.h>2425#ifdef CONFIG_UCQUICC26#include <asm/bootstd.h>27#endif2829extern void m360_cpm_reset(void);3031// Mask to select if the PLL prescaler is enabled.32#define MCU_PREEN ((unsigned short)(0x0001 << 13))3334#if defined(CONFIG_UCQUICC)35#define OSCILLATOR (unsigned long int)3300000036#endif3738unsigned long int system_clock;3940extern QUICC *pquicc;4142/* TODO DON"T Hard Code this */43/* calculate properly using the right PLL and prescaller */44// unsigned int system_clock = 33000000l;45extern unsigned long int system_clock; //In kernel setup.c464748static irqreturn_t hw_tick(int irq, void *dummy)49{50/* Reset Timer1 */51/* TSTAT &= 0; */5253pquicc->timer_ter1 = 0x0002; /* clear timer event */5455return arch_timer_interrupt(irq, dummy);56}5758static struct irqaction m68360_timer_irq = {59.name = "timer",60.flags = IRQF_DISABLED | IRQF_TIMER,61.handler = hw_tick,62};6364void hw_timer_init(void)65{66unsigned char prescaler;67unsigned short tgcr_save;6869#if 070/* Restart mode, Enable int, 32KHz, Enable timer */71TCTL = TCTL_OM | TCTL_IRQEN | TCTL_CLKSOURCE_32KHZ | TCTL_TEN;72/* Set prescaler (Divide 32KHz by 32)*/73TPRER = 31;74/* Set compare register 32Khz / 32 / 10 = 100 */75TCMP = 10;7677request_irq(IRQ_MACHSPEC | 1, timer_routine, 0, "timer", NULL);78#endif7980/* General purpose quicc timers: MC68360UM p7-20 */8182/* Set up timer 1 (in [1..4]) to do 100Hz */83tgcr_save = pquicc->timer_tgcr & 0xfff0;84pquicc->timer_tgcr = tgcr_save; /* stop and reset timer 1 */85/* pquicc->timer_tgcr |= 0x4444; */ /* halt timers when FREEZE (ie bdm freeze) */8687prescaler = 8;88pquicc->timer_tmr1 = 0x001a | /* or=1, frr=1, iclk=01b */89(unsigned short)((prescaler - 1) << 8);9091pquicc->timer_tcn1 = 0x0000; /* initial count */92/* calculate interval for 100Hz based on the _system_clock: */93pquicc->timer_trr1 = (system_clock/ prescaler) / HZ; /* reference count */9495pquicc->timer_ter1 = 0x0003; /* clear timer events */9697/* enable timer 1 interrupt in CIMR */98setup_irq(CPMVEC_TIMER1, &m68360_timer_irq);99100/* Start timer 1: */101tgcr_save = (pquicc->timer_tgcr & 0xfff0) | 0x0001;102pquicc->timer_tgcr = tgcr_save;103}104105void BSP_gettod (int *yearp, int *monp, int *dayp,106int *hourp, int *minp, int *secp)107{108}109110int BSP_set_clock_mmss(unsigned long nowtime)111{112#if 0113short real_seconds = nowtime % 60, real_minutes = (nowtime / 60) % 60;114115tod->second1 = real_seconds / 10;116tod->second2 = real_seconds % 10;117tod->minute1 = real_minutes / 10;118tod->minute2 = real_minutes % 10;119#endif120return 0;121}122123void BSP_reset (void)124{125local_irq_disable();126asm volatile (127"moveal #_start, %a0;\n"128"moveb #0, 0xFFFFF300;\n"129"moveal 0(%a0), %sp;\n"130"moveal 4(%a0), %a0;\n"131"jmp (%a0);\n"132);133}134135unsigned char *scc1_hwaddr;136static int errno;137138#if defined (CONFIG_UCQUICC)139_bsc0(char *, getserialnum)140_bsc1(unsigned char *, gethwaddr, int, a)141_bsc1(char *, getbenv, char *, a)142#endif143144145void config_BSP(char *command, int len)146{147unsigned char *p;148149m360_cpm_reset();150151/* Calculate the real system clock value. */152{153unsigned int local_pllcr = (unsigned int)(pquicc->sim_pllcr);154if( local_pllcr & MCU_PREEN ) // If the prescaler is dividing by 128155{156int mf = (int)(pquicc->sim_pllcr & 0x0fff);157system_clock = (OSCILLATOR / 128) * (mf + 1);158}159else160{161int mf = (int)(pquicc->sim_pllcr & 0x0fff);162system_clock = (OSCILLATOR) * (mf + 1);163}164}165166printk(KERN_INFO "\n68360 QUICC support (C) 2000 Lineo Inc.\n");167168#if defined(CONFIG_UCQUICC) && 0169printk(KERN_INFO "uCquicc serial string [%s]\n",getserialnum());170p = scc1_hwaddr = gethwaddr(0);171printk(KERN_INFO "uCquicc hwaddr %.2x:%.2x:%.2x:%.2x:%.2x:%.2x\n",172p[0], p[1], p[2], p[3], p[4], p[5]);173174p = getbenv("APPEND");175if (p)176strcpy(p,command);177else178command[0] = 0;179#else180scc1_hwaddr = "\00\01\02\03\04\05";181#endif182183mach_gettod = BSP_gettod;184mach_reset = BSP_reset;185}186187188