tx4927_setup.c 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230
  1. /*
  2. * Author: MontaVista Software, Inc.
  3. * source@mvista.com
  4. *
  5. * Copyright 2001-2002 MontaVista Software Inc.
  6. *
  7. * This program is free software; you can redistribute it and/or modify it
  8. * under the terms of the GNU General Public License as published by the
  9. * Free Software Foundation; either version 2 of the License, or (at your
  10. * option) any later version.
  11. *
  12. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
  13. * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
  14. * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  15. * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
  16. * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
  17. * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
  18. * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  19. * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
  20. * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
  21. * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  22. *
  23. * You should have received a copy of the GNU General Public License along
  24. * with this program; if not, write to the Free Software Foundation, Inc.,
  25. * 675 Mass Ave, Cambridge, MA 02139, USA.
  26. */
  27. #include <linux/errno.h>
  28. #include <linux/init.h>
  29. #include <linux/kernel_stat.h>
  30. #include <linux/module.h>
  31. #include <linux/signal.h>
  32. #include <linux/sched.h>
  33. #include <linux/types.h>
  34. #include <linux/interrupt.h>
  35. #include <linux/ioport.h>
  36. #include <linux/timex.h>
  37. #include <linux/slab.h>
  38. #include <linux/random.h>
  39. #include <linux/irq.h>
  40. #include <linux/bitops.h>
  41. #include <asm/bootinfo.h>
  42. #include <asm/io.h>
  43. #include <asm/irq.h>
  44. #include <asm/mipsregs.h>
  45. #include <asm/system.h>
  46. #include <asm/time.h>
  47. #include <asm/tx4927/tx4927.h>
  48. #undef DEBUG
  49. void __init tx4927_time_init(void);
  50. void dump_cp0(char *key);
  51. void (*__wbflush) (void);
  52. static void tx4927_write_buffer_flush(void)
  53. {
  54. __asm__ __volatile__
  55. ("sync\n\t" "nop\n\t" "loop: bc0f loop\n\t" "nop\n\t");
  56. }
  57. void __init plat_mem_setup(void)
  58. {
  59. board_time_init = tx4927_time_init;
  60. __wbflush = tx4927_write_buffer_flush;
  61. #ifdef CONFIG_TOSHIBA_RBTX4927
  62. {
  63. extern void toshiba_rbtx4927_setup(void);
  64. toshiba_rbtx4927_setup();
  65. }
  66. #endif
  67. }
  68. void __init tx4927_time_init(void)
  69. {
  70. #ifdef CONFIG_TOSHIBA_RBTX4927
  71. {
  72. extern void toshiba_rbtx4927_time_init(void);
  73. toshiba_rbtx4927_time_init();
  74. }
  75. #endif
  76. return;
  77. }
  78. void __init plat_timer_setup(struct irqaction *irq)
  79. {
  80. u32 count;
  81. u32 c1;
  82. u32 c2;
  83. setup_irq(TX4927_IRQ_CPU_TIMER, irq);
  84. /* to generate the first timer interrupt */
  85. c1 = read_c0_count();
  86. count = c1 + (mips_hpt_frequency / HZ);
  87. write_c0_compare(count);
  88. c2 = read_c0_count();
  89. #ifdef CONFIG_TOSHIBA_RBTX4927
  90. {
  91. extern void toshiba_rbtx4927_timer_setup(struct irqaction
  92. *irq);
  93. toshiba_rbtx4927_timer_setup(irq);
  94. }
  95. #endif
  96. return;
  97. }
  98. #ifdef DEBUG
  99. void print_cp0(char *key, int num, char *name, u32 val)
  100. {
  101. printk("%s cp0:%02d:%s=0x%08x\n", key, num, name, val);
  102. return;
  103. }
  104. indent: Standard input:25: Error:Unexpected end of file
  105. void
  106. dump_cp0(char *key)
  107. {
  108. if (key == NULL)
  109. key = "";
  110. print_cp0(key, 0, "INDEX ", read_c0_index());
  111. print_cp0(key, 2, "ENTRYLO1", read_c0_entrylo0());
  112. print_cp0(key, 3, "ENTRYLO2", read_c0_entrylo1());
  113. print_cp0(key, 4, "CONTEXT ", read_c0_context());
  114. print_cp0(key, 5, "PAGEMASK", read_c0_pagemask());
  115. print_cp0(key, 6, "WIRED ", read_c0_wired());
  116. //print_cp0(key, 8, "BADVADDR", read_c0_badvaddr());
  117. print_cp0(key, 9, "COUNT ", read_c0_count());
  118. print_cp0(key, 10, "ENTRYHI ", read_c0_entryhi());
  119. print_cp0(key, 11, "COMPARE ", read_c0_compare());
  120. print_cp0(key, 12, "STATUS ", read_c0_status());
  121. print_cp0(key, 13, "CAUSE ", read_c0_cause() & 0xffff87ff);
  122. print_cp0(key, 16, "CONFIG ", read_c0_config());
  123. return;
  124. }
  125. void print_pic(char *key, u32 reg, char *name)
  126. {
  127. printk("%s pic:0x%08x:%s=0x%08x\n", key, reg, name,
  128. TX4927_RD(reg));
  129. return;
  130. }
  131. void dump_pic(char *key)
  132. {
  133. if (key == NULL)
  134. key = "";
  135. print_pic(key, 0xff1ff600, "IRDEN ");
  136. print_pic(key, 0xff1ff604, "IRDM0 ");
  137. print_pic(key, 0xff1ff608, "IRDM1 ");
  138. print_pic(key, 0xff1ff610, "IRLVL0 ");
  139. print_pic(key, 0xff1ff614, "IRLVL1 ");
  140. print_pic(key, 0xff1ff618, "IRLVL2 ");
  141. print_pic(key, 0xff1ff61c, "IRLVL3 ");
  142. print_pic(key, 0xff1ff620, "IRLVL4 ");
  143. print_pic(key, 0xff1ff624, "IRLVL5 ");
  144. print_pic(key, 0xff1ff628, "IRLVL6 ");
  145. print_pic(key, 0xff1ff62c, "IRLVL7 ");
  146. print_pic(key, 0xff1ff640, "IRMSK ");
  147. print_pic(key, 0xff1ff660, "IREDC ");
  148. print_pic(key, 0xff1ff680, "IRPND ");
  149. print_pic(key, 0xff1ff6a0, "IRCS ");
  150. print_pic(key, 0xff1ff514, "IRFLAG1 "); /* don't read IRLAG0 -- it hangs system */
  151. print_pic(key, 0xff1ff518, "IRPOL ");
  152. print_pic(key, 0xff1ff51c, "IRRCNT ");
  153. print_pic(key, 0xff1ff520, "IRMASKINT");
  154. print_pic(key, 0xff1ff524, "IRMASKEXT");
  155. return;
  156. }
  157. void print_addr(char *hdr, char *key, u32 addr)
  158. {
  159. printk("%s %s:0x%08x=0x%08x\n", hdr, key, addr, TX4927_RD(addr));
  160. return;
  161. }
  162. void dump_180(char *key)
  163. {
  164. u32 i;
  165. for (i = 0x80000180; i < 0x80000180 + 0x80; i += 4) {
  166. print_addr("180", key, i);
  167. }
  168. return;
  169. }
  170. void dump_eh0(char *key)
  171. {
  172. int i;
  173. extern unsigned long exception_handlers[];
  174. for (i = (int) exception_handlers;
  175. i < (int) (exception_handlers + 20); i += 4) {
  176. print_addr("eh0", key, i);
  177. }
  178. return;
  179. }
  180. void pk0(void)
  181. {
  182. volatile u32 val;
  183. __asm__ __volatile__("ori %0, $26, 0":"=r"(val)
  184. );
  185. printk("k0=[0x%08x]\n", val);
  186. }
  187. #endif