0001
0002
0003
0004
0005
0006 #ifndef _SPARC_IOMMU_H
0007 #define _SPARC_IOMMU_H
0008
0009 #include <asm/page.h>
0010 #include <asm/bitext.h>
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022 struct iommu_regs {
0023
0024 volatile unsigned long control;
0025 volatile unsigned long base;
0026 volatile unsigned long _unused1[3];
0027 volatile unsigned long tlbflush;
0028 volatile unsigned long pageflush;
0029 volatile unsigned long _unused2[1017];
0030
0031 volatile unsigned long afsr;
0032 volatile unsigned long afar;
0033 volatile unsigned long _unused3[2];
0034 volatile unsigned long sbuscfg0;
0035 volatile unsigned long sbuscfg1;
0036 volatile unsigned long sbuscfg2;
0037 volatile unsigned long sbuscfg3;
0038 volatile unsigned long mfsr;
0039 volatile unsigned long mfar;
0040 volatile unsigned long _unused4[1014];
0041
0042 volatile unsigned long mid;
0043 };
0044
0045 #define IOMMU_CTRL_IMPL 0xf0000000
0046 #define IOMMU_CTRL_VERS 0x0f000000
0047 #define IOMMU_CTRL_RNGE 0x0000001c
0048 #define IOMMU_RNGE_16MB 0x00000000
0049 #define IOMMU_RNGE_32MB 0x00000004
0050 #define IOMMU_RNGE_64MB 0x00000008
0051 #define IOMMU_RNGE_128MB 0x0000000c
0052 #define IOMMU_RNGE_256MB 0x00000010
0053 #define IOMMU_RNGE_512MB 0x00000014
0054 #define IOMMU_RNGE_1GB 0x00000018
0055 #define IOMMU_RNGE_2GB 0x0000001c
0056 #define IOMMU_CTRL_ENAB 0x00000001
0057
0058 #define IOMMU_AFSR_ERR 0x80000000
0059 #define IOMMU_AFSR_LE 0x40000000
0060 #define IOMMU_AFSR_TO 0x20000000
0061 #define IOMMU_AFSR_BE 0x10000000
0062 #define IOMMU_AFSR_SIZE 0x0e000000
0063 #define IOMMU_AFSR_S 0x01000000
0064 #define IOMMU_AFSR_RESV 0x00f00000
0065 #define IOMMU_AFSR_ME 0x00080000
0066 #define IOMMU_AFSR_RD 0x00040000
0067 #define IOMMU_AFSR_FAV 0x00020000
0068
0069 #define IOMMU_SBCFG_SAB30 0x00010000
0070 #define IOMMU_SBCFG_BA16 0x00000004
0071 #define IOMMU_SBCFG_BA8 0x00000002
0072 #define IOMMU_SBCFG_BYPASS 0x00000001
0073
0074
0075
0076 #define IOMMU_MFSR_ERR 0x80000000
0077 #define IOMMU_MFSR_S 0x01000000
0078 #define IOMMU_MFSR_CPU 0x00800000
0079 #define IOMMU_MFSR_ME 0x00080000
0080 #define IOMMU_MFSR_PERR 0x00006000
0081
0082
0083 #define IOMMU_MFSR_BM 0x00001000
0084 #define IOMMU_MFSR_C 0x00000800
0085 #define IOMMU_MFSR_RTYP 0x000000f0
0086
0087 #define IOMMU_MID_SBAE 0x001f0000
0088 #define IOMMU_MID_SE 0x00100000
0089 #define IOMMU_MID_SB3 0x00080000
0090 #define IOMMU_MID_SB2 0x00040000
0091 #define IOMMU_MID_SB1 0x00020000
0092 #define IOMMU_MID_SB0 0x00010000
0093 #define IOMMU_MID_MID 0x0000000f
0094
0095
0096 #define IOPTE_PAGE 0x07ffff00
0097 #define IOPTE_CACHE 0x00000080
0098 #define IOPTE_WRITE 0x00000004
0099 #define IOPTE_VALID 0x00000002
0100 #define IOPTE_WAZ 0x00000001
0101
0102 struct iommu_struct {
0103 struct iommu_regs __iomem *regs;
0104 iopte_t *page_table;
0105
0106 unsigned long start;
0107 unsigned long end;
0108
0109 struct bit_map usemap;
0110 };
0111
0112 static inline void iommu_invalidate(struct iommu_regs __iomem *regs)
0113 {
0114 sbus_writel(0, ®s->tlbflush);
0115 }
0116
0117 static inline void iommu_invalidate_page(struct iommu_regs __iomem *regs, unsigned long ba)
0118 {
0119 sbus_writel(ba & PAGE_MASK, ®s->pageflush);
0120 }
0121
0122 #endif