i460-agp.c 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654
  1. /*
  2. * For documentation on the i460 AGP interface, see Chapter 7 (AGP Subsystem) of
  3. * the "Intel 460GTX Chipset Software Developer's Manual":
  4. * http://developer.intel.com/design/itanium/downloads/24870401s.htm
  5. */
  6. /*
  7. * 460GX support by Chris Ahna <christopher.j.ahna@intel.com>
  8. * Clean up & simplification by David Mosberger-Tang <davidm@hpl.hp.com>
  9. */
  10. #include <linux/module.h>
  11. #include <linux/pci.h>
  12. #include <linux/init.h>
  13. #include <linux/string.h>
  14. #include <linux/slab.h>
  15. #include <linux/agp_backend.h>
  16. #include "agp.h"
  17. #define INTEL_I460_BAPBASE 0x98
  18. #define INTEL_I460_GXBCTL 0xa0
  19. #define INTEL_I460_AGPSIZ 0xa2
  20. #define INTEL_I460_ATTBASE 0xfe200000
  21. #define INTEL_I460_GATT_VALID (1UL << 24)
  22. #define INTEL_I460_GATT_COHERENT (1UL << 25)
  23. /*
  24. * The i460 can operate with large (4MB) pages, but there is no sane way to support this
  25. * within the current kernel/DRM environment, so we disable the relevant code for now.
  26. * See also comments in ia64_alloc_page()...
  27. */
  28. #define I460_LARGE_IO_PAGES 0
  29. #if I460_LARGE_IO_PAGES
  30. # define I460_IO_PAGE_SHIFT i460.io_page_shift
  31. #else
  32. # define I460_IO_PAGE_SHIFT 12
  33. #endif
  34. #define I460_IOPAGES_PER_KPAGE (PAGE_SIZE >> I460_IO_PAGE_SHIFT)
  35. #define I460_KPAGES_PER_IOPAGE (1 << (I460_IO_PAGE_SHIFT - PAGE_SHIFT))
  36. #define I460_SRAM_IO_DISABLE (1 << 4)
  37. #define I460_BAPBASE_ENABLE (1 << 3)
  38. #define I460_AGPSIZ_MASK 0x7
  39. #define I460_4M_PS (1 << 1)
  40. /* Control bits for Out-Of-GART coherency and Burst Write Combining */
  41. #define I460_GXBCTL_OOG (1UL << 0)
  42. #define I460_GXBCTL_BWC (1UL << 2)
  43. /*
  44. * gatt_table entries are 32-bits wide on the i460; the generic code ought to declare the
  45. * gatt_table and gatt_table_real pointers a "void *"...
  46. */
  47. #define RD_GATT(index) readl((u32 *) i460.gatt + (index))
  48. #define WR_GATT(index, val) writel((val), (u32 *) i460.gatt + (index))
  49. /*
  50. * The 460 spec says we have to read the last location written to make sure that all
  51. * writes have taken effect
  52. */
  53. #define WR_FLUSH_GATT(index) RD_GATT(index)
  54. #define log2(x) ffz(~(x))
  55. static struct {
  56. void *gatt; /* ioremap'd GATT area */
  57. /* i460 supports multiple GART page sizes, so GART pageshift is dynamic: */
  58. u8 io_page_shift;
  59. /* BIOS configures chipset to one of 2 possible apbase values: */
  60. u8 dynamic_apbase;
  61. /* structure for tracking partial use of 4MB GART pages: */
  62. struct lp_desc {
  63. unsigned long *alloced_map; /* bitmap of kernel-pages in use */
  64. int refcount; /* number of kernel pages using the large page */
  65. u64 paddr; /* physical address of large page */
  66. } *lp_desc;
  67. } i460;
  68. static const struct aper_size_info_8 i460_sizes[3] =
  69. {
  70. /*
  71. * The 32GB aperture is only available with a 4M GART page size. Due to the
  72. * dynamic GART page size, we can't figure out page_order or num_entries until
  73. * runtime.
  74. */
  75. {32768, 0, 0, 4},
  76. {1024, 0, 0, 2},
  77. {256, 0, 0, 1}
  78. };
  79. static struct gatt_mask i460_masks[] =
  80. {
  81. {
  82. .mask = INTEL_I460_GATT_VALID | INTEL_I460_GATT_COHERENT,
  83. .type = 0
  84. }
  85. };
  86. static int i460_fetch_size (void)
  87. {
  88. int i;
  89. u8 temp;
  90. struct aper_size_info_8 *values;
  91. /* Determine the GART page size */
  92. pci_read_config_byte(agp_bridge->dev, INTEL_I460_GXBCTL, &temp);
  93. i460.io_page_shift = (temp & I460_4M_PS) ? 22 : 12;
  94. pr_debug("i460_fetch_size: io_page_shift=%d\n", i460.io_page_shift);
  95. if (i460.io_page_shift != I460_IO_PAGE_SHIFT) {
  96. printk(KERN_ERR PFX
  97. "I/O (GART) page-size %luKB doesn't match expected "
  98. "size %luKB\n",
  99. 1UL << (i460.io_page_shift - 10),
  100. 1UL << (I460_IO_PAGE_SHIFT));
  101. return 0;
  102. }
  103. values = A_SIZE_8(agp_bridge->driver->aperture_sizes);
  104. pci_read_config_byte(agp_bridge->dev, INTEL_I460_AGPSIZ, &temp);
  105. /* Exit now if the IO drivers for the GART SRAMS are turned off */
  106. if (temp & I460_SRAM_IO_DISABLE) {
  107. printk(KERN_ERR PFX "GART SRAMS disabled on 460GX chipset\n");
  108. printk(KERN_ERR PFX "AGPGART operation not possible\n");
  109. return 0;
  110. }
  111. /* Make sure we don't try to create an 2 ^ 23 entry GATT */
  112. if ((i460.io_page_shift == 0) && ((temp & I460_AGPSIZ_MASK) == 4)) {
  113. printk(KERN_ERR PFX "We can't have a 32GB aperture with 4KB GART pages\n");
  114. return 0;
  115. }
  116. /* Determine the proper APBASE register */
  117. if (temp & I460_BAPBASE_ENABLE)
  118. i460.dynamic_apbase = INTEL_I460_BAPBASE;
  119. else
  120. i460.dynamic_apbase = AGP_APBASE;
  121. for (i = 0; i < agp_bridge->driver->num_aperture_sizes; i++) {
  122. /*
  123. * Dynamically calculate the proper num_entries and page_order values for
  124. * the define aperture sizes. Take care not to shift off the end of
  125. * values[i].size.
  126. */
  127. values[i].num_entries = (values[i].size << 8) >> (I460_IO_PAGE_SHIFT - 12);
  128. values[i].page_order = log2((sizeof(u32)*values[i].num_entries) >> PAGE_SHIFT);
  129. }
  130. for (i = 0; i < agp_bridge->driver->num_aperture_sizes; i++) {
  131. /* Neglect control bits when matching up size_value */
  132. if ((temp & I460_AGPSIZ_MASK) == values[i].size_value) {
  133. agp_bridge->previous_size = agp_bridge->current_size = (void *) (values + i);
  134. agp_bridge->aperture_size_idx = i;
  135. return values[i].size;
  136. }
  137. }
  138. return 0;
  139. }
  140. /* There isn't anything to do here since 460 has no GART TLB. */
  141. static void i460_tlb_flush (struct agp_memory *mem)
  142. {
  143. return;
  144. }
  145. /*
  146. * This utility function is needed to prevent corruption of the control bits
  147. * which are stored along with the aperture size in 460's AGPSIZ register
  148. */
  149. static void i460_write_agpsiz (u8 size_value)
  150. {
  151. u8 temp;
  152. pci_read_config_byte(agp_bridge->dev, INTEL_I460_AGPSIZ, &temp);
  153. pci_write_config_byte(agp_bridge->dev, INTEL_I460_AGPSIZ,
  154. ((temp & ~I460_AGPSIZ_MASK) | size_value));
  155. }
  156. static void i460_cleanup (void)
  157. {
  158. struct aper_size_info_8 *previous_size;
  159. previous_size = A_SIZE_8(agp_bridge->previous_size);
  160. i460_write_agpsiz(previous_size->size_value);
  161. if (I460_IO_PAGE_SHIFT > PAGE_SHIFT)
  162. kfree(i460.lp_desc);
  163. }
  164. static int i460_configure (void)
  165. {
  166. union {
  167. u32 small[2];
  168. u64 large;
  169. } temp;
  170. size_t size;
  171. u8 scratch;
  172. struct aper_size_info_8 *current_size;
  173. temp.large = 0;
  174. current_size = A_SIZE_8(agp_bridge->current_size);
  175. i460_write_agpsiz(current_size->size_value);
  176. /*
  177. * Do the necessary rigmarole to read all eight bytes of APBASE.
  178. * This has to be done since the AGP aperture can be above 4GB on
  179. * 460 based systems.
  180. */
  181. pci_read_config_dword(agp_bridge->dev, i460.dynamic_apbase, &(temp.small[0]));
  182. pci_read_config_dword(agp_bridge->dev, i460.dynamic_apbase + 4, &(temp.small[1]));
  183. /* Clear BAR control bits */
  184. agp_bridge->gart_bus_addr = temp.large & ~((1UL << 3) - 1);
  185. pci_read_config_byte(agp_bridge->dev, INTEL_I460_GXBCTL, &scratch);
  186. pci_write_config_byte(agp_bridge->dev, INTEL_I460_GXBCTL,
  187. (scratch & 0x02) | I460_GXBCTL_OOG | I460_GXBCTL_BWC);
  188. /*
  189. * Initialize partial allocation trackers if a GART page is bigger than a kernel
  190. * page.
  191. */
  192. if (I460_IO_PAGE_SHIFT > PAGE_SHIFT) {
  193. size = current_size->num_entries * sizeof(i460.lp_desc[0]);
  194. i460.lp_desc = kzalloc(size, GFP_KERNEL);
  195. if (!i460.lp_desc)
  196. return -ENOMEM;
  197. }
  198. return 0;
  199. }
  200. static int i460_create_gatt_table (struct agp_bridge_data *bridge)
  201. {
  202. int page_order, num_entries, i;
  203. void *temp;
  204. /*
  205. * Load up the fixed address of the GART SRAMS which hold our GATT table.
  206. */
  207. temp = agp_bridge->current_size;
  208. page_order = A_SIZE_8(temp)->page_order;
  209. num_entries = A_SIZE_8(temp)->num_entries;
  210. i460.gatt = ioremap(INTEL_I460_ATTBASE, PAGE_SIZE << page_order);
  211. /* These are no good, the should be removed from the agp_bridge strucure... */
  212. agp_bridge->gatt_table_real = NULL;
  213. agp_bridge->gatt_table = NULL;
  214. agp_bridge->gatt_bus_addr = 0;
  215. for (i = 0; i < num_entries; ++i)
  216. WR_GATT(i, 0);
  217. WR_FLUSH_GATT(i - 1);
  218. return 0;
  219. }
  220. static int i460_free_gatt_table (struct agp_bridge_data *bridge)
  221. {
  222. int num_entries, i;
  223. void *temp;
  224. temp = agp_bridge->current_size;
  225. num_entries = A_SIZE_8(temp)->num_entries;
  226. for (i = 0; i < num_entries; ++i)
  227. WR_GATT(i, 0);
  228. WR_FLUSH_GATT(num_entries - 1);
  229. iounmap(i460.gatt);
  230. return 0;
  231. }
  232. /*
  233. * The following functions are called when the I/O (GART) page size is smaller than
  234. * PAGE_SIZE.
  235. */
  236. static int i460_insert_memory_small_io_page (struct agp_memory *mem,
  237. off_t pg_start, int type)
  238. {
  239. unsigned long paddr, io_pg_start, io_page_size;
  240. int i, j, k, num_entries;
  241. void *temp;
  242. pr_debug("i460_insert_memory_small_io_page(mem=%p, pg_start=%ld, type=%d, paddr0=0x%lx)\n",
  243. mem, pg_start, type, mem->memory[0]);
  244. if (type >= AGP_USER_TYPES || mem->type >= AGP_USER_TYPES)
  245. return -EINVAL;
  246. io_pg_start = I460_IOPAGES_PER_KPAGE * pg_start;
  247. temp = agp_bridge->current_size;
  248. num_entries = A_SIZE_8(temp)->num_entries;
  249. if ((io_pg_start + I460_IOPAGES_PER_KPAGE * mem->page_count) > num_entries) {
  250. printk(KERN_ERR PFX "Looks like we're out of AGP memory\n");
  251. return -EINVAL;
  252. }
  253. j = io_pg_start;
  254. while (j < (io_pg_start + I460_IOPAGES_PER_KPAGE * mem->page_count)) {
  255. if (!PGE_EMPTY(agp_bridge, RD_GATT(j))) {
  256. pr_debug("i460_insert_memory_small_io_page: GATT[%d]=0x%x is busy\n",
  257. j, RD_GATT(j));
  258. return -EBUSY;
  259. }
  260. j++;
  261. }
  262. io_page_size = 1UL << I460_IO_PAGE_SHIFT;
  263. for (i = 0, j = io_pg_start; i < mem->page_count; i++) {
  264. paddr = mem->memory[i];
  265. for (k = 0; k < I460_IOPAGES_PER_KPAGE; k++, j++, paddr += io_page_size)
  266. WR_GATT(j, agp_bridge->driver->mask_memory(agp_bridge,
  267. paddr, mem->type));
  268. }
  269. WR_FLUSH_GATT(j - 1);
  270. return 0;
  271. }
  272. static int i460_remove_memory_small_io_page(struct agp_memory *mem,
  273. off_t pg_start, int type)
  274. {
  275. int i;
  276. pr_debug("i460_remove_memory_small_io_page(mem=%p, pg_start=%ld, type=%d)\n",
  277. mem, pg_start, type);
  278. pg_start = I460_IOPAGES_PER_KPAGE * pg_start;
  279. for (i = pg_start; i < (pg_start + I460_IOPAGES_PER_KPAGE * mem->page_count); i++)
  280. WR_GATT(i, 0);
  281. WR_FLUSH_GATT(i - 1);
  282. return 0;
  283. }
  284. #if I460_LARGE_IO_PAGES
  285. /*
  286. * These functions are called when the I/O (GART) page size exceeds PAGE_SIZE.
  287. *
  288. * This situation is interesting since AGP memory allocations that are smaller than a
  289. * single GART page are possible. The i460.lp_desc array tracks partial allocation of the
  290. * large GART pages to work around this issue.
  291. *
  292. * i460.lp_desc[pg_num].refcount tracks the number of kernel pages in use within GART page
  293. * pg_num. i460.lp_desc[pg_num].paddr is the physical address of the large page and
  294. * i460.lp_desc[pg_num].alloced_map is a bitmap of kernel pages that are in use (allocated).
  295. */
  296. static int i460_alloc_large_page (struct lp_desc *lp)
  297. {
  298. unsigned long order = I460_IO_PAGE_SHIFT - PAGE_SHIFT;
  299. size_t map_size;
  300. void *lpage;
  301. lpage = (void *) __get_free_pages(GFP_KERNEL, order);
  302. if (!lpage) {
  303. printk(KERN_ERR PFX "Couldn't alloc 4M GART page...\n");
  304. return -ENOMEM;
  305. }
  306. map_size = ((I460_KPAGES_PER_IOPAGE + BITS_PER_LONG - 1) & -BITS_PER_LONG)/8;
  307. lp->alloced_map = kzalloc(map_size, GFP_KERNEL);
  308. if (!lp->alloced_map) {
  309. free_pages((unsigned long) lpage, order);
  310. printk(KERN_ERR PFX "Out of memory, we're in trouble...\n");
  311. return -ENOMEM;
  312. }
  313. lp->paddr = virt_to_gart(lpage);
  314. lp->refcount = 0;
  315. atomic_add(I460_KPAGES_PER_IOPAGE, &agp_bridge->current_memory_agp);
  316. return 0;
  317. }
  318. static void i460_free_large_page (struct lp_desc *lp)
  319. {
  320. kfree(lp->alloced_map);
  321. lp->alloced_map = NULL;
  322. free_pages((unsigned long) gart_to_virt(lp->paddr), I460_IO_PAGE_SHIFT - PAGE_SHIFT);
  323. atomic_sub(I460_KPAGES_PER_IOPAGE, &agp_bridge->current_memory_agp);
  324. }
  325. static int i460_insert_memory_large_io_page (struct agp_memory *mem,
  326. off_t pg_start, int type)
  327. {
  328. int i, start_offset, end_offset, idx, pg, num_entries;
  329. struct lp_desc *start, *end, *lp;
  330. void *temp;
  331. if (type >= AGP_USER_TYPES || mem->type >= AGP_USER_TYPES)
  332. return -EINVAL;
  333. temp = agp_bridge->current_size;
  334. num_entries = A_SIZE_8(temp)->num_entries;
  335. /* Figure out what pg_start means in terms of our large GART pages */
  336. start = &i460.lp_desc[pg_start / I460_KPAGES_PER_IOPAGE];
  337. end = &i460.lp_desc[(pg_start + mem->page_count - 1) / I460_KPAGES_PER_IOPAGE];
  338. start_offset = pg_start % I460_KPAGES_PER_IOPAGE;
  339. end_offset = (pg_start + mem->page_count - 1) % I460_KPAGES_PER_IOPAGE;
  340. if (end > i460.lp_desc + num_entries) {
  341. printk(KERN_ERR PFX "Looks like we're out of AGP memory\n");
  342. return -EINVAL;
  343. }
  344. /* Check if the requested region of the aperture is free */
  345. for (lp = start; lp <= end; ++lp) {
  346. if (!lp->alloced_map)
  347. continue; /* OK, the entire large page is available... */
  348. for (idx = ((lp == start) ? start_offset : 0);
  349. idx < ((lp == end) ? (end_offset + 1) : I460_KPAGES_PER_IOPAGE);
  350. idx++)
  351. {
  352. if (test_bit(idx, lp->alloced_map))
  353. return -EBUSY;
  354. }
  355. }
  356. for (lp = start, i = 0; lp <= end; ++lp) {
  357. if (!lp->alloced_map) {
  358. /* Allocate new GART pages... */
  359. if (i460_alloc_large_page(lp) < 0)
  360. return -ENOMEM;
  361. pg = lp - i460.lp_desc;
  362. WR_GATT(pg, agp_bridge->driver->mask_memory(agp_bridge,
  363. lp->paddr, 0));
  364. WR_FLUSH_GATT(pg);
  365. }
  366. for (idx = ((lp == start) ? start_offset : 0);
  367. idx < ((lp == end) ? (end_offset + 1) : I460_KPAGES_PER_IOPAGE);
  368. idx++, i++)
  369. {
  370. mem->memory[i] = lp->paddr + idx*PAGE_SIZE;
  371. __set_bit(idx, lp->alloced_map);
  372. ++lp->refcount;
  373. }
  374. }
  375. return 0;
  376. }
  377. static int i460_remove_memory_large_io_page (struct agp_memory *mem,
  378. off_t pg_start, int type)
  379. {
  380. int i, pg, start_offset, end_offset, idx, num_entries;
  381. struct lp_desc *start, *end, *lp;
  382. void *temp;
  383. temp = agp_bridge->driver->current_size;
  384. num_entries = A_SIZE_8(temp)->num_entries;
  385. /* Figure out what pg_start means in terms of our large GART pages */
  386. start = &i460.lp_desc[pg_start / I460_KPAGES_PER_IOPAGE];
  387. end = &i460.lp_desc[(pg_start + mem->page_count - 1) / I460_KPAGES_PER_IOPAGE];
  388. start_offset = pg_start % I460_KPAGES_PER_IOPAGE;
  389. end_offset = (pg_start + mem->page_count - 1) % I460_KPAGES_PER_IOPAGE;
  390. for (i = 0, lp = start; lp <= end; ++lp) {
  391. for (idx = ((lp == start) ? start_offset : 0);
  392. idx < ((lp == end) ? (end_offset + 1) : I460_KPAGES_PER_IOPAGE);
  393. idx++, i++)
  394. {
  395. mem->memory[i] = 0;
  396. __clear_bit(idx, lp->alloced_map);
  397. --lp->refcount;
  398. }
  399. /* Free GART pages if they are unused */
  400. if (lp->refcount == 0) {
  401. pg = lp - i460.lp_desc;
  402. WR_GATT(pg, 0);
  403. WR_FLUSH_GATT(pg);
  404. i460_free_large_page(lp);
  405. }
  406. }
  407. return 0;
  408. }
  409. /* Wrapper routines to call the approriate {small_io_page,large_io_page} function */
  410. static int i460_insert_memory (struct agp_memory *mem,
  411. off_t pg_start, int type)
  412. {
  413. if (I460_IO_PAGE_SHIFT <= PAGE_SHIFT)
  414. return i460_insert_memory_small_io_page(mem, pg_start, type);
  415. else
  416. return i460_insert_memory_large_io_page(mem, pg_start, type);
  417. }
  418. static int i460_remove_memory (struct agp_memory *mem,
  419. off_t pg_start, int type)
  420. {
  421. if (I460_IO_PAGE_SHIFT <= PAGE_SHIFT)
  422. return i460_remove_memory_small_io_page(mem, pg_start, type);
  423. else
  424. return i460_remove_memory_large_io_page(mem, pg_start, type);
  425. }
  426. /*
  427. * If the I/O (GART) page size is bigger than the kernel page size, we don't want to
  428. * allocate memory until we know where it is to be bound in the aperture (a
  429. * multi-kernel-page alloc might fit inside of an already allocated GART page).
  430. *
  431. * Let's just hope nobody counts on the allocated AGP memory being there before bind time
  432. * (I don't think current drivers do)...
  433. */
  434. static void *i460_alloc_page (struct agp_bridge_data *bridge)
  435. {
  436. void *page;
  437. if (I460_IO_PAGE_SHIFT <= PAGE_SHIFT) {
  438. page = agp_generic_alloc_page(agp_bridge);
  439. global_flush_tlb();
  440. } else
  441. /* Returning NULL would cause problems */
  442. /* AK: really dubious code. */
  443. page = (void *)~0UL;
  444. return page;
  445. }
  446. static void i460_destroy_page (void *page)
  447. {
  448. if (I460_IO_PAGE_SHIFT <= PAGE_SHIFT) {
  449. agp_generic_destroy_page(page);
  450. global_flush_tlb();
  451. }
  452. }
  453. #endif /* I460_LARGE_IO_PAGES */
  454. static unsigned long i460_mask_memory (struct agp_bridge_data *bridge,
  455. unsigned long addr, int type)
  456. {
  457. /* Make sure the returned address is a valid GATT entry */
  458. return bridge->driver->masks[0].mask
  459. | (((addr & ~((1 << I460_IO_PAGE_SHIFT) - 1)) & 0xfffff000) >> 12);
  460. }
  461. const struct agp_bridge_driver intel_i460_driver = {
  462. .owner = THIS_MODULE,
  463. .aperture_sizes = i460_sizes,
  464. .size_type = U8_APER_SIZE,
  465. .num_aperture_sizes = 3,
  466. .configure = i460_configure,
  467. .fetch_size = i460_fetch_size,
  468. .cleanup = i460_cleanup,
  469. .tlb_flush = i460_tlb_flush,
  470. .mask_memory = i460_mask_memory,
  471. .masks = i460_masks,
  472. .agp_enable = agp_generic_enable,
  473. .cache_flush = global_cache_flush,
  474. .create_gatt_table = i460_create_gatt_table,
  475. .free_gatt_table = i460_free_gatt_table,
  476. #if I460_LARGE_IO_PAGES
  477. .insert_memory = i460_insert_memory,
  478. .remove_memory = i460_remove_memory,
  479. .agp_alloc_page = i460_alloc_page,
  480. .agp_destroy_page = i460_destroy_page,
  481. #else
  482. .insert_memory = i460_insert_memory_small_io_page,
  483. .remove_memory = i460_remove_memory_small_io_page,
  484. .agp_alloc_page = agp_generic_alloc_page,
  485. .agp_destroy_page = agp_generic_destroy_page,
  486. #endif
  487. .alloc_by_type = agp_generic_alloc_by_type,
  488. .free_by_type = agp_generic_free_by_type,
  489. .agp_type_to_mask_type = agp_generic_type_to_mask_type,
  490. .cant_use_aperture = 1,
  491. };
  492. static int __devinit agp_intel_i460_probe(struct pci_dev *pdev,
  493. const struct pci_device_id *ent)
  494. {
  495. struct agp_bridge_data *bridge;
  496. u8 cap_ptr;
  497. cap_ptr = pci_find_capability(pdev, PCI_CAP_ID_AGP);
  498. if (!cap_ptr)
  499. return -ENODEV;
  500. bridge = agp_alloc_bridge();
  501. if (!bridge)
  502. return -ENOMEM;
  503. bridge->driver = &intel_i460_driver;
  504. bridge->dev = pdev;
  505. bridge->capndx = cap_ptr;
  506. printk(KERN_INFO PFX "Detected Intel 460GX chipset\n");
  507. pci_set_drvdata(pdev, bridge);
  508. return agp_add_bridge(bridge);
  509. }
  510. static void __devexit agp_intel_i460_remove(struct pci_dev *pdev)
  511. {
  512. struct agp_bridge_data *bridge = pci_get_drvdata(pdev);
  513. agp_remove_bridge(bridge);
  514. agp_put_bridge(bridge);
  515. }
  516. static struct pci_device_id agp_intel_i460_pci_table[] = {
  517. {
  518. .class = (PCI_CLASS_BRIDGE_HOST << 8),
  519. .class_mask = ~0,
  520. .vendor = PCI_VENDOR_ID_INTEL,
  521. .device = PCI_DEVICE_ID_INTEL_84460GX,
  522. .subvendor = PCI_ANY_ID,
  523. .subdevice = PCI_ANY_ID,
  524. },
  525. { }
  526. };
  527. MODULE_DEVICE_TABLE(pci, agp_intel_i460_pci_table);
  528. static struct pci_driver agp_intel_i460_pci_driver = {
  529. .name = "agpgart-intel-i460",
  530. .id_table = agp_intel_i460_pci_table,
  531. .probe = agp_intel_i460_probe,
  532. .remove = __devexit_p(agp_intel_i460_remove),
  533. };
  534. static int __init agp_intel_i460_init(void)
  535. {
  536. if (agp_off)
  537. return -EINVAL;
  538. return pci_register_driver(&agp_intel_i460_pci_driver);
  539. }
  540. static void __exit agp_intel_i460_cleanup(void)
  541. {
  542. pci_unregister_driver(&agp_intel_i460_pci_driver);
  543. }
  544. module_init(agp_intel_i460_init);
  545. module_exit(agp_intel_i460_cleanup);
  546. MODULE_AUTHOR("Chris Ahna <Christopher.J.Ahna@intel.com>");
  547. MODULE_LICENSE("GPL and additional rights");