fixed a few bugs but still no go.
Seem to have problems with global variables?
This commit is contained in:
@@ -33,16 +33,15 @@ SECTIONS
|
||||
OBJDIR/illegal_instruction.o(.text)
|
||||
OBJDIR/supervisor.o(.text)
|
||||
OBJDIR/mmu.o(.text)
|
||||
|
||||
OBJDIR/BaS.o(.text)
|
||||
OBJDIR/pci.o(.text)
|
||||
OBJDIR/usb.o(.text)
|
||||
OBJDIR/usb_mem.o(.text)
|
||||
OBJDIR/ohci-hcd.o(.text)
|
||||
OBJDIR/ehci-hcd.o(.text)
|
||||
|
||||
OBJDIR/BaS.o(.text)
|
||||
OBJDIR/wait.o(.text)
|
||||
|
||||
/* put other routines into the same segment (RAM) as BaS.o */
|
||||
OBJDIR/unicode.o(.text)
|
||||
OBJDIR/mmc.o(.text)
|
||||
OBJDIR/ff.o(.text)
|
||||
@@ -105,7 +104,7 @@ SECTIONS
|
||||
*/
|
||||
. = ALIGN(16);
|
||||
_usb_buffer = .;
|
||||
. = . + USB_BUFFER_SIZE;
|
||||
//. = . + USB_BUFFER_SIZE;
|
||||
} > bas_ram
|
||||
#endif
|
||||
|
||||
@@ -179,6 +178,9 @@ SECTIONS
|
||||
__RAMBAR0 = 0xFF100000;
|
||||
__RAMBAR0_SIZE = 0x00001000;
|
||||
|
||||
/* 4KB on-chip Core SRAM1 */
|
||||
__RAMBAR1 = 0xFF101000;
|
||||
__RAMBAR1_SIZE = 0x00001000;
|
||||
__SUP_SP = __RAMBAR0 + __RAMBAR0_SIZE - 4;
|
||||
|
||||
/* system variables */
|
||||
@@ -202,7 +204,4 @@ SECTIONS
|
||||
_video_sbt = __RAMBAR0 + 0x83C;
|
||||
_rt_mbar = __RAMBAR0 + 0x844; /* (c)0f */
|
||||
|
||||
/* 4KB on-chip Core SRAM1 */
|
||||
__RAMBAR1 = 0xFF101000;
|
||||
__RAMBAR1_SIZE = 0x00001000;
|
||||
}
|
||||
|
||||
@@ -446,26 +446,6 @@ static ed_t * ep_add_ed(ohci_t * ohci, struct usb_device * usb_dev, uint32_t pip
|
||||
/* we need more TDs than EDs */
|
||||
#define NUM_TD 64
|
||||
|
||||
/* pointers to aligned storage */
|
||||
extern td_t *ptd;
|
||||
|
||||
/* TDs ... */
|
||||
static inline struct td *td_alloc(struct usb_device *usb_dev)
|
||||
{
|
||||
int i;
|
||||
struct td *td;
|
||||
td = NULL;
|
||||
for (i = 0; i < NUM_TD; i++)
|
||||
{
|
||||
if (ptd[i].usb_dev == NULL)
|
||||
{
|
||||
td = &ptd[i];
|
||||
td->usb_dev = usb_dev;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return td;
|
||||
}
|
||||
|
||||
static inline void ed_free(struct ed *ed)
|
||||
{
|
||||
|
||||
@@ -228,7 +228,7 @@ typedef struct
|
||||
* this is how the lowlevel part communicate with the outer world
|
||||
*/
|
||||
|
||||
int ohci_usb_lowlevel_init(long handle, const struct pci_device_id *ent, void **priv);
|
||||
int ohci_usb_lowlevel_init(uint16_t handle, const struct pci_device_id *ent, void **priv);
|
||||
int ohci_usb_lowlevel_stop(void *priv);
|
||||
int ohci_submit_bulk_msg(struct usb_device *dev, uint32_t pipe, void *buffer, int transfer_len);
|
||||
int ohci_submit_control_msg(struct usb_device *dev, uint32_t pipe, void *buffer, int transfer_len, struct devrequest *setup);
|
||||
@@ -270,7 +270,7 @@ void usb_mem_stop(void);
|
||||
/* routines */
|
||||
USB_COOKIE *usb_get_cookie(long id);
|
||||
void usb_error_msg(const char *const fmt, ... );
|
||||
int usb_init(long handle, const struct pci_device_id *ent); /* initialize the USB Controller */
|
||||
int usb_init(uint16_t handle, const struct pci_device_id *ent); /* initialize the USB Controller */
|
||||
int usb_stop(void); /* stop the USB Controller */
|
||||
|
||||
int usb_set_protocol(struct usb_device *dev, int ifnum, int protocol);
|
||||
|
||||
@@ -49,6 +49,7 @@
|
||||
#include "wait.h" /* for wait routines */
|
||||
#include "bas_printf.h"
|
||||
#include "bas_string.h" /* for memset() */
|
||||
#include "pci.h"
|
||||
|
||||
//extern xQueueHandle queue_poll_hub;
|
||||
|
||||
@@ -133,7 +134,7 @@ extern void udelay(long usec);
|
||||
|
||||
/* global ohci_t */
|
||||
static ohci_t gohci[2];
|
||||
char ohci_inited;
|
||||
int ohci_inited;
|
||||
|
||||
static inline uint32_t roothub_a(ohci_t *ohci) { return readl(&ohci->regs->roothub.a); }
|
||||
static inline uint32_t roothub_b(ohci_t *ohci) { return readl(&ohci->regs->roothub.b); }
|
||||
@@ -147,6 +148,27 @@ static void td_submit_job(ohci_t *ohci, struct usb_device *dev, uint32_t pipe,
|
||||
void *buffer, int transfer_len, struct devrequest *setup,
|
||||
urb_priv_t *urb, int interval);
|
||||
|
||||
|
||||
static struct td *ptd;
|
||||
|
||||
/* TDs ... */
|
||||
static struct td *td_alloc(struct usb_device *usb_dev)
|
||||
{
|
||||
int i;
|
||||
struct td *td;
|
||||
td = NULL;
|
||||
for (i = 0; i < NUM_TD; i++)
|
||||
{
|
||||
if (ptd[i].usb_dev == NULL)
|
||||
{
|
||||
td = &ptd[i];
|
||||
td->usb_dev = usb_dev;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return td;
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------*
|
||||
* URB support functions
|
||||
*-------------------------------------------------------------------------*/
|
||||
@@ -449,10 +471,12 @@ static int sohci_submit_job(ohci_t *ohci, urb_priv_t *urb, struct devrequest *se
|
||||
return -1;
|
||||
}
|
||||
purb_priv->pipe = pipe;
|
||||
|
||||
/* fill the private part of the URB */
|
||||
purb_priv->length = size;
|
||||
purb_priv->ed = ed;
|
||||
purb_priv->actual_length = 0;
|
||||
|
||||
/* allocate the TDs */
|
||||
/* note that td[0] was allocated in ep_add_ed */
|
||||
for (i = 0; i < size; i++)
|
||||
@@ -475,6 +499,7 @@ static int sohci_submit_job(ohci_t *ohci, urb_priv_t *urb, struct devrequest *se
|
||||
/* link the ed into a chain if is not already */
|
||||
if (ed->state != ED_OPER)
|
||||
ep_link(ohci, ed);
|
||||
|
||||
/* fill the TDs and link it to the ed */
|
||||
td_submit_job(ohci, dev, pipe, buffer, transfer_len, setup, purb_priv, interval);
|
||||
return 0;
|
||||
@@ -1895,15 +1920,13 @@ static void hc_free_buffers(ohci_t *ohci)
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------*/
|
||||
|
||||
td_t *ptd;
|
||||
/*
|
||||
* low level initalisation routine, called from usb.c
|
||||
*/
|
||||
int ohci_usb_lowlevel_init(long handle, const struct pci_device_id *ent, void **priv)
|
||||
int ohci_usb_lowlevel_init(uint16_t handle, const struct pci_device_id *ent, void **priv)
|
||||
{
|
||||
uint32_t usb_base_addr = 0xFFFFFFFF;
|
||||
ohci_t *ohci = &gohci[(handle >> 16) & 1]; // function & 1
|
||||
ohci_t *ohci = &gohci[PCI_FUNCTION_FROM_HANDLE(handle) & 1];
|
||||
PCI_RSC_DESC *pci_rsc_desc = (PCI_RSC_DESC *) pci_get_resource(handle); /* USB OHCI */
|
||||
|
||||
if (handle && (ent != NULL))
|
||||
@@ -1916,7 +1939,9 @@ int ohci_usb_lowlevel_init(long handle, const struct pci_device_id *ent, void **
|
||||
return(-1);
|
||||
|
||||
info("ohci %p", ohci);
|
||||
|
||||
ohci->controller = (ohci->handle >> 16) & 3; /* PCI function */
|
||||
|
||||
/* this must be aligned to a 256 byte boundary */
|
||||
ohci->hcca_unaligned = (struct ohci_hcca *) usb_malloc(sizeof(struct ohci_hcca) + 256);
|
||||
if (ohci->hcca_unaligned == NULL)
|
||||
@@ -1924,6 +1949,7 @@ int ohci_usb_lowlevel_init(long handle, const struct pci_device_id *ent, void **
|
||||
err("HCCA malloc failed");
|
||||
return(-1);
|
||||
}
|
||||
|
||||
/* align the storage */
|
||||
ohci->hcca = (struct ohci_hcca *) (((uint32_t)ohci->hcca_unaligned + 255) & ~255);
|
||||
memset(ohci->hcca, 0, sizeof(struct ohci_hcca));
|
||||
@@ -1939,7 +1965,7 @@ int ohci_usb_lowlevel_init(long handle, const struct pci_device_id *ent, void **
|
||||
memset(ohci->ohci_dev, 0, sizeof(struct ohci_device));
|
||||
info("aligned EDs %p", ohci->ohci_dev);
|
||||
|
||||
ohci->td_unaligned = (td_t *) usb_malloc(sizeof(td_t) * (NUM_TD + 1));
|
||||
ohci->td_unaligned = (struct td *) usb_malloc(sizeof(struct td) * (NUM_TD + 1));
|
||||
if (ohci->td_unaligned == NULL)
|
||||
{
|
||||
err("TDs malloc failed");
|
||||
@@ -1947,7 +1973,7 @@ int ohci_usb_lowlevel_init(long handle, const struct pci_device_id *ent, void **
|
||||
return(-1);
|
||||
}
|
||||
|
||||
ptd = (td_t *) (((uint32_t) ohci->td_unaligned + 7) & ~7);
|
||||
ptd = (struct td *) (((uint32_t) ohci->td_unaligned + 7) & ~7);
|
||||
|
||||
xprintf("memset from %p to %p\r\n", ptd, ptd + sizeof(td_t) * NUM_TD);
|
||||
memset(ptd, 0, sizeof(td_t) * NUM_TD);
|
||||
@@ -1956,21 +1982,24 @@ int ohci_usb_lowlevel_init(long handle, const struct pci_device_id *ent, void **
|
||||
ohci->disabled = 1;
|
||||
ohci->sleeping = 0;
|
||||
ohci->irq = -1;
|
||||
if ((long) pci_rsc_desc >= 0)
|
||||
xprintf("pci_rsc_desc: %p\r\n", pci_rsc_desc);
|
||||
if (pci_rsc_desc != NULL)
|
||||
{
|
||||
unsigned short flags;
|
||||
do
|
||||
{
|
||||
dbg("PCI USB descriptors: flags 0x%04x start 0x%08lx \r\n offset 0x%08lx dmaoffset 0x%08lx length 0x%08lx",
|
||||
xprintf("PCI USB descriptors: flags 0x%04x start 0x%08lx \r\n offset 0x%08lx dmaoffset 0x%08lx length 0x%08lx",
|
||||
pci_rsc_desc->flags, pci_rsc_desc->start, pci_rsc_desc->offset, pci_rsc_desc->dmaoffset, pci_rsc_desc->length);
|
||||
if (!(pci_rsc_desc->flags & FLG_IO))
|
||||
{
|
||||
if (usb_base_addr == 0xFFFFFFFF)
|
||||
{
|
||||
usb_base_addr = pci_rsc_desc->start;
|
||||
xprintf("usb_base_addr = %p\r\n", usb_base_addr);
|
||||
ohci->offset = pci_rsc_desc->offset;
|
||||
ohci->regs = (void *)(pci_rsc_desc->offset + pci_rsc_desc->start);
|
||||
ohci->dma_offset = pci_rsc_desc->dmaoffset;
|
||||
|
||||
/* big_endian unused actually */
|
||||
if ((pci_rsc_desc->flags & FLG_ENDMASK) == ORD_MOTOROLA)
|
||||
ohci->big_endian = 0; /* host bridge make swapping intel -> motorola */
|
||||
@@ -1986,6 +2015,7 @@ int ohci_usb_lowlevel_init(long handle, const struct pci_device_id *ent, void **
|
||||
else
|
||||
{
|
||||
hc_free_buffers(ohci);
|
||||
xprintf("pci_get_resource() failed in %s %s\r\n", __FILE__, __LINE__);
|
||||
return(-1); /* get_resource error */
|
||||
}
|
||||
if (usb_base_addr == 0xFFFFFFFF)
|
||||
|
||||
@@ -184,7 +184,7 @@ PCI_RSC_DESC *pci_get_resource(uint16_t handle)
|
||||
index = i;
|
||||
if (index == -1)
|
||||
return NULL;
|
||||
return resource_descriptors[handles[index].index];
|
||||
return resource_descriptors[index];
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -111,7 +111,7 @@ extern int printk(PRINTK_INFO *info, const char *fmt, va_list ap);
|
||||
/***************************************************************************
|
||||
* Init USB Device
|
||||
*/
|
||||
int usb_init(long handle, const struct pci_device_id *ent)
|
||||
int usb_init(uint16_t handle, const struct pci_device_id *ent)
|
||||
{
|
||||
void *priv;
|
||||
int res = 0;
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
#include "bas_string.h"
|
||||
#include "bas_printf.h"
|
||||
#include "usb.h"
|
||||
|
||||
#if MACHINE_FIREBEE
|
||||
#include "firebee.h"
|
||||
#elif MACHINE_M5484LITE
|
||||
@@ -40,7 +41,7 @@ extern int asm_set_ipl(int level);
|
||||
extern void *info_fvdi;
|
||||
extern long offscren_reserved(void);
|
||||
|
||||
extern uint8_t usb_buffer[]; /* defined in linker control file */
|
||||
extern uint8_t usb_buffer[USB_BUFFER_SIZE]; /* defined in linker control file */
|
||||
|
||||
/* MD - Memory Descriptor */
|
||||
|
||||
|
||||
Reference in New Issue
Block a user