Commit 246a1c4c authored by Ondrej Zary's avatar Ondrej Zary Committed by Damien Le Moal

ata: pata_parport: add driver (PARIDE replacement)

The pata_parport is a libata-based replacement of the old PARIDE
subsystem - driver for parallel port IDE devices.
It uses the original paride low-level protocol drivers but does not
need the high-level drivers (pd, pcd, pf, pt, pg). The IDE devices
behind parallel port adapters are handled by the ATA layer.

This will allow paride and its high-level drivers to be removed.

Unfortunately, libata drivers cannot sleep so pata_parport claims
parport before activating the ata host and keeps it claimed (and
protocol connected) until the ata host is removed. This means that
no devices can be chained (neither other pata_parport devices nor
a printer).

paride and pata_parport are mutually exclusive because the compiled
protocol drivers are incompatible.

Tested with:
 - Imation SuperDisk LS-120 and HP C4381A (EPAT)
 - Freecom Parallel CD (FRPW)
 - Toshiba Mobile CD-RW 2793008 w/Freecom Parallel Cable rev.903 (FRIQ)
 - Backpack CD-RW 222011 and CD-RW 19350 (BPCK6)

The following bugs in low-level protocol drivers were found and will
be fixed later:

Note: EPP-32 mode is buggy in EPAT - and also in all other protocol
drivers - they don't handle non-multiple-of-4 block transfers
correctly. This causes problems with LS-120 drive.
There is also another bug in EPAT: EPP modes don't work unless a 4-bit
or 8-bit mode is used first (probably some initialization missing?).
Once the device is initialized, EPP works until power cycle.

