Source
x
// SPDX-License-Identifier: GPL-2.0
/* IEEE-1284 operations for parport.
*
* This file is for generic IEEE 1284 operations. The idea is that
* they are used by the low-level drivers. If they have a special way
* of doing something, they can provide their own routines (and put
* the function pointers in port->ops); if not, they can just use these
* as a fallback.
*
* Note: Make no assumptions about hardware or architecture in this file!
*
* Author: Tim Waugh <tim@cyberelk.demon.co.uk>
* Fixed AUTOFD polarity in ecp_forward_to_reverse(). Fred Barnes, 1999
* Software emulated EPP fixes, Fred Barnes, 04/2001.
*/
/* undef me for production */
/* Don't want a garbled console */
/*** *
* One-way data transfer functions. *
* ***/
/* Compatibility mode. */
size_t parport_ieee1284_write_compat (struct parport *port,
const void *buffer, size_t len,
int flags)
{
int no_irq = 1;
ssize_t count = 0;
const unsigned char *addr = buffer;
unsigned char byte;
struct pardevice *dev = port->physport->cad;
unsigned char ctl = (PARPORT_CONTROL_SELECT
| PARPORT_CONTROL_INIT);
if (port->irq != PARPORT_IRQ_NONE) {
parport_enable_irq (port);
no_irq = 0;
}
port->physport->ieee1284.phase = IEEE1284_PH_FWD_DATA;
parport_write_control (port, ctl);
parport_data_forward (port);
while (count < len) {
unsigned long expire = jiffies + dev->timeout;
long wait = msecs_to_jiffies(10);
unsigned char mask = (PARPORT_STATUS_ERROR
| PARPORT_STATUS_BUSY);
unsigned char val = (PARPORT_STATUS_ERROR
| PARPORT_STATUS_BUSY);
/* Wait until the peripheral's ready */
do {
/* Is the peripheral ready yet? */
if (!parport_wait_peripheral (port, mask, val))
/* Skip the loop */
goto ready;
/* Is the peripheral upset? */
if ((parport_read_status (port) &
(PARPORT_STATUS_PAPEROUT |
PARPORT_STATUS_SELECT |
PARPORT_STATUS_ERROR))
!= (PARPORT_STATUS_SELECT |
PARPORT_STATUS_ERROR))
/* If nFault is asserted (i.e. no
* error) and PAPEROUT and SELECT are
* just red herrings, give the driver
* a chance to check it's happy with
* that before continuing. */
goto stop;
/* Have we run out of time? */
if (!time_before (jiffies, expire))
break;