Lines Matching refs:ppc
70 #define LOG_PPC(function, ppc, string) \ argument
88 #define PPC_CONFIG_LOCK(ppc) critical_enter() argument
89 #define PPC_CONFIG_UNLOCK(ppc) critical_exit() argument
136 struct ppc_data *ppc = DEVTOSOFTC(dev); in ppc_ecp_sync() local
138 PPC_ASSERT_LOCKED(ppc); in ppc_ecp_sync()
139 if (!(ppc->ppc_avm & PPB_ECP) && !(ppc->ppc_dtm & PPB_ECP)) in ppc_ecp_sync()
142 r = r_ecr(ppc); in ppc_ecp_sync()
147 r = r_ecr(ppc); in ppc_ecp_sync()
164 ppc_detect_fifo(struct ppc_data *ppc) in ppc_detect_fifo() argument
171 ecr_sav = r_ecr(ppc); in ppc_detect_fifo()
172 ctr_sav = r_ctr(ppc); in ppc_detect_fifo()
175 w_ecr(ppc, 0xf4); in ppc_detect_fifo()
178 ppc->ppc_pword = (r_cnfgA(ppc) & PPC_PWORD_MASK); in ppc_detect_fifo()
181 if (ppc->ppc_pword != PPC_PWORD_8) { in ppc_detect_fifo()
182 LOG_PPC(__func__, ppc, "PWord not supported"); in ppc_detect_fifo()
186 w_ecr(ppc, 0x34); /* byte mode, no interrupt, no DMA */ in ppc_detect_fifo()
187 ctr = r_ctr(ppc); in ppc_detect_fifo()
188 w_ctr(ppc, ctr | PCD); /* set direction to 1 */ in ppc_detect_fifo()
191 w_ecr(ppc, 0xd4); in ppc_detect_fifo()
195 if (r_ecr(ppc) & PPC_FIFO_EMPTY) in ppc_detect_fifo()
197 cc = r_fifo(ppc); in ppc_detect_fifo()
201 LOG_PPC(__func__, ppc, "can't flush FIFO"); in ppc_detect_fifo()
206 w_ecr(ppc, 0xd0); in ppc_detect_fifo()
212 w_fifo(ppc, (char)i); in ppc_detect_fifo()
213 if (!ppc->ppc_rthr && (r_ecr(ppc) & PPC_SERVICE_INTR)) { in ppc_detect_fifo()
215 ppc->ppc_rthr = i+1; in ppc_detect_fifo()
217 if (r_ecr(ppc) & PPC_FIFO_FULL) { in ppc_detect_fifo()
218 ppc->ppc_fifo = i+1; in ppc_detect_fifo()
224 LOG_PPC(__func__, ppc, "can't fill FIFO"); in ppc_detect_fifo()
228 w_ecr(ppc, 0xd4); /* test mode, no interrupt, no DMA */ in ppc_detect_fifo()
229 w_ctr(ppc, ctr & ~PCD); /* set direction to 0 */ in ppc_detect_fifo()
230 w_ecr(ppc, 0xd0); /* enable interrupts */ in ppc_detect_fifo()
235 for (i=ppc->ppc_fifo; i>0; i--) { in ppc_detect_fifo()
236 if (r_fifo(ppc) != (char)(ppc->ppc_fifo-i)) { in ppc_detect_fifo()
237 LOG_PPC(__func__, ppc, "invalid data in FIFO"); in ppc_detect_fifo()
240 if (r_ecr(ppc) & PPC_SERVICE_INTR) { in ppc_detect_fifo()
242 ppc->ppc_wthr = ppc->ppc_fifo - i+1; in ppc_detect_fifo()
245 if (i>1 && (r_ecr(ppc) & PPC_FIFO_EMPTY)) { in ppc_detect_fifo()
246 LOG_PPC(__func__, ppc, "data lost in FIFO"); in ppc_detect_fifo()
252 if (!(r_ecr(ppc) & PPC_FIFO_EMPTY)) { in ppc_detect_fifo()
253 LOG_PPC(__func__, ppc, "can't empty the FIFO"); in ppc_detect_fifo()
257 w_ctr(ppc, ctr_sav); in ppc_detect_fifo()
258 w_ecr(ppc, ecr_sav); in ppc_detect_fifo()
263 w_ctr(ppc, ctr_sav); in ppc_detect_fifo()
264 w_ecr(ppc, ecr_sav); in ppc_detect_fifo()
270 ppc_detect_port(struct ppc_data *ppc) in ppc_detect_port() argument
273 w_ctr(ppc, 0x0c); /* To avoid missing PS2 ports */ in ppc_detect_port()
274 w_dtr(ppc, 0xaa); in ppc_detect_port()
275 if (r_dtr(ppc) != 0xaa) in ppc_detect_port()
289 ppc_reset_epp_timeout(struct ppc_data *ppc) in ppc_reset_epp_timeout() argument
293 r = r_str(ppc); in ppc_reset_epp_timeout()
294 w_str(ppc, r | 0x1); in ppc_reset_epp_timeout()
295 w_str(ppc, r & 0xfe); in ppc_reset_epp_timeout()
301 ppc_check_epp_timeout(struct ppc_data *ppc) in ppc_check_epp_timeout() argument
303 ppc_reset_epp_timeout(ppc); in ppc_check_epp_timeout()
305 return (!(r_str(ppc) & TIMEOUT)); in ppc_check_epp_timeout()
312 ppc_generic_setmode(struct ppc_data *ppc, int mode) in ppc_generic_setmode() argument
317 if (mode && !(ppc->ppc_avm & mode)) in ppc_generic_setmode()
321 if ((ppc->ppc_avm & PPB_ECP) || (ppc->ppc_dtm & PPB_ECP)) { in ppc_generic_setmode()
326 w_ecr(ppc, PPC_ECR_RESET); in ppc_generic_setmode()
341 w_ecr(ppc, ecr); in ppc_generic_setmode()
344 ppc->ppc_mode = mode; in ppc_generic_setmode()
357 ppc_smclike_setmode(struct ppc_data *ppc, int mode) in ppc_smclike_setmode() argument
362 if (mode && !(ppc->ppc_avm & mode)) in ppc_smclike_setmode()
366 if ((ppc->ppc_avm & PPB_ECP) || (ppc->ppc_dtm & PPB_ECP)) { in ppc_smclike_setmode()
371 w_ecr(ppc, PPC_ECR_RESET); in ppc_smclike_setmode()
387 w_ecr(ppc, ecr); in ppc_smclike_setmode()
390 ppc->ppc_mode = mode; in ppc_smclike_setmode()
422 ppc_pc873xx_detect(struct ppc_data *ppc, int chipset_mode) /* XXX mode never forced */ in ppc_pc873xx_detect() argument
451 ppc->ppc_model = NS_PC87332; in ppc_pc873xx_detect()
453 ppc->ppc_model = NS_PC87306; in ppc_pc873xx_detect()
455 ppc->ppc_model = NS_PC87334; in ppc_pc873xx_detect()
459 ppc->ppc_model = NS_PC87303; in ppc_pc873xx_detect()
490 if (pc873xx_porttab[val & 0x3] != ppc->ppc_base) { in ppc_pc873xx_detect()
494 switch (ppc->ppc_base) { in ppc_pc873xx_detect()
524 if (pc873xx_porttab[val] != ppc->ppc_base) { in ppc_pc873xx_detect()
527 pc873xx_porttab[val], ppc->ppc_base); in ppc_pc873xx_detect()
536 if (ppc->ppc_base == 0x378) in ppc_pc873xx_detect()
542 printf("PC873xx irq %d at 0x%x\n", irq, ppc->ppc_base); in ppc_pc873xx_detect()
547 if (irq != ppc->ppc_irq) { in ppc_pc873xx_detect()
552 if (ppc->ppc_base == 0x378 && !(ptr & PC873_CFGLOCK)) { in ppc_pc873xx_detect()
553 if (ppc->ppc_irq == 7) { in ppc_pc873xx_detect()
561 printf("PC873xx irq set to %d\n", ppc->ppc_irq); in ppc_pc873xx_detect()
578 ppc->ppc_avm |= PPB_NIBBLE; in ppc_pc873xx_detect()
583 ppc->ppc_avm |= PPB_EPP; in ppc_pc873xx_detect()
589 ppc->ppc_epp = EPP_1_9; in ppc_pc873xx_detect()
591 ppc->ppc_epp = EPP_1_7; in ppc_pc873xx_detect()
593 if ((ppc->ppc_model == NS_PC87332) && bootverbose) { in ppc_pc873xx_detect()
602 ppc->ppc_avm |= PPB_ECP; in ppc_pc873xx_detect()
607 ppc->ppc_avm |= PPB_PS2; in ppc_pc873xx_detect()
615 ppc->ppc_avm |= PPB_SPP; in ppc_pc873xx_detect()
642 ppc->ppc_epp = EPP_1_9; /* XXX */ in ppc_pc873xx_detect()
648 if (ppc->ppc_model == NS_PC87332) { in ppc_pc873xx_detect()
684 ppc->ppc_avm = chipset_mode; in ppc_pc873xx_detect()
690 ppc->ppc_type = PPC_TYPE_GENERIC; in ppc_pc873xx_detect()
691 ppc_generic_setmode(ppc, chipset_mode); in ppc_pc873xx_detect()
704 ppc_smc37c66xgt_detect(struct ppc_data *ppc, int chipset_mode) in ppc_smc37c66xgt_detect() argument
719 PPC_CONFIG_LOCK(ppc); in ppc_smc37c66xgt_detect()
722 PPC_CONFIG_UNLOCK(ppc); in ppc_smc37c66xgt_detect()
731 PPC_CONFIG_LOCK(ppc); in ppc_smc37c66xgt_detect()
734 PPC_CONFIG_UNLOCK(ppc); in ppc_smc37c66xgt_detect()
760 if (port_address[(int)r] != ppc->ppc_base) { in ppc_smc37c66xgt_detect()
765 ppc->ppc_model = type; in ppc_smc37c66xgt_detect()
774 device_printf(ppc->ppc_dev, "SMC registers CR1=0x%x", in ppc_smc37c66xgt_detect()
789 ppc->ppc_avm |= PPB_ECP | PPB_EPP | PPB_SPP; in ppc_smc37c66xgt_detect()
802 ppc->ppc_avm |= PPB_SPP; in ppc_smc37c66xgt_detect()
808 ppc->ppc_avm |= PPB_EPP | PPB_SPP; in ppc_smc37c66xgt_detect()
814 ppc->ppc_avm |= PPB_ECP | PPB_SPP; in ppc_smc37c66xgt_detect()
820 ppc->ppc_avm |= PPB_ECP | PPB_EPP | PPB_SPP; in ppc_smc37c66xgt_detect()
827 ppc->ppc_avm |= PPB_SPP; in ppc_smc37c66xgt_detect()
834 ppc->ppc_avm = chipset_mode; in ppc_smc37c66xgt_detect()
871 ppc->ppc_avm = chipset_mode; in ppc_smc37c66xgt_detect()
875 if (ppc->ppc_avm & PPB_ECP) { in ppc_smc37c66xgt_detect()
886 if (ppc->ppc_avm & PPB_EPP) { in ppc_smc37c66xgt_detect()
895 if (ppc->ppc_epp == EPP_1_9) in ppc_smc37c66xgt_detect()
903 ppc->ppc_type = PPC_TYPE_SMCLIKE; in ppc_smc37c66xgt_detect()
904 ppc_smclike_setmode(ppc, chipset_mode); in ppc_smc37c66xgt_detect()
914 ppc_smc37c935_detect(struct ppc_data *ppc, int chipset_mode) in ppc_smc37c935_detect() argument
918 PPC_CONFIG_LOCK(ppc); in ppc_smc37c935_detect()
921 PPC_CONFIG_UNLOCK(ppc); in ppc_smc37c935_detect()
932 ppc->ppc_model = type; in ppc_smc37c935_detect()
939 outb(SMC935_DAT, (u_char)((ppc->ppc_base & 0xff00) >> 8)); in ppc_smc37c935_detect()
941 outb(SMC935_DAT, (u_char)(ppc->ppc_base & 0xff)); in ppc_smc37c935_detect()
944 ppc->ppc_avm = PPB_COMPATIBLE; /* default mode */ in ppc_smc37c935_detect()
946 ppc->ppc_avm = chipset_mode; in ppc_smc37c935_detect()
953 if (ppc->ppc_epp == EPP_1_9) { in ppc_smc37c935_detect()
957 if (ppc->ppc_epp == EPP_1_7) { in ppc_smc37c935_detect()
970 if (ppc->ppc_epp == EPP_1_9) { in ppc_smc37c935_detect()
974 if (ppc->ppc_epp == EPP_1_7) { in ppc_smc37c935_detect()
987 ppc->ppc_type = PPC_TYPE_SMCLIKE; in ppc_smc37c935_detect()
988 ppc_smclike_setmode(ppc, chipset_mode); in ppc_smc37c935_detect()
1009 ppc_w83877f_detect(struct ppc_data *ppc, int chipset_mode) in ppc_w83877f_detect() argument
1045 if (ppc->ppc_base != inb(efdr) * 4) /* 4 bytes boundaries */ in ppc_w83877f_detect()
1053 ppc->ppc_model = WINB_W83877F; in ppc_w83877f_detect()
1057 ppc->ppc_model = WINB_W83877AF; in ppc_w83877f_detect()
1061 ppc->ppc_model = WINB_UNKNOWN; in ppc_w83877f_detect()
1066 device_printf(ppc->ppc_dev, "0x%x - ", w83877f_keys[i]); in ppc_w83877f_detect()
1084 ppc->ppc_type = PPC_TYPE_GENERIC; in ppc_w83877f_detect()
1100 device_printf(ppc->ppc_dev, in ppc_w83877f_detect()
1109 device_printf(ppc->ppc_dev, in ppc_w83877f_detect()
1114 ppc->ppc_avm |= PPB_EPP | PPB_SPP; in ppc_w83877f_detect()
1116 device_printf(ppc->ppc_dev, "EPP SPP\n"); in ppc_w83877f_detect()
1120 ppc->ppc_avm |= PPB_ECP | PPB_SPP; in ppc_w83877f_detect()
1122 device_printf(ppc->ppc_dev, "ECP SPP\n"); in ppc_w83877f_detect()
1126 ppc->ppc_avm |= PPB_ECP | PPB_EPP | PPB_SPP; in ppc_w83877f_detect()
1127 ppc->ppc_type = PPC_TYPE_SMCLIKE; in ppc_w83877f_detect()
1130 device_printf(ppc->ppc_dev, "ECP+EPP SPP\n"); in ppc_w83877f_detect()
1151 device_printf(ppc->ppc_dev, in ppc_w83877f_detect()
1154 ppc->ppc_type = PPC_TYPE_SMCLIKE; in ppc_w83877f_detect()
1159 device_printf(ppc->ppc_dev, "ECP\n"); in ppc_w83877f_detect()
1165 device_printf(ppc->ppc_dev, "EPP SPP\n"); in ppc_w83877f_detect()
1167 ppc->ppc_avm = chipset_mode; in ppc_w83877f_detect()
1173 switch (ppc->ppc_type) { in ppc_w83877f_detect()
1175 ppc_smclike_setmode(ppc, chipset_mode); in ppc_w83877f_detect()
1178 ppc_generic_setmode(ppc, chipset_mode); in ppc_w83877f_detect()
1190 ppc_generic_detect(struct ppc_data *ppc, int chipset_mode) in ppc_generic_detect() argument
1193 ppc->ppc_type = PPC_TYPE_GENERIC; in ppc_generic_detect()
1196 device_printf(ppc->ppc_dev, "SPP"); in ppc_generic_detect()
1199 w_ecr(ppc, PPC_ECR_PS2); in ppc_generic_detect()
1200 if ((r_ecr(ppc) & 0xe0) == PPC_ECR_PS2) { in ppc_generic_detect()
1201 ppc->ppc_dtm |= PPB_ECP | PPB_SPP; in ppc_generic_detect()
1206 w_ecr(ppc, PPC_ECR_EPP); in ppc_generic_detect()
1210 if (ppc_check_epp_timeout(ppc)) { in ppc_generic_detect()
1211 ppc->ppc_dtm |= PPB_EPP; in ppc_generic_detect()
1213 if (ppc->ppc_dtm & PPB_ECP) { in ppc_generic_detect()
1215 ppc->ppc_model = SMC_LIKE; in ppc_generic_detect()
1216 ppc->ppc_type = PPC_TYPE_SMCLIKE; in ppc_generic_detect()
1226 w_ecr(ppc, PPC_ECR_STD); in ppc_generic_detect()
1230 ppc->ppc_dtm |= PPB_NIBBLE; in ppc_generic_detect()
1233 ppc->ppc_avm = chipset_mode; in ppc_generic_detect()
1235 ppc->ppc_avm = ppc->ppc_dtm; in ppc_generic_detect()
1240 switch (ppc->ppc_type) { in ppc_generic_detect()
1242 ppc_smclike_setmode(ppc, chipset_mode); in ppc_generic_detect()
1245 ppc_generic_setmode(ppc, chipset_mode); in ppc_generic_detect()
1258 ppc_detect(struct ppc_data *ppc, int chipset_mode) { in ppc_detect() argument
1275 if (!ppc_detect_port(ppc) && chipset_mode == 0) in ppc_detect()
1279 ppc->ppc_avm = PPB_COMPATIBLE; in ppc_detect()
1287 if (ppc->ppc_flags & 0x40) { in ppc_detect()
1292 ppc->ppc_mode = ppc_generic_detect(ppc, chipset_mode); in ppc_detect()
1297 if ((mode = chipset_detect[i](ppc, chipset_mode)) != -1) { in ppc_detect()
1298 ppc->ppc_mode = mode; in ppc_detect()
1306 if ((ppc->ppc_avm & PPB_ECP) && !(ppc->ppc_flags & 0x80)) in ppc_detect()
1307 ppc_detect_fifo(ppc); in ppc_detect()
1321 struct ppc_data *ppc = DEVTOSOFTC(dev); in ppc_exec_microseq() local
1336 #define r_reg(reg,ppc) (bus_read_1((ppc)->res_ioport, reg)) in ppc_exec_microseq() argument
1337 #define w_reg(reg, ppc, byte) (bus_write_1((ppc)->res_ioport, reg, byte)) in ppc_exec_microseq() argument
1341 PPC_ASSERT_LOCKED(ppc); in ppc_exec_microseq()
1346 cc = r_reg(mi->arg[0].i, ppc); in ppc_exec_microseq()
1349 w_reg(mi->arg[0].i, ppc, cc); in ppc_exec_microseq()
1355 ptr = ppc->ppc_ptr; in ppc_exec_microseq()
1358 accum = ppc->ppc_accum; in ppc_exec_microseq()
1360 w_reg(reg, ppc, *ptr++); in ppc_exec_microseq()
1361 ppc->ppc_accum = accum; in ppc_exec_microseq()
1364 w_reg(reg, ppc, *ptr++); in ppc_exec_microseq()
1365 ppc->ppc_ptr = ptr; in ppc_exec_microseq()
1373 ptr = ppc->ppc_ptr; in ppc_exec_microseq()
1376 accum = ppc->ppc_accum; in ppc_exec_microseq()
1378 *ptr++ = r_reg(reg, ppc) & mask; in ppc_exec_microseq()
1379 ppc->ppc_accum = accum; in ppc_exec_microseq()
1382 *ptr++ = r_reg(reg, ppc) & mask; in ppc_exec_microseq()
1383 ppc->ppc_ptr = ptr; in ppc_exec_microseq()
1389 *((char *) mi->arg[2].p) = r_reg(mi->arg[0].i, ppc) & in ppc_exec_microseq()
1400 w_reg(mi->arg[0].i, ppc, (char)mi->arg[1].i); in ppc_exec_microseq()
1411 PPC_UNLOCK(ppc); in ppc_exec_microseq()
1413 PPC_LOCK(ppc); in ppc_exec_microseq()
1425 w_reg(reg, ppc, *p++); in ppc_exec_microseq()
1432 ppc->ppc_accum = mi->arg[0].i; in ppc_exec_microseq()
1437 if (--ppc->ppc_accum > 0) in ppc_exec_microseq()
1443 cc = r_str(ppc); in ppc_exec_microseq()
1450 cc = r_str(ppc); in ppc_exec_microseq()
1457 cc = r_str(ppc); in ppc_exec_microseq()
1469 if ((error = mi->arg[0].f(mi->arg[1].p, ppc->ppc_ptr))) in ppc_exec_microseq()
1476 ppc->ppc_ptr = (char *)mi->arg[0].p; in ppc_exec_microseq()
1536 struct ppc_data *ppc = arg; in ppcintr() local
1546 PPC_LOCK(ppc); in ppcintr()
1547 if (ppc->ppc_intr_hook != NULL && in ppcintr()
1548 ppc->ppc_intr_hook(ppc->ppc_intr_arg) == 0) { in ppcintr()
1549 PPC_UNLOCK(ppc); in ppcintr()
1553 str = r_str(ppc); in ppcintr()
1554 ctr = r_ctr(ppc); in ppcintr()
1555 ecr = r_ecr(ppc); in ppcintr()
1563 PPC_UNLOCK(ppc); in ppcintr()
1569 if ((str & nFAULT) && (ppc->ppc_mode & PPB_ECP)) { in ppcintr()
1572 if (ppc->ppc_irqstat & PPC_IRQ_nFAULT) { in ppcintr()
1574 w_ecr(ppc, ecr | PPC_nFAULT_INTR); in ppcintr()
1575 ppc->ppc_irqstat &= ~PPC_IRQ_nFAULT; in ppcintr()
1578 PPC_UNLOCK(ppc); in ppcintr()
1583 if (ppc->ppc_irqstat & PPC_IRQ_DMA) { in ppcintr()
1585 w_ecr(ppc, ecr | PPC_SERVICE_INTR); in ppcintr()
1586 ppc->ppc_irqstat &= ~PPC_IRQ_DMA; in ppcintr()
1587 ecr = r_ecr(ppc); in ppcintr()
1590 if ((ppc->ppc_avm & PPB_ECP) && (ecr & PPC_ENABLE_DMA)) { in ppcintr()
1595 w_ecr(ppc, ecr & ~PPC_ENABLE_DMA); in ppcintr()
1596 ecr = r_ecr(ppc); in ppcintr()
1598 if (ppc->ppc_dmastat == PPC_DMA_STARTED) { in ppcintr()
1602 ppc->ppc_dmadone(ppc); in ppcintr()
1603 ppc->ppc_dmastat = PPC_DMA_COMPLETE; in ppcintr()
1606 wakeup(ppc); in ppcintr()
1609 } else if (ppc->ppc_irqstat & PPC_IRQ_FIFO) { in ppcintr()
1612 ppc->ppc_irqstat &= ~PPC_IRQ_FIFO; in ppcintr()
1614 PPC_UNLOCK(ppc); in ppcintr()
1634 struct ppc_data *ppc = DEVTOSOFTC(dev); in ppc_reset_epp() local
1636 PPC_ASSERT_LOCKED(ppc); in ppc_reset_epp()
1637 ppc_reset_epp_timeout(ppc); in ppc_reset_epp()
1645 struct ppc_data *ppc = DEVTOSOFTC(dev); in ppc_setmode() local
1647 PPC_ASSERT_LOCKED(ppc); in ppc_setmode()
1648 switch (ppc->ppc_type) { in ppc_setmode()
1650 return (ppc_smclike_setmode(ppc, mode)); in ppc_setmode()
1655 return (ppc_generic_setmode(ppc, mode)); in ppc_setmode()
1669 struct ppc_data *ppc; in ppc_probe() local
1676 ppc = DEVTOSOFTC(dev); in ppc_probe()
1677 bzero(ppc, sizeof(struct ppc_data)); in ppc_probe()
1679 ppc->rid_ioport = rid; in ppc_probe()
1707 ppc->res_ioport = bus_alloc_resource_anywhere(dev, SYS_RES_IOPORT, in ppc_probe()
1708 &ppc->rid_ioport, in ppc_probe()
1712 if (ppc->res_ioport != 0) { in ppc_probe()
1717 ppc->res_ioport = bus_alloc_resource_anywhere(dev, in ppc_probe()
1719 &ppc->rid_ioport, in ppc_probe()
1722 if (ppc->res_ioport != 0) { in ppc_probe()
1732 ppc->ppc_base = rman_get_start(ppc->res_ioport); in ppc_probe()
1734 ppc->ppc_flags = device_get_flags(dev); in ppc_probe()
1736 if (!(ppc->ppc_flags & 0x20)) { in ppc_probe()
1737 ppc->res_irq = bus_alloc_resource_any(dev, SYS_RES_IRQ, in ppc_probe()
1738 &ppc->rid_irq, in ppc_probe()
1740 ppc->res_drq = bus_alloc_resource_any(dev, SYS_RES_DRQ, in ppc_probe()
1741 &ppc->rid_drq, in ppc_probe()
1745 if (ppc->res_irq) in ppc_probe()
1746 ppc->ppc_irq = rman_get_start(ppc->res_irq); in ppc_probe()
1747 if (ppc->res_drq) in ppc_probe()
1748 ppc->ppc_dmachan = rman_get_start(ppc->res_drq); in ppc_probe()
1750 ppc->ppc_dev = dev; in ppc_probe()
1751 ppc->ppc_model = GENERIC; in ppc_probe()
1753 ppc->ppc_mode = PPB_COMPATIBLE; in ppc_probe()
1754 ppc->ppc_epp = (ppc->ppc_flags & 0x10) >> 4; in ppc_probe()
1756 ppc->ppc_type = PPC_TYPE_GENERIC; in ppc_probe()
1761 if (ppc_detect(ppc, ppc->ppc_flags & 0xf)) in ppc_probe()
1767 if (ppc->res_irq != 0) { in ppc_probe()
1768 bus_release_resource(dev, SYS_RES_IRQ, ppc->rid_irq, in ppc_probe()
1769 ppc->res_irq); in ppc_probe()
1771 if (ppc->res_ioport != 0) { in ppc_probe()
1772 bus_release_resource(dev, SYS_RES_IOPORT, ppc->rid_ioport, in ppc_probe()
1773 ppc->res_ioport); in ppc_probe()
1775 if (ppc->res_drq != 0) { in ppc_probe()
1776 bus_release_resource(dev, SYS_RES_DRQ, ppc->rid_drq, in ppc_probe()
1777 ppc->res_drq); in ppc_probe()
1785 struct ppc_data *ppc = DEVTOSOFTC(dev); in ppc_attach() local
1788 mtx_init(&ppc->ppc_lock, device_get_nameunit(dev), "ppc", MTX_DEF); in ppc_attach()
1791 ppc_models[ppc->ppc_model], ppc_avms[ppc->ppc_avm], in ppc_attach()
1792 ppc_modes[ppc->ppc_mode], (PPB_IS_EPP(ppc->ppc_mode)) ? in ppc_attach()
1793 ppc_epp_protocol[ppc->ppc_epp] : ""); in ppc_attach()
1795 if (ppc->ppc_fifo) in ppc_attach()
1797 ppc->ppc_fifo, ppc->ppc_wthr, ppc->ppc_rthr); in ppc_attach()
1799 if (ppc->res_irq) { in ppc_attach()
1801 error = bus_setup_intr(dev, ppc->res_irq, INTR_TYPE_TTY | in ppc_attach()
1802 INTR_MPSAFE, NULL, ppcintr, ppc, &ppc->intr_cookie); in ppc_attach()
1807 mtx_destroy(&ppc->ppc_lock); in ppc_attach()
1813 ppc->ppbus = device_add_child(dev, "ppbus", -1); in ppc_attach()
1818 device_probe_and_attach(ppc->ppbus); in ppc_attach()
1826 struct ppc_data *ppc = DEVTOSOFTC(dev); in ppc_detach() local
1828 if (ppc->res_irq == 0) { in ppc_detach()
1835 if (ppc->res_irq != 0) { in ppc_detach()
1836 bus_teardown_intr(dev, ppc->res_irq, ppc->intr_cookie); in ppc_detach()
1837 bus_release_resource(dev, SYS_RES_IRQ, ppc->rid_irq, in ppc_detach()
1838 ppc->res_irq); in ppc_detach()
1840 if (ppc->res_ioport != 0) { in ppc_detach()
1841 bus_release_resource(dev, SYS_RES_IOPORT, ppc->rid_ioport, in ppc_detach()
1842 ppc->res_ioport); in ppc_detach()
1844 if (ppc->res_drq != 0) { in ppc_detach()
1845 bus_release_resource(dev, SYS_RES_DRQ, ppc->rid_drq, in ppc_detach()
1846 ppc->res_drq); in ppc_detach()
1849 mtx_destroy(&ppc->ppc_lock); in ppc_detach()
1857 struct ppc_data *ppc = DEVTOSOFTC(ppcdev); in ppc_io() local
1859 PPC_ASSERT_LOCKED(ppc); in ppc_io()
1862 bus_write_multi_1(ppc->res_ioport, PPC_EPP_DATA, addr, cnt); in ppc_io()
1865 bus_write_multi_2(ppc->res_ioport, PPC_EPP_DATA, (u_int16_t *)addr, cnt); in ppc_io()
1868 bus_write_multi_4(ppc->res_ioport, PPC_EPP_DATA, (u_int32_t *)addr, cnt); in ppc_io()
1871 bus_read_multi_1(ppc->res_ioport, PPC_EPP_DATA, addr, cnt); in ppc_io()
1874 bus_read_multi_2(ppc->res_ioport, PPC_EPP_DATA, (u_int16_t *)addr, cnt); in ppc_io()
1877 bus_read_multi_4(ppc->res_ioport, PPC_EPP_DATA, (u_int32_t *)addr, cnt); in ppc_io()
1880 return (r_dtr(ppc)); in ppc_io()
1882 return (r_str(ppc)); in ppc_io()
1884 return (r_ctr(ppc)); in ppc_io()
1886 return (r_epp_A(ppc)); in ppc_io()
1888 return (r_epp_D(ppc)); in ppc_io()
1890 return (r_ecr(ppc)); in ppc_io()
1892 return (r_fifo(ppc)); in ppc_io()
1894 w_dtr(ppc, byte); in ppc_io()
1897 w_str(ppc, byte); in ppc_io()
1900 w_ctr(ppc, byte); in ppc_io()
1903 w_epp_A(ppc, byte); in ppc_io()
1906 w_epp_D(ppc, byte); in ppc_io()
1909 w_ecr(ppc, byte); in ppc_io()
1912 w_fifo(ppc, byte); in ppc_io()
1925 struct ppc_data *ppc = (struct ppc_data *)device_get_softc(bus); in ppc_read_ivar() local
1929 PPC_ASSERT_LOCKED(ppc); in ppc_read_ivar()
1930 *val = (u_long)ppc->ppc_epp; in ppc_read_ivar()
1933 *val = (uintptr_t)&ppc->ppc_lock; in ppc_read_ivar()
1945 struct ppc_data *ppc = (struct ppc_data *)device_get_softc(bus); in ppc_write_ivar() local
1949 PPC_ASSERT_LOCKED(ppc); in ppc_write_ivar()
1950 if (dev != ppc->ppbus) in ppc_write_ivar()
1953 ppc->ppc_intr_hook = NULL; in ppc_write_ivar()
1956 if (ppc->ppc_intr_hook != NULL) in ppc_write_ivar()
1958 ppc->ppc_intr_hook = (void *)val; in ppc_write_ivar()
1959 ppc->ppc_intr_arg = device_get_softc(dev); in ppc_write_ivar()
1976 struct ppc_data *ppc = DEVTOSOFTC(bus); in ppc_alloc_resource() local
1981 return (ppc->res_irq); in ppc_alloc_resource()
1992 struct ppc_data *ppc = DEVTOSOFTC(bus); in ppc_release_resource() local
1998 KASSERT(r == ppc->res_irq, in ppc_release_resource()
2007 MODULE_DEPEND(ppc, ppbus, 1, 1, 1);