Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/dev/usb Add a preliminary version of a driver for In-Sys...
details: https://anonhg.NetBSD.org/src/rev/2c4cf6d0e095
branches: trunk
changeset: 519694:2c4cf6d0e095
user: augustss <augustss%NetBSD.org@localhost>
date: Mon Dec 24 13:43:24 2001 +0000
description:
Add a preliminary version of a driver for In-System Designs non-standard
ATA-over-BulkOnly protocol. The ISD chip can be found, e.g., in the
Archos MP3 player.
The driver still lacks real error handling.
diffstat:
sys/dev/usb/files.usb | 5 +-
sys/dev/usb/umass.c | 17 +-
sys/dev/usb/umass_isdata.c | 589 +++++++++++++++++++++++++++++++++++++++++++++
sys/dev/usb/umass_isdata.h | 40 +++
sys/dev/usb/umass_quirks.c | 33 ++-
sys/dev/usb/umassvar.h | 3 +-
6 files changed, 681 insertions(+), 6 deletions(-)
diffs (truncated from 777 to 300 lines):
diff -r 7728e9a483f4 -r 2c4cf6d0e095 sys/dev/usb/files.usb
--- a/sys/dev/usb/files.usb Mon Dec 24 13:40:50 2001 +0000
+++ b/sys/dev/usb/files.usb Mon Dec 24 13:43:24 2001 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: files.usb,v 1.34 2001/12/24 13:25:53 augustss Exp $
+# $NetBSD: files.usb,v 1.35 2001/12/24 13:43:25 augustss Exp $
#
# Config file and device description for machine-independent USB code.
# Included by ports that need it. Ports that use it must provide
@@ -79,9 +79,10 @@
# Mass storage
-device umass: scsi, atapi
+device umass: scsi, atapi, ata
attach umass at uhub
file dev/usb/umass.c umass
+file dev/usb/umass_isdata.c umass & wd
file dev/usb/umass_quirks.c umass
file dev/usb/umass_scsipi.c umass & (scsibus | atapibus)
diff -r 7728e9a483f4 -r 2c4cf6d0e095 sys/dev/usb/umass.c
--- a/sys/dev/usb/umass.c Mon Dec 24 13:40:50 2001 +0000
+++ b/sys/dev/usb/umass.c Mon Dec 24 13:43:24 2001 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: umass.c,v 1.79 2001/12/24 13:25:52 augustss Exp $ */
+/* $NetBSD: umass.c,v 1.80 2001/12/24 13:43:24 augustss Exp $ */
/*-
* Copyright (c) 1999 MAEKAWA Masahide <bishop%rr.iij4u.or.jp@localhost>,
* Nick Hibma <n_hibma%freebsd.org@localhost>
@@ -94,10 +94,11 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: umass.c,v 1.79 2001/12/24 13:25:52 augustss Exp $");
+__KERNEL_RCSID(0, "$NetBSD: umass.c,v 1.80 2001/12/24 13:43:24 augustss Exp $");
#include "atapibus.h"
#include "scsibus.h"
+#include "wd.h"
#include <sys/param.h>
#include <sys/systm.h>
@@ -124,6 +125,7 @@
#include <dev/usb/umassvar.h>
#include <dev/usb/umass_quirks.h>
#include <dev/usb/umass_scsipi.h>
+#include <dev/usb/umass_isdata.h>
#ifdef UMASS_DEBUG
@@ -388,6 +390,9 @@
case UMASS_CPROTO_ATAPI:
sCommand = "ATAPI";
break;
+ case UMASS_CPROTO_ISD_ATA:
+ sCommand = "ISD-ATA";
+ break;
default:
sCommand = "unknown";
break;
@@ -578,6 +583,14 @@
#endif
break;
+ case UMASS_CPROTO_ISD_ATA:
+#if NWD > 0
+ error = umass_isdata_attach(sc);
+#else
+ printf("%s: isdata not configured\n", USBDEVNAME(sc->sc_dev));
+#endif
+ break;
+
default:
printf("%s: command protocol=0x%x not supported\n",
USBDEVNAME(sc->sc_dev), sc->sc_cmd);
diff -r 7728e9a483f4 -r 2c4cf6d0e095 sys/dev/usb/umass_isdata.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/dev/usb/umass_isdata.c Mon Dec 24 13:43:24 2001 +0000
@@ -0,0 +1,589 @@
+/* $NetBSD: umass_isdata.c,v 1.1 2001/12/24 13:43:25 augustss Exp $ */
+
+/*
+ * TODO:
+ * get ATA registers on any kind of error
+ * implement more commands (what is needed)
+ */
+
+/*
+ * Copyright (c) 2001 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Lennart Augustsson (lennart%augustsson.net@localhost) at
+ * Carlstedt Research & Technology.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the NetBSD
+ * Foundation, Inc. and its contributors.
+ * 4. Neither the name of The NetBSD Foundation nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+__KERNEL_RCSID(0, "$NetBSD: umass_isdata.c,v 1.1 2001/12/24 13:43:25 augustss Exp $");
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/kernel.h>
+#include <sys/conf.h>
+#include <sys/buf.h>
+#include <sys/device.h>
+#include <sys/proc.h>
+#include <sys/disklabel.h>
+#include <sys/malloc.h>
+
+#include <dev/usb/usb.h>
+#include <dev/usb/usbdi.h>
+#include <dev/usb/usbdi_util.h>
+
+#include <dev/usb/umassvar.h>
+#include <dev/usb/umass_isdata.h>
+
+int umass_wd_attach(struct umass_softc *);
+
+#include <dev/ata/atareg.h>
+#include <dev/ata/atavar.h>
+#include <dev/ata/wdvar.h>
+#include <dev/ic/wdcreg.h>
+
+/* XXX move this */
+struct isd200_config {
+ uByte EventNotification;
+ uByte ExternalClock;
+ uByte ATAInitTimeout;
+ uByte ATAMisc1;
+#define ATATiming 0x0f
+#define ATAPIReset 0x10
+#define MasterSlaveSelection 0x20
+#define ATAPICommandBlockSize 0xc0
+ uByte ATAMajorCommand;
+ uByte ATAMinorCommand;
+ uByte ATAMisc2;
+#define LastLUNIdentifier 0x07
+#define DescriptOverride 0x08
+#define ATA3StateSuspend 0x10
+#define SkipDeviceBoot 0x20
+#define ConfigDescriptor2 0x40
+#define InitStatus 0x80
+ uByte ATAMisc3;
+#define SRSTEnable 0x01
+};
+
+struct uisdata_softc {
+ struct umassbus_softc base;
+
+ struct ata_drive_datas sc_drv_data;
+ struct isd200_config sc_isd_config;
+ void *sc_ata_bio;
+ u_long sc_skip;
+};
+
+#undef DPRINTF
+#undef DPRINTFN
+#ifdef UISDATA_DEBUG
+#define DPRINTF(x) if (uisdatadebug) logprintf x
+#define DPRINTFN(n,x) if (uisdatadebug>(n)) logprintf x
+int uisdatadebug = 0;
+#else
+#define DPRINTF(x)
+#define DPRINTFN(n,x)
+#endif
+
+int uisdata_bio(struct ata_drive_datas *, struct ata_bio *);
+int uisdata_bio1(struct ata_drive_datas *, struct ata_bio *);
+void uisdata_reset_channel(struct ata_drive_datas *);
+int uisdata_exec_command(struct ata_drive_datas *, struct wdc_command *);
+int uisdata_get_params(struct ata_drive_datas *, u_int8_t, struct ataparams *);
+int uisdata_addref(struct ata_drive_datas *);
+void uisdata_delref(struct ata_drive_datas *);
+void uisdata_kill_pending(struct ata_drive_datas *);
+
+void uisdata_bio_cb(struct umass_softc *, void *, int, int);
+void uisdata_exec_cb(struct umass_softc *, void *, int, int);
+int uwdprint(void *, const char *);
+
+const struct ata_bustype uisdata_bustype = {
+ SCSIPI_BUSTYPE_ATA,
+ uisdata_bio,
+ uisdata_reset_channel,
+ uisdata_exec_command,
+ uisdata_get_params,
+ uisdata_addref,
+ uisdata_delref,
+ uisdata_kill_pending,
+};
+
+struct ata_cmd {
+ u_int8_t ac_signature0;
+ u_int8_t ac_signature1;
+
+ u_int8_t ac_action_select;
+#define AC_ReadRegisterAccess 0x01
+#define AC_NoDeviceSelectionBit 0x02
+#define AC_NoBSYPollBit 0x04
+#define AC_IgnorePhaseErrorBit 0x08
+#define AC_IgnoreDeviceErrorBit 0x10
+
+ u_int8_t ac_register_select;
+#define AC_SelectAlternateStatus 0x01 /* R */
+#define AC_SelectDeviceControl 0x01 /* W */
+#define AC_SelectError 0x02 /* R */
+#define AC_SelectFeatures 0x02 /* W */
+#define AC_SelectSectorCount 0x04 /* RW */
+#define AC_SelectSectorNumber 0x08 /* RW */
+#define AC_SelectCylinderLow 0x10 /* RW */
+#define AC_SelectCylinderHigh 0x20 /* RW */
+#define AC_SelectDeviceHead 0x40 /* RW */
+#define AC_SelectStatus 0x80 /* R */
+#define AC_SelectCommand 0x80 /* W */
+
+ u_int8_t ac_transfer_blocksize;
+
+ u_int8_t ac_alternate_status;
+#define ac_device_control ac_alternate_status
+ u_int8_t ac_error;
+#define ac_features ac_error
+
+ u_int8_t ac_sector_count;
+ u_int8_t ac_sector_number;
+ u_int8_t ac_cylinder_low;
+ u_int8_t ac_cylinder_high;
+ u_int8_t ac_device_head;
+
+ u_int8_t ac_status;
+#define ac_command ac_status
+
+ u_int8_t ac_reserved[3];
+};
+
+#define ATA_DELAY 10000 /* 10s for a drive I/O */
+
+int
+umass_isdata_attach(struct umass_softc *sc)
+{
+ usb_device_request_t req;
+ usbd_status err;
+ struct ata_device adev;
+ struct uisdata_softc *scbus;
+ struct isd200_config *cf;
+
+ scbus = malloc(sizeof *scbus, M_DEVBUF, M_WAITOK | M_ZERO);
+ sc->bus = &scbus->base;
+ cf = &scbus->sc_isd_config;
+
+ req.bmRequestType = UT_READ_VENDOR_DEVICE;
+ req.bRequest = 0x02;
+ USETW(req.wValue, 0);
+ USETW(req.wIndex, 2);
+ USETW(req.wLength, sizeof *cf);
+
+ err = usbd_do_request(sc->sc_udev, &req, cf);
+ if (err)
+ return (EIO);
+ DPRINTF(("umass_wd_attach info:\n EventNotification=0x%02x "
+ "ExternalClock=0x%02x ATAInitTimeout=0x%02x\n"
+ " ATAMisc1=0x%02x ATAMajorCommand=0x%02x "
+ "ATAMinorCommand=0x%02x\n"
+ " ATAMisc2=0x%02x ATAMisc3=0x%02x\n",
+ cf->EventNotification, cf->ExternalClock, cf->ATAInitTimeout,
+ cf->ATAMisc1, cf->ATAMajorCommand, cf->ATAMinorCommand,
+ cf->ATAMisc2, cf->ATAMisc3));
+
+ memset(&adev, 0, sizeof(struct ata_device));
+ adev.adev_bustype = &uisdata_bustype;
+ adev.adev_channel = 1; /* XXX */
+ adev.adev_openings = 1;
+ adev.adev_drv_data = &scbus->sc_drv_data;
Home |
Main Index |
Thread Index |
Old Index