i460-agp.c 18 KB

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