Lines Matching full:ppc

58 #include <dev/ppc/ppcvar.h>
59 #include <dev/ppc/ppcreg.h>
68 #define LOG_PPC(function, ppc, string) \ argument
86 #define PPC_CONFIG_LOCK(ppc) critical_enter() argument
87 #define PPC_CONFIG_UNLOCK(ppc) critical_exit() argument
89 const char ppc_driver_name[] = "ppc";
133 struct ppc_data *ppc = DEVTOSOFTC(dev); in ppc_ecp_sync() local
135 PPC_ASSERT_LOCKED(ppc); in ppc_ecp_sync()
136 if (!(ppc->ppc_avm & PPB_ECP) && !(ppc->ppc_dtm & PPB_ECP)) in ppc_ecp_sync()
139 r = r_ecr(ppc); in ppc_ecp_sync()
144 r = r_ecr(ppc); in ppc_ecp_sync()
161 ppc_detect_fifo(struct ppc_data *ppc) in ppc_detect_fifo() argument
168 ecr_sav = r_ecr(ppc); in ppc_detect_fifo()
169 ctr_sav = r_ctr(ppc); in ppc_detect_fifo()
172 w_ecr(ppc, 0xf4); in ppc_detect_fifo()
175 ppc->ppc_pword = (r_cnfgA(ppc) & PPC_PWORD_MASK); in ppc_detect_fifo()
178 if (ppc->ppc_pword != PPC_PWORD_8) { in ppc_detect_fifo()
179 LOG_PPC(__func__, ppc, "PWord not supported"); in ppc_detect_fifo()
183 w_ecr(ppc, 0x34); /* byte mode, no interrupt, no DMA */ in ppc_detect_fifo()
184 ctr = r_ctr(ppc); in ppc_detect_fifo()
185 w_ctr(ppc, ctr | PCD); /* set direction to 1 */ in ppc_detect_fifo()
188 w_ecr(ppc, 0xd4); in ppc_detect_fifo()
192 if (r_ecr(ppc) & PPC_FIFO_EMPTY) in ppc_detect_fifo()
194 r_fifo(ppc); in ppc_detect_fifo()
198 LOG_PPC(__func__, ppc, "can't flush FIFO"); in ppc_detect_fifo()
203 w_ecr(ppc, 0xd0); in ppc_detect_fifo()
209 w_fifo(ppc, (char)i); in ppc_detect_fifo()
210 if (!ppc->ppc_rthr && (r_ecr(ppc) & PPC_SERVICE_INTR)) { in ppc_detect_fifo()
212 ppc->ppc_rthr = i+1; in ppc_detect_fifo()
214 if (r_ecr(ppc) & PPC_FIFO_FULL) { in ppc_detect_fifo()
215 ppc->ppc_fifo = i+1; in ppc_detect_fifo()
221 LOG_PPC(__func__, ppc, "can't fill FIFO"); in ppc_detect_fifo()
225 w_ecr(ppc, 0xd4); /* test mode, no interrupt, no DMA */ in ppc_detect_fifo()
226 w_ctr(ppc, ctr & ~PCD); /* set direction to 0 */ in ppc_detect_fifo()
227 w_ecr(ppc, 0xd0); /* enable interrupts */ in ppc_detect_fifo()
232 for (i=ppc->ppc_fifo; i>0; i--) { in ppc_detect_fifo()
233 if (r_fifo(ppc) != (char)(ppc->ppc_fifo-i)) { in ppc_detect_fifo()
234 LOG_PPC(__func__, ppc, "invalid data in FIFO"); in ppc_detect_fifo()
237 if (r_ecr(ppc) & PPC_SERVICE_INTR) { in ppc_detect_fifo()
239 ppc->ppc_wthr = ppc->ppc_fifo - i+1; in ppc_detect_fifo()
242 if (i>1 && (r_ecr(ppc) & PPC_FIFO_EMPTY)) { in ppc_detect_fifo()
243 LOG_PPC(__func__, ppc, "data lost in FIFO"); in ppc_detect_fifo()
249 if (!(r_ecr(ppc) & PPC_FIFO_EMPTY)) { in ppc_detect_fifo()
250 LOG_PPC(__func__, ppc, "can't empty the FIFO"); in ppc_detect_fifo()
254 w_ctr(ppc, ctr_sav); in ppc_detect_fifo()
255 w_ecr(ppc, ecr_sav); in ppc_detect_fifo()
260 w_ctr(ppc, ctr_sav); in ppc_detect_fifo()
261 w_ecr(ppc, ecr_sav); in ppc_detect_fifo()
267 ppc_detect_port(struct ppc_data *ppc) in ppc_detect_port() argument
270 w_ctr(ppc, 0x0c); /* To avoid missing PS2 ports */ in ppc_detect_port()
271 w_dtr(ppc, 0xaa); in ppc_detect_port()
272 if (r_dtr(ppc) != 0xaa) in ppc_detect_port()
286 ppc_reset_epp_timeout(struct ppc_data *ppc) in ppc_reset_epp_timeout() argument
290 r = r_str(ppc); in ppc_reset_epp_timeout()
291 w_str(ppc, r | 0x1); in ppc_reset_epp_timeout()
292 w_str(ppc, r & 0xfe); in ppc_reset_epp_timeout()
298 ppc_check_epp_timeout(struct ppc_data *ppc) in ppc_check_epp_timeout() argument
300 ppc_reset_epp_timeout(ppc); in ppc_check_epp_timeout()
302 return (!(r_str(ppc) & TIMEOUT)); in ppc_check_epp_timeout()
309 ppc_generic_setmode(struct ppc_data *ppc, int mode) in ppc_generic_setmode() argument
314 if (mode && !(ppc->ppc_avm & mode)) in ppc_generic_setmode()
318 if ((ppc->ppc_avm & PPB_ECP) || (ppc->ppc_dtm & PPB_ECP)) { in ppc_generic_setmode()
323 w_ecr(ppc, PPC_ECR_RESET); in ppc_generic_setmode()
338 w_ecr(ppc, ecr); in ppc_generic_setmode()
341 ppc->ppc_mode = mode; in ppc_generic_setmode()
347 * The ppc driver is free to choose options like FIFO or DMA
350 * The 'RAW' option allows the upper drivers to force the ppc mode
354 ppc_smclike_setmode(struct ppc_data *ppc, int mode) in ppc_smclike_setmode() argument
359 if (mode && !(ppc->ppc_avm & mode)) in ppc_smclike_setmode()
363 if ((ppc->ppc_avm & PPB_ECP) || (ppc->ppc_dtm & PPB_ECP)) { in ppc_smclike_setmode()
368 w_ecr(ppc, PPC_ECR_RESET); in ppc_smclike_setmode()
384 w_ecr(ppc, ecr); in ppc_smclike_setmode()
387 ppc->ppc_mode = mode; in ppc_smclike_setmode()
419 ppc_pc873xx_detect(struct ppc_data *ppc, int chipset_mode) /* XXX mode never forced */ in ppc_pc873xx_detect() argument
447 ppc->ppc_model = NS_PC87332; in ppc_pc873xx_detect()
449 ppc->ppc_model = NS_PC87306; in ppc_pc873xx_detect()
451 ppc->ppc_model = NS_PC87334; in ppc_pc873xx_detect()
455 ppc->ppc_model = NS_PC87303; in ppc_pc873xx_detect()
486 if (pc873xx_porttab[val & 0x3] != ppc->ppc_base) { in ppc_pc873xx_detect()
489 switch (ppc->ppc_base) { in ppc_pc873xx_detect()
519 if (pc873xx_porttab[val] != ppc->ppc_base) { in ppc_pc873xx_detect()
522 pc873xx_porttab[val], ppc->ppc_base); in ppc_pc873xx_detect()
531 if (ppc->ppc_base == 0x378) in ppc_pc873xx_detect()
537 printf("PC873xx irq %d at 0x%x\n", irq, ppc->ppc_base); in ppc_pc873xx_detect()
542 if (irq != ppc->ppc_irq) { in ppc_pc873xx_detect()
547 if (ppc->ppc_base == 0x378 && !(ptr & PC873_CFGLOCK)) { in ppc_pc873xx_detect()
548 if (ppc->ppc_irq == 7) { in ppc_pc873xx_detect()
556 printf("PC873xx irq set to %d\n", ppc->ppc_irq); in ppc_pc873xx_detect()
573 ppc->ppc_avm |= PPB_NIBBLE; in ppc_pc873xx_detect()
578 ppc->ppc_avm |= PPB_EPP; in ppc_pc873xx_detect()
584 ppc->ppc_epp = EPP_1_9; in ppc_pc873xx_detect()
586 ppc->ppc_epp = EPP_1_7; in ppc_pc873xx_detect()
588 if ((ppc->ppc_model == NS_PC87332) && bootverbose) { in ppc_pc873xx_detect()
597 ppc->ppc_avm |= PPB_ECP; in ppc_pc873xx_detect()
602 ppc->ppc_avm |= PPB_PS2; in ppc_pc873xx_detect()
610 ppc->ppc_avm |= PPB_SPP; in ppc_pc873xx_detect()
637 ppc->ppc_epp = EPP_1_9; /* XXX */ in ppc_pc873xx_detect()
643 if (ppc->ppc_model == NS_PC87332) { in ppc_pc873xx_detect()
679 ppc->ppc_avm = chipset_mode; in ppc_pc873xx_detect()
685 ppc->ppc_type = PPC_TYPE_GENERIC; in ppc_pc873xx_detect()
686 ppc_generic_setmode(ppc, chipset_mode); in ppc_pc873xx_detect()
699 ppc_smc37c66xgt_detect(struct ppc_data *ppc, int chipset_mode) in ppc_smc37c66xgt_detect() argument
713 PPC_CONFIG_LOCK(ppc); in ppc_smc37c66xgt_detect()
716 PPC_CONFIG_UNLOCK(ppc); in ppc_smc37c66xgt_detect()
725 PPC_CONFIG_LOCK(ppc); in ppc_smc37c66xgt_detect()
728 PPC_CONFIG_UNLOCK(ppc); in ppc_smc37c66xgt_detect()
754 if (port_address[(int)r] != ppc->ppc_base) { in ppc_smc37c66xgt_detect()
759 ppc->ppc_model = type; in ppc_smc37c66xgt_detect()
768 device_printf(ppc->ppc_dev, "SMC registers CR1=0x%x", in ppc_smc37c66xgt_detect()
783 ppc->ppc_avm |= PPB_ECP | PPB_EPP | PPB_SPP; in ppc_smc37c66xgt_detect()
796 ppc->ppc_avm |= PPB_SPP; in ppc_smc37c66xgt_detect()
802 ppc->ppc_avm |= PPB_EPP | PPB_SPP; in ppc_smc37c66xgt_detect()
808 ppc->ppc_avm |= PPB_ECP | PPB_SPP; in ppc_smc37c66xgt_detect()
814 ppc->ppc_avm |= PPB_ECP | PPB_EPP | PPB_SPP; in ppc_smc37c66xgt_detect()
821 ppc->ppc_avm |= PPB_SPP; in ppc_smc37c66xgt_detect()
828 ppc->ppc_avm = chipset_mode; in ppc_smc37c66xgt_detect()
865 ppc->ppc_avm = chipset_mode; in ppc_smc37c66xgt_detect()
869 if (ppc->ppc_avm & PPB_ECP) { in ppc_smc37c66xgt_detect()
880 if (ppc->ppc_avm & PPB_EPP) { in ppc_smc37c66xgt_detect()
889 if (ppc->ppc_epp == EPP_1_9) in ppc_smc37c66xgt_detect()
897 ppc->ppc_type = PPC_TYPE_SMCLIKE; in ppc_smc37c66xgt_detect()
898 ppc_smclike_setmode(ppc, chipset_mode); in ppc_smc37c66xgt_detect()
908 ppc_smc37c935_detect(struct ppc_data *ppc, int chipset_mode) in ppc_smc37c935_detect() argument
912 PPC_CONFIG_LOCK(ppc); in ppc_smc37c935_detect()
915 PPC_CONFIG_UNLOCK(ppc); in ppc_smc37c935_detect()
926 ppc->ppc_model = type; in ppc_smc37c935_detect()
933 outb(SMC935_DAT, (u_char)((ppc->ppc_base & 0xff00) >> 8)); in ppc_smc37c935_detect()
935 outb(SMC935_DAT, (u_char)(ppc->ppc_base & 0xff)); in ppc_smc37c935_detect()
938 ppc->ppc_avm = PPB_COMPATIBLE; /* default mode */ in ppc_smc37c935_detect()
940 ppc->ppc_avm = chipset_mode; in ppc_smc37c935_detect()
947 if (ppc->ppc_epp == EPP_1_9) { in ppc_smc37c935_detect()
951 if (ppc->ppc_epp == EPP_1_7) { in ppc_smc37c935_detect()
964 if (ppc->ppc_epp == EPP_1_9) { in ppc_smc37c935_detect()
968 if (ppc->ppc_epp == EPP_1_7) { in ppc_smc37c935_detect()
981 ppc->ppc_type = PPC_TYPE_SMCLIKE; in ppc_smc37c935_detect()
982 ppc_smclike_setmode(ppc, chipset_mode); in ppc_smc37c935_detect()
1003 ppc_w83877f_detect(struct ppc_data *ppc, int chipset_mode) in ppc_w83877f_detect() argument
1039 if (ppc->ppc_base != inb(efdr) * 4) /* 4 bytes boundaries */ in ppc_w83877f_detect()
1047 ppc->ppc_model = WINB_W83877F; in ppc_w83877f_detect()
1051 ppc->ppc_model = WINB_W83877AF; in ppc_w83877f_detect()
1055 ppc->ppc_model = WINB_UNKNOWN; in ppc_w83877f_detect()
1060 device_printf(ppc->ppc_dev, "0x%x - ", w83877f_keys[i]); in ppc_w83877f_detect()
1078 ppc->ppc_type = PPC_TYPE_GENERIC; in ppc_w83877f_detect()
1094 device_printf(ppc->ppc_dev, in ppc_w83877f_detect()
1103 device_printf(ppc->ppc_dev, in ppc_w83877f_detect()
1108 ppc->ppc_avm |= PPB_EPP | PPB_SPP; in ppc_w83877f_detect()
1110 device_printf(ppc->ppc_dev, "EPP SPP\n"); in ppc_w83877f_detect()
1114 ppc->ppc_avm |= PPB_ECP | PPB_SPP; in ppc_w83877f_detect()
1116 device_printf(ppc->ppc_dev, "ECP SPP\n"); in ppc_w83877f_detect()
1120 ppc->ppc_avm |= PPB_ECP | PPB_EPP | PPB_SPP; in ppc_w83877f_detect()
1121 ppc->ppc_type = PPC_TYPE_SMCLIKE; in ppc_w83877f_detect()
1124 device_printf(ppc->ppc_dev, "ECP+EPP SPP\n"); in ppc_w83877f_detect()
1145 device_printf(ppc->ppc_dev, in ppc_w83877f_detect()
1148 ppc->ppc_type = PPC_TYPE_SMCLIKE; in ppc_w83877f_detect()
1153 device_printf(ppc->ppc_dev, "ECP\n"); in ppc_w83877f_detect()
1159 device_printf(ppc->ppc_dev, "EPP SPP\n"); in ppc_w83877f_detect()
1161 ppc->ppc_avm = chipset_mode; in ppc_w83877f_detect()
1167 switch (ppc->ppc_type) { in ppc_w83877f_detect()
1169 ppc_smclike_setmode(ppc, chipset_mode); in ppc_w83877f_detect()
1172 ppc_generic_setmode(ppc, chipset_mode); in ppc_w83877f_detect()
1184 ppc_generic_detect(struct ppc_data *ppc, int chipset_mode) in ppc_generic_detect() argument
1187 ppc->ppc_type = PPC_TYPE_GENERIC; in ppc_generic_detect()
1190 device_printf(ppc->ppc_dev, "SPP"); in ppc_generic_detect()
1193 w_ecr(ppc, PPC_ECR_PS2); in ppc_generic_detect()
1194 if ((r_ecr(ppc) & 0xe0) == PPC_ECR_PS2) { in ppc_generic_detect()
1195 ppc->ppc_dtm |= PPB_ECP | PPB_SPP; in ppc_generic_detect()
1200 w_ecr(ppc, PPC_ECR_EPP); in ppc_generic_detect()
1204 if (ppc_check_epp_timeout(ppc)) { in ppc_generic_detect()
1205 ppc->ppc_dtm |= PPB_EPP; in ppc_generic_detect()
1207 if (ppc->ppc_dtm & PPB_ECP) { in ppc_generic_detect()
1209 ppc->ppc_model = SMC_LIKE; in ppc_generic_detect()
1210 ppc->ppc_type = PPC_TYPE_SMCLIKE; in ppc_generic_detect()
1220 w_ecr(ppc, PPC_ECR_STD); in ppc_generic_detect()
1224 ppc->ppc_dtm |= PPB_NIBBLE; in ppc_generic_detect()
1227 ppc->ppc_avm = chipset_mode; in ppc_generic_detect()
1229 ppc->ppc_avm = ppc->ppc_dtm; in ppc_generic_detect()
1234 switch (ppc->ppc_type) { in ppc_generic_detect()
1236 ppc_smclike_setmode(ppc, chipset_mode); in ppc_generic_detect()
1239 ppc_generic_setmode(ppc, chipset_mode); in ppc_generic_detect()
1252 ppc_detect(struct ppc_data *ppc, int chipset_mode) { in ppc_detect() argument
1268 if (!ppc_detect_port(ppc) && chipset_mode == 0) in ppc_detect()
1272 ppc->ppc_avm = PPB_COMPATIBLE; in ppc_detect()
1280 if (ppc->ppc_flags & 0x40) { in ppc_detect()
1282 printf("ppc: chipset forced to generic\n"); in ppc_detect()
1285 ppc->ppc_mode = ppc_generic_detect(ppc, chipset_mode); in ppc_detect()
1290 if ((mode = chipset_detect[i](ppc, chipset_mode)) != -1) { in ppc_detect()
1291 ppc->ppc_mode = mode; in ppc_detect()
1299 if ((ppc->ppc_avm & PPB_ECP) && !(ppc->ppc_flags & 0x80)) in ppc_detect()
1300 ppc_detect_fifo(ppc); in ppc_detect()
1314 struct ppc_data *ppc = DEVTOSOFTC(dev); in ppc_exec_microseq() local
1329 #define r_reg(reg,ppc) (bus_read_1((ppc)->res_ioport, reg)) in ppc_exec_microseq() argument
1330 #define w_reg(reg, ppc, byte) (bus_write_1((ppc)->res_ioport, reg, byte)) in ppc_exec_microseq() argument
1334 PPC_ASSERT_LOCKED(ppc); in ppc_exec_microseq()
1339 cc = r_reg(mi->arg[0].i, ppc); in ppc_exec_microseq()
1342 w_reg(mi->arg[0].i, ppc, cc); in ppc_exec_microseq()
1348 ptr = ppc->ppc_ptr; in ppc_exec_microseq()
1351 accum = ppc->ppc_accum; in ppc_exec_microseq()
1353 w_reg(reg, ppc, *ptr++); in ppc_exec_microseq()
1354 ppc->ppc_accum = accum; in ppc_exec_microseq()
1357 w_reg(reg, ppc, *ptr++); in ppc_exec_microseq()
1358 ppc->ppc_ptr = ptr; in ppc_exec_microseq()
1366 ptr = ppc->ppc_ptr; in ppc_exec_microseq()
1369 accum = ppc->ppc_accum; in ppc_exec_microseq()
1371 *ptr++ = r_reg(reg, ppc) & mask; in ppc_exec_microseq()
1372 ppc->ppc_accum = accum; in ppc_exec_microseq()
1375 *ptr++ = r_reg(reg, ppc) & mask; in ppc_exec_microseq()
1376 ppc->ppc_ptr = ptr; in ppc_exec_microseq()
1382 *((char *) mi->arg[2].p) = r_reg(mi->arg[0].i, ppc) & in ppc_exec_microseq()
1393 w_reg(mi->arg[0].i, ppc, (char)mi->arg[1].i); in ppc_exec_microseq()
1404 PPC_UNLOCK(ppc); in ppc_exec_microseq()
1406 PPC_LOCK(ppc); in ppc_exec_microseq()
1418 w_reg(reg, ppc, *p++); in ppc_exec_microseq()
1425 ppc->ppc_accum = mi->arg[0].i; in ppc_exec_microseq()
1430 if (--ppc->ppc_accum > 0) in ppc_exec_microseq()
1436 cc = r_str(ppc); in ppc_exec_microseq()
1443 cc = r_str(ppc); in ppc_exec_microseq()
1450 cc = r_str(ppc); in ppc_exec_microseq()
1462 if ((error = mi->arg[0].f(mi->arg[1].p, ppc->ppc_ptr))) in ppc_exec_microseq()
1469 ppc->ppc_ptr = (char *)mi->arg[0].p; in ppc_exec_microseq()
1529 struct ppc_data *ppc = arg; in ppcintr() local
1539 PPC_LOCK(ppc); in ppcintr()
1540 if (ppc->ppc_intr_hook != NULL && in ppcintr()
1541 ppc->ppc_intr_hook(ppc->ppc_intr_arg) == 0) { in ppcintr()
1542 PPC_UNLOCK(ppc); in ppcintr()
1546 str = r_str(ppc); in ppcintr()
1547 ctr = r_ctr(ppc); in ppcintr()
1548 ecr = r_ecr(ppc); in ppcintr()
1556 PPC_UNLOCK(ppc); in ppcintr()
1562 if ((str & nFAULT) && (ppc->ppc_mode & PPB_ECP)) { in ppcintr()
1563 /* check if ppc driver has programmed the in ppcintr()
1565 if (ppc->ppc_irqstat & PPC_IRQ_nFAULT) { in ppcintr()
1566 w_ecr(ppc, ecr | PPC_nFAULT_INTR); in ppcintr()
1567 ppc->ppc_irqstat &= ~PPC_IRQ_nFAULT; in ppcintr()
1570 PPC_UNLOCK(ppc); in ppcintr()
1575 if (ppc->ppc_irqstat & PPC_IRQ_DMA) { in ppcintr()
1577 w_ecr(ppc, ecr | PPC_SERVICE_INTR); in ppcintr()
1578 ppc->ppc_irqstat &= ~PPC_IRQ_DMA; in ppcintr()
1579 ecr = r_ecr(ppc); in ppcintr()
1582 if ((ppc->ppc_avm & PPB_ECP) && (ecr & PPC_ENABLE_DMA)) { in ppcintr()
1587 w_ecr(ppc, ecr & ~PPC_ENABLE_DMA); in ppcintr()
1588 ecr = r_ecr(ppc); in ppcintr()
1590 if (ppc->ppc_dmastat == PPC_DMA_STARTED) { in ppcintr()
1594 ppc->ppc_dmadone(ppc); in ppcintr()
1595 ppc->ppc_dmastat = PPC_DMA_COMPLETE; in ppcintr()
1598 wakeup(ppc); in ppcintr()
1601 } else if (ppc->ppc_irqstat & PPC_IRQ_FIFO) { in ppcintr()
1603 ppc->ppc_irqstat &= ~PPC_IRQ_FIFO; in ppcintr()
1605 PPC_UNLOCK(ppc); in ppcintr()
1625 struct ppc_data *ppc = DEVTOSOFTC(dev); in ppc_reset_epp() local
1627 PPC_ASSERT_LOCKED(ppc); in ppc_reset_epp()
1628 ppc_reset_epp_timeout(ppc); in ppc_reset_epp()
1636 struct ppc_data *ppc = DEVTOSOFTC(dev); in ppc_setmode() local
1638 PPC_ASSERT_LOCKED(ppc); in ppc_setmode()
1639 switch (ppc->ppc_type) { in ppc_setmode()
1641 return (ppc_smclike_setmode(ppc, mode)); in ppc_setmode()
1646 return (ppc_generic_setmode(ppc, mode)); in ppc_setmode()
1657 struct ppc_data *ppc; in ppc_probe() local
1667 ppc = DEVTOSOFTC(dev); in ppc_probe()
1668 bzero(ppc, sizeof(struct ppc_data)); in ppc_probe()
1670 ppc->rid_ioport = rid; in ppc_probe()
1698 ppc->res_ioport = bus_alloc_resource_anywhere(dev, SYS_RES_IOPORT, in ppc_probe()
1699 &ppc->rid_ioport, in ppc_probe()
1703 if (ppc->res_ioport != 0) { in ppc_probe()
1708 ppc->res_ioport = bus_alloc_resource_anywhere(dev, in ppc_probe()
1710 &ppc->rid_ioport, in ppc_probe()
1713 if (ppc->res_ioport != 0) { in ppc_probe()
1723 ppc->ppc_base = rman_get_start(ppc->res_ioport); in ppc_probe()
1725 ppc->ppc_flags = device_get_flags(dev); in ppc_probe()
1727 if (!(ppc->ppc_flags & 0x20)) { in ppc_probe()
1728 ppc->res_irq = bus_alloc_resource_any(dev, SYS_RES_IRQ, in ppc_probe()
1729 &ppc->rid_irq, in ppc_probe()
1731 ppc->res_drq = bus_alloc_resource_any(dev, SYS_RES_DRQ, in ppc_probe()
1732 &ppc->rid_drq, in ppc_probe()
1736 if (ppc->res_irq) in ppc_probe()
1737 ppc->ppc_irq = rman_get_start(ppc->res_irq); in ppc_probe()
1738 if (ppc->res_drq) in ppc_probe()
1739 ppc->ppc_dmachan = rman_get_start(ppc->res_drq); in ppc_probe()
1741 ppc->ppc_dev = dev; in ppc_probe()
1742 ppc->ppc_model = GENERIC; in ppc_probe()
1744 ppc->ppc_mode = PPB_COMPATIBLE; in ppc_probe()
1745 ppc->ppc_epp = (ppc->ppc_flags & 0x10) >> 4; in ppc_probe()
1747 ppc->ppc_type = PPC_TYPE_GENERIC; in ppc_probe()
1752 if (ppc_detect(ppc, ppc->ppc_flags & 0xf)) in ppc_probe()
1758 if (ppc->res_irq != 0) { in ppc_probe()
1759 bus_release_resource(dev, SYS_RES_IRQ, ppc->rid_irq, in ppc_probe()
1760 ppc->res_irq); in ppc_probe()
1762 if (ppc->res_ioport != 0) { in ppc_probe()
1763 bus_release_resource(dev, SYS_RES_IOPORT, ppc->rid_ioport, in ppc_probe()
1764 ppc->res_ioport); in ppc_probe()
1766 if (ppc->res_drq != 0) { in ppc_probe()
1767 bus_release_resource(dev, SYS_RES_DRQ, ppc->rid_drq, in ppc_probe()
1768 ppc->res_drq); in ppc_probe()
1776 struct ppc_data *ppc = DEVTOSOFTC(dev); in ppc_attach() local
1779 mtx_init(&ppc->ppc_lock, device_get_nameunit(dev), "ppc", MTX_DEF); in ppc_attach()
1782 ppc_models[ppc->ppc_model], ppc_avms[ppc->ppc_avm], in ppc_attach()
1783 ppc_modes[ppc->ppc_mode], (PPB_IS_EPP(ppc->ppc_mode)) ? in ppc_attach()
1784 ppc_epp_protocol[ppc->ppc_epp] : ""); in ppc_attach()
1786 if (ppc->ppc_fifo) in ppc_attach()
1788 ppc->ppc_fifo, ppc->ppc_wthr, ppc->ppc_rthr); in ppc_attach()
1790 if (ppc->res_irq) { in ppc_attach()
1792 error = bus_setup_intr(dev, ppc->res_irq, INTR_TYPE_TTY | in ppc_attach()
1793 INTR_MPSAFE, NULL, ppcintr, ppc, &ppc->intr_cookie); in ppc_attach()
1798 mtx_destroy(&ppc->ppc_lock); in ppc_attach()
1804 ppc->ppbus = device_add_child(dev, "ppbus", DEVICE_UNIT_ANY); in ppc_attach()
1809 device_probe_and_attach(ppc->ppbus); in ppc_attach()
1817 struct ppc_data *ppc = DEVTOSOFTC(dev); in ppc_detach() local
1820 if (ppc->res_irq == 0) { in ppc_detach()
1829 if (ppc->res_irq != 0) { in ppc_detach()
1830 bus_teardown_intr(dev, ppc->res_irq, ppc->intr_cookie); in ppc_detach()
1831 bus_release_resource(dev, SYS_RES_IRQ, ppc->rid_irq, in ppc_detach()
1832 ppc->res_irq); in ppc_detach()
1834 if (ppc->res_ioport != 0) { in ppc_detach()
1835 bus_release_resource(dev, SYS_RES_IOPORT, ppc->rid_ioport, in ppc_detach()
1836 ppc->res_ioport); in ppc_detach()
1838 if (ppc->res_drq != 0) { in ppc_detach()
1839 bus_release_resource(dev, SYS_RES_DRQ, ppc->rid_drq, in ppc_detach()
1840 ppc->res_drq); in ppc_detach()
1843 mtx_destroy(&ppc->ppc_lock); in ppc_detach()
1851 struct ppc_data *ppc = DEVTOSOFTC(ppcdev); in ppc_io() local
1853 PPC_ASSERT_LOCKED(ppc); in ppc_io()
1856 bus_write_multi_1(ppc->res_ioport, PPC_EPP_DATA, addr, cnt); in ppc_io()
1859 bus_write_multi_2(ppc->res_ioport, PPC_EPP_DATA, (u_int16_t *)addr, cnt); in ppc_io()
1862 bus_write_multi_4(ppc->res_ioport, PPC_EPP_DATA, (u_int32_t *)addr, cnt); in ppc_io()
1865 bus_read_multi_1(ppc->res_ioport, PPC_EPP_DATA, addr, cnt); in ppc_io()
1868 bus_read_multi_2(ppc->res_ioport, PPC_EPP_DATA, (u_int16_t *)addr, cnt); in ppc_io()
1871 bus_read_multi_4(ppc->res_ioport, PPC_EPP_DATA, (u_int32_t *)addr, cnt); in ppc_io()
1874 return (r_dtr(ppc)); in ppc_io()
1876 return (r_str(ppc)); in ppc_io()
1878 return (r_ctr(ppc)); in ppc_io()
1880 return (r_epp_A(ppc)); in ppc_io()
1882 return (r_epp_D(ppc)); in ppc_io()
1884 return (r_ecr(ppc)); in ppc_io()
1886 return (r_fifo(ppc)); in ppc_io()
1888 w_dtr(ppc, byte); in ppc_io()
1891 w_str(ppc, byte); in ppc_io()
1894 w_ctr(ppc, byte); in ppc_io()
1897 w_epp_A(ppc, byte); in ppc_io()
1900 w_epp_D(ppc, byte); in ppc_io()
1903 w_ecr(ppc, byte); in ppc_io()
1906 w_fifo(ppc, byte); in ppc_io()
1919 struct ppc_data *ppc = (struct ppc_data *)device_get_softc(bus); in ppc_read_ivar() local
1923 PPC_ASSERT_LOCKED(ppc); in ppc_read_ivar()
1924 *val = (u_long)ppc->ppc_epp; in ppc_read_ivar()
1927 *val = (uintptr_t)&ppc->ppc_lock; in ppc_read_ivar()
1939 struct ppc_data *ppc = (struct ppc_data *)device_get_softc(bus); in ppc_write_ivar() local
1943 PPC_ASSERT_LOCKED(ppc); in ppc_write_ivar()
1944 if (dev != ppc->ppbus) in ppc_write_ivar()
1947 ppc->ppc_intr_hook = NULL; in ppc_write_ivar()
1950 if (ppc->ppc_intr_hook != NULL) in ppc_write_ivar()
1952 ppc->ppc_intr_hook = (void *)val; in ppc_write_ivar()
1953 ppc->ppc_intr_arg = device_get_softc(dev); in ppc_write_ivar()
1970 struct ppc_data *ppc = DEVTOSOFTC(bus); in ppc_alloc_resource() local
1975 return (ppc->res_irq); in ppc_alloc_resource()
1984 struct ppc_data *ppc = DEVTOSOFTC(bus); in ppc_release_resource() local
1986 if (r == ppc->res_irq) in ppc_release_resource()
1991 MODULE_DEPEND(ppc, ppbus, 1, 1, 1);