Browse Source

introduce USB storage; add 640x512 mode; tweak vcap centering;

usb
mntmn 3 months ago
parent
commit
2776f36277

+ 129
- 34
ZZ9000_proto.sdk/ZZ9000Test/src/main.c View File

@@ -387,6 +387,10 @@ void pixelclock_init(int mhz) {
mul = 27;
div = 2;
otherdiv = 50;
} else if (mhz == 54) {
mul = 27;
div = 1;
otherdiv = 50;
} else if (mhz == 150) {
mul = 15;
div = 1;
@@ -395,10 +399,6 @@ void pixelclock_init(int mhz) {
mul = 15;
div = 1;
otherdiv = 60;
} else if (mhz == 27) { // 25.205
mul = 27;
div = 2;
otherdiv = 50;
} else if (mhz == 108) {
mul = 54;
div = 5;
@@ -550,9 +550,16 @@ void video_system_init(int hres, int vres, int htotal, int vtotal, int mhz,
#define MNT_BASE_EVENT_SERIAL MNT_REG_BASE+0xb0
#define MNT_BASE_EVENT_CODE MNT_REG_BASE+0xb2
#define MNT_BASE_FW_VERSION MNT_REG_BASE+0xc0
#define MNT_BASE_USBBLK_TX_HI MNT_REG_BASE+0xd0
#define MNT_BASE_USBBLK_TX_LO MNT_REG_BASE+0xd2
#define MNT_BASE_USBBLK_RX_HI MNT_REG_BASE+0xd4
#define MNT_BASE_USBBLK_RX_LO MNT_REG_BASE+0xd6
#define MNT_BASE_USB_STATUS MNT_REG_BASE+0xd8
#define MNT_BASE_USB_BUFSEL MNT_REG_BASE+0xda
#define MNT_BASE_USB_CAPACITY MNT_REG_BASE+0xdc

#define REVISION_MAJOR 1
#define REVISION_MINOR 4
#define REVISION_MINOR 5

#define ZZVMODE_1280x720 0
#define ZZVMODE_800x600 1
@@ -563,6 +570,7 @@ void video_system_init(int hres, int vres, int htotal, int vtotal, int mhz,
#define ZZVMODE_720x576 6 // 50hz
#define ZZVMODE_1920x1080_50 7 // 50hz
#define ZZVMODE_720x480 8
#define ZZVMODE_640x512 9

void video_mode_init(int mode, int scalemode, int colormode) {
int hres, vres, hmax, vmax, hstart, hend, vstart, vend, polarity, mhz, vhz, hdmi;
@@ -621,6 +629,20 @@ void video_mode_init(int mode, int scalemode, int colormode) {
vhz = 60;
hdmi = 0;
break;
case ZZVMODE_640x512:
hres = 640;
vres = 512;
hstart = 840;
hend = 968;
hmax = 1056;
vstart = 601;
vend = 605;
vmax = 628;
polarity = 0;
mhz = 40;
vhz = 60;
hdmi = 0;
break;
case ZZVMODE_720x480:
hres = 720;
vres = 480;
@@ -791,18 +813,34 @@ void sprite_reset() {
// default to more compatible 60hz mode
static int videocap_video_mode = ZZVMODE_800x600;
static int video_mode = ZZVMODE_800x600 | 2 << 12 | MNTVA_COLOR_32BIT << 8;
static int default_pan_offset = 0x00e00bd0;
static int default_pan_offset = 0x00e00bf8;
static char usb_storage_available = 0;
static uint32_t usb_storage_read_block = 0;
static uint32_t usb_storage_write_block = 0;

// ethernet state
uint16_t ethernet_send_result = 0;

// usb state
uint16_t usb_status = 0;
// we can read or write a number of USB blocks at once, and amiga can select which one is mapped at the USB storage buffer area
uint32_t usb_selected_buffer_block = 0;
uint32_t usb_read_write_num_blocks = 1;

void videocap_area_clear() {
fb_fill(0x00e00000 / 4);
}

void handle_amiga_reset() {
void reset_default_videocap_pan() {
if (videocap_video_mode == ZZVMODE_800x600) {
default_pan_offset = 0x00e00bd0;
default_pan_offset = 0x00e00bf8;
} else {
default_pan_offset = 0x00e00000;
}
}

void handle_amiga_reset() {
reset_default_videocap_pan();

framebuffer_pan_offset = default_pan_offset;
videocap_area_clear();
@@ -820,10 +858,17 @@ void handle_amiga_reset() {
video_mode_init(videocap_video_mode, 2, MNTVA_COLOR_32BIT);
video_mode = videocap_video_mode | 2 << 12 | MNTVA_COLOR_32BIT << 8;

test_usb();

ethernet_init();
sprite_reset();
ethernet_init();

usb_storage_available = zz_usb_init();

usb_status = 0;
usb_selected_buffer_block = 0;
usb_read_write_num_blocks = 1;
ethernet_send_result = 0;

// FIXME there should be more state to be reset
}

uint16_t arm_app_output_event_serial = 0;
@@ -1038,9 +1083,6 @@ int main() {
arm_run_env.argc = 0;
uint32_t arm_run_address = 0;

// ethernet state
uint16_t ethernet_send_result = 0;

// zorro state
u32 zstate_raw;
int interlace_old = 0;
@@ -1106,12 +1148,14 @@ int main() {
ptr = mem + zaddr - MNT_FB_BASE;
} else if (zaddr < MNT_REG_BASE + 0x8000) {
// FIXME remove
ptr = (u8*) (RX_FRAME_ADDRESS + zaddr
- (MNT_REG_BASE + 0x2000));
printf("ERXF write: %08lx\n", (u32) ptr);
ptr = (u8*) (RX_FRAME_ADDRESS + zaddr - (MNT_REG_BASE + 0x2000));
//printf("ERXF write: %08lx\n", (u32) ptr);
} else if (zaddr < MNT_REG_BASE + 0xa000) {
ptr = (u8*) (TX_FRAME_ADDRESS + zaddr - (MNT_REG_BASE + 0x8000));
} else if (zaddr < MNT_REG_BASE + 0x10000) {
ptr = (u8*) (TX_FRAME_ADDRESS + zaddr
- (MNT_REG_BASE + 0x8000));
// 0xa000-0xafff: write to block device (usb storage)
// TODO: this should be moved to DMA space?
ptr = (u8*) (USB_BLOCK_STORAGE_ADDRESS + zaddr - (MNT_REG_BASE + 0xa000) + usb_selected_buffer_block * 512);
}

// FIXME cache this
@@ -1496,6 +1540,47 @@ int main() {
ethernet_update_mac_address();
break;
}
case MNT_BASE_USBBLK_TX_HI: {
usb_storage_write_block = ((u32) zdata) << 16;
break;
}
case MNT_BASE_USBBLK_TX_LO: {
usb_storage_write_block |= zdata;
if (usb_storage_available) {
usb_status = zz_usb_write_blocks(0, usb_storage_write_block, usb_read_write_num_blocks, (void*)USB_BLOCK_STORAGE_ADDRESS);
} else {
printf("[USB] TX but no storage available!\n");
}
break;
}
case MNT_BASE_USBBLK_RX_HI: {
usb_storage_read_block = ((u32) zdata) << 16;
break;
}
case MNT_BASE_USBBLK_RX_LO: {
usb_storage_read_block |= zdata;
if (usb_storage_available) {
usb_status = zz_usb_read_blocks(0, usb_storage_read_block, usb_read_write_num_blocks, (void*)USB_BLOCK_STORAGE_ADDRESS);
} else {
printf("[USB] RX but no storage available!\n");
}
break;
}
case MNT_BASE_USB_STATUS: {
//printf("[USB] write to status/blocknum register: %d\n", zdata);
if (zdata==0) {
// reset USB
// FIXME memory leaks?
//usb_storage_available = zz_usb_init();
} else {
// set number of blocks to read/write at once
usb_read_write_num_blocks = zdata;
}
}
case MNT_BASE_USB_BUFSEL: {
//printf("[USB] select buffer: %d\n", zdata);
usb_selected_buffer_block = zdata;
}

// ARM core 2 execution
case MNT_BASE_RUN_HI:
@@ -1598,17 +1683,22 @@ int main() {
u8* ptr = mem;

if (zaddr >= MNT_FB_BASE) {
// read from framebuffer / generic memory
ptr = mem + zaddr - MNT_FB_BASE;
} else if (zaddr < MNT_REG_BASE + 0x8000) {
// 0x2000-0x7fff: FIXME: waste of address space
// read from ethernet RX frame
// disable INT6 interrupt
mntzorro_write(MNTZ_BASE_ADDR, MNTZORRO_REG2,
(1 << 30) | 0);
ptr = (u8*) (ethernet_current_receive_ptr() + zaddr
- (MNT_REG_BASE + 0x2000));
mntzorro_write(MNTZ_BASE_ADDR, MNTZORRO_REG2, (1 << 30) | 0);
ptr = (u8*) (ethernet_current_receive_ptr() + zaddr - (MNT_REG_BASE + 0x2000));
} else if (zaddr < MNT_REG_BASE + 0xa000) {
// 0x8000-0x9fff: read from TX frame (unusual)
ptr = (u8*) (TX_FRAME_ADDRESS + zaddr - (MNT_REG_BASE + 0x8000));
//printf("ETXF read: %08lx\n", (u32) ptr);
} else if (zaddr < MNT_REG_BASE + 0x10000) {
ptr = (u8*) (TX_FRAME_ADDRESS + zaddr
- (MNT_REG_BASE + 0x8000));
printf("ETXF read: %08lx\n", (u32) ptr);
// 0xa000-0xafff: read from block device (usb storage)
// TODO: this should be moved to DMA space?
ptr = (u8*) (USB_BLOCK_STORAGE_ADDRESS + zaddr - (MNT_REG_BASE + 0xa000) + usb_selected_buffer_block * 512);
}

if (z3) {
@@ -1640,10 +1730,21 @@ int main() {
uint8_t* mac = ethernet_get_mac_address_ptr();
data = mac[4] << 24 | mac[5] << 16;
} else if (zaddr32 == MNT_BASE_ETH_TX) {
// FIXME this is probably wrong (doesn't need swapping?)
data = (ethernet_send_result & 0xff) << 24
| (ethernet_send_result & 0xff00) << 16;
} else if (zaddr32 == MNT_BASE_FW_VERSION) {
data = (REVISION_MAJOR << 24 | REVISION_MINOR << 16);
} else if (zaddr32 == MNT_BASE_USB_STATUS) {
data = usb_status << 16;
} else if (zaddr32 == MNT_BASE_USB_CAPACITY) {
if (usb_storage_available) {
printf("[USB] query capacity: %lx\n",zz_usb_storage_capacity(0));
data = zz_usb_storage_capacity(0);
} else {
printf("[USB] query capacity: no device.\n");
data = 0;
}
}

if (z3) {
@@ -1654,8 +1755,7 @@ int main() {
mntzorro_write(MNTZ_BASE_ADDR, MNTZORRO_REG1, data);
} else {
// upper 16 bit
mntzorro_write(MNTZ_BASE_ADDR, MNTZORRO_REG1,
data >> 16);
mntzorro_write(MNTZ_BASE_ADDR, MNTZORRO_REG1, data >> 16);
}
}
}
@@ -1703,12 +1803,7 @@ int main() {
video_mode_init(ZZVMODE_720x480, 2, MNTVA_COLOR_32BIT);
} else {
// PAL
// FIXME duplication
if (videocap_video_mode == ZZVMODE_800x600) {
default_pan_offset = 0x00e00bd0;
} else {
default_pan_offset = 0x00e00000;
}
reset_default_videocap_pan();
framebuffer_pan_offset = default_pan_offset;
video_mode_init(videocap_video_mode, 2, MNTVA_COLOR_32BIT);
}

+ 27
- 1
ZZ9000_proto.sdk/ZZ9000Test/src/usb.c View File

@@ -25,6 +25,8 @@
#include "xparameters.h"
#include <xscugic.h>
#include "usb/ehci.h"
#include "usb/usb.h"
#include "ethernet.h"

struct zynq_ehci_priv _zynq_ehci;

@@ -38,10 +40,34 @@ capabilities by an exchange of device requests. The requests that the host uses
standard requests and must support these requests on all USB devices."
*/

void test_usb() {
// returns 1 if storage device available
int zz_usb_init() {
printf("[USB] trying to probe zynq ehci...\n");
ehci_zynq_probe(&_zynq_ehci);
printf("[USB] probed!\n");
usb_init();
printf("[USB] initialized!\n");

if (!usb_stor_scan(1)) {
return 1;
}
return 0;
}

unsigned long zz_usb_read_blocks(int dev_index, unsigned long blknr, unsigned long blkcnt, void *buffer) {
int res = usb_stor_read_direct(dev_index, blknr, blkcnt, buffer);
//printf("[USB] read %lu blocks at %lu: %d\n",blkcnt,blknr,res);
return res;
}

unsigned long zz_usb_write_blocks(int dev_index, unsigned long blknr, unsigned long blkcnt, void *buffer) {
int res = usb_stor_write_direct(dev_index, blknr, blkcnt, buffer);
//printf("[USB] write %lu blocks at %lu: %d\n",blkcnt,blknr,res);
return res;
}

unsigned long zz_usb_storage_capacity(int dev_index) {
unsigned long cap = usb_stor_get_capacity(dev_index);
printf("[USB] get capacity: %lx\n",cap);
return cap;
}

+ 4
- 1
ZZ9000_proto.sdk/ZZ9000Test/src/usb.h View File

@@ -1,2 +1,5 @@

void test_usb();
int zz_usb_init();
unsigned long zz_usb_read_blocks(int dev_index, unsigned long blknr, unsigned long blkcnt, void *buffer);
unsigned long zz_usb_write_blocks(int dev_index, unsigned long blknr, unsigned long blkcnt, void *buffer);
unsigned long zz_usb_storage_capacity(int dev_index);

+ 104
- 0
ZZ9000_proto.sdk/ZZ9000Test/src/usb/blk.h View File

@@ -0,0 +1,104 @@
/* SPDX-License-Identifier: GPL-2.0+ */
/*
* (C) Copyright 2000-2004
* Wolfgang Denk, DENX Software Engineering, wd@denx.de.
*/

#ifndef BLK_H
#define BLK_H

#ifdef CONFIG_SYS_64BIT_LBA
typedef uint64_t lbaint_t;
#define LBAFlength "ll"
#else
typedef ulong lbaint_t;
#define LBAFlength "l"
#endif
#define LBAF "%" LBAFlength "x"
#define LBAFU "%" LBAFlength "u"

/* Interface types: */
enum if_type {
IF_TYPE_UNKNOWN = 0,
IF_TYPE_IDE,
IF_TYPE_SCSI,
IF_TYPE_ATAPI,
IF_TYPE_USB,
IF_TYPE_DOC,
IF_TYPE_MMC,
IF_TYPE_SD,
IF_TYPE_SATA,
IF_TYPE_HOST,
IF_TYPE_NVME,
IF_TYPE_EFI,
IF_TYPE_VIRTIO,

IF_TYPE_COUNT, /* Number of interface types */
};

#define BLK_VEN_SIZE 40
#define BLK_PRD_SIZE 20
#define BLK_REV_SIZE 8

/*
* Identifies the partition table type (ie. MBR vs GPT GUID) signature
*/
enum sig_type {
SIG_TYPE_NONE,
SIG_TYPE_MBR,
SIG_TYPE_GUID,

SIG_TYPE_COUNT /* Number of signature types */
};

typedef struct {
u8 b[16];
} efi_guid_t __attribute__((aligned(8)));

/*
* With driver model (CONFIG_BLK) this is uclass platform data, accessible
* with dev_get_uclass_platdata(dev)
*/
struct blk_desc {
/*
* TODO: With driver model we should be able to use the parent
* device's uclass instead.
*/
enum if_type if_type; /* type of the interface */
int devnum; /* device number */
unsigned char part_type; /* partition type */
unsigned char target; /* target SCSI ID */
unsigned char lun; /* target LUN */
unsigned char hwpart; /* HW partition, e.g. for eMMC */
unsigned char type; /* device type */
unsigned char removable; /* removable device */
#ifdef CONFIG_LBA48
/* device can use 48bit addr (ATA/ATAPI v7) */
unsigned char lba48;
#endif
lbaint_t lba; /* number of blocks */
unsigned long blksz; /* block size */
int log2blksz; /* for convenience: log2(blksz) */
char vendor[BLK_VEN_SIZE + 1]; /* device vendor string */
char product[BLK_PRD_SIZE + 1]; /* device product number */
char revision[BLK_REV_SIZE + 1]; /* firmware revision */
enum sig_type sig_type; /* Partition table signature type */
union {
uint32_t mbr_sig; /* MBR integer signature */
efi_guid_t guid_sig; /* GPT GUID Signature */
};
unsigned long (*block_read)(struct blk_desc *block_dev,
lbaint_t start,
lbaint_t blkcnt,
void *buffer);
unsigned long (*block_write)(struct blk_desc *block_dev,
lbaint_t start,
lbaint_t blkcnt,
const void *buffer);
unsigned long (*block_erase)(struct blk_desc *block_dev,
lbaint_t start,
lbaint_t blkcnt);
void *priv; /* driver private struct pointer */
};

#endif

+ 27
- 27
ZZ9000_proto.sdk/ZZ9000Test/src/usb/ehci-hcd.c View File

@@ -176,7 +176,7 @@ static int handshake(uint32_t *ptr, uint32_t mask, uint32_t done, int usec)
uint32_t result;
do {
result = ehci_readl(ptr);
udelay(5); // FIXME
udelay(5);
if (result == ~(uint32_t)0)
return -1;
result &= mask;
@@ -256,7 +256,7 @@ static int ehci_td_buffer(struct qTD *td, void *buf, size_t sz)
int idx;

if (addr != ALIGN(addr, ARCH_DMA_MINALIGN))
printf("EHCI-HCD: Misaligned buffer address (%p)\n", buf);
printf("EHCI-HCD: Misaligned buffer address (%p vs %x)\n", buf, ALIGN(addr, ARCH_DMA_MINALIGN));

flush_dcache_range(addr, ALIGN(addr + sz, ARCH_DMA_MINALIGN));

@@ -326,8 +326,8 @@ ehci_submit_async(struct usb_device *dev, unsigned long pipe, void *buffer,
int ret = 0;
struct ehci_ctrl *ctrl = ehci_get_ctrl(dev);

printf("dev=%p, pipe=%lx, buffer=%p, length=%d, req=%p\n", dev, pipe,
buffer, length, req);
//printf("dev=%p, pipe=%lx, buffer=%p, length=%d, req=%p\n", dev, pipe,
// buffer, length, req);
/*if (req != NULL)
printf("req=%u (%#x), type=%u (%#x), value=%u (%#x), index=%u\n",
req->request, req->request,
@@ -397,7 +397,7 @@ ehci_submit_async(struct usb_device *dev, unsigned long pipe, void *buffer,

// FIXME needs 128kB ram?

qtd = memalign(USB_DMA_MINALIGN, qtd_count * sizeof(struct qTD));
qtd = memalign(USB_DMA_MINALIGN, qtd_count * sizeof(struct qTD)); // FIXME dynamic allocation
if (qtd == NULL) {
printf("unable to allocate TDs\n");
return -1;
@@ -635,7 +635,7 @@ ehci_submit_async(struct usb_device *dev, unsigned long pipe, void *buffer,

token = hc32_to_cpu(qh->qh_overlay.qt_token);
if (!(QT_TOKEN_GET_STATUS(token) & QT_TOKEN_STATUS_ACTIVE)) {
printf("TOKEN=%#lx\n", token);
//printf("TOKEN=%#lx\n", token);
switch (QT_TOKEN_GET_STATUS(token) &
~(QT_TOKEN_STATUS_SPLITXSTATE | QT_TOKEN_STATUS_PERR)) {
case 0:
@@ -664,12 +664,10 @@ ehci_submit_async(struct usb_device *dev, unsigned long pipe, void *buffer,
dev->act_len = length - QT_TOKEN_GET_TOTALBYTES(token);
} else {
dev->act_len = 0;
#ifndef CONFIG_USB_EHCI_FARADAY
printf("dev=%u, usbsts=%#lx, p[1]=%#lx, p[2]=%#lx\n",
dev->devnum, ehci_readl(&ctrl->hcor->or_usbsts),
ehci_readl(&ctrl->hcor->or_portsc[0]),
ehci_readl(&ctrl->hcor->or_portsc[1]));
#endif
//printf("dev=%u, usbsts=%#lx, p[1]=%#lx, p[2]=%#lx\n",
// dev->devnum, ehci_readl(&ctrl->hcor->or_usbsts),
// ehci_readl(&ctrl->hcor->or_portsc[0]),
// ehci_readl(&ctrl->hcor->or_portsc[1]));
}

free(qtd);
@@ -718,19 +716,19 @@ static int ehci_submit_root(struct usb_device *dev, unsigned long pipe,
case DeviceRequest | USB_REQ_GET_DESCRIPTOR:
switch (le16_to_cpu(req->value) >> 8) {
case USB_DT_DEVICE:
printf("USB_DT_DEVICE request\n");
//printf("USB_DT_DEVICE request\n");
srcptr = &descriptor.device;
srclen = descriptor.device.bLength;
break;
case USB_DT_CONFIG:
printf("USB_DT_CONFIG config\n");
//printf("USB_DT_CONFIG config\n");
srcptr = &descriptor.config;
srclen = descriptor.config.bLength +
descriptor.interface.bLength +
descriptor.endpoint.bLength;
break;
case USB_DT_STRING:
printf("USB_DT_STRING config\n");
//printf("USB_DT_STRING config\n");
switch (le16_to_cpu(req->value) & 0xff) {
case 0: /* Language */
srcptr = "\4\3\1\0";
@@ -760,7 +758,7 @@ static int ehci_submit_root(struct usb_device *dev, unsigned long pipe,
case USB_REQ_GET_DESCRIPTOR | ((USB_DIR_IN | USB_RT_HUB) << 8):
switch (le16_to_cpu(req->value) >> 8) {
case USB_DT_HUB:
printf("USB_DT_HUB config\n");
//printf("[ehci] USB_DT_HUB config\n");
srcptr = &descriptor.hub;
srclen = descriptor.hub.bLength;
break;
@@ -770,11 +768,11 @@ static int ehci_submit_root(struct usb_device *dev, unsigned long pipe,
}
break;
case USB_REQ_SET_ADDRESS | (USB_RECIP_DEVICE << 8):
printf("USB_REQ_SET_ADDRESS\n");
//printf("USB_REQ_SET_ADDRESS\n");
ctrl->rootdev = le16_to_cpu(req->value);
break;
case DeviceOutRequest | USB_REQ_SET_CONFIGURATION:
printf("USB_REQ_SET_CONFIGURATION\n");
//printf("USB_REQ_SET_CONFIGURATION\n");
/* Nothing to do */
break;
case USB_REQ_GET_STATUS | ((USB_DIR_IN | USB_RT_HUB) << 8):
@@ -947,8 +945,8 @@ static int ehci_submit_root(struct usb_device *dev, unsigned long pipe,
len = min3(srclen, (int)le16_to_cpu(req->length), length);
if (srcptr != NULL && len > 0)
memcpy(buffer, srcptr, len);
else
printf("[ehci] Len is 0\n");
//else
// printf("[ehci] Len is 0\n");

dev->act_len = len;
dev->status = 0;
@@ -1056,10 +1054,12 @@ static int ehci_common_init(struct ehci_ctrl *ctrl, unsigned int tweaks)
* S-mask and C-mask.
*/
if (ctrl->periodic_list == NULL)
ctrl->periodic_list = memalign(4096, 1024 * 4);
ctrl->periodic_list = memalign(4096, 1024 * 4); // FIXME dynamic allocation

if (!ctrl->periodic_list)
if (!ctrl->periodic_list) {
printf("[ehci_common_init] ENOMEM\n");
return -ENOMEM;
}
for (i = 0; i < 1024; i++) {
ctrl->periodic_list[i] = cpu_to_hc32((unsigned long)periodic
| QH_LINK_TYPE_QH);
@@ -1293,7 +1293,7 @@ static struct int_queue *_ehci_create_int_queue(struct usb_device *dev,
return NULL;
}

result = malloc(sizeof(*result));
result = malloc(sizeof(*result)); // FIXME dynamic allocation
if (!result) {
printf("ehci intr queue: out of memory\n");
goto fail1;
@@ -1301,7 +1301,7 @@ static struct int_queue *_ehci_create_int_queue(struct usb_device *dev,
result->elementsize = elementsize;
result->pipe = pipe;
result->first = memalign(USB_DMA_MINALIGN,
sizeof(struct QH) * queuesize);
sizeof(struct QH) * queuesize); // FIXME dynamic allocation
if (!result->first) {
printf("ehci intr queue: out of memory\n");
goto fail2;
@@ -1309,7 +1309,7 @@ static struct int_queue *_ehci_create_int_queue(struct usb_device *dev,
result->current = result->first;
result->last = result->first + queuesize - 1;
result->tds = memalign(USB_DMA_MINALIGN,
sizeof(struct qTD) * queuesize);
sizeof(struct qTD) * queuesize); // FIXME dynamic allocation
if (!result->tds) {
printf("ehci intr queue: out of memory\n");
goto fail3;
@@ -1513,8 +1513,8 @@ static int _ehci_submit_int_msg(struct usb_device *dev, unsigned long pipe,
unsigned long timeout;
int result = 0, ret;

printf("dev=%p, pipe=%lu, buffer=%p, length=%d, interval=%d",
dev, pipe, buffer, length, interval);
//printf("dev=%p, pipe=%lu, buffer=%p, length=%d, interval=%d",
// dev, pipe, buffer, length, interval);

queue = _ehci_create_int_queue(dev, pipe, 1, length, buffer, interval);
if (!queue)

+ 2
- 18
ZZ9000_proto.sdk/ZZ9000Test/src/usb/ehci-zynq.c View File

@@ -53,7 +53,7 @@ int ehci_zynq_probe(struct zynq_ehci_priv *priv)
hccr = (struct ehci_hccr *)((uint32_t)&priv->ehci->caplength);
hcor = (struct ehci_hcor *)((uint32_t) hccr + HC_LENGTH(ehci_readl(&hccr->cr_capbase)));

printf("[ehci-zynq] hccr: %p hcor: %p\n", hccr, hcor);
//printf("[ehci-zynq] hccr: %p hcor: %p\n", hccr, hcor);

priv->ehcictrl.hccr = hccr;
priv->ehcictrl.hcor = hcor;
@@ -61,8 +61,7 @@ int ehci_zynq_probe(struct zynq_ehci_priv *priv)
ulpi_vp.viewport_addr = (u32)&priv->ehci->ulpi_viewpoint;
ulpi_vp.port_num = 0;

printf("[ehci-zynq] viewport_addr: %p\n", &priv->ehci->ulpi_viewpoint);

//printf("[ehci-zynq] viewport_addr: %p\n", &priv->ehci->ulpi_viewpoint);

// lifted from https://elixir.bootlin.com/u-boot/latest/source/drivers/usb/host/ehci-fsl.c#L275
/* Set to Host mode */
@@ -70,29 +69,14 @@ int ehci_zynq_probe(struct zynq_ehci_priv *priv)

// FIXME: need to figure out which of these are necessary

//printf("[ehci-zynq] 1\n");
//out_be32(&ehci->snoop1, SNOOP_SIZE_2GB);
//printf("[ehci-zynq] 2\n");
//out_be32(&ehci->snoop2, 0x80000000 | SNOOP_SIZE_2GB);
printf("[ehci-zynq] 3\n");
setbits_le32(&ehci->portsc, USB_EN);
// following crashes
//clrsetbits_be32(&ehci->control, CONTROL_REGISTER_W1C_MASK, PHY_CLK_SEL_ULPI);
printf("[ehci-zynq] 4\n");
//clrsetbits_be32(&ehci->control, UTMI_PHY_EN | CONTROL_REGISTER_W1C_MASK, USB_EN);
printf("[ehci-zynq] 5\n");
usleep(1000); /* delay required for PHY Clk to appear */
printf("[ehci-zynq] 6\n");
out_le32(&(hcor)->or_portsc[0], PORT_PTS_ULPI);

printf("[ehci-zynq] 7\n");
out_be32(&ehci->prictrl, 0x0000000c);
printf("[ehci-zynq] 8\n");
out_be32(&ehci->age_cnt_limit, 0x00000040);
printf("[ehci-zynq] 9\n");
out_be32(&ehci->sictrl, 0x00000001);

printf("[ehci-zynq] 10\n");
in_le32(&ehci->usbmode);

/* ULPI set flags */

+ 174
- 0
ZZ9000_proto.sdk/ZZ9000Test/src/usb/part.h View File

@@ -0,0 +1,174 @@
/*
* (C) Copyright 2000-2004
* Wolfgang Denk, DENX Software Engineering, wd@denx.de.
*
* See file CREDITS for list of people who contributed to this
* project.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of
* the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*/
#ifndef _PART_H
#define _PART_H

#ifdef CONFIG_SYS_64BIT_LBA
typedef uint64_t lbaint_t;
#else
typedef unsigned long lbaint_t;
#endif

typedef struct block_dev_desc {
int if_type; /* type of the interface */
int dev; /* device number */
unsigned char part_type; /* partition type */
unsigned char target; /* target SCSI ID */
unsigned char lun; /* target LUN */
unsigned char type; /* device type */
unsigned char removable; /* removable device */
#ifdef CONFIG_LBA48
unsigned char lba48; /* device can use 48bit addr (ATA/ATAPI v7) */
#endif
lbaint_t lba; /* number of blocks */
unsigned long blksz; /* block size */
char vendor [40+1]; /* IDE model, SCSI Vendor */
char product[20+1]; /* IDE Serial no, SCSI product */
char revision[8+1]; /* firmware revision */
unsigned long (*block_read)(int dev,
unsigned long start,
lbaint_t blkcnt,
void *buffer);
unsigned long (*block_write)(int dev,
unsigned long start,
lbaint_t blkcnt,
const void *buffer);
unsigned long (*block_erase)(int dev,
unsigned long start,
lbaint_t blkcnt);
void *priv; /* driver private struct pointer */
} block_dev_desc_t;

/* Interface types: */
/*#define IF_TYPE_UNKNOWN 0
#define IF_TYPE_IDE 1
#define IF_TYPE_SCSI 2
#define IF_TYPE_ATAPI 3
#define IF_TYPE_USB 4
#define IF_TYPE_DOC 5
#define IF_TYPE_MMC 6
#define IF_TYPE_SD 7
#define IF_TYPE_SATA 8*/

/* Part types */
#define PART_TYPE_UNKNOWN 0x00
#define PART_TYPE_MAC 0x01
#define PART_TYPE_DOS 0x02
#define PART_TYPE_ISO 0x03
#define PART_TYPE_AMIGA 0x04
#define PART_TYPE_EFI 0x05

/*
* Type string for U-Boot bootable partitions
*/
#define BOOT_PART_TYPE "U-Boot" /* primary boot partition type */
#define BOOT_PART_COMP "PPCBoot" /* PPCBoot compatibility type */

/* device types */
#define DEV_TYPE_UNKNOWN 0xff /* not connected */
#define DEV_TYPE_HARDDISK 0x00 /* harddisk */
#define DEV_TYPE_TAPE 0x01 /* Tape */
#define DEV_TYPE_CDROM 0x05 /* CD-ROM */
#define DEV_TYPE_OPDISK 0x07 /* optical disk */

typedef struct disk_partition {
unsigned long start; /* # of first block in partition */
unsigned long size; /* number of blocks in partition */
unsigned long blksz; /* block size in bytes */
unsigned char name[32]; /* partition name */
unsigned char type[32]; /* string type description */
} disk_partition_t;

/* Misc _get_dev functions */
#ifdef CONFIG_PARTITIONS
block_dev_desc_t* get_dev(char* ifname, int dev);
block_dev_desc_t* ide_get_dev(int dev);
block_dev_desc_t* sata_get_dev(int dev);
block_dev_desc_t* scsi_get_dev(int dev);
block_dev_desc_t* usb_stor_get_dev(int dev);
block_dev_desc_t* mmc_get_dev(int dev);
block_dev_desc_t* systemace_get_dev(int dev);
block_dev_desc_t* mg_disk_get_dev(int dev);

/* disk/part.c */
int get_partition_info (block_dev_desc_t * dev_desc, int part, disk_partition_t *info);
void print_part (block_dev_desc_t *dev_desc);
void init_part (block_dev_desc_t *dev_desc);
void dev_print(block_dev_desc_t *dev_desc);
#else
static inline block_dev_desc_t* get_dev(char* ifname, int dev) { return NULL; }
static inline block_dev_desc_t* ide_get_dev(int dev) { return NULL; }
static inline block_dev_desc_t* sata_get_dev(int dev) { return NULL; }
static inline block_dev_desc_t* scsi_get_dev(int dev) { return NULL; }
static inline block_dev_desc_t* usb_stor_get_dev(int dev) { return NULL; }
static inline block_dev_desc_t* mmc_get_dev(int dev) { return NULL; }
static inline block_dev_desc_t* systemace_get_dev(int dev) { return NULL; }
static inline block_dev_desc_t* mg_disk_get_dev(int dev) { return NULL; }

static inline int get_partition_info (block_dev_desc_t * dev_desc, int part,
disk_partition_t *info) { return -1; }
static inline void print_part (block_dev_desc_t *dev_desc) {}
static inline void init_part (block_dev_desc_t *dev_desc) {}
static inline void dev_print(block_dev_desc_t *dev_desc) {}
#endif

#ifdef CONFIG_MAC_PARTITION
/* disk/part_mac.c */
int get_partition_info_mac (block_dev_desc_t * dev_desc, int part, disk_partition_t *info);
void print_part_mac (block_dev_desc_t *dev_desc);
int test_part_mac (block_dev_desc_t *dev_desc);
#endif

#ifdef CONFIG_DOS_PARTITION
/* disk/part_dos.c */
int get_partition_info_dos (block_dev_desc_t * dev_desc, int part, disk_partition_t *info);
void print_part_dos (block_dev_desc_t *dev_desc);
int test_part_dos (block_dev_desc_t *dev_desc);
#endif

#ifdef CONFIG_ISO_PARTITION
/* disk/part_iso.c */
int get_partition_info_iso (block_dev_desc_t * dev_desc, int part, disk_partition_t *info);
void print_part_iso (block_dev_desc_t *dev_desc);
int test_part_iso (block_dev_desc_t *dev_desc);
#endif

#ifdef CONFIG_AMIGA_PARTITION
/* disk/part_amiga.c */
int get_partition_info_amiga (block_dev_desc_t * dev_desc, int part, disk_partition_t *info);
void print_part_amiga (block_dev_desc_t *dev_desc);
int test_part_amiga (block_dev_desc_t *dev_desc);
#endif

#ifdef CONFIG_EFI_PARTITION
/* disk/part_efi.c */
int get_partition_info_efi (block_dev_desc_t * dev_desc, int part, disk_partition_t *info);
void print_part_efi (block_dev_desc_t *dev_desc);
int test_part_efi (block_dev_desc_t *dev_desc);
#endif

#define LOG2(x) (((x & 0xaaaaaaaa) ? 1 : 0) + ((x & 0xcccccccc) ? 2 : 0) + \
((x & 0xf0f0f0f0) ? 4 : 0) + ((x & 0xff00ff00) ? 8 : 0) + \
((x & 0xffff0000) ? 16 : 0))

#endif /* _PART_H */

+ 247
- 0
ZZ9000_proto.sdk/ZZ9000Test/src/usb/scsi.h View File

@@ -0,0 +1,247 @@
/* SPDX-License-Identifier: GPL-2.0+ */
/*
* (C) Copyright 2001
* Denis Peter, MPL AG Switzerland
*/
#ifndef _SCSI_H
#define _SCSI_H

struct scsi_cmd {
unsigned char cmd[16]; /* command */
/* for request sense */
unsigned char sense_buf[64]
__attribute__((aligned(ARCH_DMA_MINALIGN)));
unsigned char status; /* SCSI Status */
unsigned char target; /* Target ID */
unsigned char lun; /* Target LUN */
unsigned char cmdlen; /* command len */
unsigned long datalen; /* Total data length */
unsigned char * pdata; /* pointer to data */
unsigned char msgout[12]; /* Messge out buffer (NOT USED) */
unsigned char msgin[12]; /* Message in buffer */
unsigned char sensecmdlen; /* Sense command len */
unsigned long sensedatalen; /* Sense data len */
unsigned char sensecmd[6]; /* Sense command */
unsigned long contr_stat; /* Controller Status */
unsigned long trans_bytes; /* tranfered bytes */

unsigned int priv;
//enum dma_data_direction dma_dir;
};

/*-----------------------------------------------------------
**
** SCSI constants.
**
**-----------------------------------------------------------
*/

/*
** Messages
*/

#define M_COMPLETE (0x00)
#define M_EXTENDED (0x01)
#define M_SAVE_DP (0x02)
#define M_RESTORE_DP (0x03)
#define M_DISCONNECT (0x04)
#define M_ID_ERROR (0x05)
#define M_ABORT (0x06)
#define M_REJECT (0x07)
#define M_NOOP (0x08)
#define M_PARITY (0x09)
#define M_LCOMPLETE (0x0a)
#define M_FCOMPLETE (0x0b)
#define M_RESET (0x0c)
#define M_ABORT_TAG (0x0d)
#define M_CLEAR_QUEUE (0x0e)
#define M_INIT_REC (0x0f)
#define M_REL_REC (0x10)
#define M_TERMINATE (0x11)
#define M_SIMPLE_TAG (0x20)
#define M_HEAD_TAG (0x21)
#define M_ORDERED_TAG (0x22)
#define M_IGN_RESIDUE (0x23)
#define M_IDENTIFY (0x80)

#define M_X_MODIFY_DP (0x00)
#define M_X_SYNC_REQ (0x01)
#define M_X_WIDE_REQ (0x03)
#define M_X_PPR_REQ (0x04)


/*
** Status
*/

#define S_GOOD (0x00)
#define S_CHECK_COND (0x02)
#define S_COND_MET (0x04)
#define S_BUSY (0x08)
#define S_INT (0x10)
#define S_INT_COND_MET (0x14)
#define S_CONFLICT (0x18)
#define S_TERMINATED (0x20)
#define S_QUEUE_FULL (0x28)
#define S_ILLEGAL (0xff)
#define S_SENSE (0x80)

/*
* Sense_keys
*/

#define SENSE_NO_SENSE 0x0
#define SENSE_RECOVERED_ERROR 0x1
#define SENSE_NOT_READY 0x2
#define SENSE_MEDIUM_ERROR 0x3
#define SENSE_HARDWARE_ERROR 0x4
#define SENSE_ILLEGAL_REQUEST 0x5
#define SENSE_UNIT_ATTENTION 0x6
#define SENSE_DATA_PROTECT 0x7
#define SENSE_BLANK_CHECK 0x8
#define SENSE_VENDOR_SPECIFIC 0x9
#define SENSE_COPY_ABORTED 0xA
#define SENSE_ABORTED_COMMAND 0xB
#define SENSE_VOLUME_OVERFLOW 0xD
#define SENSE_MISCOMPARE 0xE


#define SCSI_CHANGE_DEF 0x40 /* Change Definition (Optional) */
#define SCSI_COMPARE 0x39 /* Compare (O) */
#define SCSI_COPY 0x18 /* Copy (O) */
#define SCSI_COP_VERIFY 0x3A /* Copy and Verify (O) */
#define SCSI_INQUIRY 0x12 /* Inquiry (MANDATORY) */
#define SCSI_LOG_SELECT 0x4C /* Log Select (O) */
#define SCSI_LOG_SENSE 0x4D /* Log Sense (O) */
#define SCSI_MODE_SEL6 0x15 /* Mode Select 6-byte (Device Specific) */
#define SCSI_MODE_SEL10 0x55 /* Mode Select 10-byte (Device Specific) */
#define SCSI_MODE_SEN6 0x1A /* Mode Sense 6-byte (Device Specific) */
#define SCSI_MODE_SEN10 0x5A /* Mode Sense 10-byte (Device Specific) */
#define SCSI_READ_BUFF 0x3C /* Read Buffer (O) */
#define SCSI_REQ_SENSE 0x03 /* Request Sense (MANDATORY) */
#define SCSI_SEND_DIAG 0x1D /* Send Diagnostic (O) */
#define SCSI_TST_U_RDY 0x00 /* Test Unit Ready (MANDATORY) */
#define SCSI_WRITE_BUFF 0x3B /* Write Buffer (O) */
/***************************************************************************
* %%% Commands Unique to Direct Access Devices %%%
***************************************************************************/
#define SCSI_COMPARE 0x39 /* Compare (O) */
#define SCSI_FORMAT 0x04 /* Format Unit (MANDATORY) */
#define SCSI_LCK_UN_CAC 0x36 /* Lock Unlock Cache (O) */
#define SCSI_PREFETCH 0x34 /* Prefetch (O) */
#define SCSI_MED_REMOVL 0x1E /* Prevent/Allow medium Removal (O) */
#define SCSI_READ6 0x08 /* Read 6-byte (MANDATORY) */
#define SCSI_READ10 0x28 /* Read 10-byte (MANDATORY) */
#define SCSI_READ16 0x48
#define SCSI_RD_CAPAC 0x25 /* Read Capacity (MANDATORY) */
#define SCSI_RD_CAPAC10 SCSI_RD_CAPAC /* Read Capacity (10) */
#define SCSI_RD_CAPAC16 0x9e /* Read Capacity (16) */
#define SCSI_RD_DEFECT 0x37 /* Read Defect Data (O) */
#define SCSI_READ_LONG 0x3E /* Read Long (O) */
#define SCSI_REASS_BLK 0x07 /* Reassign Blocks (O) */
#define SCSI_RCV_DIAG 0x1C /* Receive Diagnostic Results (O) */
#define SCSI_RELEASE 0x17 /* Release Unit (MANDATORY) */
#define SCSI_REZERO 0x01 /* Rezero Unit (O) */
#define SCSI_SRCH_DAT_E 0x31 /* Search Data Equal (O) */
#define SCSI_SRCH_DAT_H 0x30 /* Search Data High (O) */
#define SCSI_SRCH_DAT_L 0x32 /* Search Data Low (O) */
#define SCSI_SEEK6 0x0B /* Seek 6-Byte (O) */
#define SCSI_SEEK10 0x2B /* Seek 10-Byte (O) */
#define SCSI_SEND_DIAG 0x1D /* Send Diagnostics (MANDATORY) */
#define SCSI_SET_LIMIT 0x33 /* Set Limits (O) */
#define SCSI_START_STP 0x1B /* Start/Stop Unit (O) */
#define SCSI_SYNC_CACHE 0x35 /* Synchronize Cache (O) */
#define SCSI_VERIFY 0x2F /* Verify (O) */
#define SCSI_WRITE6 0x0A /* Write 6-Byte (MANDATORY) */
#define SCSI_WRITE10 0x2A /* Write 10-Byte (MANDATORY) */
#define SCSI_WRT_VERIFY 0x2E /* Write and Verify (O) */
#define SCSI_WRITE_LONG 0x3F /* Write Long (O) */
#define SCSI_WRITE_SAME 0x41 /* Write Same (O) */

/**
* struct scsi_platdata - stores information about SCSI controller
*
* @base: Controller base address
* @max_lun: Maximum number of logical units
* @max_id: Maximum number of target ids
* @max_bytes_per_req: Maximum number of bytes per read/write request
*/
struct scsi_platdata {
unsigned long base;
unsigned long max_lun;
unsigned long max_id;
unsigned long max_bytes_per_req;
};

/* Operations for SCSI */
struct scsi_ops {
/**
* exec() - execute a command
*
* @dev: SCSI bus
* @cmd: Command to execute
* @return 0 if OK, -ve on error
*/
int (*exec)(void *dev, struct scsi_cmd *cmd);

/**
* bus_reset() - reset the bus
*
* @dev: SCSI bus to reset
* @return 0 if OK, -ve on error
*/
int (*bus_reset)(void *dev);
};

#define scsi_get_ops(dev) ((struct scsi_ops *)(dev)->driver->ops)

extern struct scsi_ops scsi_ops;

/**
* scsi_exec() - execute a command
*
* @dev: SCSI bus
* @cmd: Command to execute
* @return 0 if OK, -ve on error
*/
int scsi_exec(void *dev, struct scsi_cmd *cmd);

/**
* scsi_bus_reset() - reset the bus
*
* @dev: SCSI bus to reset
* @return 0 if OK, -ve on error
*/
int scsi_bus_reset(void *dev);

/**
* scsi_scan() - Scan all SCSI controllers for available devices
*
* @vebose: true to show information about each device found
*/
int scsi_scan(bool verbose);

/**
* scsi_scan_dev() - scan a SCSI bus and create devices
*
* @dev: SCSI bus
* @verbose: true to show information about each device found
*/
int scsi_scan_dev(void *dev, bool verbose);

#ifndef CONFIG_DM_SCSI
void scsi_low_level_init(int busdevfunc);
void scsi_init(void);
#endif

#define SCSI_IDENTIFY 0xC0 /* not used */

/* Hardware errors */
#define SCSI_SEL_TIME_OUT 0x00000101 /* Selection time out */
#define SCSI_HNS_TIME_OUT 0x00000102 /* Handshake */
#define SCSI_MA_TIME_OUT 0x00000103 /* Phase error */
#define SCSI_UNEXP_DIS 0x00000104 /* unexpected disconnect */

#define SCSI_INT_STATE 0x00010000 /* unknown Interrupt number is stored in 16 LSB */

#endif /* _SCSI_H */

+ 25
- 25
ZZ9000_proto.sdk/ZZ9000Test/src/usb/usb.c View File

@@ -90,7 +90,7 @@ int usb_init(void)
*/
controllers_initialized++;
start_index = dev_index;
printf("scanning bus %d for devices... ", i);
printf("[usb] scanning bus %d for devices... ", i);
ret = usb_alloc_new_device(ctrl, &dev);
if (ret)
break;
@@ -104,17 +104,16 @@ int usb_init(void)
usb_free_device(dev->controller);

if (start_index == dev_index) {
puts("No USB Device found\n");
puts("[usb] No USB Device found\n");
continue;
} else {
printf("%d USB Device(s) found\n",
printf("[usb] %d USB Device(s) found\n",
dev_index - start_index);
}

usb_started = 1;
}

printf("scan end\n");
/* if we were not able to find at least one working bus, bail out */
if (controllers_initialized == 0)
puts("USB error: all controllers failed lowlevel init\n");
@@ -190,7 +189,7 @@ int usb_disable_asynch(int disable)
/*
* submits an Interrupt Message
*/
int usb_submit_int_msg(struct usb_device *dev, unsigned long pipe,
int usb_int_msg(struct usb_device *dev, unsigned long pipe,
void *buffer, int transfer_len, int interval)
{
return submit_int_msg(dev, pipe, buffer, transfer_len, interval);
@@ -224,9 +223,10 @@ int usb_control_msg(struct usb_device *dev, unsigned int pipe,
setup_packet->value = cpu_to_le16(value);
setup_packet->index = cpu_to_le16(index);
setup_packet->length = cpu_to_le16(size);
printf("[usb] usb_control_msg: request: 0x%X, requesttype: 0x%X, " \
"value 0x%X index 0x%X length 0x%X\n",
request, requesttype, value, index, size);
// FIXME debug option
//printf("[usb] usb_control_msg: request: 0x%X, requesttype: 0x%X, " \
// "value 0x%X index 0x%X length 0x%X\n",
// request, requesttype, value, index, size);
dev->status = USB_ST_NOT_PROC; /*not yet processed */

err = submit_control_msg(dev, pipe, data, size, setup_packet);
@@ -244,7 +244,7 @@ int usb_control_msg(struct usb_device *dev, unsigned int pipe,
if (!((volatile unsigned long)dev->status & USB_ST_NOT_PROC)) {
break;
}
mdelay(2); // FIXME mntmn
mdelay(1);
}
if (timeout==0) {
printf("[usb] usb_control_msg timeout!\n");
@@ -334,15 +334,15 @@ static void usb_set_maxpacket_ep(struct usb_device *dev, int if_idx, int ep_idx)
/* OUT Endpoint */
if (ep_wMaxPacketSize > dev->epmaxpacketout[b]) {
dev->epmaxpacketout[b] = ep_wMaxPacketSize;
printf("##EP epmaxpacketout[%d] = %d\n",
b, dev->epmaxpacketout[b]);
//printf("##EP epmaxpacketout[%d] = %d\n",
// b, dev->epmaxpacketout[b]);
}
} else {
/* IN Endpoint */
if (ep_wMaxPacketSize > dev->epmaxpacketin[b]) {
dev->epmaxpacketin[b] = ep_wMaxPacketSize;
printf("##EP epmaxpacketin[%d] = %d\n",
b, dev->epmaxpacketin[b]);
//printf("##EP epmaxpacketin[%d] = %d\n",
// b, dev->epmaxpacketin[b]);
}
} /* if out */
} /* if control */
@@ -471,7 +471,7 @@ static int usb_parse_config(struct usb_device *dev,
if_desc[ifno].\
ep_desc[epno].\
wMaxPacketSize);
printf("if %d, ep %d\n", ifno, epno);
//printf("if %d, ep %d\n", ifno, epno);
break;
case USB_DT_SS_ENDPOINT_COMP:
if (head->bLength != USB_DT_SS_EP_COMP_SIZE) {
@@ -594,8 +594,8 @@ int usb_get_configuration_no(struct usb_device *dev, int cfgno,

config = (struct usb_config_descriptor *)&buffer[0];
result = usb_get_descriptor(dev, USB_DT_CONFIG, cfgno, buffer, length);
printf("get_conf_no %d Result %d, wLength %d\n", cfgno, result,
le16_to_cpu(config->wTotalLength));
//printf("get_conf_no %d Result %d, wLength %d\n", cfgno, result,
// le16_to_cpu(config->wTotalLength));
config->wTotalLength = result; /* validated, with CPU byte order */

return result;
@@ -607,7 +607,7 @@ int usb_get_configuration_no(struct usb_device *dev, int cfgno,
*/
static int usb_set_address(struct usb_device *dev)
{
printf("set address %d\n", dev->devnum);
printf("[usb] set address %d\n", dev->devnum);

return usb_control_msg(dev, usb_snddefctrl(dev), USB_REQ_SET_ADDRESS,
0, (dev->devnum), 0, NULL, 0, USB_CNTL_TIMEOUT);
@@ -657,7 +657,7 @@ int usb_set_interface(struct usb_device *dev, int interface, int alternate)
static int usb_set_configuration(struct usb_device *dev, int configuration)
{
int res;
printf("set configuration %d\n", configuration);
printf("[usb] set configuration %d\n", configuration);
/* set setup command */
res = usb_control_msg(dev, usb_sndctrlpipe(dev, 0),
USB_REQ_SET_CONFIGURATION, 0,
@@ -819,7 +819,7 @@ int usb_string(struct usb_device *dev, int index, char *buf, size_t size)
dev->have_langid = -1;
dev->string_langid = tbuf[2] | (tbuf[3] << 8);
/* always use the first langid listed */
printf("USB device number %d default " \
printf("[usb] USB device number %d default " \
"language ID 0x%x\n",
dev->devnum, dev->string_langid);
}
@@ -863,7 +863,7 @@ struct usb_device *usb_get_dev_index(int index)
int usb_alloc_new_device(void *controller, struct usb_device **devp)
{
int i;
printf("New Device %d\n", dev_index);
printf("[usb] new device %d\n", dev_index);
if (dev_index == USB_MAX_DEVICE) {
printf("ERROR, too many USB Devices, max=%d\n", USB_MAX_DEVICE);
return -ENOSPC;
@@ -1123,9 +1123,9 @@ int usb_select_config(struct usb_device *dev)
*/
mdelay(10);

printf("new device strings: Mfr=%d, Product=%d, SerialNumber=%d\n",
/*printf("new device strings: Mfr=%d, Product=%d, SerialNumber=%d\n",
dev->descriptor.iManufacturer, dev->descriptor.iProduct,
dev->descriptor.iSerialNumber);
dev->descriptor.iSerialNumber);*/
memset(dev->mf, 0, sizeof(dev->mf));
memset(dev->prod, 0, sizeof(dev->prod));
memset(dev->serial, 0, sizeof(dev->serial));
@@ -1138,9 +1138,9 @@ int usb_select_config(struct usb_device *dev)
if (dev->descriptor.iSerialNumber)
usb_string(dev, dev->descriptor.iSerialNumber,
dev->serial, sizeof(dev->serial));
printf("Manufacturer %s\n", dev->mf);
printf("Product %s\n", dev->prod);
printf("SerialNumber %s\n", dev->serial);
printf("[usb] Manufacturer %s\n", dev->mf);
printf("[usb] Product %s\n", dev->prod);
printf("[usb] SerialNumber %s\n", dev->serial);

return 0;
}

+ 6
- 7
ZZ9000_proto.sdk/ZZ9000Test/src/usb/usb.h View File

@@ -49,7 +49,7 @@
* This is the timeout to allow for submitting an urb in ms. We allow more
* time for a BULK device to react - some are slow.
*/
#define USB_TIMEOUT_MS(pipe) (usb_pipebulk(pipe) ? 5000 : 1000)
#define USB_TIMEOUT_MS(pipe) (usb_pipebulk(pipe) ? 20000 : 4000) // FIXME quadrupled

/* device request (setup) */
struct devrequest {
@@ -221,13 +221,12 @@ int board_usb_init(int index, enum usb_init_type init);
*/
int board_usb_cleanup(int index, enum usb_init_type init);

#ifdef CONFIG_USB_STORAGE

#define USB_MAX_STOR_DEV 7
#define USB_MAX_STOR_DEV 1
int usb_stor_scan(int mode);
int usb_stor_info(void);

#endif
unsigned long usb_stor_read_direct(int dev_index, unsigned long blknr, unsigned long blkcnt, void *buffer);
unsigned long usb_stor_write_direct(int dev_index, unsigned long blknr, unsigned long blkcnt, void *buffer);
unsigned long usb_stor_get_capacity(int dev_index);

#ifdef CONFIG_USB_HOST_ETHER

@@ -257,7 +256,7 @@ int usb_control_msg(struct usb_device *dev, unsigned int pipe,
void *data, unsigned short size, int timeout);
int usb_bulk_msg(struct usb_device *dev, unsigned int pipe,
void *data, int len, int *actual_length, int timeout);
int usb_submit_int_msg(struct usb_device *dev, unsigned long pipe,
int usb_int_msg(struct usb_device *dev, unsigned long pipe,
void *buffer, int transfer_len, int interval);
int usb_disable_asynch(int disable);
int usb_maxpacket(struct usb_device *dev, unsigned long pipe);

+ 1399
- 0
ZZ9000_proto.sdk/ZZ9000Test/src/usb/usb_storage.c
File diff suppressed because it is too large
View File


Loading…
Cancel
Save