diff options
| author | Linus Torvalds <torvalds@linux-foundation.org> | 2023-04-26 13:09:45 -0700 |
|---|---|---|
| committer | Linus Torvalds <torvalds@linux-foundation.org> | 2023-04-26 13:09:45 -0700 |
| commit | 36006b1d5c04692924f011aa949e8788f1c604de (patch) | |
| tree | 18d70c93d1aa84d0bf1a2a6b37cd560bcaa4f59f /drivers/ata | |
| parent | 48dc810012a6b4f4ba94073d6b7edb4f76edeb72 (diff) | |
| parent | 140b26035b2d379d94e6e3936ab2e0adf94efe46 (diff) | |
| download | linux-36006b1d5c04692924f011aa949e8788f1c604de.tar.gz linux-36006b1d5c04692924f011aa949e8788f1c604de.tar.bz2 linux-36006b1d5c04692924f011aa949e8788f1c604de.zip | |
Merge tag 'ata-6.4-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/dlemoal/libata
Pull ata updates from Damien Le Moal:
- Many cleanups of the pata_parport driver and of its protocol modules
(Ondrej)
- Remove unused code (ata_id_xxx() functions) (Sergey)
- Add Add UniPhier SATA controller DT bindings (Kunihiko)
- Fix dependencies for the Freescale QorIQ AHCI SATA controller driver
(Geert)
- DT property handling improvements (Rob)
* tag 'ata-6.4-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/dlemoal/libata: (57 commits)
ata: pata_parport-bpck6: Declare mode_map as static
ata: pata_parport-bpck6: Remove dependency on 64BIT
ata: pata_parport-bpck6: reduce indents in bpck6_open
ata: pata_parport-bpck6: delete ppc6lnx.c
ata: pata_parport-bpck6: move defines and mode_map to bpck6.c
ata: pata_parport-bpck6: move ppc6_wr_data_byte to bpck6.c and rename
ata: pata_parport-bpck6: move ppc6_rd_data_byte to bpck6.c and rename
ata: pata_parport-bpck6: move ppc6_send_cmd to bpck6.c and rename
ata: pata_parport-bpck6: move ppc6_deselect to bpck6.c and rename
ata: pata_parport-bpck6: merge ppc6_select into bpck6_open
ata: pata_parport-bpck6: move ppc6_open to bpck6.c and rename
ata: pata_parport-bpck6: move ppc6_wr_extout to bpck6.c and rename
ata: pata_parport-bpck6: move ppc6_wait_for_fifo to bpck6.c and rename
ata: pata_parport-bpck6: merge ppc6_wr_data_blk into bpck6_write_block
ata: pata_parport-bpck6: merge ppc6_rd_data_blk into bpck6_read_block
ata: pata_parport-bpck6: merge ppc6_wr_port16_blk into bpck6_write_block
ata: pata_parport-bpck6: merge ppc6_rd_port16_blk into bpck6_read_block
ata: pata_parport-bpck6: merge ppc6_wr_port into bpck6_write_regr
ata: pata_parport-bpck6: merge ppc6_rd_port into bpck6_read_regr
ata: pata_parport-bpck6: remove ppc6_close
...
Diffstat (limited to 'drivers/ata')
23 files changed, 702 insertions, 1438 deletions
diff --git a/drivers/ata/Kconfig b/drivers/ata/Kconfig index b56fba76b43f..42b51c9812a0 100644 --- a/drivers/ata/Kconfig +++ b/drivers/ata/Kconfig @@ -276,6 +276,7 @@ config AHCI_XGENE config AHCI_QORIQ tristate "Freescale QorIQ AHCI SATA support" depends on OF + depends on SOC_LS1021A || ARCH_LAYERSCAPE || COMPILE_TEST select SATA_HOST help This option enables support for the Freescale QorIQ AHCI SoC's diff --git a/drivers/ata/ahci_mtk.c b/drivers/ata/ahci_mtk.c index c056378e3e72..5714efe3f8e7 100644 --- a/drivers/ata/ahci_mtk.c +++ b/drivers/ata/ahci_mtk.c @@ -106,7 +106,7 @@ static int mtk_ahci_parse_property(struct ahci_host_priv *hpriv, struct device_node *np = dev->of_node; /* enable SATA function if needed */ - if (of_find_property(np, "mediatek,phy-mode", NULL)) { + if (of_property_present(np, "mediatek,phy-mode")) { plat->mode = syscon_regmap_lookup_by_phandle( np, "mediatek,phy-mode"); if (IS_ERR(plat->mode)) { diff --git a/drivers/ata/libahci_platform.c b/drivers/ata/libahci_platform.c index b9e336bacf17..f00da19670b0 100644 --- a/drivers/ata/libahci_platform.c +++ b/drivers/ata/libahci_platform.c @@ -363,7 +363,7 @@ static int ahci_platform_get_phy(struct ahci_host_priv *hpriv, u32 port, switch (rc) { case -ENOSYS: /* No PHY support. Check if PHY is required. */ - if (of_find_property(node, "phys", NULL)) { + if (of_property_present(node, "phys")) { dev_err(dev, "couldn't get PHY in node %pOFn: ENOSYS\n", node); diff --git a/drivers/ata/pata_parport/Kconfig b/drivers/ata/pata_parport/Kconfig index 0893a13e7979..2c953f5d1396 100644 --- a/drivers/ata/pata_parport/Kconfig +++ b/drivers/ata/pata_parport/Kconfig @@ -25,7 +25,7 @@ config PATA_PARPORT_BPCK config PATA_PARPORT_BPCK6 tristate "MicroSolutions backpack (Series 6) protocol" - depends on (PATA_PARPORT) && !64BIT + depends on PATA_PARPORT help This option enables support for the Micro Solutions BACKPACK parallel port Series 6 IDE protocol. (Most BACKPACK drives made diff --git a/drivers/ata/pata_parport/aten.c b/drivers/ata/pata_parport/aten.c index b66508bedbd0..1bd248c42f8b 100644 --- a/drivers/ata/pata_parport/aten.c +++ b/drivers/ata/pata_parport/aten.c @@ -9,14 +9,6 @@ */ -/* Changes: - - 1.01 GRG 1998.05.05 init_proto, release_proto - -*/ - -#define ATEN_VERSION "1.01" - #include <linux/module.h> #include <linux/init.h> #include <linux/delay.h> @@ -24,8 +16,7 @@ #include <linux/wait.h> #include <linux/types.h> #include <asm/io.h> - -#include <linux/pata_parport.h> +#include "pata_parport.h" #define j44(a,b) ((((a>>4)&0x0f)|(b&0xf0))^0x88) @@ -35,7 +26,7 @@ static int cont_map[2] = { 0x08, 0x20 }; -static void aten_write_regr( PIA *pi, int cont, int regr, int val) +static void aten_write_regr(struct pi_adapter *pi, int cont, int regr, int val) { int r; @@ -44,7 +35,7 @@ static void aten_write_regr( PIA *pi, int cont, int regr, int val) w0(r); w2(0xe); w2(6); w0(val); w2(7); w2(6); w2(0xc); } -static int aten_read_regr( PIA *pi, int cont, int regr ) +static int aten_read_regr(struct pi_adapter *pi, int cont, int regr) { int a, b, r; @@ -67,7 +58,7 @@ static int aten_read_regr( PIA *pi, int cont, int regr ) return -1; } -static void aten_read_block( PIA *pi, char * buf, int count ) +static void aten_read_block(struct pi_adapter *pi, char *buf, int count) { int k, a, b, c, d; @@ -95,7 +86,7 @@ static void aten_read_block( PIA *pi, char * buf, int count ) } } -static void aten_write_block( PIA *pi, char * buf, int count ) +static void aten_write_block(struct pi_adapter *pi, char *buf, int count) { int k; @@ -107,28 +98,25 @@ static void aten_write_block( PIA *pi, char * buf, int count ) w2(0xc); } -static void aten_connect ( PIA *pi ) +static void aten_connect(struct pi_adapter *pi) { pi->saved_r0 = r0(); pi->saved_r2 = r2(); w2(0xc); } -static void aten_disconnect ( PIA *pi ) +static void aten_disconnect(struct pi_adapter *pi) { w0(pi->saved_r0); w2(pi->saved_r2); } -static void aten_log_adapter( PIA *pi, char * scratch, int verbose ) +static void aten_log_adapter(struct pi_adapter *pi) { char *mode_string[2] = {"4-bit","8-bit"}; - printk("%s: aten %s, ATEN EH-100 at 0x%x, ", - pi->device,ATEN_VERSION,pi->port); - printk("mode %d (%s), delay %d\n",pi->mode, - mode_string[pi->mode],pi->delay); - + dev_info(&pi->dev, "ATEN EH-100 at 0x%x, mode %d (%s), delay %d\n", + pi->port, pi->mode, mode_string[pi->mode], pi->delay); } static struct pi_protocol aten = { @@ -147,16 +135,5 @@ static struct pi_protocol aten = { .log_adapter = aten_log_adapter, }; -static int __init aten_init(void) -{ - return paride_register(&aten); -} - -static void __exit aten_exit(void) -{ - paride_unregister( &aten ); -} - MODULE_LICENSE("GPL"); -module_init(aten_init) -module_exit(aten_exit) +module_pata_parport_driver(aten); diff --git a/drivers/ata/pata_parport/bpck.c b/drivers/ata/pata_parport/bpck.c index 5fb3cf9ba11d..1c5035a09554 100644 --- a/drivers/ata/pata_parport/bpck.c +++ b/drivers/ata/pata_parport/bpck.c @@ -7,15 +7,6 @@ */ -/* Changes: - - 1.01 GRG 1998.05.05 init_proto, release_proto, pi->delay - 1.02 GRG 1998.08.15 default pi->delay returned to 4 - -*/ - -#define BPCK_VERSION "1.02" - #include <linux/module.h> #include <linux/init.h> #include <linux/delay.h> @@ -23,8 +14,7 @@ #include <linux/types.h> #include <linux/wait.h> #include <asm/io.h> - -#include <linux/pata_parport.h> +#include "pata_parport.h" #undef r2 #undef w2 @@ -46,7 +36,7 @@ static int cont_map[3] = { 0x40, 0x48, 0 }; -static int bpck_read_regr( PIA *pi, int cont, int regr ) +static int bpck_read_regr(struct pi_adapter *pi, int cont, int regr) { int r, l, h; @@ -77,7 +67,7 @@ static int bpck_read_regr( PIA *pi, int cont, int regr ) return -1; } -static void bpck_write_regr( PIA *pi, int cont, int regr, int val ) +static void bpck_write_regr(struct pi_adapter *pi, int cont, int regr, int val) { int r; @@ -106,7 +96,7 @@ static void bpck_write_regr( PIA *pi, int cont, int regr, int val ) #define WR(r,v) bpck_write_regr(pi,2,r,v) #define RR(r) (bpck_read_regr(pi,2,r)) -static void bpck_write_block( PIA *pi, char * buf, int count ) +static void bpck_write_block(struct pi_adapter *pi, char *buf, int count) { int i; @@ -147,7 +137,7 @@ static void bpck_write_block( PIA *pi, char * buf, int count ) } } -static void bpck_read_block( PIA *pi, char * buf, int count ) +static void bpck_read_block(struct pi_adapter *pi, char *buf, int count) { int i, l, h; @@ -194,7 +184,7 @@ static void bpck_read_block( PIA *pi, char * buf, int count ) } } -static int bpck_probe_unit ( PIA *pi ) +static int bpck_probe_unit(struct pi_adapter *pi) { int o1, o0, f7, id; int t, s; @@ -217,7 +207,7 @@ static int bpck_probe_unit ( PIA *pi ) return 1; } -static void bpck_connect ( PIA *pi ) +static void bpck_connect(struct pi_adapter *pi) { pi->saved_r0 = r0(); w0(0xff-pi->unit); w2(4); w0(pi->unit); @@ -241,24 +231,24 @@ static void bpck_connect ( PIA *pi ) WR(5,8); - if (pi->devtype == PI_PCD) { +/* if (pi->devtype == PI_PCD) { possibly wrong, purpose unknown */ WR(0x46,0x10); /* fiddle with ESS logic ??? */ WR(0x4c,0x38); WR(0x4d,0x88); WR(0x46,0xa0); WR(0x41,0); WR(0x4e,8); - } +/* }*/ } -static void bpck_disconnect ( PIA *pi ) +static void bpck_disconnect(struct pi_adapter *pi) { w0(0); if (pi->mode >= 2) { w2(9); w2(0); } else t2(2); w2(0x4c); w0(pi->saved_r0); } -static void bpck_force_spp ( PIA *pi ) +static void bpck_force_spp(struct pi_adapter *pi) /* This fakes the EPP protocol to turn off EPP ... */ @@ -276,7 +266,7 @@ static void bpck_force_spp ( PIA *pi ) #define TEST_LEN 16 -static int bpck_test_proto( PIA *pi, char * scratch, int verbose ) +static int bpck_test_proto(struct pi_adapter *pi) { int i, e, l, h, om; char buf[TEST_LEN]; @@ -334,19 +324,16 @@ static int bpck_test_proto( PIA *pi, char * scratch, int verbose ) } - if (verbose) { - printk("%s: bpck: 0x%x unit %d mode %d: ", - pi->device,pi->port,pi->unit,pi->mode); - for (i=0;i<TEST_LEN;i++) printk("%3d",buf[i]); - printk("\n"); - } + dev_dbg(&pi->dev, "bpck: 0x%x unit %d mode %d: ", + pi->port, pi->unit, pi->mode); + print_hex_dump_debug("bpck: ", DUMP_PREFIX_NONE, TEST_LEN, 1, buf, TEST_LEN, false); e = 0; for (i=0;i<TEST_LEN;i++) if (buf[i] != (i+1)) e++; return e; } -static void bpck_read_eeprom ( PIA *pi, char * buf ) +static void bpck_read_eeprom(struct pi_adapter *pi, char *buf) { int i, j, k, p, v, f, om, od; @@ -397,7 +384,7 @@ static void bpck_read_eeprom ( PIA *pi, char * buf ) pi->mode = om; pi->delay = od; } -static int bpck_test_port ( PIA *pi ) /* check for 8-bit port */ +static int bpck_test_port(struct pi_adapter *pi) /* check for 8-bit port */ { int i, r, m; @@ -416,31 +403,17 @@ static int bpck_test_port ( PIA *pi ) /* check for 8-bit port */ return 5; } -static void bpck_log_adapter( PIA *pi, char * scratch, int verbose ) +static void bpck_log_adapter(struct pi_adapter *pi) { char *mode_string[5] = { "4-bit","8-bit","EPP-8", "EPP-16","EPP-32" }; - -#ifdef DUMP_EEPROM - int i; -#endif + char scratch[128]; bpck_read_eeprom(pi,scratch); - -#ifdef DUMP_EEPROM - if (verbose) { - for(i=0;i<128;i++) - if ((scratch[i] < ' ') || (scratch[i] > '~')) - scratch[i] = '.'; - printk("%s: bpck EEPROM: %64.64s\n",pi->device,scratch); - printk("%s: %64.64s\n",pi->device,&scratch[64]); - } -#endif - - printk("%s: bpck %s, backpack %8.8s unit %d", - pi->device,BPCK_VERSION,&scratch[110],pi->unit); - printk(" at 0x%x, mode %d (%s), delay %d\n",pi->port, - pi->mode,mode_string[pi->mode],pi->delay); + print_hex_dump_bytes("bpck EEPROM: ", DUMP_PREFIX_NONE, scratch, 128); + dev_info(&pi->dev, "backpack %8.8s unit %d at 0x%x, mode %d (%s), delay %d\n", + &scratch[110], pi->unit, pi->port, pi->mode, + mode_string[pi->mode], pi->delay); } static struct pi_protocol bpck = { @@ -462,16 +435,5 @@ static struct pi_protocol bpck = { .log_adapter = bpck_log_adapter, }; -static int __init bpck_init(void) -{ - return paride_register(&bpck); -} - -static void __exit bpck_exit(void) -{ - paride_unregister(&bpck); -} - MODULE_LICENSE("GPL"); -module_init(bpck_init) -module_exit(bpck_exit) +module_pata_parport_driver(bpck); diff --git a/drivers/ata/pata_parport/bpck6.c b/drivers/ata/pata_parport/bpck6.c index d897e2a28efe..76febd07a9bb 100644 --- a/drivers/ata/pata_parport/bpck6.c +++ b/drivers/ata/pata_parport/bpck6.c @@ -11,219 +11,430 @@ */ -/* - This is Ken's linux wrapper for the PPC library - Version 1.0.0 is the backpack driver for which source is not available - Version 2.0.0 is the first to have source released - Version 2.0.1 is the "Cox-ified" source code - Version 2.0.2 - fixed version string usage, and made ppc functions static -*/ - - -#define BACKPACK_VERSION "2.0.2" - #include <linux/module.h> #include <linux/init.h> #include <linux/kernel.h> -#include <linux/slab.h> #include <linux/types.h> -#include <asm/io.h> #include <linux/parport.h> - -#include "ppc6lnx.c" -#include <linux/pata_parport.h> - -/* PARAMETERS */ -static bool verbose; /* set this to 1 to see debugging messages and whatnot */ - - -#define PPCSTRUCT(pi) ((Interface *)(pi->private)) - -/****************************************************************/ -/* - ATAPI CDROM DRIVE REGISTERS -*/ -#define ATAPI_DATA 0 /* data port */ -#define ATAPI_ERROR 1 /* error register (read) */ -#define ATAPI_FEATURES 1 /* feature register (write) */ -#define ATAPI_INT_REASON 2 /* interrupt reason register */ -#define ATAPI_COUNT_LOW 4 /* byte count register (low) */ -#define ATAPI_COUNT_HIGH 5 /* byte count register (high) */ -#define ATAPI_DRIVE_SEL 6 /* drive select register */ -#define ATAPI_STATUS 7 /* status port (read) */ -#define ATAPI_COMMAND 7 /* command port (write) */ -#define ATAPI_ALT_STATUS 0x0e /* alternate status reg (read) */ -#define ATAPI_DEVICE_CONTROL 0x0e /* device control (write) */ -/****************************************************************/ - -static int bpck6_read_regr(PIA *pi, int cont, int reg) +#include "pata_parport.h" + +/* 60772 Commands */ +#define ACCESS_REG 0x00 +#define ACCESS_PORT 0x40 + +#define ACCESS_READ 0x00 +#define ACCESS_WRITE 0x20 + +/* 60772 Command Prefix */ +#define CMD_PREFIX_SET 0xe0 // Special command that modifies next command's operation +#define CMD_PREFIX_RESET 0xc0 // Resets current cmd modifier reg bits + #define PREFIX_IO16 0x01 // perform 16-bit wide I/O + #define PREFIX_FASTWR 0x04 // enable PPC mode fast-write + #define PREFIX_BLK 0x08 // enable block transfer mode + +/* 60772 Registers */ +#define REG_STATUS 0x00 // status register + #define STATUS_IRQA 0x01 // Peripheral IRQA line + #define STATUS_EEPROM_DO 0x40 // Serial EEPROM data bit +#define REG_VERSION 0x01 // PPC version register (read) +#define REG_HWCFG 0x02 // Hardware Config register +#define REG_RAMSIZE 0x03 // Size of RAM Buffer + #define RAMSIZE_128K 0x02 +#define REG_EEPROM 0x06 // EEPROM control register + #define EEPROM_SK 0x01 // eeprom SK bit + #define EEPROM_DI 0x02 // eeprom DI bit + #define EEPROM_CS 0x04 // eeprom CS bit + #define EEPROM_EN 0x08 // eeprom output enable +#define REG_BLKSIZE 0x08 // Block transfer len (24 bit) + +/* flags */ +#define fifo_wait 0x10 + +/* DONT CHANGE THESE LEST YOU BREAK EVERYTHING - BIT FIELD DEPENDENCIES */ +#define PPCMODE_UNI_SW 0 +#define PPCMODE_UNI_FW 1 +#define PPCMODE_BI_SW 2 +#define PPCMODE_BI_FW 3 +#define PPCMODE_EPP_BYTE 4 +#define PPCMODE_EPP_WORD 5 +#define PPCMODE_EPP_DWORD 6 + +static int mode_map[] = { PPCMODE_UNI_FW, PPCMODE_BI_FW, PPCMODE_EPP_BYTE, + PPCMODE_EPP_WORD, PPCMODE_EPP_DWORD }; + +static void bpck6_send_cmd(struct pi_adapter *pi, u8 cmd) { - unsigned int out; + switch (mode_map[pi->mode]) { + case PPCMODE_UNI_SW: + case PPCMODE_UNI_FW: + case PPCMODE_BI_SW: + case PPCMODE_BI_FW: + parport_write_data(pi->pardev->port, cmd); + parport_frob_control(pi->pardev->port, 0, PARPORT_CONTROL_AUTOFD); + break; + case PPCMODE_EPP_BYTE: + case PPCMODE_EPP_WORD: + case PPCMODE_EPP_DWORD: + pi->pardev->port->ops->epp_write_addr(pi->pardev->port, &cmd, 1, 0); + break; + } +} - /* check for bad settings */ - if (reg<0 || reg>7 || cont<0 || cont>2) - { - return(-1); +static u8 bpck6_rd_data_byte(struct pi_adapter *pi) +{ + u8 data = 0; + + switch (mode_map[pi->mode]) { + case PPCMODE_UNI_SW: + case PPCMODE_UNI_FW: + parport_frob_control(pi->pardev->port, PARPORT_CONTROL_STROBE, + PARPORT_CONTROL_INIT); + data = parport_read_status(pi->pardev->port); + data = ((data & 0x80) >> 1) | ((data & 0x38) >> 3); + parport_frob_control(pi->pardev->port, PARPORT_CONTROL_STROBE, + PARPORT_CONTROL_STROBE); + data |= parport_read_status(pi->pardev->port) & 0xB8; + break; + case PPCMODE_BI_SW: + case PPCMODE_BI_FW: + parport_data_reverse(pi->pardev->port); + parport_frob_control(pi->pardev->port, PARPORT_CONTROL_STROBE, + PARPORT_CONTROL_STROBE | PARPORT_CONTROL_INIT); + data = parport_read_data(pi->pardev->port); + parport_frob_control(pi->pardev->port, PARPORT_CONTROL_STROBE, 0); + parport_data_forward(pi->pardev->port); + break; + case PPCMODE_EPP_BYTE: + case PPCMODE_EPP_WORD: + case PPCMODE_EPP_DWORD: + pi->pardev->port->ops->epp_read_data(pi->pardev->port, &data, 1, 0); + break; } - out=ppc6_rd_port(PPCSTRUCT(pi),cont?reg|8:reg); - return(out); + + return data; } -static void bpck6_write_regr(PIA *pi, int cont, int reg, int val) +static void bpck6_wr_data_byte(struct pi_adapter *pi, u8 data) { - /* check for bad settings */ - if (reg>=0 && reg<=7 && cont>=0 && cont<=1) - { - ppc6_wr_port(PPCSTRUCT(pi),cont?reg|8:reg,(u8)val); + switch (mode_map[pi->mode]) { + case PPCMODE_UNI_SW: + case PPCMODE_UNI_FW: + case PPCMODE_BI_SW: + case PPCMODE_BI_FW: + parport_write_data(pi->pardev->port, data); + parport_frob_control(pi->pardev->port, 0, PARPORT_CONTROL_INIT); + break; + case PPCMODE_EPP_BYTE: + case PPCMODE_EPP_WORD: + case PPCMODE_EPP_DWORD: + pi->pardev->port->ops->epp_write_data(pi->pardev->port, &data, 1, 0); + break; } } -static void bpck6_write_block( PIA *pi, char * buf, int len ) +static int bpck6_read_regr(struct pi_adapter *pi, int cont, int reg) { - ppc6_wr_port16_blk(PPCSTRUCT(pi),ATAPI_DATA,buf,(u32)len>>1); + u8 port = cont ? reg | 8 : reg; + + bpck6_send_cmd(pi, port | ACCESS_PORT | ACCESS_READ); + return bpck6_rd_data_byte(pi); } -static void bpck6_read_block( PIA *pi, char * buf, int len ) +static void bpck6_write_regr(struct pi_adapter *pi, int cont, int reg, int val) { - ppc6_rd_port16_blk(PPCSTRUCT(pi),ATAPI_DATA,buf,(u32)len>>1); + u8 port = cont ? reg | 8 : reg; + + bpck6_send_cmd(pi, port | ACCESS_PORT | ACCESS_WRITE); + bpck6_wr_data_byte(pi, val); } -static void bpck6_connect ( PIA *pi ) +static void bpck6_wait_for_fifo(struct pi_adapter *pi) { - if(verbose) - { - printk(KERN_DEBUG "connect\n"); - } + int i; - if(pi->mode >=2) - { - PPCSTRUCT(pi)->mode=4+pi->mode-2; - } - else if(pi->mode==1) - { - PPCSTRUCT(pi)->mode=3; + if (pi->private & fifo_wait) { + for (i = 0; i < 20; i++) + parport_read_status(pi->pardev->port); } - else - { - PPCSTRUCT(pi)->mode=1; +} + +static void bpck6_write_block(struct pi_adapter *pi, char *buf, int len) +{ + u8 this, last; + + bpck6_send_cmd(pi, REG_BLKSIZE | ACCESS_REG | ACCESS_WRITE); + bpck6_wr_data_byte(pi, (u8)len); + bpck6_wr_data_byte(pi, (u8)(len >> 8)); + bpck6_wr_data_byte(pi, 0); + + bpck6_send_cmd(pi, CMD_PREFIX_SET | PREFIX_IO16 | PREFIX_BLK); + bpck6_send_cmd(pi, ATA_REG_DATA | ACCESS_PORT | ACCESS_WRITE); + + switch (mode_map[pi->mode]) { + case PPCMODE_UNI_SW: + case PPCMODE_BI_SW: + while (len--) { + parport_write_data(pi->pardev->port, *buf++); + parport_frob_control(pi->pardev->port, 0, + PARPORT_CONTROL_INIT); + } + break; + case PPCMODE_UNI_FW: + case PPCMODE_BI_FW: + bpck6_send_cmd(pi, CMD_PREFIX_SET | PREFIX_FASTWR); + + parport_frob_control(pi->pardev->port, PARPORT_CONTROL_STROBE, + PARPORT_CONTROL_STROBE); + + last = *buf; + + parport_write_data(pi->pardev->port, last); + + while (len) { + this = *buf++; + len--; + + if (this == last) { + parport_frob_control(pi->pardev->port, 0, + PARPORT_CONTROL_INIT); + } else { + parport_write_data(pi->pardev->port, this); + last = this; + } + } + + parport_frob_control(pi->pardev->port, PARPORT_CONTROL_STROBE, + 0); + bpck6_send_cmd(pi, CMD_PREFIX_RESET | PREFIX_FASTWR); + break; + case PPCMODE_EPP_BYTE: + pi->pardev->port->ops->epp_write_data(pi->pardev->port, buf, + len, PARPORT_EPP_FAST_8); + bpck6_wait_for_fifo(pi); + break; + case PPCMODE_EPP_WORD: + pi->pardev->port->ops->epp_write_data(pi->pardev->port, buf, + len, PARPORT_EPP_FAST_16); + bpck6_wait_for_fifo(pi); + break; + case PPCMODE_EPP_DWORD: + pi->pardev->port->ops->epp_write_data(pi->pardev->port, buf, + len, PARPORT_EPP_FAST_32); + bpck6_wait_for_fifo(pi); + break; } - ppc6_open(PPCSTRUCT(pi)); - ppc6_wr_extout(PPCSTRUCT(pi),0x3); + bpck6_send_cmd(pi, CMD_PREFIX_RESET | PREFIX_IO16 | PREFIX_BLK); } -static void bpck6_disconnect ( PIA *pi ) +static void bpck6_read_block(struct pi_adapter *pi, char *buf, int len) { - if(verbose) - { - printk("disconnect\n"); + bpck6_send_cmd(pi, REG_BLKSIZE | ACCESS_REG | ACCESS_WRITE); + bpck6_wr_data_byte(pi, (u8)len); + bpck6_wr_data_byte(pi, (u8)(len >> 8)); + bpck6_wr_data_byte(pi, 0); + + bpck6_send_cmd(pi, CMD_PREFIX_SET | PREFIX_IO16 | PREFIX_BLK); + bpck6_send_cmd(pi, ATA_REG_DATA | ACCESS_PORT | ACCESS_READ); + + switch (mode_map[pi->mode]) { + case PPCMODE_UNI_SW: + case PPCMODE_UNI_FW: + while (len) { + u8 d; + + parport_frob_control(pi->pardev->port, + PARPORT_CONTROL_STROBE, + PARPORT_CONTROL_INIT); /* DATA STROBE */ + d = parport_read_status(pi->pardev->port); + d = ((d & 0x80) >> 1) | ((d & 0x38) >> 3); + parport_frob_control(pi->pardev->port, + PARPORT_CONTROL_STROBE, + PARPORT_CONTROL_STROBE); + d |= parport_read_status(pi->pardev->port) & 0xB8; + *buf++ = d; + len--; + } + break; + case PPCMODE_BI_SW: + case PPCMODE_BI_FW: + parport_data_reverse(pi->pardev->port); + while (len) { + parport_frob_control(pi->pardev->port, + PARPORT_CONTROL_STROBE, + PARPORT_CONTROL_STROBE | PARPORT_CONTROL_INIT); + *buf++ = parport_read_data(pi->pardev->port); + len--; + } + parport_frob_control(pi->pardev->port, PARPORT_CONTROL_STROBE, + 0); + parport_data_forward(pi->pardev->port); + break; + case PPCMODE_EPP_BYTE: + pi->pardev->port->ops->epp_read_data(pi->pardev->port, buf, len, + PARPORT_EPP_FAST_8); + break; + case PPCMODE_EPP_WORD: + pi->pardev->port->ops->epp_read_data(pi->pardev->port, buf, len, + PARPORT_EPP_FAST_16); + break; + case PPCMODE_EPP_DWORD: + pi->pardev->port->ops->epp_read_data(pi->pardev->port, buf, len, + PARPORT_EPP_FAST_32); + break; } - ppc6_wr_extout(PPCSTRUCT(pi),0x0); - ppc6_close(PPCSTRUCT(pi)); + + bpck6_send_cmd(pi, CMD_PREFIX_RESET | PREFIX_IO16 | PREFIX_BLK); } -static int bpck6_test_port ( PIA *pi ) /* check for 8-bit port */ +static int bpck6_open(struct pi_adapter *pi) { - if(verbose) - { - printk(KERN_DEBUG "PARPORT indicates modes=%x for lp=0x%lx\n", - ((struct pardevice*)(pi->pardev))->port->modes, - ((struct pardevice *)(pi->pardev))->port->base); - } + u8 i, j, k; - /*copy over duplicate stuff.. initialize state info*/ - PPCSTRUCT(pi)->ppc_id=pi->unit; - PPCSTRUCT(pi)->lpt_addr=pi->port; + pi->saved_r0 = parport_read_data(pi->pardev->port); + pi->saved_r2 = parport_read_control(pi->pardev->port) & 0x5F; - /* look at the parport device to see if what modes we can use */ - if(((struct pardevice *)(pi->pardev))->port->modes & - (PARPORT_MODE_EPP) - ) - { - return 5; /* Can do EPP*/ - } - else if(((struct pardevice *)(pi->pardev))->port->modes & - (PARPORT_MODE_TRISTATE) - ) - { - return 2; - } - else /*Just flat SPP*/ - { - return 1; - } + parport_frob_control(pi->pardev->port, PARPORT_CONTROL_SELECT, + PARPORT_CONTROL_SELECT); + if (pi->saved_r0 == 'b') + parport_write_data(pi->pardev->port, 'x'); + parport_write_data(pi->pardev->port, 'b'); + parport_write_data(pi->pardev->port, 'p'); + parport_write_data(pi->pardev->port, pi->unit); + parport_write_data(pi->pardev->port, ~pi->unit); + + parport_frob_control(pi->pardev->port, PARPORT_CONTROL_SELECT, 0); + parport_write_control(pi->pardev->port, PARPORT_CONTROL_INIT); + + i = mode_map[pi->mode] & 0x0C; + if (i == 0) + i = (mode_map[pi->mode] & 2) | 1; + parport_write_data(pi->pardev->port, i); + + parport_frob_control(pi->pardev->port, PARPORT_CONTROL_SELECT, + PARPORT_CONTROL_SELECT); + parport_frob_control(pi->pardev->port, PARPORT_CONTROL_AUTOFD, + PARPORT_CONTROL_AUTOFD); + + j = ((i & 0x08) << 4) | ((i & 0x07) << 3); + k = parport_read_status(pi->pardev->port) & 0xB8; + if (j != k) + goto fail; + + parport_frob_control(pi->pardev->port, PARPORT_CONTROL_AUTOFD, 0); + k = (parport_read_status(pi->pardev->port) & 0xB8) ^ 0xB8; + if (j != k) + goto fail; + + if (i & 4) // EPP + parport_frob_control(pi->pardev->port, + PARPORT_CONTROL_SELECT | PARPORT_CONTROL_INIT, 0); + else // PPC/ECP + parport_frob_control(pi->pardev->port, PARPORT_CONTROL_SELECT, 0); + + pi->private = 0; + + bpck6_send_cmd(pi, ACCESS_REG | ACCESS_WRITE | REG_RAMSIZE); + bpck6_wr_data_byte(pi, RAMSIZE_128K); + + bpck6_send_cmd(pi, ACCESS_REG | ACCESS_READ | REG_VERSION); + if ((bpck6_rd_data_byte(pi) & 0x3F) == 0x0C) + pi->private |= fifo_wait; + + return 1; + +fail: + parport_write_control(pi->pardev->port, pi->saved_r2); + parport_write_data(pi->pardev->port, pi->saved_r0); + + return 0; // FAIL } -static int bpck6_probe_unit ( PIA *pi ) +static void bpck6_deselect(struct pi_adapter *pi) { - int out; + if (mode_map[pi->mode] & 4) // EPP + parport_frob_control(pi->pardev->port, PARPORT_CONTROL_INIT, + PARPORT_CONTROL_INIT); + else // PPC/ECP + parport_frob_control(pi->pardev->port, PARPORT_CONTROL_SELECT, + PARPORT_CONTROL_SELECT); + + parport_write_data(pi->pardev->port, pi->saved_r0); + parport_write_control(pi->pardev->port, + pi->saved_r2 | PARPORT_CONTROL_SELECT); + parport_write_control(pi->pardev->port, pi->saved_r2); +} - if(verbose) - { - printk(KERN_DEBUG "PROBE UNIT %x on port:%x\n",pi->unit,pi->port); - } +stati |
