wbflush.c 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. /*
  2. * Setup the right wbflush routine for the different DECstations.
  3. *
  4. * Created with information from:
  5. * DECstation 3100 Desktop Workstation Functional Specification
  6. * DECstation 5000/200 KN02 System Module Functional Specification
  7. * mipsel-linux-objdump --disassemble vmunix | grep "wbflush" :-)
  8. *
  9. * This file is subject to the terms and conditions of the GNU General Public
  10. * License. See the file "COPYING" in the main directory of this archive
  11. * for more details.
  12. *
  13. * Copyright (C) 1998 Harald Koerfgen
  14. * Copyright (C) 2002 Maciej W. Rozycki
  15. */
  16. #include <linux/init.h>
  17. #include <asm/bootinfo.h>
  18. #include <asm/wbflush.h>
  19. #include <asm/barrier.h>
  20. static void wbflush_kn01(void);
  21. static void wbflush_kn210(void);
  22. static void wbflush_mips(void);
  23. void (*__wbflush) (void);
  24. void __init wbflush_setup(void)
  25. {
  26. switch (mips_machtype) {
  27. case MACH_DS23100:
  28. case MACH_DS5000_200: /* DS5000 3max */
  29. __wbflush = wbflush_kn01;
  30. break;
  31. case MACH_DS5100: /* DS5100 MIPSMATE */
  32. __wbflush = wbflush_kn210;
  33. break;
  34. case MACH_DS5000_1XX: /* DS5000/100 3min */
  35. case MACH_DS5000_XX: /* Personal DS5000/2x */
  36. case MACH_DS5000_2X0: /* DS5000/240 3max+ */
  37. case MACH_DS5900: /* DS5900 bigmax */
  38. default:
  39. __wbflush = wbflush_mips;
  40. break;
  41. }
  42. }
  43. /*
  44. * For the DS3100 and DS5000/200 the R2020/R3220 writeback buffer functions
  45. * as part of Coprocessor 0.
  46. */
  47. static void wbflush_kn01(void)
  48. {
  49. asm(".set\tpush\n\t"
  50. ".set\tnoreorder\n\t"
  51. "1:\tbc0f\t1b\n\t"
  52. "nop\n\t"
  53. ".set\tpop");
  54. }
  55. /*
  56. * For the DS5100 the writeback buffer seems to be a part of Coprocessor 3.
  57. * But CP3 has to enabled first.
  58. */
  59. static void wbflush_kn210(void)
  60. {
  61. asm(".set\tpush\n\t"
  62. ".set\tnoreorder\n\t"
  63. "mfc0\t$2,$12\n\t"
  64. "lui\t$3,0x8000\n\t"
  65. "or\t$3,$2,$3\n\t"
  66. "mtc0\t$3,$12\n\t"
  67. "nop\n"
  68. "1:\tbc3f\t1b\n\t"
  69. "nop\n\t"
  70. "mtc0\t$2,$12\n\t"
  71. "nop\n\t"
  72. ".set\tpop"
  73. : : : "$2", "$3");
  74. }
  75. /*
  76. * I/O ASIC systems use a standard writeback buffer that gets flushed
  77. * upon an uncached read.
  78. */
  79. static void wbflush_mips(void)
  80. {
  81. __fast_iob();
  82. }
  83. #include <linux/module.h>
  84. EXPORT_SYMBOL(__wbflush);