calgary.h 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. /*
  2. * Derived from include/asm-powerpc/iommu.h
  3. *
  4. * Copyright (C) 2006 Jon Mason <jdmason@us.ibm.com>, IBM Corporation
  5. * Copyright (C) 2006 Muli Ben-Yehuda <muli@il.ibm.com>, IBM Corporation
  6. *
  7. * This program is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License as published by
  9. * the Free Software Foundation; either version 2 of the License, or
  10. * (at your option) any later version.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this program; if not, write to the Free Software
  19. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  20. */
  21. #ifndef _ASM_X86_64_CALGARY_H
  22. #define _ASM_X86_64_CALGARY_H
  23. #include <linux/config.h>
  24. #include <linux/spinlock.h>
  25. #include <linux/device.h>
  26. #include <linux/dma-mapping.h>
  27. #include <asm/types.h>
  28. struct iommu_table {
  29. unsigned long it_base; /* mapped address of tce table */
  30. unsigned long it_hint; /* Hint for next alloc */
  31. unsigned long *it_map; /* A simple allocation bitmap for now */
  32. spinlock_t it_lock; /* Protects it_map */
  33. unsigned int it_size; /* Size of iommu table in entries */
  34. unsigned char it_busno; /* Bus number this table belongs to */
  35. void __iomem *bbar;
  36. u64 tar_val;
  37. struct timer_list watchdog_timer;
  38. };
  39. #define TCE_TABLE_SIZE_UNSPECIFIED ~0
  40. #define TCE_TABLE_SIZE_64K 0
  41. #define TCE_TABLE_SIZE_128K 1
  42. #define TCE_TABLE_SIZE_256K 2
  43. #define TCE_TABLE_SIZE_512K 3
  44. #define TCE_TABLE_SIZE_1M 4
  45. #define TCE_TABLE_SIZE_2M 5
  46. #define TCE_TABLE_SIZE_4M 6
  47. #define TCE_TABLE_SIZE_8M 7
  48. #ifdef CONFIG_CALGARY_IOMMU
  49. extern int calgary_iommu_init(void);
  50. extern void detect_calgary(void);
  51. #else
  52. static inline int calgary_iommu_init(void) { return 1; }
  53. static inline void detect_calgary(void) { return; }
  54. #endif
  55. static inline unsigned int bus_to_phb(unsigned char busno)
  56. {
  57. return ((busno % 15 == 0) ? 0 : busno / 2 + 1);
  58. }
  59. #endif /* _ASM_X86_64_CALGARY_H */