wbflush.c 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  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/export.h>
  17. #include <linux/init.h>
  18. #include <asm/bootinfo.h>
  19. #include <asm/wbflush.h>
  20. #include <asm/barrier.h>
  21. static void wbflush_kn01(void);
  22. static void wbflush_kn210(void);
  23. static void wbflush_mips(void);
  24. void (*__wbflush) (void);
  25. void __init wbflush_setup(void)
  26. {
  27. switch (mips_machtype) {
  28. case MACH_DS23100:
  29. case MACH_DS5000_200: /* DS5000 3max */
  30. __wbflush = wbflush_kn01;
  31. break;
  32. case MACH_DS5100: /* DS5100 MIPSMATE */
  33. __wbflush = wbflush_kn210;
  34. break;
  35. case MACH_DS5000_1XX: /* DS5000/100 3min */
  36. case MACH_DS5000_XX: /* Personal DS5000/2x */
  37. case MACH_DS5000_2X0: /* DS5000/240 3max+ */
  38. case MACH_DS5900: /* DS5900 bigmax */
  39. default:
  40. __wbflush = wbflush_mips;
  41. break;
  42. }
  43. }
  44. /*
  45. * For the DS3100 and DS5000/200 the R2020/R3220 writeback buffer functions
  46. * as part of Coprocessor 0.
  47. */
  48. static void wbflush_kn01(void)
  49. {
  50. asm(".set\tpush\n\t"
  51. ".set\tnoreorder\n\t"
  52. "1:\tbc0f\t1b\n\t"
  53. "nop\n\t"
  54. ".set\tpop");
  55. }
  56. /*
  57. * For the DS5100 the writeback buffer seems to be a part of Coprocessor 3.
  58. * But CP3 has to enabled first.
  59. */
  60. static void wbflush_kn210(void)
  61. {
  62. asm(".set\tpush\n\t"
  63. ".set\tnoreorder\n\t"
  64. "mfc0\t$2,$12\n\t"
  65. "lui\t$3,0x8000\n\t"
  66. "or\t$3,$2,$3\n\t"
  67. "mtc0\t$3,$12\n\t"
  68. "nop\n"
  69. "1:\tbc3f\t1b\n\t"
  70. "nop\n\t"
  71. "mtc0\t$2,$12\n\t"
  72. "nop\n\t"
  73. ".set\tpop"
  74. : : : "$2", "$3");
  75. }
  76. /*
  77. * I/O ASIC systems use a standard writeback buffer that gets flushed
  78. * upon an uncached read.
  79. */
  80. static void wbflush_mips(void)
  81. {
  82. __fast_iob();
  83. }
  84. EXPORT_SYMBOL(__wbflush);