config.c 4.4 KB

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