config.c 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  1. /*
  2. * config.c - non-mmu 68360 platform initialization code
  3. *
  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>
  7. *
  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
  10. * for more details.
  11. */
  12. #include <stdarg.h>
  13. #include <linux/init.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. #include <asm/setup.h>
  20. #include <asm/pgtable.h>
  21. #include <asm/machdep.h>
  22. #include <asm/m68360.h>
  23. #ifdef CONFIG_UCQUICC
  24. #include <asm/bootstd.h>
  25. #endif
  26. extern void m360_cpm_reset(void);
  27. // Mask to select if the PLL prescaler is enabled.
  28. #define MCU_PREEN ((unsigned short)(0x0001 << 13))
  29. #if defined(CONFIG_UCQUICC)
  30. #define OSCILLATOR (unsigned long int)33000000
  31. #endif
  32. static irq_handler_t timer_interrupt;
  33. unsigned long int system_clock;
  34. extern QUICC *pquicc;
  35. /* TODO DON"T Hard Code this */
  36. /* calculate properly using the right PLL and prescaller */
  37. // unsigned int system_clock = 33000000l;
  38. extern unsigned long int system_clock; //In kernel setup.c
  39. static irqreturn_t hw_tick(int irq, void *dummy)
  40. {
  41. /* Reset Timer1 */
  42. /* TSTAT &= 0; */
  43. pquicc->timer_ter1 = 0x0002; /* clear timer event */
  44. return timer_interrupt(irq, dummy);
  45. }
  46. static struct irqaction m68360_timer_irq = {
  47. .name = "timer",
  48. .flags = IRQF_TIMER,
  49. .handler = hw_tick,
  50. };
  51. void hw_timer_init(irq_handler_t handler)
  52. {
  53. unsigned char prescaler;
  54. unsigned short tgcr_save;
  55. #if 0
  56. /* Restart mode, Enable int, 32KHz, Enable timer */
  57. TCTL = TCTL_OM | TCTL_IRQEN | TCTL_CLKSOURCE_32KHZ | TCTL_TEN;
  58. /* Set prescaler (Divide 32KHz by 32)*/
  59. TPRER = 31;
  60. /* Set compare register 32Khz / 32 / 10 = 100 */
  61. TCMP = 10;
  62. request_irq(IRQ_MACHSPEC | 1, timer_routine, 0, "timer", NULL);
  63. #endif
  64. /* General purpose quicc timers: MC68360UM p7-20 */
  65. /* Set up timer 1 (in [1..4]) to do 100Hz */
  66. tgcr_save = pquicc->timer_tgcr & 0xfff0;
  67. pquicc->timer_tgcr = tgcr_save; /* stop and reset timer 1 */
  68. /* pquicc->timer_tgcr |= 0x4444; */ /* halt timers when FREEZE (ie bdm freeze) */
  69. prescaler = 8;
  70. pquicc->timer_tmr1 = 0x001a | /* or=1, frr=1, iclk=01b */
  71. (unsigned short)((prescaler - 1) << 8);
  72. pquicc->timer_tcn1 = 0x0000; /* initial count */
  73. /* calculate interval for 100Hz based on the _system_clock: */
  74. pquicc->timer_trr1 = (system_clock/ prescaler) / HZ; /* reference count */
  75. pquicc->timer_ter1 = 0x0003; /* clear timer events */
  76. timer_interrupt = handler;
  77. /* enable timer 1 interrupt in CIMR */
  78. setup_irq(CPMVEC_TIMER1, &m68360_timer_irq);
  79. /* Start timer 1: */
  80. tgcr_save = (pquicc->timer_tgcr & 0xfff0) | 0x0001;
  81. pquicc->timer_tgcr = tgcr_save;
  82. }
  83. void BSP_reset (void)
  84. {
  85. local_irq_disable();
  86. asm volatile (
  87. "moveal #_start, %a0;\n"
  88. "moveb #0, 0xFFFFF300;\n"
  89. "moveal 0(%a0), %sp;\n"
  90. "moveal 4(%a0), %a0;\n"
  91. "jmp (%a0);\n"
  92. );
  93. }
  94. unsigned char *scc1_hwaddr;
  95. static int errno;
  96. #if defined (CONFIG_UCQUICC)
  97. _bsc0(char *, getserialnum)
  98. _bsc1(unsigned char *, gethwaddr, int, a)
  99. _bsc1(char *, getbenv, char *, a)
  100. #endif
  101. void __init config_BSP(char *command, int len)
  102. {
  103. unsigned char *p;
  104. m360_cpm_reset();
  105. /* Calculate the real system clock value. */
  106. {
  107. unsigned int local_pllcr = (unsigned int)(pquicc->sim_pllcr);
  108. if( local_pllcr & MCU_PREEN ) // If the prescaler is dividing by 128
  109. {
  110. int mf = (int)(pquicc->sim_pllcr & 0x0fff);
  111. system_clock = (OSCILLATOR / 128) * (mf + 1);
  112. }
  113. else
  114. {
  115. int mf = (int)(pquicc->sim_pllcr & 0x0fff);
  116. system_clock = (OSCILLATOR) * (mf + 1);
  117. }
  118. }
  119. printk(KERN_INFO "\n68360 QUICC support (C) 2000 Lineo Inc.\n");
  120. #if defined(CONFIG_UCQUICC) && 0
  121. printk(KERN_INFO "uCquicc serial string [%s]\n",getserialnum());
  122. p = scc1_hwaddr = gethwaddr(0);
  123. printk(KERN_INFO "uCquicc hwaddr %pM\n", p);
  124. p = getbenv("APPEND");
  125. if (p)
  126. strcpy(p,command);
  127. else
  128. command[0] = 0;
  129. #else
  130. scc1_hwaddr = "\00\01\02\03\04\05";
  131. #endif
  132. mach_reset = BSP_reset;
  133. }