/* Test if the peripheral is IEEE 1284 compliant. * return values are: * 0 - handshake failed; peripheral is not compliant (or none present) * 1 - handshake OK; IEEE1284 peripheral present but no data available * 2 - handshake OK; IEEE1284 peripheral and data available */ int parport_ieee1284_nibble_mode_ok(struct parport *port, unsigned char mode) { /* make sure it's a valid state, set nStrobe & nAutoFeed high */ parport_write_control(port, (parport_read_control(port) \ & ~1 ) & ~2); udelay(1); parport_write_data(port, mode); udelay(1); /* nSelectIn high, nAutoFd low */ parport_write_control(port, (parport_read_control(port) & ~8) | 2); if (parport_wait_peripheral(port, 0x78, 0x38)) { parport_write_control(port, (parport_read_control(port) & ~2) | 8); return 0; } /* nStrobe low */ parport_write_control(port, parport_read_control(port) | 1); udelay(1); /* Strobe wait */ /* nStrobe high, nAutoFeed low, last step before transferring * reverse data */ parport_write_control(port, (parport_read_control(port) \ & ~1) & ~2); udelay(1); /* Data available? */ return (parport_wait_peripheral(port, 0x20, 0))?1:2; }
static void bit_lp_setscl(void *data, int state) { /*be cautious about state of the control register - touch only the one bit needed*/ if (state) { parport_write_control((struct parport *) data, parport_read_control((struct parport *) data)|I2C_SCL); } else { parport_write_control((struct parport *) data, parport_read_control((struct parport *) data)&I2C_CMASK); } }
static unsigned int in(int offset) { switch (offset) { case LIRC_LP_BASE: return parport_read_data(pport); case LIRC_LP_STATUS: return parport_read_status(pport); case LIRC_LP_CONTROL: return parport_read_control(pport); } return 0; /* make compiler happy */ }
static unsigned char port_read_control(struct parport *p) { return parport_read_control(p); }