/* * Device mode to submsq conversion */ static struct ppb_xfer * mode2xfer(device_t bus, struct ppb_device *ppbdev, int opcode) { int index, epp, mode; struct ppb_xfer *table; switch (opcode) { case MS_OP_GET: table = ppbdev->get_xfer; break; case MS_OP_PUT: table = ppbdev->put_xfer; break; default: panic("%s: unknown opcode (%d)", __func__, opcode); } /* retrieve the device operating mode */ mode = ppb_get_mode(bus); switch (mode) { case PPB_COMPATIBLE: index = COMPAT_MSQ; break; case PPB_NIBBLE: index = NIBBLE_MSQ; break; case PPB_PS2: index = PS2_MSQ; break; case PPB_EPP: switch ((epp = ppb_get_epp_protocol(bus))) { case EPP_1_7: index = EPP17_MSQ; break; case EPP_1_9: index = EPP19_MSQ; break; default: panic("%s: unknown EPP protocol (0x%x)!", __func__, epp); } break; case PPB_ECP: index = ECP_MSQ; break; default: panic("%s: unknown mode (%d)", __func__, mode); } return (&table[index]); }
/* * ppb_set_mode() * * Set the operating mode of the chipset, return the previous mode */ int ppb_set_mode(device_t bus, int mode) { struct ppb_data *ppb = DEVTOSOFTC(bus); int old_mode = ppb_get_mode(bus); ppb_assert_locked(bus); if (PPBUS_SETMODE(device_get_parent(bus), mode)) return (-1); /* XXX yet device mode = ppbus mode = chipset mode */ ppb->mode = (mode & PPB_MASK); return (old_mode); }