tc.c 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. /*
  2. * TURBOchannel architecture calls.
  3. *
  4. * Copyright (c) Harald Koerfgen, 1998
  5. * Copyright (c) 2001, 2003, 2005, 2006 Maciej W. Rozycki
  6. * Copyright (c) 2005 James Simmons
  7. *
  8. * This file is subject to the terms and conditions of the GNU
  9. * General Public License. See the file "COPYING" in the main
  10. * directory of this archive for more details.
  11. */
  12. #include <linux/compiler.h>
  13. #include <linux/errno.h>
  14. #include <linux/init.h>
  15. #include <linux/string.h>
  16. #include <linux/tc.h>
  17. #include <linux/types.h>
  18. #include <asm/addrspace.h>
  19. #include <asm/bootinfo.h>
  20. #include <asm/paccess.h>
  21. #include <asm/dec/interrupts.h>
  22. #include <asm/dec/prom.h>
  23. #include <asm/dec/system.h>
  24. /*
  25. * Protected read byte from TURBOchannel slot space.
  26. */
  27. int tc_preadb(u8 *valp, void __iomem *addr)
  28. {
  29. return get_dbe(*valp, (u8 *)addr);
  30. }
  31. /*
  32. * Get TURBOchannel bus information as specified by the spec, plus
  33. * the slot space base address and the number of slots.
  34. */
  35. int __init tc_bus_get_info(struct tc_bus *tbus)
  36. {
  37. if (!dec_tc_bus)
  38. return -ENXIO;
  39. memcpy(&tbus->info, rex_gettcinfo(), sizeof(tbus->info));
  40. tbus->slot_base = CPHYSADDR((long)rex_slot_address(0));
  41. switch (mips_machtype) {
  42. case MACH_DS5000_200:
  43. tbus->num_tcslots = 7;
  44. break;
  45. case MACH_DS5000_2X0:
  46. case MACH_DS5900:
  47. tbus->ext_slot_base = 0x20000000;
  48. tbus->ext_slot_size = 0x20000000;
  49. /* fall through */
  50. case MACH_DS5000_1XX:
  51. tbus->num_tcslots = 3;
  52. break;
  53. case MACH_DS5000_XX:
  54. tbus->num_tcslots = 2;
  55. default:
  56. break;
  57. }
  58. return 0;
  59. }
  60. /*
  61. * Get the IRQ for the specified slot.
  62. */
  63. void __init tc_device_get_irq(struct tc_dev *tdev)
  64. {
  65. switch (tdev->slot) {
  66. case 0:
  67. tdev->interrupt = dec_interrupt[DEC_IRQ_TC0];
  68. break;
  69. case 1:
  70. tdev->interrupt = dec_interrupt[DEC_IRQ_TC1];
  71. break;
  72. case 2:
  73. tdev->interrupt = dec_interrupt[DEC_IRQ_TC2];
  74. break;
  75. /*
  76. * Yuck! DS5000/200 onboard devices
  77. */
  78. case 5:
  79. tdev->interrupt = dec_interrupt[DEC_IRQ_TC5];
  80. break;
  81. case 6:
  82. tdev->interrupt = dec_interrupt[DEC_IRQ_TC6];
  83. break;
  84. default:
  85. tdev->interrupt = -1;
  86. break;
  87. }
  88. }