Lines Matching refs:hw
176 static int sdla_detect (sdlahw_t* hw);
177 static int sdla_autodpm (sdlahw_t* hw);
178 static int sdla_setdpm (sdlahw_t* hw);
179 static int sdla_load (sdlahw_t* hw, sfm_t* sfm, unsigned len);
180 static int sdla_init (sdlahw_t* hw);
181 static unsigned long sdla_memtest (sdlahw_t* hw);
182 static int sdla_bootcfg (sdlahw_t* hw, sfm_info_t* sfminfo);
183 static unsigned char make_config_byte (sdlahw_t* hw);
184 static int sdla_start (sdlahw_t* hw, unsigned addr);
186 static int init_s502a (sdlahw_t* hw);
187 static int init_s502e (sdlahw_t* hw);
188 static int init_s503 (sdlahw_t* hw);
189 static int init_s507 (sdlahw_t* hw);
190 static int init_s508 (sdlahw_t* hw);
197 static int detect_s514 (sdlahw_t* hw);
198 static int find_s514_adapter(sdlahw_t* hw, char find_first_S514_card);
210 static int pci_probe(sdlahw_t *hw);
388 int sdla_setup (sdlahw_t* hw, void* sfm, unsigned len) in sdla_setup() argument
395 if (sdla_detect(hw)) { in sdla_setup()
396 if(hw->type != SDLA_S514) in sdla_setup()
398 modname, hw->port); in sdla_setup()
402 if(hw->type != SDLA_S514) { in sdla_setup()
404 modname, hw->type, hw->port); in sdla_setup()
406 hw->dpmsize = SDLA_WINDOWSIZE; in sdla_setup()
407 switch (hw->type) { in sdla_setup()
409 hw->io_range = S502A_IORANGE; in sdla_setup()
416 hw->io_range = S502E_IORANGE; in sdla_setup()
423 hw->io_range = S503_IORANGE; in sdla_setup()
430 hw->io_range = S507_IORANGE; in sdla_setup()
437 hw->io_range = S508_IORANGE; in sdla_setup()
445 if (!get_option_index(irq_opt, hw->irq)) { in sdla_setup()
447 modname, hw->irq); in sdla_setup()
452 if (hw->pclk == 0) in sdla_setup()
453 hw->pclk = pclk_opt[1]; /* use default */ in sdla_setup()
455 else if (!get_option_index(pclk_opt, hw->pclk)) { in sdla_setup()
457 modname, hw->pclk); in sdla_setup()
461 modname, hw->pclk); in sdla_setup()
464 if (hw->dpmbase == 0) { in sdla_setup()
465 err = sdla_autodpm(hw); in sdla_setup()
474 virt_to_phys(hw->dpmbase))) { in sdla_setup()
477 modname, virt_to_phys(hw->dpmbase)); in sdla_setup()
480 else if (sdla_setdpm(hw)) { in sdla_setup()
483 modname, virt_to_phys(hw->dpmbase)); in sdla_setup()
488 modname, virt_to_phys(hw->dpmbase)); in sdla_setup()
495 if (virt_to_phys(hw->dpmbase) >= 0xE0000){ in sdla_setup()
498 modname, virt_to_phys(hw->dpmbase)); in sdla_setup()
506 hw->memory = test_memregion((void*)hw->dpmbase, in sdla_setup()
508 if(hw->memory < (256 * 1024)) { in sdla_setup()
511 modname, hw->memory); in sdla_setup()
512 sdla_down(hw); in sdla_setup()
518 modname, hw->memory / 1024); in sdla_setup()
521 err = sdla_load(hw, sfm, len); in sdla_setup()
522 if (err) sdla_down(hw); /* shutdown adapter */ in sdla_setup()
535 int sdla_down (sdlahw_t* hw) in sdla_down() argument
537 unsigned port = hw->port; in sdla_down()
542 if(!port && (hw->type != SDLA_S514)) in sdla_down()
545 switch (hw->type) { in sdla_down()
550 hw->regs[0] = 0x08; in sdla_down()
552 hw->regs[1] = 0xFF; in sdla_down()
559 hw->regs[i] = 0 in sdla_down()
567 hw->regs[0] = 0; in sdla_down()
572 *(char *)hw->vector = S514_CPU_HALT; in sdla_down()
573 CPU_no = hw->S514_cpu_no[0]; in sdla_down()
577 pci_read_config_dword(hw->pci_dev, PCI_INT_CONFIG, &int_config); in sdla_down()
579 pci_write_config_dword(hw->pci_dev, PCI_INT_CONFIG, int_config); in sdla_down()
580 read_S514_int_stat(hw, &int_status); in sdla_down()
581 S514_intack(hw, int_status); in sdla_down()
583 pci_write_config_dword(hw->pci_dev, PCI_MAP0_DWORD, in sdla_down()
586 pci_write_config_dword(hw->pci_dev, PCI_MAP1_DWORD, in sdla_down()
590 pcibios_read_config_dword(hw->pci_bus, hw->pci_dev_func, in sdla_down()
593 pcibios_write_config_dword(hw->pci_bus, hw->pci_dev_func, in sdla_down()
595 read_S514_int_stat(hw, &int_status); in sdla_down()
596 S514_intack(hw, int_status); in sdla_down()
599 pcibios_write_config_dword(hw->pci_bus,hw->pci_dev_func, in sdla_down()
602 …pcibios_write_config_dword(hw->pci_bus,hw->pci_dev_func, PCI_MAP1_DWORD, PCI_CPU_B_MEM_DISAB… in sdla_down()
606 iounmap((void *)hw->dpmbase); in sdla_down()
607 iounmap((void *)hw->vector); in sdla_down()
625 int sdla_mapmem (sdlahw_t* hw, unsigned long addr) in sdla_mapmem() argument
627 unsigned port = hw->port; in sdla_mapmem()
630 switch (hw->type) { in sdla_mapmem()
636 hw->regs[2] = tmp; in sdla_mapmem()
643 tmp = (hw->regs[0] & 0x8F) | ((addr >> 9) & 0x70); in sdla_mapmem()
645 hw->regs[0] = tmp; in sdla_mapmem()
656 hw->regs[2] = tmp; in sdla_mapmem()
665 hw->regs[2] = tmp; in sdla_mapmem()
676 hw->vector = addr & 0xFFFFE000L; in sdla_mapmem()
688 int sdla_inten (sdlahw_t* hw) in sdla_inten() argument
690 unsigned port = hw->port; in sdla_inten()
693 switch (hw->type) { in sdla_inten()
701 hw->regs[0] = 0x06; in sdla_inten()
707 tmp = hw->regs[0] | 0x04; in sdla_inten()
709 hw->regs[0] = tmp; /* update mirror */ in sdla_inten()
716 tmp = hw->regs[0] | 0x10; in sdla_inten()
718 hw->regs[0] = tmp; /* update mirror */ in sdla_inten()
746 int sdla_intde (sdlahw_t* hw) in sdla_intde() argument
748 unsigned port = hw->port; in sdla_intde()
751 switch (hw->type) { in sdla_intde()
761 _OUTB(port, hw->regs[0] & ~0x04); in sdla_intde()
762 hw->regs[0] &= ~0x04; in sdla_intde()
768 tmp = hw->regs[0] & ~0x04; in sdla_intde()
770 hw->regs[0] = tmp; /* update mirror */ in sdla_intde()
777 tmp = hw->regs[0] & ~0x10; in sdla_intde()
779 hw->regs[0] = tmp; /* update mirror */ in sdla_intde()
803 int sdla_intack (sdlahw_t* hw) in sdla_intack() argument
805 unsigned port = hw->port; in sdla_intack()
808 switch (hw->type) { in sdla_intack()
816 tmp = hw->regs[0] & ~0x04; in sdla_intack()
820 hw->regs[0] = tmp; in sdla_intack()
827 tmp = hw->regs[0] & ~0x08; in sdla_intack()
831 hw->regs[0] = tmp; in sdla_intack()
855 void S514_intack (sdlahw_t* hw, u32 int_status) in S514_intack() argument
858 pci_write_config_dword(hw->pci_dev, PCI_INT_STATUS, int_status); in S514_intack()
860 pcibios_write_config_dword(hw->pci_bus, hw->pci_dev_func, in S514_intack()
874 void read_S514_int_stat (sdlahw_t* hw, u32* int_status) in read_S514_int_stat() argument
877 pci_read_config_dword(hw->pci_dev, PCI_INT_STATUS, int_status); in read_S514_int_stat()
879 pcibios_read_config_dword(hw->pci_bus, hw->pci_dev_func, PCI_INT_STATUS, in read_S514_int_stat()
893 int sdla_intr (sdlahw_t* hw) in sdla_intr() argument
895 unsigned port = hw->port; in sdla_intr()
897 switch (hw->type) { in sdla_intr()
901 hw->regs[0] = 0x10; in sdla_intr()
977 int sdla_peek (sdlahw_t* hw, unsigned long addr, void* buf, unsigned len) in sdla_peek() argument
980 if (addr + len > hw->memory) /* verify arguments */ in sdla_peek()
983 if(hw->type == SDLA_S514) { /* copy data for the S514 adapter */ in sdla_peek()
984 peek_by_4 ((unsigned long)hw->dpmbase + addr, buf, len); in sdla_peek()
989 unsigned long oldvec = hw->vector; in sdla_peek()
990 unsigned winsize = hw->dpmsize; in sdla_peek()
1001 err = sdla_mapmem(hw, curvec); in sdla_peek()
1002 peek_by_4 ((unsigned long)hw->dpmbase + curpos, buf, in sdla_peek()
1010 sdla_mapmem(hw, oldvec); in sdla_peek()
1061 int sdla_poke (sdlahw_t* hw, unsigned long addr, void* buf, unsigned len) in sdla_poke() argument
1064 if (addr + len > hw->memory) /* verify arguments */ in sdla_poke()
1067 if(hw->type == SDLA_S514) { /* copy data for the S514 adapter */ in sdla_poke()
1068 poke_by_4 ((unsigned long)hw->dpmbase + addr, buf, len); in sdla_poke()
1073 unsigned long oldvec = hw->vector; in sdla_poke()
1074 unsigned winsize = hw->dpmsize; in sdla_poke()
1085 sdla_mapmem(hw, curvec); in sdla_poke()
1086 poke_by_4 ((unsigned long)hw->dpmbase + curpos, buf, in sdla_poke()
1094 sdla_mapmem(hw, oldvec); in sdla_poke()
1146 static int sdla_detect (sdlahw_t* hw) in sdla_detect() argument
1148 unsigned port = hw->port; in sdla_detect()
1151 if (!port && (hw->type != SDLA_S514)) in sdla_detect()
1154 switch (hw->type) { in sdla_detect()
1176 if (!detect_s514(hw)) err = -ENODEV; in sdla_detect()
1181 hw->type = SDLA_S502A; in sdla_detect()
1183 hw->type = SDLA_S502E; in sdla_detect()
1185 hw->type = SDLA_S503; in sdla_detect()
1187 hw->type = SDLA_S507; in sdla_detect()
1189 hw->type = SDLA_S508; in sdla_detect()
1199 static int sdla_autodpm (sdlahw_t* hw) in sdla_autodpm() argument
1204 switch (hw->type) { in sdla_autodpm()
1228 hw->dpmbase = phys_to_virt(opt[i]); in sdla_autodpm()
1229 err = sdla_setdpm(hw); in sdla_autodpm()
1243 static int sdla_setdpm (sdlahw_t* hw) in sdla_setdpm() argument
1248 sdla_down(hw); in sdla_setdpm()
1249 if (check_memregion(hw->dpmbase, hw->dpmsize)) in sdla_setdpm()
1256 err = sdla_init(hw); in sdla_setdpm()
1259 if (sdla_memtest(hw) < hw->dpmsize) { /* less than window size */ in sdla_setdpm()
1260 sdla_down(hw); in sdla_setdpm()
1263 sdla_mapmem(hw, 0L); /* set window vector at bottom */ in sdla_setdpm()
1272 static int sdla_load (sdlahw_t* hw, sfm_t* sfm, unsigned len) in sdla_load() argument
1305 if(hw->type == SDLA_S514) in sdla_load()
1307 modname, hw->S514_cpu_no[0]); in sdla_load()
1313 (i < SFM_MAX_SDLA) && (sfm->info.adapter[i] != hw->type); in sdla_load()
1318 modname, hw->type); in sdla_load()
1324 if (hw->memory < sfm->info.memsize) { in sdla_load()
1332 if (sdla_poke(hw, sfm->info.codeoffs, sfm->image, sfm->info.codesize)) { in sdla_load()
1339 sdla_bootcfg(hw, &sfm->info); in sdla_load()
1340 if (sdla_start(hw, sfm->info.startoffs)) { in sdla_load()
1347 if (sdla_mapmem(hw, sfm->info.winoffs) || sdla_inten(hw)) { in sdla_load()
1352 hw->fwid = sfm->info.codeid; /* set firmware ID */ in sdla_load()
1359 static int sdla_init (sdlahw_t* hw) in sdla_init() argument
1364 hw->regs[i] = 0; in sdla_init()
1366 switch (hw->type) { in sdla_init()
1367 case SDLA_S502A: return init_s502a(hw); in sdla_init()
1368 case SDLA_S502E: return init_s502e(hw); in sdla_init()
1369 case SDLA_S503: return init_s503(hw); in sdla_init()
1370 case SDLA_S507: return init_s507(hw); in sdla_init()
1371 case SDLA_S508: return init_s508(hw); in sdla_init()
1382 static unsigned long sdla_memtest (sdlahw_t* hw) in sdla_memtest() argument
1387 for (memsize = 0, winsize = hw->dpmsize; in sdla_memtest()
1388 !sdla_mapmem(hw, memsize) && in sdla_memtest()
1389 (test_memregion(hw->dpmbase, winsize) == winsize) in sdla_memtest()
1393 hw->memory = memsize; in sdla_memtest()
1402 static int sdla_bootcfg (sdlahw_t* hw, sfm_info_t* sfminfo) in sdla_bootcfg() argument
1408 if (sdla_mapmem(hw, sfminfo->dataoffs) != 0) in sdla_bootcfg()
1411 if(hw->type == SDLA_S514) in sdla_bootcfg()
1412 data = (void*)(hw->dpmbase + sfminfo->dataoffs); in sdla_bootcfg()
1414 data = (void*)((u8 *)hw->dpmbase + in sdla_bootcfg()
1415 (sfminfo->dataoffs - hw->vector)); in sdla_bootcfg()
1419 writeb (make_config_byte(hw), &data[0x00]); in sdla_bootcfg()
1439 static unsigned char make_config_byte (sdlahw_t* hw) in make_config_byte() argument
1443 switch (hw->pclk) { in make_config_byte()
1451 switch (hw->type) { in make_config_byte()
1465 static int sdla_start (sdlahw_t* hw, unsigned addr) in sdla_start() argument
1467 unsigned port = hw->port; in sdla_start()
1471 if (!port && (hw->type != SDLA_S514)) return -EFAULT; in sdla_start()
1473 switch (hw->type) { in sdla_start()
1475 bootp = hw->dpmbase; in sdla_start()
1484 bootp = hw->dpmbase; in sdla_start()
1491 err = sdla_mapmem(hw, 0); in sdla_start()
1498 switch (hw->type) { in sdla_start()
1501 hw->regs[0] = 0x10; in sdla_start()
1506 hw->regs[3] = 0x01; in sdla_start()
1515 hw->regs[0] = 0; in sdla_start()
1521 tmp = hw->regs[0] | 0x09; /* set bits 0 and 3 */ in sdla_start()
1523 hw->regs[0] = tmp; /* update mirror */ in sdla_start()
1530 tmp = hw->regs[0] | 0x02; in sdla_start()
1532 hw->regs[0] = tmp; /* update mirror */ in sdla_start()
1539 tmp = hw->regs[0] | 0x02; in sdla_start()
1541 hw->regs[0] = tmp; /* update mirror */ in sdla_start()
1548 writeb (S514_CPU_START, hw->vector); in sdla_start()
1560 static int init_s502a (sdlahw_t* hw) in init_s502a() argument
1562 unsigned port = hw->port; in init_s502a()
1568 hw->regs[0] = 0x08; in init_s502a()
1569 hw->regs[1] = 0xFF; in init_s502a()
1572 i = get_option_index(s502a_dpmbase_options, virt_to_phys(hw->dpmbase)); in init_s502a()
1577 switch (hw->dpmsize) { in init_s502a()
1591 hw->regs[1] = tmp; in init_s502a()
1592 hw->regs[0] = 0x08; in init_s502a()
1599 static int init_s502e (sdlahw_t* hw) in init_s502e() argument
1601 unsigned port = hw->port; in init_s502e()
1608 i = get_option_index(s508_dpmbase_options, virt_to_phys(hw->dpmbase)); in init_s502e()
1613 switch (hw->dpmsize) { in init_s502e()
1627 hw->regs[1] = tmp; in init_s502e()
1631 hw->regs[0] = 0x02; in init_s502e()
1640 static int init_s503 (sdlahw_t* hw) in init_s503() argument
1642 unsigned port = hw->port; in init_s503()
1649 i = get_option_index(s508_dpmbase_options, virt_to_phys(hw->dpmbase)); in init_s503()
1654 switch (hw->dpmsize) { in init_s503()
1668 hw->regs[1] = tmp; in init_s503()
1672 hw->regs[0] = 0x02; /* update mirror */ in init_s503()
1679 static int init_s507 (sdlahw_t* hw) in init_s507() argument
1681 unsigned port = hw->port; in init_s507()
1688 i = get_option_index(s507_dpmbase_options, virt_to_phys(hw->dpmbase)); in init_s507()
1693 switch (hw->dpmsize) { in init_s507()
1707 hw->regs[0] = 0x01; in init_s507()
1714 hw->regs[1] = tmp; in init_s507()
1717 tmp = hw->regs[0] | 0x04; in init_s507()
1718 if (hw->irq) { in init_s507()
1719 i = get_option_index(s508_irq_options, hw->irq); in init_s507()
1723 hw->regs[0] = tmp; /* update mirror */ in init_s507()
1731 static int init_s508 (sdlahw_t* hw) in init_s508() argument
1733 unsigned port = hw->port; in init_s508()
1740 i = get_option_index(s508_dpmbase_options, virt_to_phys(hw->dpmbase)); in init_s508()
1747 hw->regs[1] = tmp; in init_s508()
1751 hw->regs[0] = 0x04; /* update mirror */ in init_s508()
1958 static int detect_s514 (sdlahw_t* hw) in detect_s514() argument
1991 CPU_no = hw->S514_cpu_no[0]; in detect_s514()
1992 slot_no = hw->S514_slot_no; in detect_s514()
1993 auto_slot_cfg = hw->auto_pci_cfg; in detect_s514()
2017 number_S514_cards = find_s514_adapter(hw, 0); in detect_s514()
2024 number_S514_cards = find_s514_adapter(hw, 1); in detect_s514()
2033 pci_dev = hw->pci_dev; in detect_s514()
2040 pci_dev = hw->pci_dev; in detect_s514()
2047 pcibios_read_config_dword(hw->pci_bus, hw->pci_dev_func, in detect_s514()
2071 pcibios_read_config_dword(hw->pci_bus, hw->pci_dev_func, in detect_s514()
2074 pcibios_write_config_dword(hw->pci_bus, hw->pci_dev_func, in detect_s514()
2081 if(!(hw->irq = pci_dev->irq)) { in detect_s514()
2095 if (init_pci_slot(hw)) in detect_s514()
2105 pcibios_read_config_byte(hw->pci_bus, hw->pci_dev_func, in detect_s514()
2112 pcibios_read_config_byte(hw->pci_bus, hw->pci_dev_func, in detect_s514()
2113 PCI_INT_LINE_BYTE, (unsigned char *)&hw->irq); in detect_s514()
2114 if(hw->irq == PCI_IRQ_NOT_ALLOCATED) { in detect_s514()
2119 pcibios_read_config_dword(hw->pci_bus, hw->pci_dev_func, PCI_INT_CONFIG, &ut_u32); in detect_s514()
2122 pcibios_write_config_dword(hw->pci_bus, hw->pci_dev_func, in detect_s514()
2127 modname, hw->irq); in detect_s514()
2130 hw->dpmbase = (void *)ioremap((unsigned long)S514_mem_base_addr, in detect_s514()
2133 hw->vector = (unsigned long)ioremap( in detect_s514()
2137 if(!hw->dpmbase || !hw->vector) { in detect_s514()
2144 writeb (S514_CPU_HALT, hw->vector); in detect_s514()
2153 static int find_s514_adapter(sdlahw_t* hw, char find_first_S514_card) in find_s514_adapter() argument
2166 slot_no = hw->S514_slot_no; in find_s514_adapter()
2178 hw->pci_dev = pci_dev; in find_s514_adapter()
2190 if (hw->auto_pci_cfg){ in find_s514_adapter()
2191 hw->S514_slot_no = ((pci_dev->devfn >> 3) & PCI_DEV_SLOT_MASK); in find_s514_adapter()
2192 slot_no = hw->S514_slot_no; in find_s514_adapter()
2204 &hw->pci_bus, &hw->pci_dev_func)!=PCIBIOS_SUCCESSFUL) { in find_s514_adapter()
2208 pcibios_read_config_word(hw->pci_bus, hw->pci_dev_func, in find_s514_adapter()
2220 modname, hw->pci_bus, in find_s514_adapter()
2221 ((hw->pci_dev_func >> 3) & PCI_DEV_SLOT_MASK)); in find_s514_adapter()
2223 if (hw->auto_pci_cfg){ in find_s514_adapter()
2224 hw->S514_slot_no = ((hw->pci_dev_func >> 3) & PCI_DEV_SLOT_MASK) in find_s514_adapter()
2225 slot_no = hw->S514_slot_no; in find_s514_adapter()
2227 }else if (((hw->pci_dev_func >> 3) & PCI_DEV_SLOT_MASK) == slot_no) { in find_s514_adapter()
2240 else if ((number_S514_cards > 1) && hw->auto_pci_cfg) { in find_s514_adapter()
2250 else if (!hw->auto_pci_cfg && !S514_found_in_slot) { in find_s514_adapter()
2365 static int init_pci_slot(sdlahw_t *hw) in init_pci_slot() argument
2378 if (pci_slot_ar[i] == hw->S514_slot_no){ in init_pci_slot()
2388 read_S514_int_stat(hw,&int_status); in init_pci_slot()
2389 S514_intack(hw,int_status); in init_pci_slot()
2398 pci_slot_ar[i] = hw->S514_slot_no; in init_pci_slot()
2403 static int pci_probe(sdlahw_t *hw) in pci_probe() argument
2460 &hw->pci_bus, &hw->pci_dev_func)!=PCIBIOS_SUCCESSFUL) { in pci_probe()
2463 pcibios_read_config_word(hw->pci_bus, hw->pci_dev_func, in pci_probe()
2468 pcibios_read_config_word(hw->pci_bus,hw->pci_dev_func,PCI_CARD_TYPE, in pci_probe()
2471 pcibios_read_config_byte(hw->pci_bus, hw->pci_dev_func, in pci_probe()
2482 modname, hw->pci_bus, in pci_probe()
2483 ((hw->pci_dev_func >> 3) & PCI_DEV_SLOT_MASK),irq); in pci_probe()
2486 modname, hw->pci_bus, in pci_probe()
2487 ((hw->pci_dev_func >> 3) & PCI_DEV_SLOT_MASK),irq); in pci_probe()
2505 sdlahw_t hw; in wanpipe_hw_probe() local
2510 memset(&hw, 0, sizeof(hw)); in wanpipe_hw_probe()
2521 hw.S514_slot_no = 0; in wanpipe_hw_probe()
2522 cardno += pci_probe(&hw); in wanpipe_hw_probe()