1 | /* |
---|
2 | * This program is free software; you can redistribute it and/or modify |
---|
3 | * it under the terms of the GNU General Public License as published by |
---|
4 | * the Free Software Foundation; either version 2 of the License, or |
---|
5 | * (at your option) any later version. |
---|
6 | * |
---|
7 | * This program is distributed in the hope that it will be useful, |
---|
8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
10 | * GNU General Public License for more details. |
---|
11 | * |
---|
12 | * You should have received a copy of the GNU General Public License |
---|
13 | * along with this program; if not, write to the Free Software |
---|
14 | * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
---|
15 | * |
---|
16 | * Copyright (C) IBM Corp. 2005 |
---|
17 | * |
---|
18 | * Authors: Jimi Xenidis <jimix@watson.ibm.com> |
---|
19 | */ |
---|
20 | |
---|
21 | #undef DEBUG |
---|
22 | |
---|
23 | #include <xen/config.h> |
---|
24 | #include <xen/types.h> |
---|
25 | #include <xen/sched.h> |
---|
26 | #include <xen/mm.h> |
---|
27 | #include <public/xen.h> |
---|
28 | #include <asm/io.h> |
---|
29 | #include <asm/current.h> |
---|
30 | #include "tce.h" |
---|
31 | #include "iommu.h" |
---|
32 | #include "dart.h" |
---|
33 | |
---|
34 | union dart_ctl { |
---|
35 | u32 dc_word; |
---|
36 | struct { |
---|
37 | u32 dc_base:20; |
---|
38 | u32 dc_stop_access:1; |
---|
39 | u32 dc_invtlb:1; |
---|
40 | u32 dc_enable:1; |
---|
41 | u32 dc_size:9; |
---|
42 | } reg; |
---|
43 | }; |
---|
44 | |
---|
45 | static u32 volatile *dart_ctl_reg; |
---|
46 | |
---|
47 | static void u3_inv_all(void) |
---|
48 | { |
---|
49 | union dart_ctl dc; |
---|
50 | ulong r = 0; |
---|
51 | int l = 0; |
---|
52 | |
---|
53 | for (;;) { |
---|
54 | dc.dc_word = in_32(dart_ctl_reg); |
---|
55 | dc.reg.dc_invtlb = 1; |
---|
56 | out_32(dart_ctl_reg, dc.dc_word); |
---|
57 | |
---|
58 | do { |
---|
59 | dc.dc_word = in_32(dart_ctl_reg); |
---|
60 | r++; |
---|
61 | } while ((dc.reg.dc_invtlb == 1) && (r < (1 << l))); |
---|
62 | |
---|
63 | if (r == (1 << l)) { |
---|
64 | if (l < 4) { |
---|
65 | l++; |
---|
66 | dc.dc_word = in_32(dart_ctl_reg); |
---|
67 | dc.reg.dc_invtlb = 0; |
---|
68 | out_32(dart_ctl_reg, dc.dc_word); |
---|
69 | continue; |
---|
70 | } else { |
---|
71 | panic(" broken U3???\n"); |
---|
72 | } |
---|
73 | } |
---|
74 | return; |
---|
75 | } |
---|
76 | } |
---|
77 | |
---|
78 | static void u3_inv_entry(ulong pg) |
---|
79 | { |
---|
80 | /* sadly single entry invalidation has been reported not to work */ |
---|
81 | u3_inv_all(); |
---|
82 | } |
---|
83 | |
---|
84 | static struct dart_ops u3_ops = { |
---|
85 | .do_inv_all = u3_inv_all, |
---|
86 | .do_inv_entry = u3_inv_entry, |
---|
87 | }; |
---|
88 | |
---|
89 | struct dart_ops *u3_init(ulong base, ulong table, ulong dart_pages) |
---|
90 | { |
---|
91 | union dart_ctl dc; |
---|
92 | |
---|
93 | dart_ctl_reg = (u32 *)base; |
---|
94 | |
---|
95 | dc.dc_word = 0; |
---|
96 | |
---|
97 | dc.reg.dc_base = table >> PAGE_SHIFT; |
---|
98 | dc.reg.dc_size = dart_pages; |
---|
99 | dc.reg.dc_enable = 1; |
---|
100 | |
---|
101 | |
---|
102 | printk("Initializing DART Model U3: reg: %p word: %x\n", |
---|
103 | dart_ctl_reg, dc.dc_word); |
---|
104 | |
---|
105 | out_32(dart_ctl_reg, dc.dc_word); |
---|
106 | |
---|
107 | return &u3_ops; |
---|
108 | } |
---|