So after device power on, you have to:
echo "parport0 epat 0" >/sys/bus/pata_parport/new_device
echo pata_parport.0 >/sys/bus/pata_parport/delete_device
echo "parport0 epat 4" >/sys/bus/pata_parport/new_device
(autoprobe will initialize correctly as it tries the slowest modes
first but you'll get the broken EPP-32 mode)

Note: EPP modes are buggy in FRPW, only modes 0 and 1 work.
Signed-off-by: default avatarOndrej Zary <linux@zary.sk>
Reviewed-by: default avatarChristoph Hellwig <hch@lst.de>
Reviewed-by: default avatarHannes Reinecke <hare@suse.de>
Acked-by: default avatarJens Axboe <axboe@kernel.dk>
Signed-off-by: default avatarDamien Le Moal <damien.lemoal@opensource.wdc.com>
parent 38d43122
......@@ -2,6 +2,9 @@
Linux and parallel port IDE devices
===================================
Most of this document describes the old paride driver. For the new libata
pata_parport drivrer, jump to the section 4 at the end.
PARIDE v1.03 (c) 1997-8 Grant Guenther <grant@torque.net>
1. Introduction
......@@ -437,3 +440,52 @@ You might also find some useful information on the linux-parport
web pages (although they are not always up to date) at
http://web.archive.org/web/%2E/http://www.torque.net/parport/
4. pata_parport driver
======================
pata_parport is a libata-based driver that uses the same low-level protocol
drivers as PARIDE but there are no high-level drivers (pd, pcd, pf, pt, pg).
The IDE devices behind parallel port adapters are handled by the ATA layer.
The device creation is also changed - no protocol numbers or parport I/O
addresses are used.
All parports and all protocol drivers are probed automatically unless probe=0
parameter is used. So just "modprobe epat" is enough for a Imation SuperDisk
drive to work.
Manual device creation::
# echo "port protocol mode unit delay" >/sys/bus/pata_parport/new_device
where:
======== ================================================
port parport name (or "auto" for all parports)
protocol protocol name (or "auto" for all protocols)
mode mode number (protocol-specific) or -1 for probe
unit unit number (see the paride documentation above)
delay I/O delay (see the paride documentation above)
======== ================================================
If you omit the parameters from the end, defaults will be used, e.g.:
Probe all parports with all protocols::
# echo auto >/sys/bus/pata_parport/new_device
Probe parport0 using protocol epat and mode 4 (EPP-16)::
# echo "parport0 epat 4" >/sys/bus/pata_parport/new_device
Probe parport0 using all protocols::
# echo "parport0 auto" >/sys/bus/pata_parport/new_device
Probe all parports using protoocol epat::
# echo "auto epat" >/sys/bus/pata_parport/new_device
Deleting devices::
# echo pata_parport.0 >/sys/bus/pata_parport/delete_device
......@@ -98,7 +98,7 @@ obj-$(CONFIG_DIO) += dio/
obj-$(CONFIG_SBUS) += sbus/
obj-$(CONFIG_ZORRO) += zorro/
obj-$(CONFIG_ATA_OVER_ETH) += block/aoe/
obj-$(CONFIG_PARIDE) += block/paride/
obj-y += block/paride/
obj-$(CONFIG_TC) += tc/
obj-$(CONFIG_USB_PHY) += usb/
obj-$(CONFIG_USB) += usb/
......
......@@ -1162,6 +1162,20 @@ config PATA_WINBOND_VLB
Support for the Winbond W83759A controller on Vesa Local Bus
systems.
config PATA_PARPORT
tristate "Parallel port IDE device support"
depends on PARPORT_PC && PARIDE=n
help
There are many external CD-ROM and disk devices that connect through
your computer's parallel port. Most of them are actually IDE devices
using a parallel port IDE adapter. This option enables the
PATA_PARPORT subsystem which contains drivers for many of these
external drives.
Read <file:Documentation/admin-guide/blockdev/paride.rst> for more
information.
Use the old PARIDE protocol modules.
comment "Generic fallback / legacy drivers"
config PATA_ACPI
......
......@@ -114,6 +114,8 @@ obj-$(CONFIG_PATA_SAMSUNG_CF) += pata_samsung_cf.o
obj-$(CONFIG_PATA_PXA) += pata_pxa.o
obj-$(CONFIG_PATA_PARPORT) += pata_parport.o
# Should be last but two libata driver
obj-$(CONFIG_PATA_ACPI) += pata_acpi.o
# Should be last but one libata driver
......
This diff is collapsed.
......@@ -92,11 +92,11 @@ config PARIDE_PG
later fully support this driver.
comment "Parallel IDE protocol modules"
depends on PARIDE
depends on PARIDE || PATA_PARPORT
config PARIDE_ATEN
tristate "ATEN EH-100 protocol"
depends on PARIDE
depends on PARIDE || PATA_PARPORT
help
This option enables support for the ATEN EH-100 parallel port IDE
protocol. This protocol is used in some inexpensive low performance
......@@ -109,7 +109,7 @@ config PARIDE_ATEN
config PARIDE_BPCK
tristate "MicroSolutions backpack (Series 5) protocol"
depends on PARIDE
depends on PARIDE || PATA_PARPORT
help
This option enables support for the Micro Solutions BACKPACK
parallel port Series 5 IDE protocol. (Most BACKPACK drives made
......@@ -127,7 +127,7 @@ config PARIDE_BPCK
config PARIDE_BPCK6
tristate "MicroSolutions backpack (Series 6) protocol"
depends on PARIDE && !64BIT
depends on (PARIDE || PATA_PARPORT) && !64BIT
help
This option enables support for the Micro Solutions BACKPACK
parallel port Series 6 IDE protocol. (Most BACKPACK drives made
......@@ -146,7 +146,7 @@ config PARIDE_BPCK6
config PARIDE_COMM
tristate "DataStor Commuter protocol"
depends on PARIDE
depends on PARIDE || PATA_PARPORT
help
This option enables support for the Commuter parallel port IDE
protocol from DataStor. If you chose to build PARIDE support
......@@ -157,7 +157,7 @@ config PARIDE_COMM
config PARIDE_DSTR
tristate "DataStor EP-2000 protocol"
depends on PARIDE
depends on PARIDE || PATA_PARPORT
help
This option enables support for the EP-2000 parallel port IDE
protocol from DataStor. If you chose to build PARIDE support
......@@ -168,7 +168,7 @@ config PARIDE_DSTR
config PARIDE_FIT2
tristate "FIT TD-2000 protocol"
depends on PARIDE
depends on PARIDE || PATA_PARPORT
help
This option enables support for the TD-2000 parallel port IDE
protocol from Fidelity International Technology. This is a simple
......@@ -181,7 +181,7 @@ config PARIDE_FIT2
config PARIDE_FIT3
tristate "FIT TD-3000 protocol"
depends on PARIDE
depends on PARIDE || PATA_PARPORT
help
This option enables support for the TD-3000 parallel port IDE
protocol from Fidelity International Technology. This protocol is
......@@ -194,7 +194,7 @@ config PARIDE_FIT3
config PARIDE_EPAT
tristate "Shuttle EPAT/EPEZ protocol"
depends on PARIDE
depends on PARIDE || PATA_PARPORT
help
This option enables support for the EPAT parallel port IDE protocol.
EPAT is a parallel port IDE adapter manufactured by Shuttle
......@@ -216,7 +216,7 @@ config PARIDE_EPATC8
config PARIDE_EPIA
tristate "Shuttle EPIA protocol"
depends on PARIDE
depends on PARIDE || PATA_PARPORT
help
This option enables support for the (obsolete) EPIA parallel port
IDE protocol from Shuttle Technology. This adapter can still be
......@@ -228,7 +228,7 @@ config PARIDE_EPIA
config PARIDE_FRIQ
tristate "Freecom IQ ASIC-2 protocol"
depends on PARIDE
depends on PARIDE || PATA_PARPORT
help
This option enables support for version 2 of the Freecom IQ parallel
port IDE adapter. This adapter is used by the Maxell Superdisk
......@@ -240,7 +240,7 @@ config PARIDE_FRIQ
config PARIDE_FRPW
tristate "FreeCom power protocol"
depends on PARIDE
depends on PARIDE || PATA_PARPORT
help
This option enables support for the Freecom power parallel port IDE
protocol. If you chose to build PARIDE support into your kernel, you
......@@ -251,7 +251,7 @@ config PARIDE_FRPW
config PARIDE_KBIC
tristate "KingByte KBIC-951A/971A protocols"
depends on PARIDE
depends on PARIDE || PATA_PARPORT
help
This option enables support for the KBIC-951A and KBIC-971A parallel
port IDE protocols from KingByte Information Corp. KingByte's
......@@ -264,7 +264,7 @@ config PARIDE_KBIC
config PARIDE_KTTI
tristate "KT PHd protocol"
depends on PARIDE
depends on PARIDE || PATA_PARPORT
help
This option enables support for the "PHd" parallel port IDE protocol
from KT Technology. This is a simple (low speed) adapter that is
......@@ -277,7 +277,7 @@ config PARIDE_KTTI
config PARIDE_ON20
tristate "OnSpec 90c20 protocol"
depends on PARIDE
depends on PARIDE || PATA_PARPORT
help
This option enables support for the (obsolete) 90c20 parallel port
IDE protocol from OnSpec (often marketed under the ValuStore brand
......@@ -289,7 +289,7 @@ config PARIDE_ON20
config PARIDE_ON26
tristate "OnSpec 90c26 protocol"
depends on PARIDE
depends on PARIDE || PATA_PARPORT
help
This option enables support for the 90c26 parallel port IDE protocol
from OnSpec Electronics (often marketed under the ValuStore brand
......
/*
* The low-level protocol modules are used by either paride or pata_parport.
* These two are mutually exclusive because the compiled low-level protocol
* modules are not compatible.
* When PATA_PARPORT is enabled, include pata_parport.h instead of the rest
* of this file.
*/
#if IS_ENABLED(CONFIG_PATA_PARPORT)
#include <linux/pata_parport.h>
#else
#ifndef __DRIVERS_PARIDE_H__
#define __DRIVERS_PARIDE_H__
......@@ -170,3 +182,4 @@ void pi_unregister_driver(void *);
#endif /* __DRIVERS_PARIDE_H__ */
/* end of paride.h */
#endif /* IS_ENABLED(CONFIG_PATA_PARPORT) */
/* SPDX-License-Identifier: GPL-2.0-only */
/*
* pata_parport.h (c) 1997-8 Grant R. Guenther <grant@torque.net>
* Under the terms of the GPL.
*
* This file defines the interface for parallel port IDE adapter chip drivers.
*/
#ifndef LINUX_PATA_PARPORT_H
#define LINUX_PATA_PARPORT_H
#include <linux/libata.h>
#define PI_PCD 1 /* dummy for paride protocol modules */
struct pi_adapter {
struct device dev;
struct pi_protocol *proto; /* adapter protocol */
int port; /* base address of parallel port */
int mode; /* transfer mode in use */
int delay; /* adapter delay setting */
int devtype; /* dummy for paride protocol modules */
char *device; /* dummy for paride protocol modules */
int unit; /* unit number for chained adapters */
int saved_r0; /* saved port state */
int saved_r2; /* saved port state */
unsigned long private; /* for protocol module */
struct pardevice *pardev; /* pointer to pardevice */
};
typedef struct pi_adapter PIA; /* for paride protocol modules */
/* registers are addressed as (cont,regr)
* cont: 0 for command register file, 1 for control register(s)
* regr: 0-7 for register number.
*/
/* macros and functions exported to the protocol modules */
#define delay_p (pi->delay ? udelay(pi->delay) : (void)0)
#define out_p(offs, byte) do { outb(byte, pi->port + offs); delay_p; } while (0)
#define in_p(offs) (delay_p, inb(pi->port + offs))
#define w0(byte) out_p(0, byte)
#define r0() in_p(0)
#define w1(byte) out_p(1, byte)
#define r1() in_p(1)
#define w2(byte) out_p(2, byte)
#define r2() in_p(2)
#define w3(byte) out_p(3, byte)
#define w4(byte) out_p(4, byte)
#define r4() in_p(4)
#define w4w(data) do { outw(data, pi->port + 4); delay_p; } while (0)
#define w4l(data) do { outl(data, pi->port + 4); delay_p; } while (0)
#define r4w() (delay_p, inw(pi->port + 4))
#define r4l() (delay_p, inl(pi->port + 4))
static inline u16 pi_swab16(char *b, int k)
{
union { u16 u; char t[2]; } r;
r.t[0] = b[2 * k + 1]; r.t[1] = b[2 * k];
return r.u;
}
static inline u32 pi_swab32(char *b, int k)
{
union { u32 u; char f[4]; } r;
r.f[0] = b[4 * k + 1]; r.f[1] = b[4 * k];
r.f[2] = b[4 * k + 3]; r.f[3] = b[4 * k + 2];
return r.u;
}
struct pi_protocol {
char name[8];
int max_mode;
int epp_first; /* modes >= this use 8 ports */
int default_delay;
int max_units; /* max chained units probed for */
void (*write_regr)(struct pi_adapter *pi, int cont, int regr, int val);
int (*read_regr)(struct pi_adapter *pi, int cont, int regr);
void (*write_block)(struct pi_adapter *pi, char *buf, int count);
void (*read_block)(struct pi_adapter *pi, char *buf, int count);
void (*connect)(struct pi_adapter *pi);
void (*disconnect)(struct pi_adapter *pi);
int (*test_port)(struct pi_adapter *pi);
int (*probe_unit)(struct pi_adapter *pi);
int (*test_proto)(struct pi_adapter *pi, char *scratch, int verbose);
void (*log_adapter)(struct pi_adapter *pi, char *scratch, int verbose);
int (*init_proto)(struct pi_adapter *pi);
void (*release_proto)(struct pi_adapter *pi);
struct module *owner;
struct device_driver driver;
struct scsi_host_template sht;
};
#define PATA_PARPORT_SHT ATA_PIO_SHT
int pata_parport_register_driver(struct pi_protocol *pr);
void pata_parport_unregister_driver(struct pi_protocol *pr);
/* defines for old paride protocol modules */
#define paride_register pata_parport_register_driver
#define paride_unregister pata_parport_unregister_driver
#endif /* LINUX_PATA_PARPORT_H */
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment