blob: b03bedb62aa7f43ab8bc8f75168206dfbb5dd721 [file] [log] [blame]
Jon Masone4650582006-06-26 13:58:14 +02001/*
2 * Derived from include/asm-powerpc/iommu.h
3 *
Muli Ben-Yehudaff297b82007-07-21 17:10:50 +02004 * Copyright IBM Corporation, 2006-2007
Muli Ben-Yehudaaa0a9f32006-07-10 17:06:15 +02005 *
6 * Author: Jon Mason <jdmason@us.ibm.com>
7 * Author: Muli Ben-Yehuda <muli@il.ibm.com>
Jon Masone4650582006-06-26 13:58:14 +02008 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 */
23
H. Peter Anvin1965aae2008-10-22 22:26:29 -070024#ifndef _ASM_X86_CALGARY_H
25#define _ASM_X86_CALGARY_H
Jon Masone4650582006-06-26 13:58:14 +020026
Jon Masone4650582006-06-26 13:58:14 +020027#include <linux/spinlock.h>
28#include <linux/device.h>
29#include <linux/dma-mapping.h>
Alexey Dobriyane8edc6e2007-05-21 01:22:52 +040030#include <linux/timer.h>
Jon Masone4650582006-06-26 13:58:14 +020031#include <asm/types.h>
32
33struct iommu_table {
Muli Ben-Yehudaff297b82007-07-21 17:10:50 +020034 struct cal_chipset_ops *chip_ops; /* chipset specific funcs */
Jon Masone4650582006-06-26 13:58:14 +020035 unsigned long it_base; /* mapped address of tce table */
36 unsigned long it_hint; /* Hint for next alloc */
37 unsigned long *it_map; /* A simple allocation bitmap for now */
Muli Ben-Yehuda5f4a7a92006-09-26 10:52:31 +020038 void __iomem *bbar; /* Bridge BAR */
39 u64 tar_val; /* Table Address Register */
40 struct timer_list watchdog_timer;
Jon Masone4650582006-06-26 13:58:14 +020041 spinlock_t it_lock; /* Protects it_map */
42 unsigned int it_size; /* Size of iommu table in entries */
43 unsigned char it_busno; /* Bus number this table belongs to */
Jon Masone4650582006-06-26 13:58:14 +020044};
45
Muli Ben-Yehudaff297b82007-07-21 17:10:50 +020046struct cal_chipset_ops {
47 void (*handle_quirks)(struct iommu_table *tbl, struct pci_dev *dev);
48 void (*tce_cache_blast)(struct iommu_table *tbl);
Muli Ben-Yehuda8cb32dc2007-07-21 17:10:55 +020049 void (*dump_error_regs)(struct iommu_table *tbl);
Muli Ben-Yehudaff297b82007-07-21 17:10:50 +020050};
51
Jon Masone4650582006-06-26 13:58:14 +020052#define TCE_TABLE_SIZE_UNSPECIFIED ~0
53#define TCE_TABLE_SIZE_64K 0
54#define TCE_TABLE_SIZE_128K 1
55#define TCE_TABLE_SIZE_256K 2
56#define TCE_TABLE_SIZE_512K 3
57#define TCE_TABLE_SIZE_1M 4
58#define TCE_TABLE_SIZE_2M 5
59#define TCE_TABLE_SIZE_4M 6
60#define TCE_TABLE_SIZE_8M 7
61
Muli Ben-Yehudabff65472006-12-07 02:14:07 +010062extern int use_calgary;
63
Jon Masone4650582006-06-26 13:58:14 +020064#ifdef CONFIG_CALGARY_IOMMU
65extern int calgary_iommu_init(void);
66extern void detect_calgary(void);
67#else
68static inline int calgary_iommu_init(void) { return 1; }
69static inline void detect_calgary(void) { return; }
70#endif
71
H. Peter Anvin1965aae2008-10-22 22:26:29 -070072#endif /* _ASM_X86_CALGARY_H */