Lines Matching refs:hp
76 struct _hp_private *hp = &hp_private; in hp_zx1_ioc_shared() local
86 hp->io_tlb_ps = readq(hp->ioc_regs+HP_ZX1_TCNFG); in hp_zx1_ioc_shared()
87 switch (hp->io_tlb_ps) { in hp_zx1_ioc_shared()
88 case 0: hp->io_tlb_shift = 12; break; in hp_zx1_ioc_shared()
89 case 1: hp->io_tlb_shift = 13; break; in hp_zx1_ioc_shared()
90 case 2: hp->io_tlb_shift = 14; break; in hp_zx1_ioc_shared()
91 case 3: hp->io_tlb_shift = 16; break; in hp_zx1_ioc_shared()
94 "configuration 0x%x\n", hp->io_tlb_ps); in hp_zx1_ioc_shared()
95 hp->gatt = NULL; in hp_zx1_ioc_shared()
96 hp->gatt_entries = 0; in hp_zx1_ioc_shared()
99 hp->io_page_size = 1 << hp->io_tlb_shift; in hp_zx1_ioc_shared()
100 hp->io_pages_per_kpage = PAGE_SIZE / hp->io_page_size; in hp_zx1_ioc_shared()
102 hp->iova_base = readq(hp->ioc_regs+HP_ZX1_IBASE) & ~0x1; in hp_zx1_ioc_shared()
103 hp->gart_base = hp->iova_base + HP_ZX1_IOVA_SIZE - HP_ZX1_GART_SIZE; in hp_zx1_ioc_shared()
105 hp->gart_size = HP_ZX1_GART_SIZE; in hp_zx1_ioc_shared()
106 hp->gatt_entries = hp->gart_size / hp->io_page_size; in hp_zx1_ioc_shared()
108 hp->io_pdir = phys_to_virt(readq(hp->ioc_regs+HP_ZX1_PDIR_BASE)); in hp_zx1_ioc_shared()
109 hp->gatt = &hp->io_pdir[HP_ZX1_IOVA_TO_PDIR(hp->gart_base)]; in hp_zx1_ioc_shared()
111 if (hp->gatt[0] != HP_ZX1_SBA_IOMMU_COOKIE) { in hp_zx1_ioc_shared()
113 hp->gatt = NULL; in hp_zx1_ioc_shared()
114 hp->gatt_entries = 0; in hp_zx1_ioc_shared()
126 struct _hp_private *hp = &hp_private; in hp_zx1_ioc_owner() local
134 hp->io_tlb_shift = 16; in hp_zx1_ioc_owner()
135 hp->io_tlb_ps = 3; in hp_zx1_ioc_owner()
137 hp->io_tlb_shift = 14; in hp_zx1_ioc_owner()
138 hp->io_tlb_ps = 2; in hp_zx1_ioc_owner()
140 hp->io_tlb_shift = 13; in hp_zx1_ioc_owner()
141 hp->io_tlb_ps = 1; in hp_zx1_ioc_owner()
143 hp->io_tlb_shift = 12; in hp_zx1_ioc_owner()
144 hp->io_tlb_ps = 0; in hp_zx1_ioc_owner()
146 hp->io_page_size = 1 << hp->io_tlb_shift; in hp_zx1_ioc_owner()
147 hp->io_pages_per_kpage = PAGE_SIZE / hp->io_page_size; in hp_zx1_ioc_owner()
149 hp->iova_base = HP_ZX1_IOVA_BASE; in hp_zx1_ioc_owner()
150 hp->gart_size = HP_ZX1_GART_SIZE; in hp_zx1_ioc_owner()
151 hp->gart_base = hp->iova_base + HP_ZX1_IOVA_SIZE - hp->gart_size; in hp_zx1_ioc_owner()
153 hp->gatt_entries = hp->gart_size / hp->io_page_size; in hp_zx1_ioc_owner()
154 hp->io_pdir_size = (HP_ZX1_IOVA_SIZE / hp->io_page_size) * sizeof(u64); in hp_zx1_ioc_owner()
162 struct _hp_private *hp = &hp_private; in hp_zx1_ioc_init() local
164 hp->ioc_regs = ioremap(hpa, 1024); in hp_zx1_ioc_init()
165 if (!hp->ioc_regs) in hp_zx1_ioc_init()
172 hp->io_pdir_owner = (readq(hp->ioc_regs+HP_ZX1_IBASE) & 0x1) == 0; in hp_zx1_ioc_init()
174 if (hp->io_pdir_owner) in hp_zx1_ioc_init()
206 struct _hp_private *hp = &hp_private; in hp_zx1_lba_init() local
209 hp->lba_regs = ioremap(hpa, 256); in hp_zx1_lba_init()
210 if (!hp->lba_regs) in hp_zx1_lba_init()
213 hp->lba_cap_offset = hp_zx1_lba_find_capability(hp->lba_regs, PCI_CAP_ID_AGP); in hp_zx1_lba_init()
215 cap = readl(hp->lba_regs+hp->lba_cap_offset) & 0xff; in hp_zx1_lba_init()
218 cap, hp->lba_cap_offset); in hp_zx1_lba_init()
219 iounmap(hp->lba_regs); in hp_zx1_lba_init()
240 struct _hp_private *hp = &hp_private; in hp_zx1_configure() local
242 agp_bridge->gart_bus_addr = hp->gart_base; in hp_zx1_configure()
243 agp_bridge->capndx = hp->lba_cap_offset; in hp_zx1_configure()
244 agp_bridge->mode = readl(hp->lba_regs+hp->lba_cap_offset+PCI_AGP_STATUS); in hp_zx1_configure()
246 if (hp->io_pdir_owner) { in hp_zx1_configure()
247 writel(virt_to_phys(hp->io_pdir), hp->ioc_regs+HP_ZX1_PDIR_BASE); in hp_zx1_configure()
248 readl(hp->ioc_regs+HP_ZX1_PDIR_BASE); in hp_zx1_configure()
249 writel(hp->io_tlb_ps, hp->ioc_regs+HP_ZX1_TCNFG); in hp_zx1_configure()
250 readl(hp->ioc_regs+HP_ZX1_TCNFG); in hp_zx1_configure()
251 writel((unsigned int)(~(HP_ZX1_IOVA_SIZE-1)), hp->ioc_regs+HP_ZX1_IMASK); in hp_zx1_configure()
252 readl(hp->ioc_regs+HP_ZX1_IMASK); in hp_zx1_configure()
253 writel(hp->iova_base|1, hp->ioc_regs+HP_ZX1_IBASE); in hp_zx1_configure()
254 readl(hp->ioc_regs+HP_ZX1_IBASE); in hp_zx1_configure()
255 writel(hp->iova_base|ilog2(HP_ZX1_IOVA_SIZE), hp->ioc_regs+HP_ZX1_PCOM); in hp_zx1_configure()
256 readl(hp->ioc_regs+HP_ZX1_PCOM); in hp_zx1_configure()
265 struct _hp_private *hp = &hp_private; in hp_zx1_cleanup() local
267 if (hp->ioc_regs) { in hp_zx1_cleanup()
268 if (hp->io_pdir_owner) { in hp_zx1_cleanup()
269 writeq(0, hp->ioc_regs+HP_ZX1_IBASE); in hp_zx1_cleanup()
270 readq(hp->ioc_regs+HP_ZX1_IBASE); in hp_zx1_cleanup()
272 iounmap(hp->ioc_regs); in hp_zx1_cleanup()
274 if (hp->lba_regs) in hp_zx1_cleanup()
275 iounmap(hp->lba_regs); in hp_zx1_cleanup()
281 struct _hp_private *hp = &hp_private; in hp_zx1_tlbflush() local
283 writeq(hp->gart_base | ilog2(hp->gart_size), hp->ioc_regs+HP_ZX1_PCOM); in hp_zx1_tlbflush()
284 readq(hp->ioc_regs+HP_ZX1_PCOM); in hp_zx1_tlbflush()
290 struct _hp_private *hp = &hp_private; in hp_zx1_create_gatt_table() local
293 if (hp->io_pdir_owner) { in hp_zx1_create_gatt_table()
294 hp->io_pdir = (u64 *) __get_free_pages(GFP_KERNEL, in hp_zx1_create_gatt_table()
295 get_order(hp->io_pdir_size)); in hp_zx1_create_gatt_table()
296 if (!hp->io_pdir) { in hp_zx1_create_gatt_table()
299 hp->gatt = NULL; in hp_zx1_create_gatt_table()
300 hp->gatt_entries = 0; in hp_zx1_create_gatt_table()
303 memset(hp->io_pdir, 0, hp->io_pdir_size); in hp_zx1_create_gatt_table()
305 hp->gatt = &hp->io_pdir[HP_ZX1_IOVA_TO_PDIR(hp->gart_base)]; in hp_zx1_create_gatt_table()
308 for (i = 0; i < hp->gatt_entries; i++) { in hp_zx1_create_gatt_table()
309 hp->gatt[i] = (unsigned long) agp_bridge->scratch_page; in hp_zx1_create_gatt_table()
318 struct _hp_private *hp = &hp_private; in hp_zx1_free_gatt_table() local
320 if (hp->io_pdir_owner) in hp_zx1_free_gatt_table()
321 free_pages((unsigned long) hp->io_pdir, in hp_zx1_free_gatt_table()
322 get_order(hp->io_pdir_size)); in hp_zx1_free_gatt_table()
324 hp->gatt[0] = HP_ZX1_SBA_IOMMU_COOKIE; in hp_zx1_free_gatt_table()
331 struct _hp_private *hp = &hp_private; in hp_zx1_insert_memory() local
341 io_pg_start = hp->io_pages_per_kpage * pg_start; in hp_zx1_insert_memory()
342 io_pg_count = hp->io_pages_per_kpage * mem->page_count; in hp_zx1_insert_memory()
343 if ((io_pg_start + io_pg_count) > hp->gatt_entries) { in hp_zx1_insert_memory()
349 if (hp->gatt[j]) { in hp_zx1_insert_memory()
365 k < hp->io_pages_per_kpage; in hp_zx1_insert_memory()
366 k++, j++, paddr += hp->io_page_size) { in hp_zx1_insert_memory()
367 hp->gatt[j] = HP_ZX1_PDIR_VALID_BIT | paddr; in hp_zx1_insert_memory()
378 struct _hp_private *hp = &hp_private; in hp_zx1_remove_memory() local
386 io_pg_start = hp->io_pages_per_kpage * pg_start; in hp_zx1_remove_memory()
387 io_pg_count = hp->io_pages_per_kpage * mem->page_count; in hp_zx1_remove_memory()
389 hp->gatt[i] = agp_bridge->scratch_page; in hp_zx1_remove_memory()
405 struct _hp_private *hp = &hp_private; in hp_zx1_enable() local
408 command = readl(hp->lba_regs+hp->lba_cap_offset+PCI_AGP_STATUS); in hp_zx1_enable()
412 writel(command, hp->lba_regs+hp->lba_cap_offset+PCI_AGP_COMMAND); in hp_zx1_enable()