pata_parport: add driver (PARIDE replacement)
Subsystems (4)
PATCH v2 1/1 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.
---
Changes in v2:
- keep device connected, remove disconnect timer
Documentation/admin-guide/blockdev/paride.rst | 52 ++ drivers/Makefile | 2 +- drivers/ata/Kconfig | 14 + drivers/ata/Makefile | 2 + drivers/ata/pata_parport.c | 783 ++++++++++++++++++ drivers/block/paride/Kconfig | 32 +- drivers/block/paride/paride.h | 13 + include/linux/pata_parport.h | 106 +++ 8 files changed, 987 insertions(+), 17 deletions(-) create mode 100644 drivers/ata/pata_parport.c create mode 100644 include/linux/pata_parport.h
Documentation/admin-guide/blockdev/paride.rst +52 -0
@@ -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 <[email protected]> 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
drivers/Makefile +1 -1
@@ -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/
drivers/ata/Kconfig +14 -0
@@ -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
drivers/ata/Makefile +2 -0
@@ -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
drivers/ata/pata_parport.c new file +783 -0
783 lines not on this page · raw message
drivers/block/paride/Kconfig +16 -16
@@ -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
drivers/block/paride/paride.h +13 -0
@@ -1,3 +1,15 @@ +/* +* 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) */
include/linux/pata_parport.h new file +106 -0
106 lines not on this page · raw message
Signature · 1 line
Ondrej Zary
I suspect a comment in the Kconfig for the old PARIDE code to point to this and maybe even a runtime warning when using the old paride code would be great.
But except for that the code looks awesome, so let's get it merged ASAP:
PATCH 1/1 paride: Mark PARIDE as deprecated, point to PATA_PARPORT
Add Kconfig and runtime deprecation warnings to PARIDE, pointing users to PATA_PARPORT.
--- drivers/block/Kconfig | 4 +++- drivers/block/paride/paride.c | 2 ++ 2 files changed, 5 insertions(+), 1 deletion(-)
drivers/block/Kconfig +3 -1
@@ -104,7 +104,7 @@ config GDROM You can also build this as a module which will be called gdrom. config PARIDE - tristate "Parallel port IDE device support" + tristate "Parallel port IDE device support (DEPRECATED)" depends on PARPORT_PC help There are many external CD-ROM and disk devices that connect through
@@ -130,6 +130,8 @@ config PARIDE "MicroSolutions backpack protocol", "DataStor Commuter protocol" etc.). + This driver is deprecated, replaced by libata-based PATA_PARPORT. + source "drivers/block/paride/Kconfig" source "drivers/block/mtip32xx/Kconfig"
drivers/block/paride/paride.c +2 -0
@@ -452,6 +452,8 @@ void *pi_register_driver(char *name)struct parport_driver *parp_drv;int ret; +printk (KERN_WARNING "PARIDE is deprecated. Use PATA_PARPORT instead.\n" ); + parp_drv =kzalloc (sizeof (*parp_drv),GFP_KERNEL );if (!parp_drv)return NULL ;
Signature · 1 line
Ondrej Zary
Re: [PATCH] paride: Mark PARIDE as deprecated, point to PATA_PARPORT
Hello!
Quoted 4 lines · Ondrej Zary
Add
Kconfigand runtime deprecation warnings to PARIDE, pointing users toPATA_PARPORT.Signed-off-by Ondrej Zary <[email protected]>
[...]
drivers/block/paride/paride.c void *pi_register_driver(char *name) · line 455
Quoted 9 lines
drivers/block/paride/paride.c +1
-0@@ -452,6 +452,8 @@ void *pi_register_driver(char *name)struct parport_driver *parp_drv;int ret; +printk (KERN_WARNING "PARIDE is deprecated. Use PATA_PARPORT instead.\n" );
Why not pr_warn()?
[...]
MBR, Sergey
PATCH v2 1/1 paride: Mark PARIDE as deprecated, point to PATA_PARPORT
Add Kconfig and runtime deprecation warnings to PARIDE, pointing users to PATA_PARPORT.
--- drivers/block/Kconfig | 4 +++- drivers/block/paride/paride.c | 2 ++ 2 files changed, 5 insertions(+), 1 deletion(-)
drivers/block/Kconfig +3 -1
@@ -104,7 +104,7 @@ config GDROM You can also build this as a module which will be called gdrom. config PARIDE - tristate "Parallel port IDE device support" + tristate "Parallel port IDE device support (DEPRECATED)" depends on PARPORT_PC help There are many external CD-ROM and disk devices that connect through
@@ -130,6 +130,8 @@ config PARIDE "MicroSolutions backpack protocol", "DataStor Commuter protocol" etc.). + This driver is deprecated, replaced by libata-based PATA_PARPORT. + source "drivers/block/paride/Kconfig" source "drivers/block/mtip32xx/Kconfig"
drivers/block/paride/paride.c +2 -0
@@ -452,6 +452,8 @@ void *pi_register_driver(char *name)struct parport_driver *parp_drv;int ret; +pr_warn ("PARIDE is deprecated. Use PATA_PARPORT instead.\n" ); + parp_drv =kzalloc (sizeof (*parp_drv),GFP_KERNEL );if (!parp_drv)return NULL ;
Signature · 1 line
Ondrej Zary
Re: [PATCH] paride: Mark PARIDE as deprecated, point to PATA_PARPORT
In reply to Ondrej ZaryQuoted 9 lines · Ondrej Zary
Add
Kconfigand runtime deprecation warnings to PARIDE, pointing users toPATA_PARPORT.Signed-off-by Ondrej Zary <[email protected]>--- drivers/block/Kconfig | 4 +++- drivers/block/paride/paride.c | 2 ++ 2 files changed, 5 insertions(+), 1 deletion(-)
Cheers,
Hannes
Signature · 5 lines
Dr. Hannes Reinecke Kernel Storage Architect [email protected] +49 911 74053 688 SUSE Software Solutions GmbH, Maxfeldstr. 5, 90409 Nürnberg HRB 36809 (AG Nürnberg), Geschäftsführer: Ivo Totev, Andrew Myers, Andrew McDonald, Martje Boudien Moerman
Jens Axboe
maintainerQuoted 7 lines · Christoph Hellwig
I suspect a comment in the
Kconfigfor the old PARIDE code to point to this and maybe even a runtime warning when using the old paride code would be great.But except for that the code looks awesome, so let's get it merged ASAP:
Reviewed-by Christoph Hellwig <[email protected]>
Since Ondrej is probably one of the few (maybe the only) user of this code, why don't we just kill off the paride code in a separate patch right after?
Signature · 1 line
Jens Axboe
Quoted 5 lines · Jens Axboe
Quoted 4 lines · Christoph Hellwig
I suspect a comment in the
Kconfigfor the old PARIDE code to point to this and maybe even a runtime warning when using the old paride code would be great.
Quoted 7 lines
Quoted 3 lines
But except for that the code looks awesome, so let's get it merged ASAP:
Reviewed-by Christoph Hellwig <[email protected]>Since Ondrej is probably one of the few (maybe the only) user of this code, why don't we just kill off the paride code in a separate patch right after?
+1
I do not see the point of deprecating it first. Let's remove that code directly.
Signature · 2 lines
Damien Le Moal Western Digital Research
Quoted 3 lines · Jens Axboe
Since Ondrej is probably one of the few (maybe the only) user of this code, why don't we just kill off the paride code in a separate patch right after?
That seems a little too fast too me. I'd give it at least another merge window if not two.
Jens Axboe
maintainerQuoted 7 lines · Christoph Hellwig
Quoted 3 lines · Jens Axboe
Since Ondrej is probably one of the few (maybe the only) user of this code, why don't we just kill off the paride code in a separate patch right after?
That seems a little too fast too me. I'd give it at least another merge window if not two.
It's not going to matter in this case. If we do it immediately or after two releases, nobody else is going to have noticed that message and decided "Oh, let me just switch over and test the other one". And since it's stuff that hasn't been released since the 90s, let's just get it done.
Signature · 1 line
Jens Axboe
Quoted 5 lines · Jens Axboe
Quoted 4 lines · Christoph Hellwig
I suspect a comment in the
Kconfigfor the old PARIDE code to point to this and maybe even a runtime warning when using the old paride code would be great.
Quoted 8 lines
Quoted 3 lines
But except for that the code looks awesome, so let's get it merged ASAP:
Reviewed-by Christoph Hellwig <[email protected]>Since Ondrej is probably one of the few (maybe the only) user of this code, why don't we just kill off the paride code in a separate patch right after?
Go for it.
Cheers,
Hannes
Signature · 5 lines
Dr. Hannes Reinecke Kernel Storage Architect [email protected] +49 911 74053 688 SUSE Software Solutions GmbH, Maxfeldstr. 5, 90409 Nürnberg HRB 36809 (AG Nürnberg), Geschäftsführer: Ivo Totev, Andrew Myers, Andrew McDonald, Martje Boudien Moerman
Quoted 40 lines · Ondrej Zary
The
pata_parportis 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_parportclaims 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 otherpata_parportdevices nor a printer).paride and
pata_parportare 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)
Quoted 2 lines
Note: EPP modes are buggy in FRPW, only modes 0 and 1 work.
Signed-off-by Ondrej Zary <[email protected]>
Overall, look good to me. Several comments below about simple cleanups/improvements.
Quoted 1 line
---
[...]
Quoted 20 lines
drivers/ata/pata_parport.c new file +14
-0@@ -0,0 +1,783 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* +* Copyright 2023 Ondrej Zary +* based on paride.c by Grant R. Guenther <[email protected]> +*/ +#include <linux/kernel.h> +#include <linux/module.h> +#include <linux/parport.h> +#include <linux/pata_parport.h> + +#define DRV_NAME "pata_parport" + +static DEFINE_IDR (parport_list); +static DEFINE_IDR (protocols);
drivers/ata/pata_parport.c line 24
Quoted 10 lines
drivers/ata/pata_parport.c new file +10
-0+static DEFINE_IDA (pata_parport_bus_dev_ids); +static DEFINE_MUTEX (pi_mutex); + +static bool probe = true; +module_param (probe, bool,0644 ); +MODULE_PARM_DESC (probe,"Enable automatic device probing (0=off, 1=on [default])" ); + +static bool verbose; +module_param (verbose, bool,0644 ); +MODULE_PARM_DESC (verbose,"Enable verbose messages (0=off [default], 1=on)" );
This is not needed. Use dynamic pr_debug()/dev_dbg() instead.
drivers/ata/pata_parport.c line 32
Quoted 8 lines
drivers/ata/pata_parport.c new file +8
-0+ +#define DISCONNECT_TIMEOUT (HZ / 10) + +/* libata drivers cannot sleep so this driver claims parport before activating +* the ata host and keeps it claimed (and protocol connected) until the ata +* host is removed. Unfortunately, this means that you cannot use any chained +* devices (neither other pata_parport devices nor a printer). +*/
Incorrect comment format. This should start with a "/*" line.
drivers/ata/pata_parport.c line 45
Quoted 13 lines
drivers/ata/pata_parport.c new file +13
-0+static void pi_connect (struct pi_adapter *pi) +{ +parport_claim_or_block (pi->pardev); + pi->proto->connect (pi); +} + +static void pi_disconnect (struct pi_adapter *pi) +{ + pi->proto->disconnect (pi); +parport_release (pi->pardev); +} + +/* functions taken from libata-sff.c and converted from direct port I/O */
I do not see how this comment is useful. I think you can drop it.
Quoted 27 lines
drivers/ata/pata_parport.c new file +27
-0+static void pata_parport_dev_select (struct ata_port *ap,unsigned int device) +{ +struct pi_adapter *pi = ap->host->private_data; +u8 tmp; + +if (device ==0 ) + tmp =ATA_DEVICE_OBS ; +else + tmp =ATA_DEVICE_OBS |ATA_DEV1 ; + + pi->proto->write_regr (pi,0 ,ATA_REG_DEVICE , tmp); +ata_sff_pause (ap); +} + +static bool pata_parport_devchk (struct ata_port *ap,unsigned int device) +{ +struct pi_adapter *pi = ap->host->private_data; +u8 nsect, lbal; + +pata_parport_dev_select (ap, device); + + pi->proto->write_regr (pi,0 ,ATA_REG_NSECT ,0x55 ); + pi->proto->write_regr (pi,0 ,ATA_REG_LBAL ,0xaa ); + + pi->proto->write_regr (pi,0 ,ATA_REG_NSECT ,0xaa ); + pi->proto->write_regr (pi,0 ,ATA_REG_LBAL ,0x55 ); +
drivers/ata/pata_parport.c line 82
Quoted 10 lines
drivers/ata/pata_parport.c new file +10
-0+ pi->proto->write_regr (pi,0 ,ATA_REG_NSECT ,055 ); + pi->proto->write_regr (pi,0 ,ATA_REG_LBAL ,0xaa ); + + nsect = pi->proto->read_regr (pi,0 ,ATA_REG_NSECT ); + lbal = pi->proto->read_regr (pi,0 ,ATA_REG_LBAL ); + +if ((nsect ==0x55 ) && (lbal ==0xaa )) +return true;/* we found a device */ + +return false;/* nothing found */
Simplify:
return (nsect == 0x55) && (lbal == 0xaa);
[...]
drivers/ata/pata_parport.c line 143
Quoted 8 lines
drivers/ata/pata_parport.c new file +8
-0+static u8 pata_parport_check_status (struct ata_port *ap) +{ +u8 status; +struct pi_adapter *pi = ap->host->private_data; + + status = pi->proto->read_regr (pi,0 ,ATA_REG_STATUS ); + +return status;
The status variable is not necessary. Simply do:
return pi->proto->read_regr(pi, 0, ATA_REG_STATUS);
drivers/ata/pata_parport.c line 153
Quoted 10 lines
drivers/ata/pata_parport.c new file +10
-0+} + +static u8 pata_parport_check_altstatus (struct ata_port *ap) +{ +u8 altstatus; +struct pi_adapter *pi = ap->host->private_data; + + altstatus = pi->proto->read_regr (pi,1 ,6 ); + +return altstatus;
Same here for altstatus.
[...]
Quoted 12 lines
drivers/ata/pata_parport.c new file +12
-0+static int default_test_proto (struct pi_adapter *pi,char *scratch) +{ +int j, k; +int e[2 ] = {0 ,0 }; + + pi->proto->connect (pi); + +for (j =0 ; j <2 ; j++) { + pi->proto->write_regr (pi,0 ,6 ,0xa0 + j *0x10 ); +for (k =0 ; k <256 ; k++) { + pi->proto->write_regr (pi,0 ,2 , k ^0xaa ); + pi->proto->write_regr (pi,0 ,3 , k ^0x55 );
drivers/ata/pata_parport.c line 315
Quoted 10 lines
drivers/ata/pata_parport.c new file +10
-0+if (pi->proto->read_regr (pi,0 ,2 ) != (k ^0xaa )) + e[j]++; + } + } + pi->proto->disconnect (pi); + +if (verbose) +dev_info (&pi->dev,"%s: port 0x%x, mode %d, test=(%d,%d)\n" , + pi->proto->name, pi->port, + pi->mode, e[0 ], e[1 ]);
Please remove the "if (verbose)" and use dev_dbg().
[...]
drivers/ata/pata_parport.c line 418
Quoted 10 lines
drivers/ata/pata_parport.c new file +10
-0+static struct bus_type pata_parport_bus_type = { + .name =DRV_NAME , +}; + +static struct device pata_parport_bus = { + .init_name =DRV_NAME , + .release = pata_parport_bus_release, +}; + +/* temporary for old paride protocol modules */
s/temporary/necessary ?
[...]
Quoted 22 lines
drivers/ata/pata_parport.c new file +22
-0+int pata_parport_register_driver (struct pi_protocol *pr) +{ +int error; +struct parport *parport; +int port_num; + + pr->driver.bus = &pata_parport_bus_type; + pr->driver.name = pr->name; + error =driver_register (&pr->driver); +if (error) +return error; + +mutex_lock (&pi_mutex); + error =idr_alloc (&protocols, pr,0 ,0 ,GFP_KERNEL ); +if (error <0 ) { +driver_unregister (&pr->driver); +mutex_unlock (&pi_mutex); +return error; + } + +pr_info ("pata_parport: protocol %s registered\n" , pr->name); +
drivers/ata/pata_parport.c line 555
Quoted 10 lines
drivers/ata/pata_parport.c new file +10
-0+if (probe) { +/* probe all parports using this protocol */ +idr_for_each_entry (&parport_list, parport, port_num) +pi_init_one (parport, pr,-1 ,0 ,-1 ); + } +mutex_unlock (&pi_mutex); + +return 0 ; +} +EXPORT_SYMBOL (pata_parport_register_driver);
EXPORT_SYMBOL_GPL()
Quoted 6 lines
drivers/ata/pata_parport.c new file +6
-0+ +void pata_parport_unregister_driver (struct pi_protocol *pr) +{ +struct pi_protocol *pr_iter; +int id =-1 ; +
drivers/ata/pata_parport.c line 571
Quoted 10 lines
drivers/ata/pata_parport.c new file +10
-0+mutex_lock (&pi_mutex); +idr_for_each_entry (&protocols, pr_iter, id) { +if (pr_iter == pr) +break ; + } +idr_remove (&protocols, id); +mutex_unlock (&pi_mutex); +driver_unregister (&pr->driver); +} +EXPORT_SYMBOL (pata_parport_unregister_driver);
Same here.
Quoted 14 lines
drivers/ata/pata_parport.c new file +14
-0+ +static ssize_t new_device_store (struct bus_type *bus,const char *buf, +size_t count) +{ +char port[12 ] ="auto" ; +char protocol[8 ] ="auto" ; +int mode =-1 , unit =-1 , delay =-1 ; +struct pi_protocol *pr, *pr_wanted; +struct device_driver *drv; +struct parport *parport; +int port_num, port_wanted, pr_num; +bool ok = false; + + if (sscanf(buf, "%11s %7s %d %d %d",
drivers/ata/pata_parport.c line 595
Quoted 10 lines
drivers/ata/pata_parport.c new file +10
-0+ port, protocol, &mode, &unit, &delay) < 1) +return -EINVAL ; + +if (sscanf (port,"parport%u" , &port_wanted) <1 ) { +if (!strcmp (port,"auto" )) { + port_wanted =-1 ; + }else { +pr_err ("invalid port name %s\n" , port); +return -EINVAL ; + }
It would be nicer to reverse the if condition to drop the else:
if (strcmp(port, "auto")) {
pr_err("invalid port name %s\n", port);
return -EINVAL;
}
port_wanted = -1;drivers/ata/pata_parport.c line 605
Quoted 10 lines
drivers/ata/pata_parport.c new file +10
-0+ } + + drv =driver_find (protocol, &pata_parport_bus_type); +if (!drv) { +if (!strcmp (protocol,"auto" )) { + pr_wanted =NULL ; + }else { +pr_err ("protocol %s not found\n" , protocol); +return -EINVAL ; + }
Same here.
[...]
drivers/ata/pata_parport.c line 658
Quoted 8 lines
drivers/ata/pata_parport.c new file +8
-0+static ssize_t delete_device_store (struct bus_type *bus,const char *buf, +size_t count) +{ +struct device *dev; +char device_name[32 ]; + +if (sscanf (buf,"%31s" , device_name) <1 ) +return -EINVAL ;
Why sscanf() ? You can strncpy from buf to device_name directly, no ? And given how you use device_name below, I think that you do not even need the device_name variable.
Quoted 14 lines
drivers/ata/pata_parport.c new file +14
-0+ +mutex_lock (&pi_mutex); + dev =bus_find_device_by_name (bus,NULL , device_name); +if (!dev) { +mutex_unlock (&pi_mutex); +return -ENODEV ; + } + +pi_remove_one (dev); +mutex_unlock (&pi_mutex); + +return count; +} +static BUS_ATTR_WO (delete_device);
[...]
Quoted 6 lines
include/linux/pata_parport.h new file +0
-0
include/linux/pata_parport.h line 8
Quoted 8 lines
include/linux/pata_parport.h new file +8
-0@@ -0,0 +1,106 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* +* pata_parport.h (c) 1997-8 Grant R. Guenther <[email protected]> +* Under the terms of the GPL. +* +* This file defines the interface for parallel port IDE adapter chip drivers. +*/ +
You are missing:
#ifndef LINUX_PATA_PARPORT_H
#define LINUX_PATA_PARPORT_H
Quoted 20 lines
include/linux/pata_parport.h new file +20
-0+#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 */
include/linux/pata_parport.h line 38
Quoted 10 lines
include/linux/pata_parport.h new file +10
-0+ +/* 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))
It would be way nicer to have these as inline functions.
Quoted 68 lines
include/linux/pata_parport.h new file +68
-0+ +#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
Signature · 2 lines
Damien Le Moal Western Digital Research
PATCH v3 1/1 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.
---
Changes in v3:
- addressed Damien's comments
Changes in v2:
- keep device connected, remove disconnect timer
Documentation/admin-guide/blockdev/paride.rst | 52 ++ drivers/Makefile | 2 +- drivers/ata/Kconfig | 14 + drivers/ata/Makefile | 2 + drivers/ata/pata_parport.c | 759 ++++++++++++++++++ drivers/block/paride/Kconfig | 32 +- drivers/block/paride/paride.h | 13 + include/linux/pata_parport.h | 111 +++ 8 files changed, 968 insertions(+), 17 deletions(-) create mode 100644 drivers/ata/pata_parport.c create mode 100644 include/linux/pata_parport.h
Documentation/admin-guide/blockdev/paride.rst +52 -0
@@ -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 <[email protected]> 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
drivers/Makefile +1 -1
@@ -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/
drivers/ata/Kconfig +14 -0
@@ -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
drivers/ata/Makefile +2 -0
@@ -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
drivers/ata/pata_parport.c new file +759 -0
759 lines not on this page · raw message
drivers/block/paride/Kconfig +16 -16
@@ -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
drivers/block/paride/paride.h +13 -0
@@ -1,3 +1,15 @@ +/* +* 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) */
include/linux/pata_parport.h new file +111 -0
111 lines not on this page · raw message
Signature · 1 line
Ondrej Zary
Quoted 40 lines · Ondrej Zary
The
pata_parportis 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_parportclaims 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 otherpata_parportdevices nor a printer).paride and
pata_parportare 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)
Quoted 2 lines
Note: EPP modes are buggy in FRPW, only modes 0 and 1 work.
Signed-off-by Ondrej Zary <[email protected]>
Are you going to send a patch to remove the legacy parport code ? If we want this queued for 6.3, it is now (this week, asap) or we will have to delay to 6.4. Unless Jens prefers the deprecation first, which I think he said "better delete now".
Quoted 1,189 lines
---
Changes in v3:
- addressed Damien's commentsChanges in v2:
- keep device connected, remove disconnect timerDocumentation/admin-guide/blockdev/paride.rst | 52 ++ drivers/Makefile | 2 +- drivers/ata/Kconfig | 14 + drivers/ata/Makefile | 2 + drivers/ata/pata_parport.c | 759 ++++++++++++++++++ drivers/block/paride/Kconfig | 32 +- drivers/block/paride/paride.h | 13 + include/linux/pata_parport.h | 111 +++ 8 files changed, 968 insertions(+), 17 deletions(-) create mode 100644 drivers/ata/pata_parport.c create mode 100644 include/linux/pata_parport.hDocumentation/admin-guide/blockdev/paride.rst +52
-0@@ -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 <[email protected]> 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_devicedrivers/Makefile +1
-1@@ -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/drivers/ata/Kconfig +14
-0@@ -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_ACPIdrivers/ata/Makefile +2
-0@@ -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 driverdrivers/ata/pata_parport.c new file +759
-0@@ -0,0 +1,759 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* +* Copyright 2023 Ondrej Zary +* based on paride.c by Grant R. Guenther <[email protected]> +*/ +#include <linux/kernel.h> +#include <linux/module.h> +#include <linux/parport.h> +#include <linux/pata_parport.h> + +#define DRV_NAME "pata_parport" + +static DEFINE_IDR (parport_list); +static DEFINE_IDR (protocols); +static DEFINE_IDA (pata_parport_bus_dev_ids); +static DEFINE_MUTEX (pi_mutex); + +static bool probe = true; +module_param (probe, bool,0644 ); +MODULE_PARM_DESC (probe,"Enable automatic device probing (0=off, 1=on [default])" ); + +/* +* libata drivers cannot sleep so this driver claims parport before activating +* the ata host and keeps it claimed (and protocol connected) until the ata +* host is removed. Unfortunately, this means that you cannot use any chained +* devices (neither other pata_parport devices nor a printer). +*/ +static void pi_connect (struct pi_adapter *pi) +{ +parport_claim_or_block (pi->pardev); + pi->proto->connect (pi); +} + +static void pi_disconnect (struct pi_adapter *pi) +{ + pi->proto->disconnect (pi); +parport_release (pi->pardev); +} + +static void pata_parport_dev_select (struct ata_port *ap,unsigned int device) +{ +struct pi_adapter *pi = ap->host->private_data; +u8 tmp; + +if (device ==0 ) + tmp =ATA_DEVICE_OBS ; +else + tmp =ATA_DEVICE_OBS |ATA_DEV1 ; + + pi->proto->write_regr (pi,0 ,ATA_REG_DEVICE , tmp); +ata_sff_pause (ap); +} + +static bool pata_parport_devchk (struct ata_port *ap,unsigned int device) +{ +struct pi_adapter *pi = ap->host->private_data; +u8 nsect, lbal; + +pata_parport_dev_select (ap, device); + + pi->proto->write_regr (pi,0 ,ATA_REG_NSECT ,0x55 ); + pi->proto->write_regr (pi,0 ,ATA_REG_LBAL ,0xaa ); + + pi->proto->write_regr (pi,0 ,ATA_REG_NSECT ,0xaa ); + pi->proto->write_regr (pi,0 ,ATA_REG_LBAL ,0x55 ); + + pi->proto->write_regr (pi,0 ,ATA_REG_NSECT ,055 ); + pi->proto->write_regr (pi,0 ,ATA_REG_LBAL ,0xaa ); + + nsect = pi->proto->read_regr (pi,0 ,ATA_REG_NSECT ); + lbal = pi->proto->read_regr (pi,0 ,ATA_REG_LBAL ); + +return (nsect ==0x55 ) && (lbal ==0xaa ); +} + +static int pata_parport_bus_softreset (struct ata_port *ap,unsigned int devmask, +unsigned long deadline) +{ +struct pi_adapter *pi = ap->host->private_data; + +/* software reset. causes dev0 to be selected */ + pi->proto->write_regr (pi,1 ,6 , ap->ctl); +udelay (20 ); + pi->proto->write_regr (pi,1 ,6 , ap->ctl |ATA_SRST ); +udelay (20 ); + pi->proto->write_regr (pi,1 ,6 , ap->ctl); + ap->last_ctl = ap->ctl; + +/* wait the port to become ready */ +return ata_sff_wait_after_reset (&ap->link, devmask, deadline); +} + +static int pata_parport_softreset (struct ata_link *link,unsigned int *classes, +unsigned long deadline) +{ +struct ata_port *ap = link->ap; +unsigned int devmask =0 ; +int rc; +u8 err; + +/* determine if device 0/1 are present */ +if (pata_parport_devchk (ap,0 )) + devmask |= (1 <<0 ); +if (pata_parport_devchk (ap,1 )) + devmask |= (1 <<1 ); + +/* select device 0 again */ +pata_parport_dev_select (ap,0 ); + +/* issue bus reset */ + rc =pata_parport_bus_softreset (ap, devmask, deadline); +if (rc && rc != -ENODEV ) { +ata_link_err (link,"SRST failed (errno=%d)\n" , rc); +return rc; + } + +/* determine by signature whether we have ATA or ATAPI devices */ + classes[0 ] =ata_sff_dev_classify (&link->device[0 ], + devmask & (1 <<0 ), &err); +if (err !=0x81 ) + classes[1 ] =ata_sff_dev_classify (&link->device[1 ], + devmask & (1 <<1 ), &err); + +return 0 ; +} + +static u8 pata_parport_check_status (struct ata_port *ap) +{ +struct pi_adapter *pi = ap->host->private_data; + +return pi->proto->read_regr (pi,0 ,ATA_REG_STATUS ); +} + +static u8 pata_parport_check_altstatus (struct ata_port *ap) +{ +struct pi_adapter *pi = ap->host->private_data; + +return pi->proto->read_regr (pi,1 ,6 ); +} + +static void pata_parport_tf_load (struct ata_port *ap, +const struct ata_taskfile *tf) +{ +struct pi_adapter *pi = ap->host->private_data; + +if (tf->ctl != ap->last_ctl) { + pi->proto->write_regr (pi,1 ,6 , tf->ctl); + ap->last_ctl = tf->ctl; +ata_wait_idle (ap); + } + +if (tf->flags &ATA_TFLAG_ISADDR ) { +if (tf->flags &ATA_TFLAG_LBA48 ) { + pi->proto->write_regr (pi,0 ,ATA_REG_FEATURE , + tf->hob_feature); + pi->proto->write_regr (pi,0 ,ATA_REG_NSECT , + tf->hob_nsect); + pi->proto->write_regr (pi,0 ,ATA_REG_LBAL , + tf->hob_lbal); + pi->proto->write_regr (pi,0 ,ATA_REG_LBAM , + tf->hob_lbam); + pi->proto->write_regr (pi,0 ,ATA_REG_LBAH , + tf->hob_lbah); + } + pi->proto->write_regr (pi,0 ,ATA_REG_FEATURE , tf->feature); + pi->proto->write_regr (pi,0 ,ATA_REG_NSECT , tf->nsect); + pi->proto->write_regr (pi,0 ,ATA_REG_LBAL , tf->lbal); + pi->proto->write_regr (pi,0 ,ATA_REG_LBAM , tf->lbam); + pi->proto->write_regr (pi,0 ,ATA_REG_LBAH , tf->lbah); + } + +if (tf->flags &ATA_TFLAG_DEVICE ) + pi->proto->write_regr (pi,0 ,ATA_REG_DEVICE , tf->device); + +ata_wait_idle (ap); +} + +static void pata_parport_tf_read (struct ata_port *ap,struct ata_taskfile *tf) +{ +struct pi_adapter *pi = ap->host->private_data; + + tf->status = pi->proto->read_regr (pi,0 ,ATA_REG_STATUS ); + tf->error = pi->proto->read_regr (pi,0 ,ATA_REG_ERR ); + tf->nsect = pi->proto->read_regr (pi,0 ,ATA_REG_NSECT ); + tf->lbal = pi->proto->read_regr (pi,0 ,ATA_REG_LBAL ); + tf->lbam = pi->proto->read_regr (pi,0 ,ATA_REG_LBAM ); + tf->lbah = pi->proto->read_regr (pi,0 ,ATA_REG_LBAH ); + tf->device = pi->proto->read_regr (pi,0 ,ATA_REG_DEVICE ); + +if (tf->flags &ATA_TFLAG_LBA48 ) { + pi->proto->write_regr (pi,1 ,6 , tf->ctl |ATA_HOB ); + tf->hob_feature = pi->proto->read_regr (pi,0 ,ATA_REG_ERR ); + tf->hob_nsect = pi->proto->read_regr (pi,0 ,ATA_REG_NSECT ); + tf->hob_lbal = pi->proto->read_regr (pi,0 ,ATA_REG_LBAL ); + tf->hob_lbam = pi->proto->read_regr (pi,0 ,ATA_REG_LBAM ); + tf->hob_lbah = pi->proto->read_regr (pi,0 ,ATA_REG_LBAH ); + pi->proto->write_regr (pi,1 ,6 , tf->ctl); + ap->last_ctl = tf->ctl; + } +} + +static void pata_parport_exec_command (struct ata_port *ap, +const struct ata_taskfile *tf) +{ +struct pi_adapter *pi = ap->host->private_data; + + pi->proto->write_regr (pi,0 ,ATA_REG_CMD , tf->command); +ata_sff_pause (ap); +} + +static unsigned int pata_parport_data_xfer (struct ata_queued_cmd *qc, +unsigned char *buf,unsigned int buflen,int rw) +{ +struct ata_port *ap = qc->dev->link->ap; +struct pi_adapter *pi = ap->host->private_data; + +if (rw ==READ ) + pi->proto->read_block (pi, buf, buflen); +else + pi->proto->write_block (pi, buf, buflen); + +return buflen; +} + +static void pata_parport_drain_fifo (struct ata_queued_cmd *qc) +{ +int count; +struct ata_port *ap; +struct pi_adapter *pi; +char junk[2 ]; + +/* We only need to flush incoming data when a command was running */ +if (qc ==NULL || qc->dma_dir ==DMA_TO_DEVICE ) +return ; + + ap = qc->ap; + pi = ap->host->private_data; +/* Drain up to 64K of data before we give up this recovery method */ +for (count =0 ; (pata_parport_check_status (ap) &ATA_DRQ ) + && count <65536 ; count +=2 ) { + pi->proto->read_block (pi, junk,2 ); + } + +if (count) +ata_port_dbg (ap,"drained %d bytes to clear DRQ\n" , count); +} + +static struct ata_port_operations pata_parport_port_ops = { + .inherits = &ata_sff_port_ops, + + .softreset = pata_parport_softreset, + .hardreset =NULL , + + .sff_dev_select = pata_parport_dev_select, + .sff_check_status = pata_parport_check_status, + .sff_check_altstatus = pata_parport_check_altstatus, + .sff_tf_load = pata_parport_tf_load, + .sff_tf_read = pata_parport_tf_read, + .sff_exec_command = pata_parport_exec_command, + .sff_data_xfer = pata_parport_data_xfer, + .sff_drain_fifo = pata_parport_drain_fifo, +}; + +static const struct ata_port_info pata_parport_port_info = { + .flags =ATA_FLAG_SLAVE_POSS |ATA_FLAG_PIO_POLLING , + .pio_mask =ATA_PIO0 , +/* No DMA */ + .port_ops = &pata_parport_port_ops, +}; + +static void pi_release (struct pi_adapter *pi) +{ +parport_unregister_device (pi->pardev); +if (pi->proto->release_proto) + pi->proto->release_proto (pi); +module_put (pi->proto->owner); +} + +static int default_test_proto (struct pi_adapter *pi,char *scratch) +{ +int j, k; +int e[2 ] = {0 ,0 }; + + pi->proto->connect (pi); + +for (j =0 ; j <2 ; j++) { + pi->proto->write_regr (pi,0 ,6 ,0xa0 + j *0x10 ); +for (k =0 ; k <256 ; k++) { + pi->proto->write_regr (pi,0 ,2 , k ^0xaa ); + pi->proto->write_regr (pi,0 ,3 , k ^0x55 ); +if (pi->proto->read_regr (pi,0 ,2 ) != (k ^0xaa )) + e[j]++; + } + } + pi->proto->disconnect (pi); + +dev_dbg (&pi->dev,"%s: port 0x%x, mode %d, test=(%d,%d)\n" , + pi->proto->name, pi->port, pi->mode, e[0 ], e[1 ]); + +return e[0 ] && e[1 ];/* not here if both > 0 */ +} + +static int pi_test_proto (struct pi_adapter *pi,char *scratch) +{ +int res; + +parport_claim_or_block (pi->pardev); +if (pi->proto->test_proto) + res = pi->proto->test_proto (pi, scratch,1 ); +else + res =default_test_proto (pi, scratch); +parport_release (pi->pardev); + +return res; +} + +static bool pi_probe_mode (struct pi_adapter *pi,int max,char *scratch) +{ +int best, range; + +if (pi->mode !=-1 ) { +if (pi->mode >= max) +return false; + range =3 ; +if (pi->mode >= pi->proto->epp_first) + range =8 ; +if (range ==8 && pi->port %8 ) +return false; +return !pi_test_proto (pi, scratch); + } + best =-1 ; +for (pi->mode =0 ; pi->mode < max; pi->mode++) { + range =3 ; +if (pi->mode >= pi->proto->epp_first) + range =8 ; +if (range ==8 && pi->port %8 ) +break ; +if (!pi_test_proto (pi, scratch)) + best = pi->mode; + } + pi->mode = best; +return best >-1 ; +} + +static bool pi_probe_unit (struct pi_adapter *pi,int unit,char *scratch) +{ +int max, s, e; + + s = unit; + e = s +1 ; + +if (s ==-1 ) { + s =0 ; + e = pi->proto->max_units; + } + +if (pi->proto->test_port) { +parport_claim_or_block (pi->pardev); + max = pi->proto->test_port (pi); +parport_release (pi->pardev); + }else { + max = pi->proto->max_mode; + } + +if (pi->proto->probe_unit) { +parport_claim_or_block (pi->pardev); +for (pi->unit = s; pi->unit < e; pi->unit++) { +if (pi->proto->probe_unit (pi)) { +parport_release (pi->pardev); +return pi_probe_mode (pi, max, scratch); + } + } +parport_release (pi->pardev); +return false; + } + +return pi_probe_mode (pi, max, scratch); +} + +static void pata_parport_dev_release (struct device *dev) +{ + struct pi_adapter *pi = container_of(dev, struct pi_adapter, dev); + +kfree (pi); +} + +static void pata_parport_bus_release (struct device *dev) +{ +/* nothing to do here but required to avoid warning on device removal */ +} + +static struct bus_type pata_parport_bus_type = { + .name =DRV_NAME , +}; + +static struct device pata_parport_bus = { + .init_name =DRV_NAME , + .release = pata_parport_bus_release, +}; + +static struct scsi_host_template pata_parport_sht = { +PATA_PARPORT_SHT ("pata_parport" ) +}; + +struct pi_device_match { +struct parport *parport; +struct pi_protocol *proto; +}; + +static int pi_find_dev (struct device *dev,void *data) +{ + struct pi_adapter *pi = container_of(dev, struct pi_adapter, dev); +struct pi_device_match *match = data; + +return pi->pardev->port == match->parport && pi->proto == match->proto; +} + +static struct pi_adapter *pi_init_one (struct parport *parport, +struct pi_protocol *pr,int mode,int unit,int delay) +{ +struct pardev_cb par_cb = { }; +char scratch[512 ]; +const struct ata_port_info *ppi[] = { &pata_parport_port_info }; +struct ata_host *host; +struct pi_adapter *pi; +struct pi_device_match match = { .parport = parport, .proto = pr }; + +/* +* Abort if there's a device already registered on the same parport +* using the same protocol. +*/ +if (bus_for_each_dev (&pata_parport_bus_type,NULL , &match, pi_find_dev)) +return NULL ; + + pi =kzalloc (sizeof (struct pi_adapter ),GFP_KERNEL ); +if (!pi) +return NULL ; + +/* set up pi->dev before pi_probe_unit() so it can use dev_printk() */ + pi->dev.parent = &pata_parport_bus; + pi->dev.bus = &pata_parport_bus_type; + pi->dev.driver = &pr->driver; + pi->dev.release = pata_parport_dev_release; + pi->dev.id =ida_alloc (&pata_parport_bus_dev_ids,GFP_KERNEL ); +if (pi->dev.id <0 ) +return NULL ;/* pata_parport_dev_release will do kfree(pi) */ +dev_set_name (&pi->dev,"pata_parport.%u" , pi->dev.id); +if (device_register (&pi->dev)) { +put_device (&pi->dev); + goto out_ida_free; + } + + pi->proto = pr; + +if (!try_module_get (pi->proto->owner)) + goto out_unreg_dev; +if (pi->proto->init_proto && pi->proto->init_proto (pi) <0 ) + goto out_module_put; + + pi->delay = (delay ==-1 ) ? pi->proto->default_delay : delay; + pi->mode = mode; + pi->port = parport->base; + + par_cb.private = pi; + pi->pardev =parport_register_dev_model (parport,DRV_NAME , &par_cb, + pi->dev.id); +if (!pi->pardev) + goto out_module_put; + +if (!pi_probe_unit (pi, unit, scratch)) { +dev_info (&pi->dev,"Adapter not found\n" ); + goto out_unreg_parport; + } + + pi->proto->log_adapter (pi, scratch,1 ); + + host =ata_host_alloc_pinfo (&pi->pardev->dev, ppi,1 ); +if (!host) + goto out_unreg_parport; +dev_set_drvdata (&pi->dev, host); + host->private_data = pi; + +ata_port_desc (host->ports[0 ],"port %s" , pi->pardev->port->name); +ata_port_desc (host->ports[0 ],"protocol %s" , pi->proto->name); + +pi_connect (pi); +if (ata_host_activate (host,0 ,NULL ,0 , &pata_parport_sht)) + goto out_unreg_parport; + +return pi; + +out_unreg_parport: +pi_disconnect (pi); +parport_unregister_device (pi->pardev); +if (pi->proto->release_proto) + pi->proto->release_proto (pi); +out_module_put: +module_put (pi->proto->owner); +out_unreg_dev: +device_unregister (&pi->dev); +out_ida_free: +ida_free (&pata_parport_bus_dev_ids, pi->dev.id); +return NULL ; +} + +int pata_parport_register_driver (struct pi_protocol *pr) +{ +int error; +struct parport *parport; +int port_num; + + pr->driver.bus = &pata_parport_bus_type; + pr->driver.name = pr->name; + error =driver_register (&pr->driver); +if (error) +return error; + +mutex_lock (&pi_mutex); + error =idr_alloc (&protocols, pr,0 ,0 ,GFP_KERNEL ); +if (error <0 ) { +driver_unregister (&pr->driver); +mutex_unlock (&pi_mutex); +return error; + } + +pr_info ("pata_parport: protocol %s registered\n" , pr->name); + +if (probe) { +/* probe all parports using this protocol */ +idr_for_each_entry (&parport_list, parport, port_num) +pi_init_one (parport, pr,-1 ,0 ,-1 ); + } +mutex_unlock (&pi_mutex); + +return 0 ; +} +EXPORT_SYMBOL_GPL (pata_parport_register_driver); + +void pata_parport_unregister_driver (struct pi_protocol *pr) +{ +struct pi_protocol *pr_iter; +int id =-1 ; + +mutex_lock (&pi_mutex); +idr_for_each_entry (&protocols, pr_iter, id) { +if (pr_iter == pr) +break ; + } +idr_remove (&protocols, id); +mutex_unlock (&pi_mutex); +driver_unregister (&pr->driver); +} +EXPORT_SYMBOL_GPL (pata_parport_unregister_driver); + +static ssize_t new_device_store (struct bus_type *bus,const char *buf, +size_t count) +{ +char port[12 ] ="auto" ; +char protocol[8 ] ="auto" ; +int mode =-1 , unit =-1 , delay =-1 ; +struct pi_protocol *pr, *pr_wanted; +struct device_driver *drv; +struct parport *parport; +int port_num, port_wanted, pr_num; +bool ok = false; + +if (sscanf (buf,"%11s %7s %d %d %d" , + port, protocol, &mode, &unit, &delay) <1 ) +return -EINVAL ; + +if (sscanf (port,"parport%u" , &port_wanted) <1 ) { +if (strcmp (port,"auto" )) { +pr_err ("invalid port name %s\n" , port); +return -EINVAL ; + } + port_wanted =-1 ; + } + + drv =driver_find (protocol, &pata_parport_bus_type); +if (!drv) { +if (strcmp (protocol,"auto" )) { +pr_err ("protocol %s not found\n" , protocol); +return -EINVAL ; + } + pr_wanted =NULL ; + }else { + pr_wanted = container_of(drv, struct pi_protocol, driver); + } + +mutex_lock (&pi_mutex); +/* walk all parports */ +idr_for_each_entry (&parport_list, parport, port_num) { +if (port_num == port_wanted || port_wanted ==-1 ) { + parport =parport_find_number (port_num); +if (!parport) { +pr_err ("no such port %s\n" , port); +mutex_unlock (&pi_mutex); +return -ENODEV ; + } +/* walk all protocols */ +idr_for_each_entry (&protocols, pr, pr_num) { +if (pr == pr_wanted || !pr_wanted) +if (pi_init_one (parport, pr, mode, unit, + delay)) + ok = true; + } +parport_put_port (parport); + } + } +mutex_unlock (&pi_mutex); +if (!ok) +return -ENODEV ; + +return count; +} +static BUS_ATTR_WO (new_device); + +static void pi_remove_one (struct device *dev) +{ +struct ata_host *host =dev_get_drvdata (dev); +struct pi_adapter *pi = host->private_data; + +ata_host_detach (host); +pi_disconnect (pi); +pi_release (pi); +device_unregister (dev); +ida_free (&pata_parport_bus_dev_ids, dev->id); +/* pata_parport_dev_release will do kfree(pi) */ +} + +static ssize_t delete_device_store (struct bus_type *bus,const char *buf, +size_t count) +{ +struct device *dev; + +mutex_lock (&pi_mutex); + dev =bus_find_device_by_name (bus,NULL , buf); +if (!dev) { +mutex_unlock (&pi_mutex); +return -ENODEV ; + } + +pi_remove_one (dev); +mutex_unlock (&pi_mutex); + +return count; +} +static BUS_ATTR_WO (delete_device); + +static void pata_parport_attach (struct parport *port) +{ +struct pi_protocol *pr; +int pr_num, id; + +mutex_lock (&pi_mutex); + id =idr_alloc (&parport_list, port, port->number, port->number, +GFP_KERNEL ); +if (id <0 ) { +mutex_unlock (&pi_mutex); +return ; + } + +if (probe) { +/* probe this port using all protocols */ +idr_for_each_entry (&protocols, pr, pr_num) +pi_init_one (port, pr,-1 ,0 ,-1 ); + } +mutex_unlock (&pi_mutex); +} + +static int pi_remove_port (struct device *dev,void *p) +{ +struct ata_host *host =dev_get_drvdata (dev); +struct pi_adapter *pi = host->private_data; + +if (pi->pardev->port == p) +pi_remove_one (dev); + +return 0 ; +} + +static void pata_parport_detach (struct parport *port) +{ +mutex_lock (&pi_mutex); +bus_for_each_dev (&pata_parport_bus_type,NULL , port, pi_remove_port); +idr_remove (&parport_list, port->number); +mutex_unlock (&pi_mutex); +} + +static struct parport_driver pata_parport_driver = { + .name =DRV_NAME , + .match_port = pata_parport_attach, + .detach = pata_parport_detach, + .devmodel = true, +}; + +static __init int pata_parport_init (void ) +{ +int error; + + error =bus_register (&pata_parport_bus_type); +if (error) { +pr_err ("failed to register pata_parport bus, error: %d\n" , error); +return error; + } + + error =device_register (&pata_parport_bus); +if (error) { +pr_err ("failed to register pata_parport bus, error: %d\n" , error); + goto out_unregister_bus; + } + + error =bus_create_file (&pata_parport_bus_type, &bus_attr_new_device); +if (error) { +pr_err ("unable to create sysfs file, error: %d\n" , error); + goto out_unregister_dev; + } + + error =bus_create_file (&pata_parport_bus_type, &bus_attr_delete_device); +if (error) { +pr_err ("unable to create sysfs file, error: %d\n" , error); + goto out_remove_new; + } + + error =parport_register_driver (&pata_parport_driver); +if (error) { +pr_err ("unable to register parport driver, error: %d\n" , error); + goto out_remove_del; + } + +return 0 ; + +out_remove_del: +bus_remove_file (&pata_parport_bus_type, &bus_attr_delete_device); +out_remove_new: +bus_remove_file (&pata_parport_bus_type, &bus_attr_new_device); +out_unregister_dev: +device_unregister (&pata_parport_bus); +out_unregister_bus: +bus_unregister (&pata_parport_bus_type); +return error; +} + +static __exit void pata_parport_exit(void) +{ +parport_unregister_driver (&pata_parport_driver); +bus_remove_file (&pata_parport_bus_type, &bus_attr_new_device); +bus_remove_file (&pata_parport_bus_type, &bus_attr_delete_device); +device_unregister (&pata_parport_bus); +bus_unregister (&pata_parport_bus_type); +} + +MODULE_AUTHOR ("Ondrej Zary" ); +MODULE_DESCRIPTION ("driver for parallel port ATA adapters" ); +MODULE_LICENSE ("GPL" ); +MODULE_ALIAS ("paride" ); + +module_init (pata_parport_init); +module_exit (pata_parport_exit);drivers/block/paride/Kconfig +16
-16@@ -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 branddrivers/block/paride/paride.h +13
-0@@ -1,3 +1,15 @@ +/* +* 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) */ include/linux/pata_parport.h new file +111
-0@@ -0,0 +1,111 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* +* pata_parport.h (c) 1997-8 Grant R. Guenther <[email protected]> +* 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 */
Signature · 2 lines
Damien Le Moal Western Digital Research
Jens Axboe
maintainerQuoted 41 lines · Damien Le Moal
Quoted 40 lines · Ondrej Zary
The
pata_parportis 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_parportclaims 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 otherpata_parportdevices nor a printer).paride and
pata_parportare 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)
Quoted 7 lines
Quoted 2 lines
Note: EPP modes are buggy in FRPW, only modes 0 and 1 work.
Signed-off-by Ondrej Zary <[email protected]>Are you going to send a patch to remove the legacy parport code ? If we want this queued for 6.3, it is now (this week, asap) or we will have to delay to 6.4. Unless Jens prefers the deprecation first, which I think he said "better delete now".
I would prefer if we just delete it after merging this one, in the same release. I don't think there's any point in delaying, as we're not removing any functionality.
You could just queue that up too when adding this patch.
Signature · 1 line
Jens Axboe
Quoted 5 lines · Jens Axboe
I would prefer if we just delete it after merging this one, in the same release. I don't think there's any point in delaying, as we're not removing any functionality.
You could just queue that up too when adding this patch.
I'd prefer to just deprecate. But most importantly I want this patch in ASAP in some form.
Quoted 9 lines · Christoph Hellwig
Quoted 5 lines · Jens Axboe
I would prefer if we just delete it after merging this one, in the same release. I don't think there's any point in delaying, as we're not removing any functionality.
You could just queue that up too when adding this patch.
I'd prefer to just deprecate. But most importantly I want this patch in ASAP in some form.
I will queue it. But I think it needs a follow up to result in something consistent with KConfig. So either deprecate or delete PARPORT. I can queue the deprecate patch and delete in 6.4, even though I share Jen's opinion to simply delete directly. I am still fine either way.
Jens,
If you are OK with that, can I get your ack for the deprecate patch ? Unless you prefer taking it through the block tree. Either way is fine with me.
Signature · 2 lines
Damien Le Moal Western Digital Research
Jens Axboe
maintainerQuoted 16 lines · Damien Le Moal
Quoted 9 lines · Christoph Hellwig
Quoted 5 lines · Jens Axboe
I would prefer if we just delete it after merging this one, in the same release. I don't think there's any point in delaying, as we're not removing any functionality.
You could just queue that up too when adding this patch.
I'd prefer to just deprecate. But most importantly I want this patch in ASAP in some form.
I will queue it. But I think it needs a follow up to result in something consistent with KConfig. So either deprecate or delete PARPORT. I can queue the deprecate patch and delete in 6.4, even though I share Jen's opinion to simply delete directly. I am still fine either way.
Quoted 4 lines
Jens,
If you are OK with that, can I get your ack for the deprecate patch ? Unless you prefer taking it through the block tree. Either way is fine with me.
Yeah I'd be happy to ack that, did you post it? You can add my ack to the new driver, fine with that now.
Signature · 1 line
Jens Axboe
Quoted 17 lines · Jens Axboe
Quoted 16 lines · Damien Le Moal
Quoted 9 lines · Christoph Hellwig
Quoted 5 lines · Jens Axboe
I would prefer if we just delete it after merging this one, in the same release. I don't think there's any point in delaying, as we're not removing any functionality.
You could just queue that up too when adding this patch.
I'd prefer to just deprecate. But most importantly I want this patch in ASAP in some form.
I will queue it. But I think it needs a follow up to result in something consistent with KConfig. So either deprecate or delete PARPORT. I can queue the deprecate patch and delete in 6.4, even though I share Jen's opinion to simply delete directly. I am still fine either way.
Quoted 7 lines
Quoted 4 lines
Jens,
If you are OK with that, can I get your ack for the deprecate patch ? Unless you prefer taking it through the block tree. Either way is fine with me.
Yeah I'd be happy to ack that, did you post it? You can add my ack to the new driver, fine with that now.
Will do. But I did not want to queue the new driver without killing (or deprecating) the old code too. Ondrej has now sent 2 patches to remove the old code. Please ack that !
Signature · 2 lines
Damien Le Moal Western Digital Research
Jens Axboe
maintainerQuoted 9 lines · Christoph Hellwig
Quoted 5 lines · Jens Axboe
I would prefer if we just delete it after merging this one, in the same release. I don't think there's any point in delaying, as we're not removing any functionality.
You could just queue that up too when adding this patch.
I'd prefer to just deprecate. But most importantly I want this patch in ASAP in some form.
There's feature parity and probably the single user of this already knows it... I think we're grossly overthinking this one, just kill the old code.
Signature · 1 line
Jens Axboe
PATCH 1/2 drivers/block: Remove PARIDE core and high-level protocols
In reply to Damien Le MoalRemove PARIDE core and high level protocols, taking care not to break low-level drivers (used by pata_parport). Also update documentation.
--- Documentation/admin-guide/blockdev/paride.rst | 440 ++----- .../admin-guide/kernel-parameters.rst | 1 - .../admin-guide/kernel-parameters.txt | 16 - MAINTAINERS | 7 - drivers/ata/Kconfig | 2 +- drivers/block/Kconfig | 27 - drivers/block/paride/Kconfig | 121 +- drivers/block/paride/Makefile | 6 - drivers/block/paride/Transition-notes | 128 -- drivers/block/paride/aten.c | 2 +- drivers/block/paride/bpck.c | 2 +- drivers/block/paride/bpck6.c | 2 +- drivers/block/paride/comm.c | 2 +- drivers/block/paride/dstr.c | 2 +- drivers/block/paride/epat.c | 2 +- drivers/block/paride/epia.c | 2 +- drivers/block/paride/fit2.c | 2 +- drivers/block/paride/fit3.c | 2 +- drivers/block/paride/friq.c | 2 +- drivers/block/paride/frpw.c | 2 +- drivers/block/paride/kbic.c | 2 +- drivers/block/paride/ktti.c | 2 +- drivers/block/paride/mkd | 31 - drivers/block/paride/on20.c | 2 +- drivers/block/paride/on26.c | 2 +- drivers/block/paride/paride.c | 479 -------- drivers/block/paride/paride.h | 185 --- drivers/block/paride/pcd.c | 1042 ---------------- drivers/block/paride/pd.c | 1032 ---------------- drivers/block/paride/pf.c | 1057 ----------------- drivers/block/paride/pg.c | 734 ------------ drivers/block/paride/pseudo.h | 102 -- drivers/block/paride/pt.c | 1024 ---------------- 33 files changed, 110 insertions(+), 6354 deletions(-) delete mode 100644 drivers/block/paride/Transition-notes delete mode 100644 drivers/block/paride/mkd delete mode 100644 drivers/block/paride/paride.c delete mode 100644 drivers/block/paride/paride.h delete mode 100644 drivers/block/paride/pcd.c delete mode 100644 drivers/block/paride/pd.c delete mode 100644 drivers/block/paride/pf.c delete mode 100644 drivers/block/paride/pg.c delete mode 100644 drivers/block/paride/pseudo.h delete mode 100644 drivers/block/paride/pt.c
Documentation/admin-guide/blockdev/paride.rst +78 -362
@@ -2,10 +2,8 @@ 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 <[email protected]> +PATA_PARPORT (c) 2023 Ondrej Zary 1. Introduction ===============
@@ -54,27 +52,15 @@ parallel port IDE subsystem, including: as well as most of the clone and no-name products on the market. -To support such a wide range of devices, PARIDE, the parallel port IDE -subsystem, is actually structured in three parts. There is a base -paride module which provides a registry and some common methods for -accessing the parallel ports. The second component is a set of -high-level drivers for each of the different types of supported devices: - - === ============= - pd IDE disk - pcd ATAPI CD-ROM - pf ATAPI disk - pt ATAPI tape - pg ATAPI generic - === ============= - -(Currently, the pg driver is only used with CD-R drives). +To support such a wide range of devices, pata_parport is actually structured +in two parts. There is a base pata_parport module which provides an interface +to kernel libata subsystem, registry and some common methods for accessing +the parallel ports. -The high-level drivers function according to the relevant standards. -The third component of PARIDE is a set of low-level protocol drivers -for each of the parallel port IDE adapter chips. Thanks to the interest -and encouragement of Linux users from many parts of the world, -support is available for almost all known adapter protocols: +The second component is a set of low-level protocol drivers for each of the +parallel port IDE adapter chips. Thanks to the interest and encouragement of +Linux users from many parts of the world, support is available for almost all +known adapter protocols: ==== ====================================== ==== aten ATEN EH-100 (HK)
@@ -94,251 +80,87 @@ support is available for almost all known adapter protocols: ==== ====================================== ==== -2. Using the PARIDE subsystem -============================= +2. Using pata_parport subsystem +=============================== While configuring the Linux kernel, you may choose either to build -the PARIDE drivers into your kernel, or to build them as modules. +the pata_parport drivers into your kernel, or to build them as modules. In either case, you will need to select "Parallel port IDE device support" -as well as at least one of the high-level drivers and at least one -of the parallel port communication protocols. If you do not know -what kind of parallel port adapter is used in your drive, you could -begin by checking the file names and any text files on your DOS +and at least one of the parallel port communication protocols. +If you do not know what kind of parallel port adapter is used in your drive, +you could begin by checking the file names and any text files on your DOS installation floppy. Alternatively, you can look at the markings on the adapter chip itself. That's usually sufficient to identify the correct device. -You can actually select all the protocol modules, and allow the PARIDE +You can actually select all the protocol modules, and allow the pata_parport subsystem to try them all for you. For the "brand-name" products listed above, here are the protocol and high-level drivers that you would use: - ================ ============ ====== ======== - Manufacturer Model Driver Protocol - ================ ============ ====== ======== - MicroSolutions CD-ROM pcd bpck - MicroSolutions PD drive pf bpck - MicroSolutions hard-drive pd bpck - MicroSolutions 8000t tape pt bpck - SyQuest EZ, SparQ pd epat - Imation Superdisk pf epat - Maxell Superdisk pf friq - Avatar Shark pd epat - FreeCom CD-ROM pcd frpw - Hewlett-Packard 5GB Tape pt epat - Hewlett-Packard 7200e (CD) pcd epat - Hewlett-Packard 7200e (CD-R) pg epat - ================ ============ ====== ======== - -2.1 Configuring built-in drivers ---------------------------------- - -We recommend that you get to know how the drivers work and how to -configure them as loadable modules, before attempting to compile a -kernel with the drivers built-in. - -If you built all of your PARIDE support directly into your kernel, -and you have just a single parallel port IDE device, your kernel should -locate it automatically for you. If you have more than one device, -you may need to give some command line options to your bootloader -(eg: LILO), how to do that is beyond the scope of this document. - -The high-level drivers accept a number of command line parameters, all -of which are documented in the source files in linux/drivers/block/paride. -By default, each driver will automatically try all parallel ports it -can find, and all protocol types that have been installed, until it finds -a parallel port IDE adapter. Once it finds one, the probe stops. So, -if you have more than one device, you will need to tell the drivers -how to identify them. This requires specifying the port address, the -protocol identification number and, for some devices, the drive's -chain ID. While your system is booting, a number of messages are -displayed on the console. Like all such messages, they can be -reviewed with the 'dmesg' command. Among those messages will be -some lines like:: - - paride: bpck registered as protocol 0 - paride: epat registered as protocol 1 - -The numbers will always be the same until you build a new kernel with -different protocol selections. You should note these numbers as you -will need them to identify the devices. + ================ ============ ======== + Manufacturer Model Protocol + ================ ============ ======== + MicroSolutions CD-ROM bpck + MicroSolutions PD drive bpck + MicroSolutions hard-drive bpck + MicroSolutions 8000t tape bpck + SyQuest EZ, SparQ epat + Imation Superdisk epat + Maxell Superdisk friq + Avatar Shark epat + FreeCom CD-ROM frpw + Hewlett-Packard 5GB Tape epat + Hewlett-Packard 7200e (CD) epat + Hewlett-Packard 7200e (CD-R) epat + ================ ============ ======== + +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 (for backpack only, see below) + delay I/O delay (see troubleshooting section below) + ======== ================================================ If you happen to be using a MicroSolutions backpack device, you will also need to know the unit ID number for each drive. This is usually the last two digits of the drive's serial number (but read MicroSolutions' documentation about this). -As an example, let's assume that you have a MicroSolutions PD/CD drive -with unit ID number 36 connected to the parallel port at 0x378, a SyQuest -EZ-135 connected to the chained port on the PD/CD drive and also an -Imation Superdisk connected to port 0x278. You could give the following -options on your boot command:: - - pd.drive0=0x378,1 pf.drive0=0x278,1 pf.drive1=0x378,0,36 - -In the last option, pf.drive1 configures device /dev/pf1, the 0x378 -is the parallel port base address, the 0 is the protocol registration -number and 36 is the chain ID. - -Please note: while PARIDE will work both with and without the -PARPORT parallel port sharing system that is included by the -"Parallel port support" option, PARPORT must be included and enabled -if you want to use chains of devices on the same parallel port. - -2.2 Loading and configuring PARIDE as modules ----------------------------------------------- - -It is much faster and simpler to get to understand the PARIDE drivers -if you use them as loadable kernel modules. - -Note 1: - using these drivers with the "kerneld" automatic module loading - system is not recommended for beginners, and is not documented here. - -Note 2: - if you build PARPORT support as a loadable module, PARIDE must - also be built as loadable modules, and PARPORT must be loaded before - the PARIDE modules. - -To use PARIDE, you must begin by:: - - insmod paride - -this loads a base module which provides a registry for the protocols, -among other tasks. - -Then, load as many of the protocol modules as you think you might need. -As you load each module, it will register the protocols that it supports, -and print a log message to your kernel log file and your console. For -example:: - - # insmod epat - paride: epat registered as protocol 0 - # insmod kbic - paride: k951 registered as protocol 1 - paride: k971 registered as protocol 2 - -Finally, you can load high-level drivers for each kind of device that -you have connected. By default, each driver will autoprobe for a single -device, but you can support up to four similar devices by giving their -individual coordinates when you load the driver. - -For example, if you had two no-name CD-ROM drives both using the -KingByte KBIC-951A adapter, one on port 0x378 and the other on 0x3bc -you could give the following command:: - - # insmod pcd drive0=0x378,1 drive1=0x3bc,1 - -For most adapters, giving a port address and protocol number is sufficient, -but check the source files in linux/drivers/block/paride for more -information. (Hopefully someone will write some man pages one day !). - -As another example, here's what happens when PARPORT is installed, and -a SyQuest EZ-135 is attached to port 0x378:: - - # insmod paride - paride: version 1.0 installed - # insmod epat - paride: epat registered as protocol 0 - # insmod pd - pd: pd version 1.0, major 45, cluster 64, nice 0 - pda: Sharing parport1 at 0x378 - pda: epat 1.0, Shuttle EPAT chip c3 at 0x378, mode 5 (EPP-32), delay 1 - pda: SyQuest EZ135A, 262144 blocks [128M], (512/16/32), removable media - pda: pda1 - -Note that the last line is the output from the generic partition table -scanner - in this case it reports that it has found a disk with one partition. - -2.3 Using a PARIDE device --------------------------- - -Once the drivers have been loaded, you can access PARIDE devices in the -same way as their traditional counterparts. You will probably need to -create the device "special files". Here is a simple script that you can -cut to a file and execute:: - - #!/bin/bash - # - # mkd -- a script to create the device special files for the PARIDE subsystem - # - function mkdev { - mknod $1 $2 $3 $4 ; chmod 0660 $1 ; chown root:disk $1 - } - # - function pd { - D=$( printf \\$( printf "x%03x" $[ $1 + 97 ] ) ) - mkdev pd$D b 45 $[ $1 * 16 ] - for P in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 - do mkdev pd$D$P b 45 $[ $1 * 16 + $P ] - done - } - # - cd /dev - # - for u in 0 1 2 3 ; do pd $u ; done - for u in 0 1 2 3 ; do mkdev pcd$u b 46 $u ; done - for u in 0 1 2 3 ; do mkdev pf$u b 47 $u ; done - for u in 0 1 2 3 ; do mkdev pt$u c 96 $u ; done - for u in 0 1 2 3 ; do mkdev npt$u c 96 $[ $u + 128 ] ; done - for u in 0 1 2 3 ; do mkdev pg$u c 97 $u ; done - # - # end of mkd - -With the device files and drivers in place, you can access PARIDE devices -like any other Linux device. For example, to mount a CD-ROM in pcd0, use:: - - mount /dev/pcd0 /cdrom - -If you have a fresh Avatar Shark cartridge, and the drive is pda, you -might do something like:: - - fdisk /dev/pda -- make a new partition table with - partition 1 of type 83 - - mke2fs /dev/pda1 -- to build the file system - - mkdir /shark -- make a place to mount the disk - - mount /dev/pda1 /shark - -Devices like the Imation superdisk work in the same way, except that -they do not have a partition table. For example to make a 120MB -floppy that you could share with a DOS system:: - - mkdosfs /dev/pf0 - mount /dev/pf0 /mnt - - -2.4 The pf driver ------------------- - -The pf driver is intended for use with parallel port ATAPI disk -devices. The most common devices in this category are PD drives -and LS-120 drives. Traditionally, media for these devices are not -partitioned. Consequently, the pf driver does not support partitioned -media. This may be changed in a future version of the driver. - -2.5 Using the pt driver ------------------------- - -The pt driver for parallel port ATAPI tape drives is a minimal driver. -It does not yet support many of the standard tape ioctl operations. -For best performance, a block size of 32KB should be used. You will -probably want to set the parallel port delay to 0, if you can. - -2.6 Using the pg driver ------------------------- - -The pg driver can be used in conjunction with the cdrecord program -to create CD-ROMs. Please get cdrecord version 1.6.1 or later -from ftp://ftp.fokus.gmd.de/pub/unix/cdrecord/ . To record CD-R media -your parallel port should ideally be set to EPP mode, and the "port delay" -should be set to 0. With those settings it is possible to record at 2x -speed without any buffer underruns. If you cannot get the driver to work -in EPP mode, try to use "bidirectional" or "PS/2" mode and 1x speeds only. +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 3. Troubleshooting
@@ -347,9 +169,9 @@ in EPP mode, try to use "bidirectional" or "PS/2" mode and 1x speeds only. 3.1 Use EPP mode if you can ---------------------------- -The most common problems that people report with the PARIDE drivers +The most common problems that people report with the pata_parport drivers concern the parallel port CMOS settings. At this time, none of the -PARIDE protocol modules support ECP mode, or any ECP combination modes. +protocol modules support ECP mode, or any ECP combination modes. If you are able to do so, please set your parallel port into EPP mode using your CMOS setup procedure.
@@ -357,17 +179,14 @@ using your CMOS setup procedure. ------------------------- Some parallel ports cannot reliably transfer data at full speed. To -offset the errors, the PARIDE protocol modules introduce a "port +offset the errors, the protocol modules introduce a "port delay" between each access to the i/o ports. Each protocol sets a default value for this delay. In most cases, the user can override the default and set it to 0 - resulting in somewhat higher transfer rates. In some rare cases (especially with older 486 systems) the default delays are not long enough. if you experience corrupt data transfers, or unexpected failures, you may wish to increase the -port delay. The delay can be programmed using the "driveN" parameters -to each of the high-level drivers. Please see the notes above, or -read the comments at the beginning of the driver source files in -linux/drivers/block/paride. +port delay. 3.3 Some drives need a printer reset -------------------------------------
@@ -377,115 +196,12 @@ that do not always power up correctly. We have noticed this with some drives based on OnSpec and older Freecom adapters. In these rare cases, the adapter can often be reinitialised by issuing a "printer reset" on the parallel port. As the reset operation is potentially disruptive in -multiple device environments, the PARIDE drivers will not do it +multiple device environments, the pata_parport drivers will not do it automatically. You can however, force a printer reset by doing:: insmod lp reset=1 rmmod lp If you have one of these marginal cases, you should probably build -your paride drivers as modules, and arrange to do the printer reset -before loading the PARIDE drivers. - -3.4 Use the verbose option and dmesg if you need help ------------------------------------------------------- - -While a lot of testing has gone into these drivers to make them work -as smoothly as possible, problems will arise. If you do have problems, -please check all the obvious things first: does the drive work in -DOS with the manufacturer's drivers ? If that doesn't yield any useful -clues, then please make sure that only one drive is hooked to your system, -and that either (a) PARPORT is enabled or (b) no other device driver -is using your parallel port (check in /proc/ioports). Then, load the -appropriate drivers (you can load several protocol modules if you want) -as in:: - - # insmod paride - # insmod epat - # insmod bpck - # insmod kbic - ... - # insmod pd verbose=1 - -(using the correct driver for the type of device you have, of course). -The verbose=1 parameter will cause the drivers to log a trace of their -activity as they attempt to locate your drive. - -Use 'dmesg' to capture a log of all the PARIDE messages (any messages -beginning with paride:, a protocol module's name or a driver's name) and -include that with your bug report. You can submit a bug report in one -of two ways. Either send it directly to the author of the PARIDE suite, -by e-mail to [email protected], or join the linux-parport mailing list -and post your report there. - -3.5 For more information or help ---------------------------------- - -You can join the linux-parport mailing list by sending a mail message -to: - - [email protected] - -with the single word:: - - subscribe - -in the body of the mail message (not in the subject line). Please be -sure that your mail program is correctly set up when you do this, as -the list manager is a robot that will subscribe you using the reply -address in your mail headers. REMOVE any anti-spam gimmicks you may -have in your mail headers, when sending mail to the list server. - -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 +your pata_parport drivers as modules, and arrange to do the printer reset +before loading the pata_parport drivers.
Documentation/admin-guide/kernel-parameters.rst +0 -1
@@ -142,7 +142,6 @@ parameter is applicable:: NFS Appropriate NFS support is enabled. OF Devicetree is enabled. PV_OPS A paravirtualized kernel is enabled. - PARIDE The ParIDE (parallel port IDE) subsystem is enabled. PARISC The PA-RISC architecture is enabled. PCI PCI bus support is enabled. PCIE PCI Express support is enabled.
Documentation/admin-guide/kernel-parameters.txt +0 -16
@@ -4120,10 +4120,6 @@ pcbit= [HW,ISDN] - pcd. [PARIDE] - See header of drivers/block/paride/pcd.c. - See also Documentation/admin-guide/blockdev/paride.rst. - pci=option[,option...] [PCI] various PCI subsystem options. Some options herein operate on a specific device
@@ -4386,9 +4382,6 @@ for debug and development, but should not be needed on a platform with proper driver support. - pd. [PARIDE] - See Documentation/admin-guide/blockdev/paride.rst. - pdcchassis= [PARISC,HW] Disable/Enable PDC Chassis Status codes at boot time. Format: { 0 | 1 }
@@ -4401,12 +4394,6 @@ allocator. This parameter is primarily for debugging and performance comparison. - pf. [PARIDE] - See Documentation/admin-guide/blockdev/paride.rst. - - pg. [PARIDE] - See Documentation/admin-guide/blockdev/paride.rst. - pirq= [SMP,APIC] Manual mp-table setup See Documentation/x86/i386/IO-APIC.rst.
@@ -4568,9 +4555,6 @@ pstore.backend= Specify the name of the pstore backend to use - pt. [PARIDE] - See Documentation/admin-guide/blockdev/paride.rst. - pti= [X86-64] Control Page Table Isolation of user and kernel address spaces. Disabling this feature removes hardening, but improves performance of
MAINTAINERS +0 -7
@@ -15844,13 +15844,6 @@ F: arch/*/include/asm/paravirt*.h F: arch/*/kernel/paravirt* F: include/linux/hypervisor.h -PARIDE DRIVERS FOR PARALLEL PORT IDE DEVICES -M: Tim Waugh <[email protected]> -L: [email protected] (subscribers-only) -S: Maintained -F: Documentation/admin-guide/blockdev/paride.rst -F: drivers/block/paride/ - PARISC ARCHITECTURE M: "James E.J. Bottomley" <[email protected]> M: Helge Deller <[email protected]>
drivers/ata/Kconfig +1 -1
@@ -1164,7 +1164,7 @@ config PATA_WINBOND_VLB config PATA_PARPORT tristate "Parallel port IDE device support" - depends on PARPORT_PC && PARIDE=n + depends on PARPORT_PC 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
drivers/block/Kconfig +0 -27
@@ -103,33 +103,6 @@ config GDROM Most users will want to say "Y" here. You can also build this as a module which will be called gdrom. -config PARIDE - tristate "Parallel port IDE device support" - depends on PARPORT_PC - 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 PARIDE - subsystem which contains drivers for many of these external drives. - Read <file:Documentation/admin-guide/blockdev/paride.rst> for more information. - - If you have said Y to the "Parallel-port support" configuration - option, you may share a single port between your printer and other - parallel port devices. Answer Y to build PARIDE support into your - kernel, or M if you would like to build it as a loadable module. If - your parallel port support is in a loadable module, you must build - PARIDE as a module. If you built PARIDE support into your kernel, - you may still build the individual protocol modules and high-level - drivers as loadable modules. If you build this support as a module, - it will be called paride. - - To use the PARIDE support, you must say Y or M here and also to at - least one high-level driver (e.g. "Parallel port IDE disks", - "Parallel port ATAPI CD-ROMs", "Parallel port ATAPI disks" etc.) and - to at least one protocol driver (e.g. "ATEN EH-100 protocol", - "MicroSolutions backpack protocol", "DataStor Commuter protocol" - etc.). - source "drivers/block/paride/Kconfig" source "drivers/block/mtip32xx/Kconfig"
drivers/block/paride/Kconfig +16 -105
216 lines not on this page · raw message
drivers/block/paride/Makefile +0 -6
@@ -6,7 +6,6 @@ # Rewritten to use lists instead of if-statements. # -obj-$(CONFIG_PARIDE) += paride.o obj-$(CONFIG_PARIDE_ATEN) += aten.o obj-$(CONFIG_PARIDE_BPCK) += bpck.o obj-$(CONFIG_PARIDE_COMM) += comm.o
@@ -22,8 +21,3 @@ obj-$(CONFIG_PARIDE_ON20) += on20.o obj-$(CONFIG_PARIDE_ON26) += on26.o obj-$(CONFIG_PARIDE_KTTI) += ktti.o obj-$(CONFIG_PARIDE_BPCK6) += bpck6.o -obj-$(CONFIG_PARIDE_PD) += pd.o -obj-$(CONFIG_PARIDE_PCD) += pcd.o -obj-$(CONFIG_PARIDE_PF) += pf.o -obj-$(CONFIG_PARIDE_PT) += pt.o -obj-$(CONFIG_PARIDE_PG) += pg.o
drivers/block/paride/Transition-notes deleted +0 -128
128 lines not on this page · raw message
drivers/block/paride/aten.c +1 -1
@@ -25,7 +25,7 @@#include <linux/types.h> #include <asm/io.h> -#include "paride.h" +#include <linux/pata_parport.h> #define j44 (a,b) ((((a>>4)&0x0f)|(b&0xf0))^0x88)
drivers/block/paride/bpck.c +1 -1
@@ -24,7 +24,7 @@#include <linux/wait.h> #include <asm/io.h> -#include "paride.h" +#include <linux/pata_parport.h> #undef r2#undef w2
drivers/block/paride/bpck6.c +1 -1
@@ -31,7 +31,7 @@#include <linux/parport.h> #include "ppc6lnx.c" -#include "paride.h" +#include <linux/pata_parport.h> /* PARAMETERS */ static bool verbose;/* set this to 1 to see debugging messages and whatnot */
drivers/block/paride/comm.c +1 -1
@@ -24,7 +24,7 @@#include <linux/wait.h> #include <asm/io.h> -#include "paride.h" +#include <linux/pata_parport.h> /* mode codes: 0 nybble reads, 8-bit writes 1 8-bit reads and writes
drivers/block/paride/dstr.c +1 -1
@@ -23,7 +23,7 @@#include <linux/wait.h> #include <asm/io.h> -#include "paride.h" +#include <linux/pata_parport.h> /* mode codes: 0 nybble reads, 8-bit writes 1 8-bit reads and writes
drivers/block/paride/epat.c +1 -1
@@ -26,7 +26,7 @@#include <linux/wait.h> #include <asm/io.h> -#include "paride.h" +#include <linux/pata_parport.h> #define j44 (a,b) (((a>>4)&0x0f)+(b&0xf0))#define j53 (a,b) (((a>>3)&0x1f)+((b<<4)&0xe0))
drivers/block/paride/epia.c +1 -1
@@ -27,7 +27,7 @@#include <linux/wait.h> #include <asm/io.h> -#include "paride.h" +#include <linux/pata_parport.h> /* mode codes: 0 nybble reads on port 1, 8-bit writes 1 5/3 reads on ports 1 & 2, 8-bit writes
drivers/block/paride/fit2.c +1 -1
@@ -23,7 +23,7 @@#include <linux/wait.h> #include <asm/io.h> -#include "paride.h" +#include <linux/pata_parport.h> #define j44 (a,b) (((a>>4)&0x0f)|(b&0xf0))
drivers/block/paride/fit3.c +1 -1
@@ -27,7 +27,7 @@#include <linux/wait.h> #include <asm/io.h> -#include "paride.h" +#include <linux/pata_parport.h> #define j44 (a,b) (((a>>3)&0x0f)|((b<<1)&0xf0))
drivers/block/paride/friq.c +1 -1
@@ -35,7 +35,7 @@#include <linux/wait.h> #include <asm/io.h> -#include "paride.h" +#include <linux/pata_parport.h> #define CMD (x) w2(4);w0(0xff);w0(0xff);w0(0x73);w0(0x73);\ w0(0xc9);w0(0xc9);w0(0x26);w0(0x26);w0(x);w0(x);
drivers/block/paride/frpw.c +1 -1
@@ -33,7 +33,7 @@#include <linux/wait.h> #include <asm/io.h> -#include "paride.h" +#include <linux/pata_parport.h> #define cec4 w2(0xc);w2(0xe);w2(0xe);w2(0xc);w2(4);w2(4);w2(4);#define j44 (l,h) (((l>>4)&0x0f)|(h&0xf0))
drivers/block/paride/kbic.c +1 -1
@@ -28,7 +28,7 @@#include <linux/wait.h> #include <asm/io.h> -#include "paride.h" +#include <linux/pata_parport.h> #define r12w () (delay_p,inw(pi->port+1)&0xffff)
drivers/block/paride/ktti.c +1 -1
@@ -19,7 +19,7 @@#include <linux/wait.h> #include <asm/io.h> -#include "paride.h" +#include <linux/pata_parport.h> #define j44 (a,b) (((a>>4)&0x0f)|(b&0xf0))
drivers/block/paride/mkd deleted +0 -31
@@ -1,31 +0,0 @@ -#!/bin/bash -# SPDX-License-Identifier: GPL-2.0 -# -# mkd -- a script to create the device special files for the PARIDE subsystem -# -# block devices: pd (45), pcd (46), pf (47) -# character devices: pt (96), pg (97) -# -function mkdev { - mknod $1 $2 $3 $4 ; chmod 0660 $1 ; chown root:disk $1 -} -# -function pd { - D=$( printf \\$( printf "x%03x" $[ $1 + 97 ] ) ) - mkdev pd$D b 45 $[ $1 * 16 ] - for P in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 - do mkdev pd$D$P b 45 $[ $1 * 16 + $P ] - done -} -# -cd /dev -# -for u in 0 1 2 3 ; do pd $u ; done -for u in 0 1 2 3 ; do mkdev pcd$u b 46 $u ; done -for u in 0 1 2 3 ; do mkdev pf$u b 47 $u ; done -for u in 0 1 2 3 ; do mkdev pt$u c 96 $u ; done -for u in 0 1 2 3 ; do mkdev npt$u c 96 $[ $u + 128 ] ; done -for u in 0 1 2 3 ; do mkdev pg$u c 97 $u ; done -# -# end of mkd -
drivers/block/paride/on20.c +1 -1
@@ -22,7 +22,7 @@#include <linux/wait.h> #include <asm/io.h> -#include "paride.h" +#include <linux/pata_parport.h> #define op (f) w2(4);w0(f);w2(5);w2(0xd);w2(5);w2(0xd);w2(5);w2(4);#define vl (v) w2(4);w0(v);w2(5);w2(7);w2(5);w2(4);
drivers/block/paride/on26.c +1 -1
@@ -26,7 +26,7 @@#include <linux/wait.h> #include <asm/io.h> -#include "paride.h" +#include <linux/pata_parport.h> /* mode codes: 0 nybble reads, 8-bit writes 1 8-bit reads and writes
drivers/block/paride/paride.c deleted +0 -479
479 lines not on this page · raw message
drivers/block/paride/paride.h deleted +0 -185
185 lines not on this page · raw message
drivers/block/paride/pcd.c deleted +0 -1042
1,042 lines not on this page · raw message
drivers/block/paride/pd.c deleted +0 -1032
176 lines not on this page · raw message
drivers/block/paride/pf.c deleted +0 -1057
1,057 lines not on this page · raw message
drivers/block/paride/pg.c deleted +0 -734
734 lines not on this page · raw message
drivers/block/paride/pseudo.h deleted +0 -102
102 lines not on this page · raw message
drivers/block/paride/pt.c deleted +0 -1024
1,024 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Signature · 1 line
Ondrej Zary
Part of the diff is not shown here. View the raw message.
PATCH 2/2 drivers/block: Move PARIDE protocol modules to drivers/ata/pata_parport
Move PARIDE protocol modules out of drivers/block and update CONFIG_ symbol names to PATA_PARPORT.
---
drivers/Makefile | 2 +-
drivers/ata/Kconfig | 2 +-
drivers/ata/pata_parport/Kconfig | 141 ++++++++++++
drivers/ata/pata_parport/Makefile | 17 ++
.../{block/paride => ata/pata_parport}/aten.c | 0
.../{block/paride => ata/pata_parport}/bpck.c | 0
.../paride => ata/pata_parport}/bpck6.c | 0
.../{block/paride => ata/pata_parport}/comm.c | 0
.../{block/paride => ata/pata_parport}/dstr.c | 0
.../{block/paride => ata/pata_parport}/epat.c | 0
.../{block/paride => ata/pata_parport}/epia.c | 0
.../{block/paride => ata/pata_parport}/fit2.c | 0
.../{block/paride => ata/pata_parport}/fit3.c | 0
.../{block/paride => ata/pata_parport}/friq.c | 0
.../{block/paride => ata/pata_parport}/frpw.c | 0
.../{block/paride => ata/pata_parport}/kbic.c | 0
.../{block/paride => ata/pata_parport}/ktti.c | 0
.../{block/paride => ata/pata_parport}/on20.c | 0
.../{block/paride => ata/pata_parport}/on26.c | 0
.../paride => ata/pata_parport}/ppc6lnx.c | 0
drivers/block/Kconfig | 2 -
drivers/block/paride/Kconfig | 213 ------------------
drivers/block/paride/Makefile | 23 --
23 files changed, 160 insertions(+), 240 deletions(-)
create mode 100644 drivers/ata/pata_parport/Kconfig
create mode 100644 drivers/ata/pata_parport/Makefile
rename drivers/{block/paride => ata/pata_parport}/aten.c (100%)
rename drivers/{block/paride => ata/pata_parport}/bpck.c (100%)
rename drivers/{block/paride => ata/pata_parport}/bpck6.c (100%)
rename drivers/{block/paride => ata/pata_parport}/comm.c (100%)
rename drivers/{block/paride => ata/pata_parport}/dstr.c (100%)
rename drivers/{block/paride => ata/pata_parport}/epat.c (100%)
rename drivers/{block/paride => ata/pata_parport}/epia.c (100%)
rename drivers/{block/paride => ata/pata_parport}/fit2.c (100%)
rename drivers/{block/paride => ata/pata_parport}/fit3.c (100%)
rename drivers/{block/paride => ata/pata_parport}/friq.c (100%)
rename drivers/{block/paride => ata/pata_parport}/frpw.c (100%)
rename drivers/{block/paride => ata/pata_parport}/kbic.c (100%)
rename drivers/{block/paride => ata/pata_parport}/ktti.c (100%)
rename drivers/{block/paride => ata/pata_parport}/on20.c (100%)
rename drivers/{block/paride => ata/pata_parport}/on26.c (100%)
rename drivers/{block/paride => ata/pata_parport}/ppc6lnx.c (100%)
delete mode 100644 drivers/block/paride/Kconfig
delete mode 100644 drivers/block/paride/Makefiledrivers/Makefile +1 -1
@@ -98,7 +98,7 @@ obj-$(CONFIG_DIO) += dio/ obj-$(CONFIG_SBUS) += sbus/ obj-$(CONFIG_ZORRO) += zorro/ obj-$(CONFIG_ATA_OVER_ETH) += block/aoe/ -obj-y += block/paride/ +obj-$(CONFIG_PATA_PARPORT) += ata/pata_parport/ obj-$(CONFIG_TC) += tc/ obj-$(CONFIG_USB_PHY) += usb/ obj-$(CONFIG_USB) += usb/
drivers/ata/Kconfig +1 -1
@@ -1174,7 +1174,7 @@ config PATA_PARPORT Read <file:Documentation/admin-guide/blockdev/paride.rst> for more information. - Use the old PARIDE protocol modules. +source "drivers/ata/pata_parport/Kconfig" comment "Generic fallback / legacy drivers"
drivers/ata/pata_parport/Kconfig new file +141 -0
141 lines not on this page · raw message
drivers/ata/pata_parport/Makefile new file +17 -0
@@ -0,0 +1,17 @@ +# SPDX-License-Identifier: GPL-2.0 + +obj-$(CONFIG_PATA_PARPORT_ATEN) += aten.o +obj-$(CONFIG_PATA_PARPORT_BPCK) += bpck.o +obj-$(CONFIG_PATA_PARPORT_COMM) += comm.o +obj-$(CONFIG_PATA_PARPORT_DSTR) += dstr.o +obj-$(CONFIG_PATA_PARPORT_KBIC) += kbic.o +obj-$(CONFIG_PATA_PARPORT_EPAT) += epat.o +obj-$(CONFIG_PATA_PARPORT_EPIA) += epia.o +obj-$(CONFIG_PATA_PARPORT_FRPW) += frpw.o +obj-$(CONFIG_PATA_PARPORT_FRIQ) += friq.o +obj-$(CONFIG_PATA_PARPORT_FIT2) += fit2.o +obj-$(CONFIG_PATA_PARPORT_FIT3) += fit3.o +obj-$(CONFIG_PATA_PARPORT_ON20) += on20.o +obj-$(CONFIG_PATA_PARPORT_ON26) += on26.o +obj-$(CONFIG_PATA_PARPORT_KTTI) += ktti.o +obj-$(CONFIG_PATA_PARPORT_BPCK6) += bpck6.o
drivers/ata/pata_parport/aten.c renamed from drivers/block/paride/aten.c +0 -0
drivers/ata/pata_parport/bpck.c renamed from drivers/block/paride/bpck.c +0 -0
drivers/ata/pata_parport/bpck6.c renamed from drivers/block/paride/bpck6.c +0 -0
drivers/ata/pata_parport/comm.c renamed from drivers/block/paride/comm.c +0 -0
drivers/ata/pata_parport/dstr.c renamed from drivers/block/paride/dstr.c +0 -0
drivers/ata/pata_parport/epat.c renamed from drivers/block/paride/epat.c +0 -0
drivers/ata/pata_parport/epia.c renamed from drivers/block/paride/epia.c +0 -0
drivers/ata/pata_parport/fit2.c renamed from drivers/block/paride/fit2.c +0 -0
drivers/ata/pata_parport/fit3.c renamed from drivers/block/paride/fit3.c +0 -0
drivers/ata/pata_parport/friq.c renamed from drivers/block/paride/friq.c +0 -0
drivers/ata/pata_parport/frpw.c renamed from drivers/block/paride/frpw.c +0 -0
drivers/ata/pata_parport/kbic.c renamed from drivers/block/paride/kbic.c +0 -0
drivers/ata/pata_parport/ktti.c renamed from drivers/block/paride/ktti.c +0 -0
drivers/ata/pata_parport/on20.c renamed from drivers/block/paride/on20.c +0 -0
drivers/ata/pata_parport/on26.c renamed from drivers/block/paride/on26.c +0 -0
drivers/ata/pata_parport/ppc6lnx.c renamed from drivers/block/paride/ppc6lnx.c +0 -0
drivers/block/Kconfig +0 -2
@@ -103,8 +103,6 @@ config GDROM Most users will want to say "Y" here. You can also build this as a module which will be called gdrom. -source "drivers/block/paride/Kconfig" - source "drivers/block/mtip32xx/Kconfig" source "drivers/block/zram/Kconfig"
drivers/block/paride/Kconfig deleted +0 -213
213 lines not on this page · raw message
drivers/block/paride/Makefile deleted +0 -23
@@ -1,23 +0,0 @@ -# SPDX-License-Identifier: GPL-2.0 -# -# Makefile for Parallel port IDE device drivers. -# -# 7 October 2000, Bartlomiej Zolnierkiewicz <[email protected]> -# Rewritten to use lists instead of if-statements. -# - -obj-$(CONFIG_PARIDE_ATEN) += aten.o -obj-$(CONFIG_PARIDE_BPCK) += bpck.o -obj-$(CONFIG_PARIDE_COMM) += comm.o -obj-$(CONFIG_PARIDE_DSTR) += dstr.o -obj-$(CONFIG_PARIDE_KBIC) += kbic.o -obj-$(CONFIG_PARIDE_EPAT) += epat.o -obj-$(CONFIG_PARIDE_EPIA) += epia.o -obj-$(CONFIG_PARIDE_FRPW) += frpw.o -obj-$(CONFIG_PARIDE_FRIQ) += friq.o -obj-$(CONFIG_PARIDE_FIT2) += fit2.o -obj-$(CONFIG_PARIDE_FIT3) += fit3.o -obj-$(CONFIG_PARIDE_ON20) += on20.o -obj-$(CONFIG_PARIDE_ON26) += on26.o -obj-$(CONFIG_PARIDE_KTTI) += ktti.o -obj-$(CONFIG_PARIDE_BPCK6) += bpck6.o
Signature · 1 line
Ondrej Zary
Re: [PATCH 2/2] drivers/block: Move PARIDE protocol modules to drivers/ata/pata_parport
Quoted 2 lines · Ondrej Zary
Move PARIDE protocol modules out of
drivers/blockand updateCONFIG_symbol names toPATA_PARPORT.
Signature · 1 line
Jens Axboe
Re: [PATCH 2/2] drivers/block: Move PARIDE protocol modules to drivers/ata/pata_parport
In reply to Ondrej Zarydrivers/Makefile obj-$(CONFIG_DIO) += dio/ · line 101
Quoted 10 lines · Ondrej Zary
drivers/Makefile +1
-1@@ -98,7 +98,7 @@ obj-$(CONFIG_DIO) += dio/ obj-$(CONFIG_SBUS) += sbus/ obj-$(CONFIG_ZORRO) += zorro/ obj-$(CONFIG_ATA_OVER_ETH) += block/aoe/ -obj-y += block/paride/ +obj-$(CONFIG_PATA_PARPORT) += ata/pata_parport/
It would be better to have this in drivers/ata/Makefile, not here, so that doing something like:
make -j64 M=drivers/ata W=1
or
make -j64 M=drivers/ata C=1
actually also checks the parport protocol modules too.
drivers/ata/Makefile +1 -0
@@ -114,6 +114,7 @@ obj-$(CONFIG_PATA_SAMSUNG_CF) += pata_samsung_cf.o obj-$(CONFIG_PATA_PXA) += pata_pxa.o +obj-$(CONFIG_PATA_PARPORT) += pata_parport/ obj-$(CONFIG_PATA_PARPORT) += pata_parport.o
And then we could also have drivers/ata/pata_parport.c moved under drivers/ata/pata_parport/ to tidy things up.
If you agree, I can fix that up, that is easy to do.
Signature · 2 lines
Damien Le Moal Western Digital Research
Re: [PATCH 2/2] drivers/block: Move PARIDE protocol modules to drivers/ata/pata_parport
Quoted 35 lines · Damien Le Moal
drivers/Makefile obj-$(CONFIG_DIO) += dio/ · line 101
Quoted 10 lines · Ondrej Zary
drivers/Makefile +1
-1@@ -98,7 +98,7 @@ obj-$(CONFIG_DIO) += dio/ obj-$(CONFIG_SBUS) += sbus/ obj-$(CONFIG_ZORRO) += zorro/ obj-$(CONFIG_ATA_OVER_ETH) += block/aoe/ -obj-y += block/paride/ +obj-$(CONFIG_PATA_PARPORT) += ata/pata_parport/It would be better to have this in
drivers/ata/Makefile, not here, so that doing something like:make -j64 M=drivers/ata W=1
or
make -j64 M=drivers/ata C=1actually also checks the parport protocol modules too.
drivers/ata/Makefile +1
-0@@ -114,6 +114,7 @@ obj-$(CONFIG_PATA_SAMSUNG_CF) += pata_samsung_cf.o obj-$(CONFIG_PATA_PXA) += pata_pxa.o +obj-$(CONFIG_PATA_PARPORT) += pata_parport/ obj-$(CONFIG_PATA_PARPORT) += pata_parport.oAnd then we could also have
drivers/ata/pata_parport.cmoved underdrivers/ata/pata_parport/to tidy things up.
Quoted 1 line
If you agree, I can fix that up, that is easy to do.
OK, thank you.
Signature · 1 line
Ondrej Zary
Re: [PATCH 2/2] drivers/block: Move PARIDE protocol modules to drivers/ata/pata_parport
Quoted 33 lines · Ondrej Zary
Quoted 32 lines · Damien Le Moal
drivers/Makefile obj-$(CONFIG_DIO) += dio/ · line 101
Quoted 10 lines · Ondrej Zary
drivers/Makefile +1
-1@@ -98,7 +98,7 @@ obj-$(CONFIG_DIO) += dio/ obj-$(CONFIG_SBUS) += sbus/ obj-$(CONFIG_ZORRO) += zorro/ obj-$(CONFIG_ATA_OVER_ETH) += block/aoe/ -obj-y += block/paride/ +obj-$(CONFIG_PATA_PARPORT) += ata/pata_parport/It would be better to have this in
drivers/ata/Makefile, not here, so that doing something like:make -j64 M=drivers/ata W=1
or
make -j64 M=drivers/ata C=1actually also checks the parport protocol modules too.
drivers/ata/Makefile +1
-0@@ -114,6 +114,7 @@ obj-$(CONFIG_PATA_SAMSUNG_CF) += pata_samsung_cf.o obj-$(CONFIG_PATA_PXA) += pata_pxa.o +obj-$(CONFIG_PATA_PARPORT) += pata_parport/ obj-$(CONFIG_PATA_PARPORT) += pata_parport.o
Quoted 6 lines
Quoted 4 lines
And then we could also have
drivers/ata/pata_parport.cmoved underdrivers/ata/pata_parport/to tidy things up.If you agree, I can fix that up, that is easy to do.
OK, thank you.
All queued now. Thanks !
Signature · 2 lines
Damien Le Moal Western Digital Research
Re: [PATCH 1/2] drivers/block: Remove PARIDE core and high-level protocols
In reply to Ondrej ZaryQuoted 4 lines · Ondrej Zary
Remove PARIDE core and high level protocols, taking care not to break low-level drivers (used by
pata_parport). Also update documentation.Signed-off-by Ondrej Zary <[email protected]>
Signature · 1 line
Jens Axboe
On Monday 23 January 2023 02:03:16 Damien Le Moal wrote:
[...]
Quoted 29 lines
You are missing:
#ifndef
LINUX_PATA_PARPORT_H
#defineLINUX_PATA_PARPORT_HQuoted 24 lines
include/linux/pata_parport.h new file +24
-0+#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.
Quoted 8 lines
include/linux/pata_parport.h line 38
Quoted 6 lines
+ */
include/linux/pata_parport.h new file +5
-0+ +/* 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))It would be way nicer to have these as inline functions.
This should go away (as well as the code below) so I'm not touching it now.
Quoted 31 lines
Quoted 31 lines
include/linux/pata_parport.h new file +31
-0+ +#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; +}
Signature · 1 line
Ondrej Zary
Quoted 56 lines · Ondrej Zary
The
pata_parportis 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_parportclaims 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 otherpata_parportdevices nor a printer).paride and
pata_parportare 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 Ondrej Zary <[email protected]>---
Changes in v2:
- keep device connected, remove disconnect timerDocumentation/admin-guide/blockdev/paride.rst | 52 ++ drivers/Makefile | 2 +- drivers/ata/Kconfig | 14 + drivers/ata/Makefile | 2 + drivers/ata/pata_parport.c | 783 ++++++++++++++++++ drivers/block/paride/Kconfig | 32 +- drivers/block/paride/paride.h | 13 + include/linux/pata_parport.h | 106 +++ 8 files changed, 987 insertions(+), 17 deletions(-)
Quoted 3 lines
create mode 100644
drivers/ata/pata_parport.c
create mode 100644include/linux/pata_parport.h
Cheers,
Hannes
Signature · 4 lines
Dr. Hannes Reinecke Kernel Storage Architect [email protected] +49 911 74053 688 SUSE Software Solutions Germany GmbH, Maxfeldstr. 5, 90409 Nürnberg HRB 36809 (AG Nürnberg), GF: Felix Imendörffer