blob: 2f73ddc8676d62be9d8d557d6facfe6369743f84 [file] [log] [blame]
David S. Millerb28422e2008-08-24 21:32:42 -07001/* chmc.c: Driver for UltraSPARC-III memory controller.
Linus Torvalds1da177e2005-04-16 15:20:36 -07002 *
David S. Millerb28422e2008-08-24 21:32:42 -07003 * Copyright (C) 2001, 2007, 2008 David S. Miller (davem@davemloft.net)
Linus Torvalds1da177e2005-04-16 15:20:36 -07004 */
5
6#include <linux/module.h>
7#include <linux/kernel.h>
8#include <linux/types.h>
9#include <linux/slab.h>
10#include <linux/list.h>
11#include <linux/string.h>
12#include <linux/sched.h>
13#include <linux/smp.h>
14#include <linux/errno.h>
15#include <linux/init.h>
David S. Millerb28422e2008-08-24 21:32:42 -070016#include <linux/of.h>
17#include <linux/of_device.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070018#include <asm/spitfire.h>
19#include <asm/chmctrl.h>
David S. Millerb332b8b2007-12-07 00:58:55 -080020#include <asm/cpudata.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070021#include <asm/oplib.h>
David S. Miller44bdef52006-06-22 20:04:30 -070022#include <asm/prom.h>
David S. Millerb28422e2008-08-24 21:32:42 -070023#include <asm/head.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070024#include <asm/io.h>
25
David S. Millerb28422e2008-08-24 21:32:42 -070026#define DRV_MODULE_NAME "chmc"
27#define PFX DRV_MODULE_NAME ": "
28#define DRV_MODULE_VERSION "0.2"
29
30MODULE_AUTHOR("David S. Miller (davem@davemloft.net)");
31MODULE_DESCRIPTION("UltraSPARC-III memory controller driver");
32MODULE_LICENSE("GPL");
33MODULE_VERSION(DRV_MODULE_VERSION);
34
Linus Torvalds1da177e2005-04-16 15:20:36 -070035#define CHMCTRL_NDGRPS 2
36#define CHMCTRL_NDIMMS 4
37
David S. Miller83ef64b2008-08-24 21:45:44 -070038#define CHMC_DIMMS_PER_MC (CHMCTRL_NDGRPS * CHMCTRL_NDIMMS)
Linus Torvalds1da177e2005-04-16 15:20:36 -070039
40/* OBP memory-layout property format. */
David S. Miller83ef64b2008-08-24 21:45:44 -070041struct chmc_obp_map {
Linus Torvalds1da177e2005-04-16 15:20:36 -070042 unsigned char dimm_map[144];
43 unsigned char pin_map[576];
44};
45
46#define DIMM_LABEL_SZ 8
47
David S. Miller83ef64b2008-08-24 21:45:44 -070048struct chmc_obp_mem_layout {
Linus Torvalds1da177e2005-04-16 15:20:36 -070049 /* One max 8-byte string label per DIMM. Usually
50 * this matches the label on the motherboard where
51 * that DIMM resides.
52 */
David S. Miller83ef64b2008-08-24 21:45:44 -070053 char dimm_labels[CHMC_DIMMS_PER_MC][DIMM_LABEL_SZ];
Linus Torvalds1da177e2005-04-16 15:20:36 -070054
55 /* If symmetric use map[0], else it is
56 * asymmetric and map[1] should be used.
57 */
David S. Miller83ef64b2008-08-24 21:45:44 -070058 char symmetric;
Linus Torvalds1da177e2005-04-16 15:20:36 -070059
David S. Miller83ef64b2008-08-24 21:45:44 -070060 struct chmc_obp_map map[2];
Linus Torvalds1da177e2005-04-16 15:20:36 -070061};
62
63#define CHMCTRL_NBANKS 4
64
David S. Miller83ef64b2008-08-24 21:45:44 -070065struct chmc_bank_info {
66 struct chmc *p;
Linus Torvalds1da177e2005-04-16 15:20:36 -070067 int bank_id;
68
69 u64 raw_reg;
70 int valid;
71 int uk;
72 int um;
73 int lk;
74 int lm;
75 int interleave;
76 unsigned long base;
77 unsigned long size;
78};
79
David S. Miller83ef64b2008-08-24 21:45:44 -070080struct chmc {
81 struct list_head list;
82 int portid;
Linus Torvalds1da177e2005-04-16 15:20:36 -070083
David S. Miller83ef64b2008-08-24 21:45:44 -070084 struct chmc_obp_mem_layout layout_prop;
85 int layout_size;
Linus Torvalds1da177e2005-04-16 15:20:36 -070086
David S. Miller83ef64b2008-08-24 21:45:44 -070087 void __iomem *regs;
Linus Torvalds1da177e2005-04-16 15:20:36 -070088
David S. Miller83ef64b2008-08-24 21:45:44 -070089 u64 timing_control1;
90 u64 timing_control2;
91 u64 timing_control3;
92 u64 timing_control4;
93 u64 memaddr_control;
Linus Torvalds1da177e2005-04-16 15:20:36 -070094
David S. Miller83ef64b2008-08-24 21:45:44 -070095 struct chmc_bank_info logical_banks[CHMCTRL_NBANKS];
Linus Torvalds1da177e2005-04-16 15:20:36 -070096};
97
98static LIST_HEAD(mctrl_list);
99
100/* Does BANK decode PHYS_ADDR? */
David S. Miller83ef64b2008-08-24 21:45:44 -0700101static int chmc_bank_match(struct chmc_bank_info *bp, unsigned long phys_addr)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700102{
103 unsigned long upper_bits = (phys_addr & PA_UPPER_BITS) >> PA_UPPER_BITS_SHIFT;
104 unsigned long lower_bits = (phys_addr & PA_LOWER_BITS) >> PA_LOWER_BITS_SHIFT;
105
106 /* Bank must be enabled to match. */
107 if (bp->valid == 0)
108 return 0;
109
110 /* Would BANK match upper bits? */
111 upper_bits ^= bp->um; /* What bits are different? */
112 upper_bits = ~upper_bits; /* Invert. */
113 upper_bits |= bp->uk; /* What bits don't matter for matching? */
114 upper_bits = ~upper_bits; /* Invert. */
115
116 if (upper_bits)
117 return 0;
118
119 /* Would BANK match lower bits? */
120 lower_bits ^= bp->lm; /* What bits are different? */
121 lower_bits = ~lower_bits; /* Invert. */
122 lower_bits |= bp->lk; /* What bits don't matter for matching? */
123 lower_bits = ~lower_bits; /* Invert. */
124
125 if (lower_bits)
126 return 0;
127
128 /* I always knew you'd be the one. */
129 return 1;
130}
131
132/* Given PHYS_ADDR, search memory controller banks for a match. */
David S. Miller83ef64b2008-08-24 21:45:44 -0700133static struct chmc_bank_info *chmc_find_bank(unsigned long phys_addr)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700134{
135 struct list_head *mctrl_head = &mctrl_list;
136 struct list_head *mctrl_entry = mctrl_head->next;
137
138 for (;;) {
David S. Miller83ef64b2008-08-24 21:45:44 -0700139 struct chmc *p = list_entry(mctrl_entry, struct chmc, list);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700140 int bank_no;
141
142 if (mctrl_entry == mctrl_head)
143 break;
144 mctrl_entry = mctrl_entry->next;
145
146 for (bank_no = 0; bank_no < CHMCTRL_NBANKS; bank_no++) {
David S. Miller83ef64b2008-08-24 21:45:44 -0700147 struct chmc_bank_info *bp;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700148
David S. Miller83ef64b2008-08-24 21:45:44 -0700149 bp = &p->logical_banks[bank_no];
150 if (chmc_bank_match(bp, phys_addr))
Linus Torvalds1da177e2005-04-16 15:20:36 -0700151 return bp;
152 }
153 }
154
155 return NULL;
156}
157
158/* This is the main purpose of this driver. */
159#define SYNDROME_MIN -1
160#define SYNDROME_MAX 144
161int chmc_getunumber(int syndrome_code,
162 unsigned long phys_addr,
163 char *buf, int buflen)
164{
David S. Miller83ef64b2008-08-24 21:45:44 -0700165 struct chmc_bank_info *bp;
166 struct chmc_obp_mem_layout *prop;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700167 int bank_in_controller, first_dimm;
168
David S. Miller83ef64b2008-08-24 21:45:44 -0700169 bp = chmc_find_bank(phys_addr);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700170 if (bp == NULL ||
171 syndrome_code < SYNDROME_MIN ||
172 syndrome_code > SYNDROME_MAX) {
173 buf[0] = '?';
174 buf[1] = '?';
175 buf[2] = '?';
176 buf[3] = '\0';
177 return 0;
178 }
179
David S. Miller83ef64b2008-08-24 21:45:44 -0700180 prop = &bp->p->layout_prop;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700181 bank_in_controller = bp->bank_id & (CHMCTRL_NBANKS - 1);
182 first_dimm = (bank_in_controller & (CHMCTRL_NDGRPS - 1));
183 first_dimm *= CHMCTRL_NDIMMS;
184
185 if (syndrome_code != SYNDROME_MIN) {
David S. Miller83ef64b2008-08-24 21:45:44 -0700186 struct chmc_obp_map *map;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700187 int qword, where_in_line, where, map_index, map_offset;
188 unsigned int map_val;
189
190 /* Yaay, single bit error so we can figure out
191 * the exact dimm.
192 */
193 if (prop->symmetric)
194 map = &prop->map[0];
195 else
196 map = &prop->map[1];
197
198 /* Covert syndrome code into the way the bits are
199 * positioned on the bus.
200 */
201 if (syndrome_code < 144 - 16)
202 syndrome_code += 16;
203 else if (syndrome_code < 144)
204 syndrome_code -= (144 - 7);
205 else if (syndrome_code < (144 + 3))
206 syndrome_code -= (144 + 3 - 4);
207 else
208 syndrome_code -= 144 + 3;
209
210 /* All this magic has to do with how a cache line
211 * comes over the wire on Safari. A 64-bit line
212 * comes over in 4 quadword cycles, each of which
213 * transmit ECC/MTAG info as well as the actual
214 * data. 144 bits per quadword, 576 total.
215 */
216#define LINE_SIZE 64
217#define LINE_ADDR_MSK (LINE_SIZE - 1)
218#define QW_PER_LINE 4
219#define QW_BYTES (LINE_SIZE / QW_PER_LINE)
220#define QW_BITS 144
221#define LAST_BIT (576 - 1)
222
223 qword = (phys_addr & LINE_ADDR_MSK) / QW_BYTES;
224 where_in_line = ((3 - qword) * QW_BITS) + syndrome_code;
225 where = (LAST_BIT - where_in_line);
226 map_index = where >> 2;
227 map_offset = where & 0x3;
228 map_val = map->dimm_map[map_index];
229 map_val = ((map_val >> ((3 - map_offset) << 1)) & (2 - 1));
230
231 sprintf(buf, "%s, pin %3d",
232 prop->dimm_labels[first_dimm + map_val],
233 map->pin_map[where_in_line]);
234 } else {
235 int dimm;
236
237 /* Multi-bit error, we just dump out all the
238 * dimm labels associated with this bank.
239 */
240 for (dimm = 0; dimm < CHMCTRL_NDIMMS; dimm++) {
241 sprintf(buf, "%s ",
242 prop->dimm_labels[first_dimm + dimm]);
243 buf += strlen(buf);
244 }
245 }
246 return 0;
247}
248
249/* Accessing the registers is slightly complicated. If you want
250 * to get at the memory controller which is on the same processor
251 * the code is executing, you must use special ASI load/store else
252 * you go through the global mapping.
253 */
David S. Miller83ef64b2008-08-24 21:45:44 -0700254static u64 chmc_read_mcreg(struct chmc *p, unsigned long offset)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700255{
David S. Millerb332b8b2007-12-07 00:58:55 -0800256 unsigned long ret, this_cpu;
257
258 preempt_disable();
259
260 this_cpu = real_hard_smp_processor_id();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700261
David S. Miller83ef64b2008-08-24 21:45:44 -0700262 if (p->portid == this_cpu) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700263 __asm__ __volatile__("ldxa [%1] %2, %0"
264 : "=r" (ret)
265 : "r" (offset), "i" (ASI_MCU_CTRL_REG));
266 } else {
267 __asm__ __volatile__("ldxa [%1] %2, %0"
268 : "=r" (ret)
David S. Miller83ef64b2008-08-24 21:45:44 -0700269 : "r" (p->regs + offset),
Linus Torvalds1da177e2005-04-16 15:20:36 -0700270 "i" (ASI_PHYS_BYPASS_EC_E));
271 }
David S. Millerb332b8b2007-12-07 00:58:55 -0800272
273 preempt_enable();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700274
275 return ret;
276}
277
278#if 0 /* currently unused */
David S. Miller83ef64b2008-08-24 21:45:44 -0700279static void chmc_write_mcreg(struct chmc *p, unsigned long offset, u64 val)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700280{
David S. Miller83ef64b2008-08-24 21:45:44 -0700281 if (p->portid == smp_processor_id()) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700282 __asm__ __volatile__("stxa %0, [%1] %2"
283 : : "r" (val),
284 "r" (offset), "i" (ASI_MCU_CTRL_REG));
285 } else {
286 __asm__ __volatile__("ldxa %0, [%1] %2"
287 : : "r" (val),
David S. Miller83ef64b2008-08-24 21:45:44 -0700288 "r" (p->regs + offset),
Linus Torvalds1da177e2005-04-16 15:20:36 -0700289 "i" (ASI_PHYS_BYPASS_EC_E));
290 }
291}
292#endif
293
David S. Miller83ef64b2008-08-24 21:45:44 -0700294static void chmc_interpret_one_decode_reg(struct chmc *p, int which_bank, u64 val)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700295{
David S. Miller83ef64b2008-08-24 21:45:44 -0700296 struct chmc_bank_info *bp = &p->logical_banks[which_bank];
Linus Torvalds1da177e2005-04-16 15:20:36 -0700297
David S. Miller83ef64b2008-08-24 21:45:44 -0700298 bp->p = p;
299 bp->bank_id = (CHMCTRL_NBANKS * p->portid) + which_bank;
300 bp->raw_reg = val;
301 bp->valid = (val & MEM_DECODE_VALID) >> MEM_DECODE_VALID_SHIFT;
302 bp->uk = (val & MEM_DECODE_UK) >> MEM_DECODE_UK_SHIFT;
303 bp->um = (val & MEM_DECODE_UM) >> MEM_DECODE_UM_SHIFT;
304 bp->lk = (val & MEM_DECODE_LK) >> MEM_DECODE_LK_SHIFT;
305 bp->lm = (val & MEM_DECODE_LM) >> MEM_DECODE_LM_SHIFT;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700306
David S. Miller83ef64b2008-08-24 21:45:44 -0700307 bp->base = (bp->um);
308 bp->base &= ~(bp->uk);
309 bp->base <<= PA_UPPER_BITS_SHIFT;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700310
David S. Miller83ef64b2008-08-24 21:45:44 -0700311 switch(bp->lk) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700312 case 0xf:
313 default:
David S. Miller83ef64b2008-08-24 21:45:44 -0700314 bp->interleave = 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700315 break;
316
317 case 0xe:
David S. Miller83ef64b2008-08-24 21:45:44 -0700318 bp->interleave = 2;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700319 break;
320
321 case 0xc:
David S. Miller83ef64b2008-08-24 21:45:44 -0700322 bp->interleave = 4;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700323 break;
324
325 case 0x8:
David S. Miller83ef64b2008-08-24 21:45:44 -0700326 bp->interleave = 8;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700327 break;
328
329 case 0x0:
David S. Miller83ef64b2008-08-24 21:45:44 -0700330 bp->interleave = 16;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700331 break;
332 };
333
334 /* UK[10] is reserved, and UK[11] is not set for the SDRAM
335 * bank size definition.
336 */
David S. Miller83ef64b2008-08-24 21:45:44 -0700337 bp->size = (((unsigned long)bp->uk &
338 ((1UL << 10UL) - 1UL)) + 1UL) << PA_UPPER_BITS_SHIFT;
339 bp->size /= bp->interleave;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700340}
341
David S. Miller83ef64b2008-08-24 21:45:44 -0700342static void chmc_fetch_decode_regs(struct chmc *p)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700343{
David S. Miller83ef64b2008-08-24 21:45:44 -0700344 if (p->layout_size == 0)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700345 return;
346
David S. Miller83ef64b2008-08-24 21:45:44 -0700347 chmc_interpret_one_decode_reg(p, 0,
348 chmc_read_mcreg(p, CHMCTRL_DECODE1));
349 chmc_interpret_one_decode_reg(p, 1,
350 chmc_read_mcreg(p, CHMCTRL_DECODE2));
351 chmc_interpret_one_decode_reg(p, 2,
352 chmc_read_mcreg(p, CHMCTRL_DECODE3));
353 chmc_interpret_one_decode_reg(p, 3,
354 chmc_read_mcreg(p, CHMCTRL_DECODE4));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700355}
356
David S. Millerb28422e2008-08-24 21:32:42 -0700357static int __devinit chmc_probe(struct of_device *op,
358 const struct of_device_id *match)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700359{
David S. Millerb28422e2008-08-24 21:32:42 -0700360 struct device_node *dp = op->node;
David S. Millerb28422e2008-08-24 21:32:42 -0700361 unsigned long ver;
Stephen Rothwell6a23acf2007-04-23 15:53:27 -0700362 const void *pval;
David S. Millerb28422e2008-08-24 21:32:42 -0700363 int len, portid;
David S. Miller83ef64b2008-08-24 21:45:44 -0700364 struct chmc *p;
365 int err;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700366
David S. Miller83ef64b2008-08-24 21:45:44 -0700367 err = -ENODEV;
David S. Millerb28422e2008-08-24 21:32:42 -0700368 __asm__ ("rdpr %%ver, %0" : "=r" (ver));
369 if ((ver >> 32UL) == __JALAPENO_ID ||
370 (ver >> 32UL) == __SERRANO_ID)
David S. Miller83ef64b2008-08-24 21:45:44 -0700371 goto out;
David S. Millerb28422e2008-08-24 21:32:42 -0700372
373 portid = of_getintprop_default(dp, "portid", -1);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700374 if (portid == -1)
David S. Miller83ef64b2008-08-24 21:45:44 -0700375 goto out;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700376
David S. Miller44bdef52006-06-22 20:04:30 -0700377 pval = of_get_property(dp, "memory-layout", &len);
David S. Miller83ef64b2008-08-24 21:45:44 -0700378 if (pval && len > sizeof(p->layout_prop)) {
379 printk(KERN_ERR PFX "Unexpected memory-layout property "
380 "size %d.\n", len);
381 goto out;
382 }
383
384 err = -ENOMEM;
385 p = kzalloc(sizeof(*p), GFP_KERNEL);
386 if (!p) {
387 printk(KERN_ERR PFX "Could not allocate struct chmc.\n");
388 goto out;
389 }
390
391 p->portid = portid;
392 p->layout_size = len;
David S. Miller44bdef52006-06-22 20:04:30 -0700393 if (!pval)
David S. Miller83ef64b2008-08-24 21:45:44 -0700394 p->layout_size = 0;
395 else
396 memcpy(&p->layout_prop, pval, len);
David S. Miller44bdef52006-06-22 20:04:30 -0700397
David S. Miller83ef64b2008-08-24 21:45:44 -0700398 p->regs = of_ioremap(&op->resource[0], 0, 0x48, "chmc");
399 if (!p->regs) {
David S. Millerb28422e2008-08-24 21:32:42 -0700400 printk(KERN_ERR PFX "Could not map registers.\n");
David S. Miller83ef64b2008-08-24 21:45:44 -0700401 goto out_free;
David S. Millerb28422e2008-08-24 21:32:42 -0700402 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700403
David S. Miller83ef64b2008-08-24 21:45:44 -0700404 if (p->layout_size != 0UL) {
405 p->timing_control1 = chmc_read_mcreg(p, CHMCTRL_TCTRL1);
406 p->timing_control2 = chmc_read_mcreg(p, CHMCTRL_TCTRL2);
407 p->timing_control3 = chmc_read_mcreg(p, CHMCTRL_TCTRL3);
408 p->timing_control4 = chmc_read_mcreg(p, CHMCTRL_TCTRL4);
409 p->memaddr_control = chmc_read_mcreg(p, CHMCTRL_MACTRL);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700410 }
411
David S. Miller83ef64b2008-08-24 21:45:44 -0700412 chmc_fetch_decode_regs(p);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700413
David S. Miller83ef64b2008-08-24 21:45:44 -0700414 list_add(&p->list, &mctrl_list);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700415
416 /* Report the device. */
David S. Millerb28422e2008-08-24 21:32:42 -0700417 printk(KERN_INFO PFX "UltraSPARC-III memory controller at %s [%s]\n",
David S. Miller44bdef52006-06-22 20:04:30 -0700418 dp->full_name,
David S. Miller83ef64b2008-08-24 21:45:44 -0700419 (p->layout_size ? "ACTIVE" : "INACTIVE"));
David S. Millerb28422e2008-08-24 21:32:42 -0700420
David S. Miller83ef64b2008-08-24 21:45:44 -0700421 dev_set_drvdata(&op->dev, p);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700422
David S. Miller83ef64b2008-08-24 21:45:44 -0700423 err = 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700424
David S. Miller83ef64b2008-08-24 21:45:44 -0700425out:
426 return err;
427
428out_free:
429 kfree(p);
430 goto out;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700431}
432
David S. Millerb28422e2008-08-24 21:32:42 -0700433static int __devexit chmc_remove(struct of_device *op)
434{
David S. Miller83ef64b2008-08-24 21:45:44 -0700435 struct chmc *p = dev_get_drvdata(&op->dev);
David S. Millerb28422e2008-08-24 21:32:42 -0700436
David S. Miller83ef64b2008-08-24 21:45:44 -0700437 if (p) {
438 list_del(&p->list);
439 of_iounmap(&op->resource[0], p->regs, 0x48);
440 kfree(p);
David S. Millerb28422e2008-08-24 21:32:42 -0700441 }
442 return 0;
443}
444
445static struct of_device_id chmc_match[] = {
446 {
447 .name = "memory-controller",
448 },
449 {},
450};
451MODULE_DEVICE_TABLE(of, chmc_match);
452
453static struct of_platform_driver chmc_driver = {
454 .name = "chmc",
455 .match_table = chmc_match,
456 .probe = chmc_probe,
457 .remove = __devexit_p(chmc_remove),
458};
459
460static inline bool chmc_platform(void)
461{
462 if (tlb_type == cheetah || tlb_type == cheetah_plus)
463 return true;
464 return false;
465}
466
Linus Torvalds1da177e2005-04-16 15:20:36 -0700467static int __init chmc_init(void)
468{
David S. Millerb28422e2008-08-24 21:32:42 -0700469 if (!chmc_platform())
Linus Torvalds1da177e2005-04-16 15:20:36 -0700470 return -ENODEV;
471
David S. Millerb28422e2008-08-24 21:32:42 -0700472 return of_register_driver(&chmc_driver, &of_bus_type);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700473}
474
475static void __exit chmc_cleanup(void)
476{
David S. Millerb28422e2008-08-24 21:32:42 -0700477 if (chmc_platform())
478 of_unregister_driver(&chmc_driver);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700479}
480
481module_init(chmc_init);
482module_exit(chmc_cleanup);