more USB work
This commit is contained in:
@@ -1,3 +1,3 @@
|
|||||||
// ADD PREDEFINED MACROS HERE!
|
// ADD PREDEFINED MACROS HERE!
|
||||||
//#define MACHINE_FIREBEE
|
#define MACHINE_FIREBEE
|
||||||
#define MACHINE_M5484LITE
|
// #define MACHINE_M5484LITE
|
||||||
|
|||||||
@@ -33,8 +33,8 @@
|
|||||||
#define BOOTFLASH_SIZE 0x800000
|
#define BOOTFLASH_SIZE 0x800000
|
||||||
#define BOOTFLASH_BAM (BOOTFLASH_SIZE - 1)
|
#define BOOTFLASH_BAM (BOOTFLASH_SIZE - 1)
|
||||||
|
|
||||||
#define SDRAM_START 0x00000000 /* start at address 0 */
|
#define SDRAM_START 0x40000000 /* start at address 40000000 */
|
||||||
#define SDRAM_SIZE 0x8000000
|
#define SDRAM_SIZE 0x10000000 /* 256 MB */
|
||||||
|
|
||||||
#ifdef COMPILE_RAM
|
#ifdef COMPILE_RAM
|
||||||
#define TARGET_ADDRESS (SDRAM_START + SDRAM_SIZE - 0x200000)
|
#define TARGET_ADDRESS (SDRAM_START + SDRAM_SIZE - 0x200000)
|
||||||
|
|||||||
@@ -80,7 +80,7 @@ struct ed
|
|||||||
uint32_t hwHeadP;
|
uint32_t hwHeadP;
|
||||||
uint32_t hwNextED;
|
uint32_t hwNextED;
|
||||||
|
|
||||||
struct ed *ed_prev;
|
volatile struct ed *ed_prev;
|
||||||
uint8_t int_period;
|
uint8_t int_period;
|
||||||
uint8_t int_branch;
|
uint8_t int_branch;
|
||||||
uint8_t int_load;
|
uint8_t int_load;
|
||||||
@@ -91,7 +91,7 @@ struct ed
|
|||||||
struct ed *ed_rm_list;
|
struct ed *ed_rm_list;
|
||||||
|
|
||||||
struct usb_device *usb_dev;
|
struct usb_device *usb_dev;
|
||||||
void *purb;
|
volatile void *purb;
|
||||||
uint32_t unused[2];
|
uint32_t unused[2];
|
||||||
} __attribute__((aligned(16)));
|
} __attribute__((aligned(16)));
|
||||||
typedef struct ed ed_t;
|
typedef struct ed ed_t;
|
||||||
@@ -145,8 +145,8 @@ struct td
|
|||||||
uint16_t hwPSW[MAXPSW];
|
uint16_t hwPSW[MAXPSW];
|
||||||
uint8_t unused;
|
uint8_t unused;
|
||||||
uint8_t index;
|
uint8_t index;
|
||||||
struct ed *ed;
|
volatile struct ed *ed;
|
||||||
struct td *next_dl_td;
|
volatile struct td *next_dl_td;
|
||||||
struct usb_device *usb_dev;
|
struct usb_device *usb_dev;
|
||||||
int transfer_len;
|
int transfer_len;
|
||||||
uint32_t data;
|
uint32_t data;
|
||||||
@@ -166,7 +166,7 @@ typedef struct td td_t;
|
|||||||
#define NUM_INTS 32 /* part of the OHCI standard */
|
#define NUM_INTS 32 /* part of the OHCI standard */
|
||||||
struct ohci_hcca
|
struct ohci_hcca
|
||||||
{
|
{
|
||||||
uint32_t int_table[NUM_INTS]; /* Interrupt ED table */
|
volatile uint32_t int_table[NUM_INTS]; /* Interrupt ED table */
|
||||||
#if defined(CONFIG_MPC5200)
|
#if defined(CONFIG_MPC5200)
|
||||||
uint16_t pad1; /* set to 0 on each frame_no change */
|
uint16_t pad1; /* set to 0 on each frame_no change */
|
||||||
uint16_t frame_no; /* current frame number */
|
uint16_t frame_no; /* current frame number */
|
||||||
@@ -372,7 +372,7 @@ struct virt_root_hub
|
|||||||
#define N_URB_TD 48
|
#define N_URB_TD 48
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
ed_t *ed;
|
volatile ed_t *ed;
|
||||||
uint16_t length; /* number of tds associated with this request */
|
uint16_t length; /* number of tds associated with this request */
|
||||||
uint16_t td_cnt; /* number of tds already serviced */
|
uint16_t td_cnt; /* number of tds already serviced */
|
||||||
struct usb_device *dev;
|
struct usb_device *dev;
|
||||||
@@ -411,8 +411,8 @@ typedef struct ohci
|
|||||||
/* ---- end of common part ---- */
|
/* ---- end of common part ---- */
|
||||||
int big_endian; /* PCI BIOS */
|
int big_endian; /* PCI BIOS */
|
||||||
int controller;
|
int controller;
|
||||||
struct ohci_hcca *hcca_unaligned;
|
volatile struct ohci_hcca *hcca_unaligned;
|
||||||
struct ohci_hcca *hcca; /* hcca */
|
volatile struct ohci_hcca *hcca; /* hcca */
|
||||||
td_t *td_unaligned;
|
td_t *td_unaligned;
|
||||||
struct ohci_device *ohci_dev_unaligned;
|
struct ohci_device *ohci_dev_unaligned;
|
||||||
/* this allocates EDs for all possible endpoints */
|
/* this allocates EDs for all possible endpoints */
|
||||||
@@ -420,7 +420,7 @@ typedef struct ohci
|
|||||||
|
|
||||||
int irq_enabled;
|
int irq_enabled;
|
||||||
int stat_irq;
|
int stat_irq;
|
||||||
int irq;
|
volatile int irq;
|
||||||
int disabled; /* e.g. got a UE, we're hung */
|
int disabled; /* e.g. got a UE, we're hung */
|
||||||
int sleeping;
|
int sleeping;
|
||||||
#define OHCI_FLAGS_NEC 0x80000000
|
#define OHCI_FLAGS_NEC 0x80000000
|
||||||
@@ -428,12 +428,12 @@ typedef struct ohci
|
|||||||
|
|
||||||
uint32_t offset;
|
uint32_t offset;
|
||||||
uint32_t dma_offset;
|
uint32_t dma_offset;
|
||||||
struct ohci_regs *regs; /* OHCI controller's memory */
|
volatile struct ohci_regs *regs; /* OHCI controller's memory */
|
||||||
|
|
||||||
int ohci_int_load[32]; /* load of the 32 Interrupt Chains (for load balancing)*/
|
int ohci_int_load[32]; /* load of the 32 Interrupt Chains (for load balancing)*/
|
||||||
ed_t *ed_rm_list[2]; /* lists of all endpoints to be removed */
|
volatile ed_t *ed_rm_list[2]; /* lists of all endpoints to be removed */
|
||||||
ed_t *ed_bulktail; /* last endpoint of bulk list */
|
volatile ed_t *ed_bulktail; /* last endpoint of bulk list */
|
||||||
ed_t *ed_controltail; /* last endpoint of control list */
|
volatile ed_t *ed_controltail; /* last endpoint of control list */
|
||||||
int intrstatus;
|
int intrstatus;
|
||||||
uint32_t hc_control; /* copy of the hc control reg */
|
uint32_t hc_control; /* copy of the hc control reg */
|
||||||
uint32_t ndp; /* copy NDP from roothub_a */
|
uint32_t ndp; /* copy NDP from roothub_a */
|
||||||
@@ -447,9 +447,9 @@ typedef struct ohci
|
|||||||
|
|
||||||
/* hcd */
|
/* hcd */
|
||||||
/* endpoint */
|
/* endpoint */
|
||||||
static int ep_link(ohci_t * ohci, ed_t * ed);
|
static int ep_link(volatile ohci_t * ohci, volatile ed_t *ed);
|
||||||
static int ep_unlink(ohci_t * ohci, ed_t * ed);
|
static int ep_unlink(volatile ohci_t * ohci, volatile ed_t *ed);
|
||||||
static ed_t * ep_add_ed(ohci_t * ohci, struct usb_device * usb_dev, uint32_t pipe, int interval, int load);
|
static ed_t * ep_add_ed(volatile ohci_t * ohci, struct usb_device * usb_dev, uint32_t pipe, int interval, int load);
|
||||||
|
|
||||||
|
|
||||||
/* we need more TDs than EDs */
|
/* we need more TDs than EDs */
|
||||||
|
|||||||
@@ -26,6 +26,7 @@
|
|||||||
#ifndef _USB_DEFS_H_
|
#ifndef _USB_DEFS_H_
|
||||||
#define _USB_DEFS_H_
|
#define _USB_DEFS_H_
|
||||||
|
|
||||||
|
#define CONFIG_USB_INTERRUPT_POLLING
|
||||||
/* USB constants */
|
/* USB constants */
|
||||||
|
|
||||||
/* Device and/or Interface Class codes */
|
/* Device and/or Interface Class codes */
|
||||||
|
|||||||
@@ -30,6 +30,7 @@
|
|||||||
#include "ehci.h"
|
#include "ehci.h"
|
||||||
#include "pci.h"
|
#include "pci.h"
|
||||||
|
|
||||||
|
// #define DEBUG
|
||||||
#include "debug.h"
|
#include "debug.h"
|
||||||
|
|
||||||
static char ehci_inited;
|
static char ehci_inited;
|
||||||
|
|||||||
@@ -49,7 +49,7 @@
|
|||||||
#include "pci.h"
|
#include "pci.h"
|
||||||
#include "interrupts.h"
|
#include "interrupts.h"
|
||||||
|
|
||||||
// // #define DEBUG
|
// #define DEBUG
|
||||||
#include "debug.h"
|
#include "debug.h"
|
||||||
|
|
||||||
#undef OHCI_USE_NPS /* force NoPowerSwitching mode */
|
#undef OHCI_USE_NPS /* force NoPowerSwitching mode */
|
||||||
@@ -87,7 +87,7 @@ static inline uint32_t readl(volatile uint32_t *addr)
|
|||||||
/*
|
/*
|
||||||
* byteswap value and write it to address
|
* byteswap value and write it to address
|
||||||
*/
|
*/
|
||||||
static inline void writel(uint32_t value, uint32_t *address)
|
static inline void writel(uint32_t value, volatile uint32_t *address)
|
||||||
{
|
{
|
||||||
// dbg("writing %08x to %08x\r\n", value, address);
|
// dbg("writing %08x to %08x\r\n", value, address);
|
||||||
* (volatile uint32_t *) address = swpl(value);
|
* (volatile uint32_t *) address = swpl(value);
|
||||||
@@ -156,16 +156,16 @@ struct pci_device_id ohci_usb_pci_table[] =
|
|||||||
static ohci_t gohci[10];
|
static ohci_t gohci[10];
|
||||||
int 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_a(volatile ohci_t *ohci) { return readl(&ohci->regs->roothub.a); }
|
||||||
static inline uint32_t roothub_b(ohci_t *ohci) { return readl(&ohci->regs->roothub.b); }
|
static inline uint32_t roothub_b(volatile ohci_t *ohci) { return readl(&ohci->regs->roothub.b); }
|
||||||
static inline uint32_t roothub_status(ohci_t *ohci) { return readl(&ohci->regs->roothub.status); }
|
static inline uint32_t roothub_status(volatile ohci_t *ohci) { return readl(&ohci->regs->roothub.status); }
|
||||||
static inline uint32_t roothub_portstatus(ohci_t *ohci, int i) { return readl(&ohci->regs->roothub.portstatus[i]); }
|
static inline uint32_t roothub_portstatus(volatile ohci_t *ohci, int i) { return readl(&ohci->regs->roothub.portstatus[i]); }
|
||||||
|
|
||||||
/* forward declaration */
|
/* forward declaration */
|
||||||
static int hc_interrupt(ohci_t *ohci);
|
static int hc_interrupt(volatile ohci_t *ohci);
|
||||||
static void td_submit_job(ohci_t *ohci, struct usb_device *dev, uint32_t pipe,
|
static void td_submit_job(volatile ohci_t *ohci, struct usb_device *dev, uint32_t pipe,
|
||||||
void *buffer, int transfer_len, struct devrequest *setup,
|
void *buffer, int transfer_len, struct devrequest *setup,
|
||||||
urb_priv_t *urb, int interval);
|
volatile urb_priv_t *urb, int interval);
|
||||||
|
|
||||||
|
|
||||||
static struct td *ptd;
|
static struct td *ptd;
|
||||||
@@ -196,7 +196,7 @@ static struct td *td_alloc(struct usb_device *usb_dev)
|
|||||||
|
|
||||||
/* free HCD-private data associated with this URB */
|
/* free HCD-private data associated with this URB */
|
||||||
|
|
||||||
static void urb_free_priv(urb_priv_t *urb)
|
static void urb_free_priv(volatile urb_priv_t *urb)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
struct td *td;
|
struct td *td;
|
||||||
@@ -463,10 +463,10 @@ static void ohci_dump(ohci_t *ohci, int verbose)
|
|||||||
|
|
||||||
/* get a transfer request */
|
/* get a transfer request */
|
||||||
|
|
||||||
static int sohci_submit_job(ohci_t *ohci, urb_priv_t *urb, struct devrequest *setup)
|
static int sohci_submit_job(volatile ohci_t *ohci, volatile urb_priv_t *urb, struct devrequest *setup)
|
||||||
{
|
{
|
||||||
ed_t *ed;
|
volatile ed_t *ed;
|
||||||
urb_priv_t *purb_priv = urb;
|
volatile urb_priv_t *purb_priv = urb;
|
||||||
int i;
|
int i;
|
||||||
int size = 0;
|
int size = 0;
|
||||||
struct usb_device *dev = urb->dev;
|
struct usb_device *dev = urb->dev;
|
||||||
@@ -564,9 +564,9 @@ static int sohci_submit_job(ohci_t *ohci, urb_priv_t *urb, struct devrequest *se
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline int sohci_return_job(ohci_t *ohci, urb_priv_t *urb)
|
static inline int sohci_return_job(volatile ohci_t *ohci, volatile urb_priv_t *urb)
|
||||||
{
|
{
|
||||||
struct ohci_regs *regs = ohci->regs;
|
volatile struct ohci_regs *regs = ohci->regs;
|
||||||
|
|
||||||
switch (usb_pipetype(urb->pipe))
|
switch (usb_pipetype(urb->pipe))
|
||||||
{
|
{
|
||||||
@@ -620,7 +620,7 @@ static int sohci_get_current_frame_number(ohci_t *ohci, struct usb_device *usb_d
|
|||||||
* sets the interval to interval = 2^integer (ld (interval))
|
* sets the interval to interval = 2^integer (ld (interval))
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static int ep_int_balance(ohci_t *ohci, int interval, int load)
|
static int ep_int_balance(volatile ohci_t *ohci, int interval, int load)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
int branch = 0;
|
int branch = 0;
|
||||||
@@ -676,7 +676,7 @@ static int ep_rev(int num_bits, int word)
|
|||||||
|
|
||||||
/* link an ed into one of the HC chains */
|
/* link an ed into one of the HC chains */
|
||||||
|
|
||||||
static int ep_link(ohci_t *ohci, ed_t *edi)
|
static int ep_link(volatile ohci_t *ohci, volatile ed_t *edi)
|
||||||
{
|
{
|
||||||
volatile ed_t *ed = edi;
|
volatile ed_t *ed = edi;
|
||||||
int int_branch;
|
int int_branch;
|
||||||
@@ -684,7 +684,7 @@ static int ep_link(ohci_t *ohci, ed_t *edi)
|
|||||||
int inter;
|
int inter;
|
||||||
int interval;
|
int interval;
|
||||||
int load;
|
int load;
|
||||||
uint32_t *ed_p;
|
volatile uint32_t *ed_p;
|
||||||
|
|
||||||
ed->state = ED_OPER;
|
ed->state = ED_OPER;
|
||||||
ed->int_interval = 0;
|
ed->int_interval = 0;
|
||||||
@@ -731,7 +731,7 @@ static int ep_link(ohci_t *ohci, ed_t *edi)
|
|||||||
{
|
{
|
||||||
inter = 1;
|
inter = 1;
|
||||||
for (ed_p = &(ohci->hcca->int_table[ep_rev(5, i) + int_branch]);
|
for (ed_p = &(ohci->hcca->int_table[ep_rev(5, i) + int_branch]);
|
||||||
(*ed_p != 0) && (((ed_t *)ed_p)->int_interval >= interval);
|
(*ed_p != 0) && (((volatile ed_t *)ed_p)->int_interval >= interval);
|
||||||
ed_p = &(((ed_t *)ed_p)->hwNextED))
|
ed_p = &(((ed_t *)ed_p)->hwNextED))
|
||||||
inter = ep_rev(6, ((ed_t *)ed_p)->int_interval);
|
inter = ep_rev(6, ((ed_t *)ed_p)->int_interval);
|
||||||
ed->hwNextED = *ed_p;
|
ed->hwNextED = *ed_p;
|
||||||
@@ -745,11 +745,11 @@ static int ep_link(ohci_t *ohci, ed_t *edi)
|
|||||||
/*-------------------------------------------------------------------------*/
|
/*-------------------------------------------------------------------------*/
|
||||||
|
|
||||||
/* scan the periodic table to find and unlink this ED */
|
/* scan the periodic table to find and unlink this ED */
|
||||||
static void periodic_unlink(struct ohci *ohci, volatile struct ed *ed, unsigned index, unsigned period)
|
static void periodic_unlink(volatile struct ohci *ohci, volatile struct ed *ed, unsigned index, unsigned period)
|
||||||
{
|
{
|
||||||
for ( ;index < NUM_INTS; index += period)
|
for ( ;index < NUM_INTS; index += period)
|
||||||
{
|
{
|
||||||
uint32_t *ed_p = &ohci->hcca->int_table[index];
|
volatile uint32_t *ed_p = &ohci->hcca->int_table[index];
|
||||||
|
|
||||||
/* ED might have been unlinked through another path */
|
/* ED might have been unlinked through another path */
|
||||||
while (*ed_p != 0)
|
while (*ed_p != 0)
|
||||||
@@ -771,7 +771,7 @@ static void periodic_unlink(struct ohci *ohci, volatile struct ed *ed, unsigned
|
|||||||
* so the HC can eventually finish the processing of the unlinked ed
|
* so the HC can eventually finish the processing of the unlinked ed
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static int ep_unlink(ohci_t *ohci, ed_t *edi)
|
static int ep_unlink(volatile ohci_t *ohci, volatile ed_t *edi)
|
||||||
{
|
{
|
||||||
volatile ed_t *ed = edi;
|
volatile ed_t *ed = edi;
|
||||||
int i;
|
int i;
|
||||||
@@ -837,7 +837,7 @@ static int ep_unlink(ohci_t *ohci, ed_t *edi)
|
|||||||
* info fields are setted anyway even though most of them should not
|
* info fields are setted anyway even though most of them should not
|
||||||
* change
|
* change
|
||||||
*/
|
*/
|
||||||
static ed_t *ep_add_ed(ohci_t *ohci, struct usb_device *usb_dev, uint32_t pipe, int interval, int load)
|
static ed_t *ep_add_ed(volatile ohci_t *ohci, struct usb_device *usb_dev, uint32_t pipe, int interval, int load)
|
||||||
{
|
{
|
||||||
td_t *td;
|
td_t *td;
|
||||||
ed_t *ed_ret;
|
ed_t *ed_ret;
|
||||||
@@ -884,8 +884,8 @@ static ed_t *ep_add_ed(ohci_t *ohci, struct usb_device *usb_dev, uint32_t pipe,
|
|||||||
|
|
||||||
/* enqueue next TD for this URB (OHCI spec 5.2.8.2) */
|
/* enqueue next TD for this URB (OHCI spec 5.2.8.2) */
|
||||||
|
|
||||||
static void td_fill(ohci_t *ohci, unsigned int info, void *data, int len,
|
static void td_fill(volatile ohci_t *ohci, unsigned int info, void *data, int len,
|
||||||
struct usb_device *dev, int index, urb_priv_t *urb_priv)
|
struct usb_device *dev, int index, volatile urb_priv_t *urb_priv)
|
||||||
{
|
{
|
||||||
volatile td_t *td;
|
volatile td_t *td;
|
||||||
volatile td_t *td_pt;
|
volatile td_t *td_pt;
|
||||||
@@ -953,9 +953,9 @@ static void td_fill(ohci_t *ohci, unsigned int info, void *data, int len,
|
|||||||
|
|
||||||
/* prepare all TDs of a transfer */
|
/* prepare all TDs of a transfer */
|
||||||
|
|
||||||
static void td_submit_job(ohci_t *ohci, struct usb_device *dev, uint32_t pipe,
|
static void td_submit_job(volatile ohci_t *ohci, struct usb_device *dev, uint32_t pipe,
|
||||||
void *buffer, int transfer_len, struct devrequest *setup,
|
void *buffer, int transfer_len, struct devrequest *setup,
|
||||||
urb_priv_t *urb, int interval)
|
volatile urb_priv_t *urb, int interval)
|
||||||
{
|
{
|
||||||
int data_len = transfer_len;
|
int data_len = transfer_len;
|
||||||
void *data;
|
void *data;
|
||||||
@@ -1028,12 +1028,12 @@ static void td_submit_job(ohci_t *ohci, struct usb_device *dev, uint32_t pipe,
|
|||||||
|
|
||||||
/* calculate the transfer length and update the urb */
|
/* calculate the transfer length and update the urb */
|
||||||
|
|
||||||
static void dl_transfer_length(ohci_t *ohci, td_t *td)
|
static void dl_transfer_length(volatile ohci_t *ohci, volatile td_t *td)
|
||||||
{
|
{
|
||||||
uint32_t tdBE;
|
uint32_t tdBE;
|
||||||
uint32_t tdCBP;
|
uint32_t tdCBP;
|
||||||
|
|
||||||
urb_priv_t *lurb_priv = td->ed->purb;
|
volatile urb_priv_t *lurb_priv = td->ed->purb;
|
||||||
|
|
||||||
tdBE = swpl(td->hwBE);
|
tdBE = swpl(td->hwBE);
|
||||||
tdCBP = swpl(td->hwCBP);
|
tdCBP = swpl(td->hwCBP);
|
||||||
@@ -1056,11 +1056,11 @@ static void dl_transfer_length(ohci_t *ohci, td_t *td)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*-------------------------------------------------------------------------*/
|
/*-------------------------------------------------------------------------*/
|
||||||
static void check_status(ohci_t *ohci, td_t *td_list)
|
static void check_status(volatile ohci_t *ohci, td_t *td_list)
|
||||||
{
|
{
|
||||||
urb_priv_t *lurb_priv = td_list->ed->purb;
|
volatile urb_priv_t *lurb_priv = td_list->ed->purb;
|
||||||
int urb_len = lurb_priv->length;
|
int urb_len = lurb_priv->length;
|
||||||
uint32_t *phwHeadP = &td_list->ed->hwHeadP;
|
volatile uint32_t *phwHeadP = &td_list->ed->hwHeadP;
|
||||||
int cc = TD_CC_GET(swpl(td_list->hwINFO));
|
int cc = TD_CC_GET(swpl(td_list->hwINFO));
|
||||||
|
|
||||||
if (cc)
|
if (cc)
|
||||||
@@ -1086,7 +1086,7 @@ static void check_status(ohci_t *ohci, td_t *td_list)
|
|||||||
* replies to the request have to be on a FIFO basis so
|
* replies to the request have to be on a FIFO basis so
|
||||||
* we reverse the reversed done-list
|
* we reverse the reversed done-list
|
||||||
*/
|
*/
|
||||||
static td_t *dl_reverse_done_list(ohci_t *ohci)
|
static td_t *dl_reverse_done_list(volatile ohci_t *ohci)
|
||||||
{
|
{
|
||||||
uint32_t td_list_hc;
|
uint32_t td_list_hc;
|
||||||
td_t *td_rev = NULL;
|
td_t *td_rev = NULL;
|
||||||
@@ -1117,7 +1117,7 @@ static td_t *dl_reverse_done_list(ohci_t *ohci)
|
|||||||
|
|
||||||
/*-------------------------------------------------------------------------*/
|
/*-------------------------------------------------------------------------*/
|
||||||
|
|
||||||
static void finish_urb(ohci_t *ohci, urb_priv_t *urb, int status)
|
static void finish_urb(volatile ohci_t *ohci, volatile urb_priv_t *urb, int status)
|
||||||
{
|
{
|
||||||
if ((status & (ED_OPER | ED_UNLINK)) && (urb->state != URB_DEL))
|
if ((status & (ED_OPER | ED_UNLINK)) && (urb->state != URB_DEL))
|
||||||
{
|
{
|
||||||
@@ -1135,12 +1135,12 @@ static void finish_urb(ohci_t *ohci, urb_priv_t *urb, int status)
|
|||||||
* HC no longer sees the TD and it has not appeared on the donelist (after
|
* HC no longer sees the TD and it has not appeared on the donelist (after
|
||||||
* two frames). This bug has been observed on ZF Micro systems.
|
* two frames). This bug has been observed on ZF Micro systems.
|
||||||
*/
|
*/
|
||||||
static int takeback_td(ohci_t *ohci, td_t *td_list)
|
static int takeback_td(volatile ohci_t *ohci, volatile td_t *td_list)
|
||||||
{
|
{
|
||||||
ed_t *ed;
|
volatile ed_t *ed;
|
||||||
int cc;
|
int cc;
|
||||||
int stat = 0;
|
int stat = 0;
|
||||||
urb_priv_t *lurb_priv;
|
volatile urb_priv_t *lurb_priv;
|
||||||
uint32_t tdINFO;
|
uint32_t tdINFO;
|
||||||
uint32_t edHeadP;
|
uint32_t edHeadP;
|
||||||
uint32_t edTailP;
|
uint32_t edTailP;
|
||||||
@@ -1200,14 +1200,14 @@ static int takeback_td(ohci_t *ohci, td_t *td_list)
|
|||||||
return stat;
|
return stat;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int dl_done_list(ohci_t *ohci)
|
static int dl_done_list(volatile ohci_t *ohci)
|
||||||
{
|
{
|
||||||
int stat = 0;
|
int stat = 0;
|
||||||
td_t *td_list = dl_reverse_done_list(ohci);
|
volatile td_t *td_list = dl_reverse_done_list(ohci);
|
||||||
|
|
||||||
while (td_list)
|
while (td_list)
|
||||||
{
|
{
|
||||||
td_t *td_next = td_list->next_dl_td;
|
volatile td_t *td_next = td_list->next_dl_td;
|
||||||
|
|
||||||
stat = takeback_td(ohci, td_list);
|
stat = takeback_td(ohci, td_list);
|
||||||
td_list = td_next;
|
td_list = td_next;
|
||||||
@@ -1362,7 +1362,7 @@ int rh_check_port_status(ohci_t *controller)
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int ohci_submit_rh_msg(ohci_t *ohci, struct usb_device *dev, uint32_t pipe,
|
static int ohci_submit_rh_msg(volatile ohci_t *ohci, struct usb_device *dev, uint32_t pipe,
|
||||||
void *buffer, int transfer_len, struct devrequest *cmd)
|
void *buffer, int transfer_len, struct devrequest *cmd)
|
||||||
{
|
{
|
||||||
void *data = buffer;
|
void *data = buffer;
|
||||||
@@ -1601,13 +1601,13 @@ static int ohci_submit_rh_msg(ohci_t *ohci, struct usb_device *dev, uint32_t pip
|
|||||||
* common code for handling submit messages - used for all but root hub accesses.
|
* common code for handling submit messages - used for all but root hub accesses.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static int submit_common_msg(ohci_t *ohci, struct usb_device *dev, uint32_t pipe, void *buffer,
|
static int submit_common_msg(volatile ohci_t *ohci, struct usb_device *dev, uint32_t pipe, void *buffer,
|
||||||
int transfer_len, struct devrequest *setup, int interval)
|
int transfer_len, struct devrequest *setup, int interval)
|
||||||
{
|
{
|
||||||
int stat = 0;
|
int stat = 0;
|
||||||
int maxsize = usb_maxpacket(dev, pipe);
|
int maxsize = usb_maxpacket(dev, pipe);
|
||||||
int timeout;
|
int timeout;
|
||||||
urb_priv_t *urb = driver_mem_alloc(sizeof(urb_priv_t));
|
volatile urb_priv_t *urb = driver_mem_alloc(sizeof(urb_priv_t));
|
||||||
|
|
||||||
if (urb == NULL)
|
if (urb == NULL)
|
||||||
{
|
{
|
||||||
@@ -1615,7 +1615,7 @@ static int submit_common_msg(ohci_t *ohci, struct usb_device *dev, uint32_t pipe
|
|||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
memset(urb, 0, sizeof(urb_priv_t));
|
memset((void *) urb, 0, sizeof(urb_priv_t));
|
||||||
|
|
||||||
urb->dev = dev;
|
urb->dev = dev;
|
||||||
urb->pipe = pipe;
|
urb->pipe = pipe;
|
||||||
@@ -1627,7 +1627,7 @@ static int submit_common_msg(ohci_t *ohci, struct usb_device *dev, uint32_t pipe
|
|||||||
if (ohci->devgone == dev)
|
if (ohci->devgone == dev)
|
||||||
{
|
{
|
||||||
dev->status = USB_ST_CRC_ERR;
|
dev->status = USB_ST_CRC_ERR;
|
||||||
dbg("device is gone...\r\n");
|
err("device is gone...\r\n");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
#ifdef DEBUG_OHCI
|
#ifdef DEBUG_OHCI
|
||||||
@@ -1636,7 +1636,7 @@ static int submit_common_msg(ohci_t *ohci, struct usb_device *dev, uint32_t pipe
|
|||||||
#else
|
#else
|
||||||
if (ohci->irq)
|
if (ohci->irq)
|
||||||
{
|
{
|
||||||
wait_ms(10);
|
wait_us(10);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -1653,7 +1653,7 @@ static int submit_common_msg(ohci_t *ohci, struct usb_device *dev, uint32_t pipe
|
|||||||
}
|
}
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
wait_ms(10);
|
wait_us(10);
|
||||||
/* ohci_dump_status(ohci); */
|
/* ohci_dump_status(ohci); */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -1670,7 +1670,7 @@ static int submit_common_msg(ohci_t *ohci, struct usb_device *dev, uint32_t pipe
|
|||||||
timeout = 1000;
|
timeout = 1000;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* wait_ms for it to complete */
|
/* wait for it to complete */
|
||||||
while (ohci->irq)
|
while (ohci->irq)
|
||||||
{
|
{
|
||||||
/* check whether the controller is done */
|
/* check whether the controller is done */
|
||||||
@@ -1684,9 +1684,10 @@ static int submit_common_msg(ohci_t *ohci, struct usb_device *dev, uint32_t pipe
|
|||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
stat = hc_interrupt(ohci);
|
stat = hc_interrupt(ohci);
|
||||||
|
|
||||||
if (stat < 0)
|
if (stat < 0)
|
||||||
{
|
{
|
||||||
dbg("USB CRC error\r\n");
|
err("USB CRC error\r\n");
|
||||||
stat = USB_ST_CRC_ERR;
|
stat = USB_ST_CRC_ERR;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -1710,19 +1711,19 @@ static int submit_common_msg(ohci_t *ohci, struct usb_device *dev, uint32_t pipe
|
|||||||
if (--timeout)
|
if (--timeout)
|
||||||
{
|
{
|
||||||
wait_ms(10);
|
wait_ms(10);
|
||||||
if (!urb->finished)
|
// if (!urb->finished)
|
||||||
xprintf("*\r\n");
|
// xprintf("*\r\n");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
err("OHCI usb-%s-%c CTL:TIMEOUT", ohci->slot_name, (char) ohci->controller + '0');
|
err("OHCI usb-%s-%c CTL:TIMEOUT\r\n", ohci->slot_name, (char) ohci->controller + '0');
|
||||||
dbg("submit_common_msg: TO status %x\r\n", stat);
|
dbg("submit_common_msg: TO status %x\r\n", stat);
|
||||||
urb->finished = 1;
|
urb->finished = 1;
|
||||||
stat = USB_ST_CRC_ERR;
|
stat = USB_ST_CRC_ERR;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
dbg("\n");
|
|
||||||
dev->status = stat;
|
dev->status = stat;
|
||||||
dev->act_len = transfer_len;
|
dev->act_len = transfer_len;
|
||||||
#ifdef DEBUG_OHCI
|
#ifdef DEBUG_OHCI
|
||||||
@@ -1746,7 +1747,7 @@ int ohci_submit_bulk_msg(struct usb_device *dev, uint32_t pipe, void *buffer, in
|
|||||||
|
|
||||||
int ohci_submit_control_msg(struct usb_device *dev, uint32_t pipe, void *buffer, int transfer_len, struct devrequest *setup)
|
int ohci_submit_control_msg(struct usb_device *dev, uint32_t pipe, void *buffer, int transfer_len, struct devrequest *setup)
|
||||||
{
|
{
|
||||||
ohci_t *ohci = (ohci_t *)dev->priv_hcd;
|
volatile ohci_t *ohci = (ohci_t *) dev->priv_hcd;
|
||||||
int maxsize = usb_maxpacket(dev, pipe);
|
int maxsize = usb_maxpacket(dev, pipe);
|
||||||
|
|
||||||
dbg("submit_control_msg dev 0x%p ohci 0x%p\r\n", dev, ohci);
|
dbg("submit_control_msg dev 0x%p ohci 0x%p\r\n", dev, ohci);
|
||||||
@@ -1756,7 +1757,7 @@ int ohci_submit_control_msg(struct usb_device *dev, uint32_t pipe, void *buffer,
|
|||||||
#else
|
#else
|
||||||
if (ohci->irq)
|
if (ohci->irq)
|
||||||
{
|
{
|
||||||
wait_ms(10);
|
wait_us(10);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -1769,7 +1770,7 @@ int ohci_submit_control_msg(struct usb_device *dev, uint32_t pipe, void *buffer,
|
|||||||
if (((pipe >> 8) & 0x7f) == ohci->rh.devnum)
|
if (((pipe >> 8) & 0x7f) == ohci->rh.devnum)
|
||||||
{
|
{
|
||||||
ohci->rh.dev = dev;
|
ohci->rh.dev = dev;
|
||||||
|
dbg("redirect\r\n");
|
||||||
/* root hub - redirect */
|
/* root hub - redirect */
|
||||||
return ohci_submit_rh_msg(ohci, dev, pipe, buffer, transfer_len, setup);
|
return ohci_submit_rh_msg(ohci, dev, pipe, buffer, transfer_len, setup);
|
||||||
}
|
}
|
||||||
@@ -1788,7 +1789,7 @@ int ohci_submit_int_msg(struct usb_device *dev, uint32_t pipe, void *buffer, int
|
|||||||
|
|
||||||
/* reset the HC and BUS */
|
/* reset the HC and BUS */
|
||||||
|
|
||||||
static int hc_reset(ohci_t *ohci)
|
static int hc_reset(volatile ohci_t *ohci)
|
||||||
{
|
{
|
||||||
int timeout = 30;
|
int timeout = 30;
|
||||||
int smm_timeout = 50; /* 0,5 sec */
|
int smm_timeout = 50; /* 0,5 sec */
|
||||||
@@ -1838,7 +1839,7 @@ static int hc_reset(ohci_t *ohci)
|
|||||||
err("USB RootHub reset timed out!\r\n");
|
err("USB RootHub reset timed out!\r\n");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
wait_ms(1);
|
wait_us(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1925,7 +1926,7 @@ static int hc_reset(ohci_t *ohci)
|
|||||||
* connect the virtual root hub
|
* connect the virtual root hub
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static int hc_start(ohci_t *ohci)
|
static int hc_start(volatile ohci_t *ohci)
|
||||||
{
|
{
|
||||||
uint32_t mask;
|
uint32_t mask;
|
||||||
unsigned int fminterval;
|
unsigned int fminterval;
|
||||||
@@ -1994,9 +1995,9 @@ static int hc_start(ohci_t *ohci)
|
|||||||
/*
|
/*
|
||||||
* an interrupt happens
|
* an interrupt happens
|
||||||
*/
|
*/
|
||||||
static int hc_interrupt(ohci_t *ohci)
|
static int hc_interrupt(volatile ohci_t *ohci)
|
||||||
{
|
{
|
||||||
struct ohci_regs *regs = ohci->regs;
|
volatile struct ohci_regs *regs = ohci->regs;
|
||||||
int ints;
|
int ints;
|
||||||
int stat = -1;
|
int stat = -1;
|
||||||
|
|
||||||
@@ -2008,7 +2009,7 @@ static int hc_interrupt(ohci_t *ohci)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
ints = readl(®s->intrstatus);
|
ints = readl(®s->intrstatus);
|
||||||
if (ints == ~ 0UL)
|
if (ints == ~0UL)
|
||||||
{
|
{
|
||||||
ohci->disabled++;
|
ohci->disabled++;
|
||||||
err("OHCI usb-%s-%c device removed!\r\n", ohci->slot_name, (char) ohci->controller + '0');
|
err("OHCI usb-%s-%c device removed!\r\n", ohci->slot_name, (char) ohci->controller + '0');
|
||||||
@@ -2040,8 +2041,6 @@ static int hc_interrupt(ohci_t *ohci)
|
|||||||
{
|
{
|
||||||
unsigned short status = pci_read_config_word(ohci->handle, PCISR);
|
unsigned short status = pci_read_config_word(ohci->handle, PCISR);
|
||||||
|
|
||||||
(void) status;
|
|
||||||
|
|
||||||
err("OHCI Unrecoverable Error, controller usb-%s-%c disabled\r\n(SR:0x%04X%s%s%s%s%s%s)",
|
err("OHCI Unrecoverable Error, controller usb-%s-%c disabled\r\n(SR:0x%04X%s%s%s%s%s%s)",
|
||||||
ohci->slot_name, (char) ohci->controller + '0', status & 0xFFFF,
|
ohci->slot_name, (char) ohci->controller + '0', status & 0xFFFF,
|
||||||
status & 0x8000 ? ", Parity error" : "",
|
status & 0x8000 ? ", Parity error" : "",
|
||||||
@@ -2143,7 +2142,7 @@ void ohci_usb_enable_interrupt(int enable)
|
|||||||
|
|
||||||
/* De-allocate all resources.. */
|
/* De-allocate all resources.. */
|
||||||
|
|
||||||
static void hc_release_ohci(ohci_t *ohci)
|
static void hc_release_ohci(volatile ohci_t *ohci)
|
||||||
{
|
{
|
||||||
dbg("USB HC release OHCI usb-%s-%c", ohci->slot_name, (char) ohci->controller + '0');
|
dbg("USB HC release OHCI usb-%s-%c", ohci->slot_name, (char) ohci->controller + '0');
|
||||||
if (!ohci->disabled)
|
if (!ohci->disabled)
|
||||||
@@ -2152,7 +2151,7 @@ static void hc_release_ohci(ohci_t *ohci)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void hc_free_buffers(ohci_t *ohci)
|
static void hc_free_buffers(volatile ohci_t *ohci)
|
||||||
{
|
{
|
||||||
if (ohci->td_unaligned != NULL)
|
if (ohci->td_unaligned != NULL)
|
||||||
{
|
{
|
||||||
@@ -2177,12 +2176,12 @@ static void hc_free_buffers(ohci_t *ohci)
|
|||||||
int ohci_usb_lowlevel_init(int32_t handle, const struct pci_device_id *ent, void **priv)
|
int ohci_usb_lowlevel_init(int32_t handle, const struct pci_device_id *ent, void **priv)
|
||||||
{
|
{
|
||||||
uint32_t usb_base_addr = 0xFFFFFFFF;
|
uint32_t usb_base_addr = 0xFFFFFFFF;
|
||||||
ohci_t *ohci = &gohci[pci_handle2index(handle)];
|
volatile ohci_t *ohci = &gohci[pci_handle2index(handle)];
|
||||||
struct pci_rd *pci_rsc_desc = pci_get_resource(handle); /* USB OHCI */
|
struct pci_rd *pci_rsc_desc = pci_get_resource(handle); /* USB OHCI */
|
||||||
|
|
||||||
if (handle && (ent != NULL))
|
if (handle && (ent != NULL))
|
||||||
{
|
{
|
||||||
memset(ohci, 0, sizeof(ohci_t));
|
memset((void *) ohci, 0, sizeof(ohci_t));
|
||||||
ohci->handle = handle;
|
ohci->handle = handle;
|
||||||
ohci->ent = ent;
|
ohci->ent = ent;
|
||||||
}
|
}
|
||||||
@@ -2191,7 +2190,7 @@ int ohci_usb_lowlevel_init(int32_t handle, const struct pci_device_id *ent, void
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
err("ohci %p, handle = 0x%x, fctn = 0x%x\r\n", ohci, handle, PCI_FUNCTION_FROM_HANDLE(handle));
|
inf("ohci %p, handle = 0x%x, fctn = 0x%x\r\n", ohci, handle, PCI_FUNCTION_FROM_HANDLE(handle));
|
||||||
|
|
||||||
ohci->controller = PCI_FUNCTION_FROM_HANDLE(ohci->handle);
|
ohci->controller = PCI_FUNCTION_FROM_HANDLE(ohci->handle);
|
||||||
|
|
||||||
@@ -2208,8 +2207,9 @@ int ohci_usb_lowlevel_init(int32_t handle, const struct pci_device_id *ent, void
|
|||||||
|
|
||||||
/* align the storage */
|
/* align the storage */
|
||||||
ohci->hcca = (struct ohci_hcca *) (((uint32_t) ohci->hcca_unaligned + 255) & ~255);
|
ohci->hcca = (struct ohci_hcca *) (((uint32_t) ohci->hcca_unaligned + 255) & ~255);
|
||||||
memset(ohci->hcca, 0, sizeof(struct ohci_hcca));
|
memset((void *) ohci->hcca, 0, sizeof(struct ohci_hcca));
|
||||||
err("aligned ghcca %p\r\n", ohci->hcca);
|
inf("aligned ghcca %p\r\n", ohci->hcca);
|
||||||
|
|
||||||
ohci->ohci_dev_unaligned = driver_mem_alloc(sizeof(struct ohci_device) + 8);
|
ohci->ohci_dev_unaligned = driver_mem_alloc(sizeof(struct ohci_device) + 8);
|
||||||
if (ohci->ohci_dev_unaligned == NULL)
|
if (ohci->ohci_dev_unaligned == NULL)
|
||||||
{
|
{
|
||||||
@@ -2220,7 +2220,7 @@ int ohci_usb_lowlevel_init(int32_t handle, const struct pci_device_id *ent, void
|
|||||||
}
|
}
|
||||||
ohci->ohci_dev = (struct ohci_device *) (((uint32_t) ohci->ohci_dev_unaligned + 7) & ~7);
|
ohci->ohci_dev = (struct ohci_device *) (((uint32_t) ohci->ohci_dev_unaligned + 7) & ~7);
|
||||||
memset(ohci->ohci_dev, 0, sizeof(struct ohci_device));
|
memset(ohci->ohci_dev, 0, sizeof(struct ohci_device));
|
||||||
err("aligned EDs %p\r\n", ohci->ohci_dev);
|
dbg("aligned EDs %p\r\n", ohci->ohci_dev);
|
||||||
|
|
||||||
ohci->td_unaligned = driver_mem_alloc(sizeof(struct td) * (NUM_TD + 1));
|
ohci->td_unaligned = driver_mem_alloc(sizeof(struct td) * (NUM_TD + 1));
|
||||||
if (ohci->td_unaligned == NULL)
|
if (ohci->td_unaligned == NULL)
|
||||||
@@ -2246,10 +2246,9 @@ int ohci_usb_lowlevel_init(int32_t handle, const struct pci_device_id *ent, void
|
|||||||
unsigned short flags;
|
unsigned short flags;
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
dbg("\r\nPCI USB descriptors (at %p): flags 0x%04x start 0x%08lx \r\n offset 0x%08lx dmaoffset 0x%08lx length 0x%08lx\r\n",
|
dbg("PCI USB descriptors (at %p): flags 0x%04x start 0x%08lx\r\n",
|
||||||
pci_rsc_desc,
|
pci_rsc_desc, pci_rsc_desc->flags, pci_rsc_desc->start);
|
||||||
pci_rsc_desc->flags,
|
dbg("offset 0x%08lx dmaoffset 0x%08lx length 0x%08lx\r\n",
|
||||||
pci_rsc_desc->start,
|
|
||||||
pci_rsc_desc->offset,
|
pci_rsc_desc->offset,
|
||||||
pci_rsc_desc->dmaoffset,
|
pci_rsc_desc->dmaoffset,
|
||||||
pci_rsc_desc->length);
|
pci_rsc_desc->length);
|
||||||
@@ -2276,8 +2275,7 @@ int ohci_usb_lowlevel_init(int32_t handle, const struct pci_device_id *ent, void
|
|||||||
}
|
}
|
||||||
flags = pci_rsc_desc->flags;
|
flags = pci_rsc_desc->flags;
|
||||||
pci_rsc_desc = (struct pci_rd *) ((uint32_t) pci_rsc_desc->next + (uint32_t) pci_rsc_desc);
|
pci_rsc_desc = (struct pci_rd *) ((uint32_t) pci_rsc_desc->next + (uint32_t) pci_rsc_desc);
|
||||||
}
|
} while (!(flags & FLG_LAST));
|
||||||
while (!(flags & FLG_LAST));
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -2343,7 +2341,7 @@ int ohci_usb_lowlevel_init(int32_t handle, const struct pci_device_id *ent, void
|
|||||||
#ifdef DEBUG_OHCI
|
#ifdef DEBUG_OHCI
|
||||||
ohci_dump(ohci, 1);
|
ohci_dump(ohci, 1);
|
||||||
#endif
|
#endif
|
||||||
pci_hook_interrupt(handle, (pci_interrupt_handler) handle_usb_interrupt, ohci);
|
pci_hook_interrupt(handle, (pci_interrupt_handler) handle_usb_interrupt, (void *) ohci);
|
||||||
if (priv != NULL)
|
if (priv != NULL)
|
||||||
{
|
{
|
||||||
*priv = (void *) ohci;
|
*priv = (void *) ohci;
|
||||||
|
|||||||
@@ -974,7 +974,7 @@ static void pci_bridge_config(uint16_t bus, uint16_t device, uint16_t function)
|
|||||||
|
|
||||||
pci_write_config_longword(handle, PCIBISTR, MCF_PCI_PCICR1_CACHELINESIZE(8) |
|
pci_write_config_longword(handle, PCIBISTR, MCF_PCI_PCICR1_CACHELINESIZE(8) |
|
||||||
MCF_PCI_PCICR1_LATTIMER(0x20));
|
MCF_PCI_PCICR1_LATTIMER(0x20));
|
||||||
pci_write_config_longword(handle, PCIBAR0, swpl(0x40000000));
|
pci_write_config_longword(handle, PCIBAR0, swpl(0x80000000));
|
||||||
pci_write_config_longword(handle, PCIBAR1, 0x0);
|
pci_write_config_longword(handle, PCIBAR1, 0x0);
|
||||||
pci_write_config_word(handle, PCI_LANESWAP_W(PCICR), swpw(
|
pci_write_config_word(handle, PCI_LANESWAP_W(PCICR), swpw(
|
||||||
(1 << 1) /* memory space */
|
(1 << 1) /* memory space */
|
||||||
|
|||||||
@@ -511,7 +511,7 @@ void BaS(void)
|
|||||||
video_init();
|
video_init();
|
||||||
|
|
||||||
/* initialize USB devices */
|
/* initialize USB devices */
|
||||||
init_usb();
|
// init_usb();
|
||||||
|
|
||||||
set_ipl(7); /* disable interrupts */
|
set_ipl(7); /* disable interrupts */
|
||||||
|
|
||||||
|
|||||||
@@ -441,7 +441,7 @@ static void init_fbcs()
|
|||||||
* i.e. it can burst on an 8 bit port up to 4 burst cycles or two on a 16 bit port.
|
* i.e. it can burst on an 8 bit port up to 4 burst cycles or two on a 16 bit port.
|
||||||
* Enabling burst on a 32 bit port has no effect (unfortunately).
|
* Enabling burst on a 32 bit port has no effect (unfortunately).
|
||||||
*/
|
*/
|
||||||
MCF_FBCS4_CSAR = MCF_FBCS_CSAR_BA(0x40000000); /* video ram area, FB_CS3 not used, decoded on FPGA */
|
MCF_FBCS4_CSAR = MCF_FBCS_CSAR_BA(0x40000000); /* video ram area, FB_CS4 not used, decoded on FPGA */
|
||||||
MCF_FBCS4_CSCR = MCF_FBCS_CSCR_PS_32 /* 32 bit port */
|
MCF_FBCS4_CSCR = MCF_FBCS_CSCR_PS_32 /* 32 bit port */
|
||||||
| MCF_FBCS_CSCR_WS(32) /* 0 wait states */
|
| MCF_FBCS_CSCR_WS(32) /* 0 wait states */
|
||||||
| MCF_FBCS_CSCR_AA /* /TA auto acknowledge */
|
| MCF_FBCS_CSCR_AA /* /TA auto acknowledge */
|
||||||
@@ -588,6 +588,11 @@ void init_usb(void)
|
|||||||
int usb_found = 0;
|
int usb_found = 0;
|
||||||
int index = 0;
|
int index = 0;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* disabled for now
|
||||||
|
*/
|
||||||
|
return;
|
||||||
|
|
||||||
inf("USB controller initialization:\r\n");
|
inf("USB controller initialization:\r\n");
|
||||||
|
|
||||||
do
|
do
|
||||||
|
|||||||
@@ -19,10 +19,117 @@
|
|||||||
#define SYSCLK 132000
|
#define SYSCLK 132000
|
||||||
|
|
||||||
long bas_start = 0xe0000000;
|
long bas_start = 0xe0000000;
|
||||||
extern volatile uint32_t _VRAM[];
|
|
||||||
|
|
||||||
volatile int32_t time, start, end;
|
volatile uint16_t *FB_CS1 = (volatile uint16_t *) 0xfff00000; /* "classic" ATARI I/O registers */
|
||||||
int i;
|
volatile uint32_t *FB_CS2 = (volatile uint32_t *) 0xf0000000; /* FireBee 32 bit I/O registers */
|
||||||
|
volatile uint16_t *FB_CS3 = (volatile uint16_t *) 0xf8000000; /* FireBee SRAM */
|
||||||
|
volatile uint32_t *FB_CS4 = (volatile uint32_t *) 0x40000000; /* FireBee SD RAM */
|
||||||
|
|
||||||
|
bool verify_longaddr(volatile uint32_t * const addr, uint32_t value)
|
||||||
|
{
|
||||||
|
*addr = value;
|
||||||
|
|
||||||
|
if (value != *addr)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool verify_long(volatile uint32_t * const addr, uint32_t low_value, uint32_t high_value)
|
||||||
|
{
|
||||||
|
uint32_t i;
|
||||||
|
|
||||||
|
for (i = low_value; i <= high_value; i++)
|
||||||
|
if (verify_longaddr(addr, i) == false)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void firebee_io_test(void)
|
||||||
|
{
|
||||||
|
volatile uint32_t *ACP_VCTR = &FB_CS2[0x100]; /* 0xf000400 */
|
||||||
|
volatile uint32_t *CCR = &FB_CS2[0x101]; /* 0xf000401 - FireBee mode border color */
|
||||||
|
volatile uint32_t *ATARI_HH = &FB_CS2[0x104]; /* 0xf000410 */
|
||||||
|
volatile uint32_t *ATARI_VH = &FB_CS2[0x105]; /* 0xf000414 */
|
||||||
|
volatile uint32_t *ATARI_HL = &FB_CS2[0x106]; /* 0xf000418 */
|
||||||
|
volatile uint32_t *ATARI_VL = &FB_CS2[0x107]; /* 0xf00041c */
|
||||||
|
|
||||||
|
volatile uint32_t *VIDEO_PLL_CONFIG = &FB_CS2[0x180]; /* 0xf000600 */
|
||||||
|
volatile uint32_t *VIDEO_PLL_RECONFIG = &FB_CS2[0x200]; /* 0xf000800 */
|
||||||
|
|
||||||
|
verify_long(ACP_VCTR, 0, 0x7fffffff);
|
||||||
|
verify_long(CCR, 0, 0x7fffffff);
|
||||||
|
verify_long(ATARI_HH, 0, 0xffffffff);
|
||||||
|
verify_long(ATARI_VH, 0, 0xffffffff);
|
||||||
|
verify_long(ATARI_HL, 0, 0xffffffff);
|
||||||
|
verify_long(ATARI_VL, 0, 0xffffffff);
|
||||||
|
|
||||||
|
verify_long(VIDEO_PLL_CONFIG, 0, 0xffffffff);
|
||||||
|
verify_long(VIDEO_PLL_RECONFIG, 0, 0xffffffff);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool verify_wordaddr(volatile uint16_t * const addr, uint16_t value)
|
||||||
|
{
|
||||||
|
*addr = value;
|
||||||
|
|
||||||
|
if (value != *addr)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool verify_word(volatile uint16_t * const addr, uint16_t low_value, uint16_t high_value)
|
||||||
|
{
|
||||||
|
int16_t i;
|
||||||
|
|
||||||
|
for (i = low_value; i <= high_value; i++)
|
||||||
|
if (verify_wordaddr(addr, i) == false)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void atari_io_test(void)
|
||||||
|
{
|
||||||
|
volatile uint16_t *SYS_CTR = &FB_CS1[0x7c003]; /* 0xffff8006 */
|
||||||
|
volatile uint16_t *VDL_LOF = &FB_CS1[0x7c107]; /* 0xffff820e */
|
||||||
|
volatile uint16_t *VDL_LWD = &FB_CS1[0x7c108]; /* 0xffff8210 */
|
||||||
|
volatile uint16_t *VDL_HHT = &FB_CS1[0x7c141]; /* 0xffff8282 */
|
||||||
|
volatile uint16_t *VDL_HBB = &FB_CS1[0x7c142]; /* 0xffff8284 */
|
||||||
|
volatile uint16_t *VDL_HBE = &FB_CS1[0x7c143]; /* 0xffff8286 */
|
||||||
|
volatile uint16_t *VDL_HDB = &FB_CS1[0x7c144]; /* 0xffff8288 */
|
||||||
|
volatile uint16_t *VDL_HDE = &FB_CS1[0x7c145]; /* 0xffff828a */
|
||||||
|
volatile uint16_t *VDL_HSS = &FB_CS1[0x7c146]; /* 0xffff828c */
|
||||||
|
|
||||||
|
volatile uint16_t *VDL_VFT = &FB_CS1[0x7c151]; /* 0xffff82a2 */
|
||||||
|
volatile uint16_t *VDL_VBB = &FB_CS1[0x7c152]; /* 0xffff82a4 */
|
||||||
|
volatile uint16_t *VDL_VBE = &FB_CS1[0x7c153]; /* 0xffff82a6 */
|
||||||
|
volatile uint16_t *VDL_VDB = &FB_CS1[0x7c154]; /* 0xffff82a8 */
|
||||||
|
volatile uint16_t *VDL_VDE = &FB_CS1[0x7c155]; /* 0xffff82aa */
|
||||||
|
volatile uint16_t *VDL_VSS = &FB_CS1[0x7c156]; /* 0xffff82ac */
|
||||||
|
volatile uint16_t *VDL_VCT = &FB_CS1[0x7c160]; /* 0xffff82c0 */
|
||||||
|
volatile uint16_t *VDL_VMD = &FB_CS1[0x7c161]; /* 0xffff82c2 */
|
||||||
|
|
||||||
|
verify_word(SYS_CTR, 0, 0x7fff);
|
||||||
|
verify_word(VDL_LOF, 0, 0x7fff);
|
||||||
|
verify_word(VDL_LWD, 0, 0x7fff);
|
||||||
|
verify_word(VDL_HHT, 0, 0x7fff);
|
||||||
|
verify_word(VDL_HBB, 0, 0x7fff);
|
||||||
|
verify_word(VDL_HBE, 0, 0x7fff);
|
||||||
|
verify_word(VDL_HDB, 0, 0x7fff);
|
||||||
|
verify_word(VDL_HDE, 0, 0x7fff);
|
||||||
|
verify_word(VDL_HSS, 0, 0x7fff);
|
||||||
|
|
||||||
|
verify_word(VDL_VFT, 0, 0x7fff);
|
||||||
|
verify_word(VDL_VBB, 0, 0x7fff);
|
||||||
|
verify_word(VDL_VBE, 0, 0x7fff);
|
||||||
|
verify_word(VDL_VDB, 0, 0x7fff);
|
||||||
|
verify_word(VDL_VDE, 0, 0x7fff);
|
||||||
|
verify_word(VDL_VSS, 0, 0x7fff);
|
||||||
|
verify_word(VDL_VCT, 0, 0x7fff);
|
||||||
|
verify_word(VDL_VMD, 0, 0x7fff);
|
||||||
|
}
|
||||||
|
|
||||||
void do_tests(void)
|
void do_tests(void)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -54,7 +54,7 @@
|
|||||||
#include "usb.h"
|
#include "usb.h"
|
||||||
#include "usb_hub.h"
|
#include "usb_hub.h"
|
||||||
|
|
||||||
#define DEBUG
|
// #define DEBUG
|
||||||
#include "debug.h"
|
#include "debug.h"
|
||||||
|
|
||||||
struct hci
|
struct hci
|
||||||
@@ -156,7 +156,7 @@ int usb_init(int32_t handle, const struct pci_device_id *ent)
|
|||||||
|
|
||||||
case PCI_CLASS_SERIAL_USB_OHCI:
|
case PCI_CLASS_SERIAL_USB_OHCI:
|
||||||
dbg("initialize ohci host controller interface\r\n");
|
dbg("initialize ohci host controller interface\r\n");
|
||||||
//res = ohci_usb_lowlevel_init(handle, ent, (void *) &priv);
|
res = ohci_usb_lowlevel_init(handle, ent, (void *) &priv);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PCI_CLASS_SERIAL_USB_EHCI:
|
case PCI_CLASS_SERIAL_USB_EHCI:
|
||||||
@@ -322,7 +322,7 @@ int usb_control_msg(struct usb_device *dev, unsigned int pipe,
|
|||||||
{
|
{
|
||||||
/* request for a asynch control pipe is not allowed */
|
/* request for a asynch control pipe is not allowed */
|
||||||
|
|
||||||
dbg("request for an async control pipe is not allowed\r\n");
|
err("request for an async control pipe is not allowed\r\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -333,9 +333,9 @@ int usb_control_msg(struct usb_device *dev, unsigned int pipe,
|
|||||||
setup_packet->index = swpw(index);
|
setup_packet->index = swpw(index);
|
||||||
setup_packet->length = swpw(size);
|
setup_packet->length = swpw(size);
|
||||||
|
|
||||||
dbg("usb_control_msg: request: 0x%X, requesttype: 0x%X, value 0x%X index 0x%X length 0x%X\r\n", request, requesttype, value, index, size);
|
dbg("request: 0x%X, requesttype: 0x%X, value 0x%X index 0x%X length 0x%X\r\n", request, requesttype, value, index, size);
|
||||||
|
|
||||||
switch(priv->ent->class)
|
switch (priv->ent->class)
|
||||||
{
|
{
|
||||||
case PCI_CLASS_SERIAL_USB_OHCI:
|
case PCI_CLASS_SERIAL_USB_OHCI:
|
||||||
dev->status = USB_ST_NOT_PROC; /* not yet processed */
|
dev->status = USB_ST_NOT_PROC; /* not yet processed */
|
||||||
@@ -631,6 +631,7 @@ int usb_get_descriptor(struct usb_device *dev, unsigned char type, unsigned char
|
|||||||
{
|
{
|
||||||
int res;
|
int res;
|
||||||
|
|
||||||
|
dbg("dev=%d type=%d, index=%d\r\n", dev->devnum, type, index);
|
||||||
res = usb_control_msg(dev, usb_rcvctrlpipe(dev, 0),
|
res = usb_control_msg(dev, usb_rcvctrlpipe(dev, 0),
|
||||||
USB_REQ_GET_DESCRIPTOR, USB_DIR_IN, (type << 8) + index, 0, buf, size, USB_CNTL_TIMEOUT);
|
USB_REQ_GET_DESCRIPTOR, USB_DIR_IN, (type << 8) + index, 0, buf, size, USB_CNTL_TIMEOUT);
|
||||||
return res;
|
return res;
|
||||||
@@ -695,6 +696,8 @@ int usb_set_interface(struct usb_device *dev, int interface, int alternate)
|
|||||||
struct usb_interface_descriptor *if_face = NULL;
|
struct usb_interface_descriptor *if_face = NULL;
|
||||||
int ret, i;
|
int ret, i;
|
||||||
|
|
||||||
|
dbg("set interface number=%d (alternate=%d)\r\n", interface, alternate);
|
||||||
|
|
||||||
for (i = 0; i < dev->config.bNumInterfaces; i++)
|
for (i = 0; i < dev->config.bNumInterfaces; i++)
|
||||||
{
|
{
|
||||||
if (dev->config.if_desc[i].bInterfaceNumber == interface)
|
if (dev->config.if_desc[i].bInterfaceNumber == interface)
|
||||||
@@ -763,6 +766,8 @@ int usb_set_configuration(struct usb_device *dev, int configuration)
|
|||||||
*/
|
*/
|
||||||
int usb_set_protocol(struct usb_device *dev, int ifnum, int protocol)
|
int usb_set_protocol(struct usb_device *dev, int ifnum, int protocol)
|
||||||
{
|
{
|
||||||
|
dbg("set protocol %d on interface %d\r\n", protocol, ifnum);
|
||||||
|
|
||||||
return usb_control_msg(dev, usb_sndctrlpipe(dev, 0),
|
return usb_control_msg(dev, usb_sndctrlpipe(dev, 0),
|
||||||
USB_REQ_SET_PROTOCOL, USB_TYPE_CLASS | USB_RECIP_INTERFACE,
|
USB_REQ_SET_PROTOCOL, USB_TYPE_CLASS | USB_RECIP_INTERFACE,
|
||||||
protocol, ifnum, NULL, 0, USB_CNTL_TIMEOUT);
|
protocol, ifnum, NULL, 0, USB_CNTL_TIMEOUT);
|
||||||
@@ -773,6 +778,8 @@ int usb_set_protocol(struct usb_device *dev, int ifnum, int protocol)
|
|||||||
*/
|
*/
|
||||||
int usb_set_idle(struct usb_device *dev, int ifnum, int duration, int report_id)
|
int usb_set_idle(struct usb_device *dev, int ifnum, int duration, int report_id)
|
||||||
{
|
{
|
||||||
|
dbg("set if %d idle for %d (report id %d)\r\n", ifnum, duration, report_id);
|
||||||
|
|
||||||
return usb_control_msg(dev, usb_sndctrlpipe(dev, 0),
|
return usb_control_msg(dev, usb_sndctrlpipe(dev, 0),
|
||||||
USB_REQ_SET_IDLE, USB_TYPE_CLASS | USB_RECIP_INTERFACE,
|
USB_REQ_SET_IDLE, USB_TYPE_CLASS | USB_RECIP_INTERFACE,
|
||||||
(duration << 8) | report_id, ifnum, NULL, 0, USB_CNTL_TIMEOUT);
|
(duration << 8) | report_id, ifnum, NULL, 0, USB_CNTL_TIMEOUT);
|
||||||
@@ -784,6 +791,8 @@ int usb_set_idle(struct usb_device *dev, int ifnum, int duration, int report_id)
|
|||||||
int usb_get_report(struct usb_device *dev, int ifnum, unsigned char type,
|
int usb_get_report(struct usb_device *dev, int ifnum, unsigned char type,
|
||||||
unsigned char id, void *buf, int size)
|
unsigned char id, void *buf, int size)
|
||||||
{
|
{
|
||||||
|
dbg("get report on if %d, type %d, id %d\r\n", ifnum, type, id);
|
||||||
|
|
||||||
return usb_control_msg(dev, usb_rcvctrlpipe(dev, 0),
|
return usb_control_msg(dev, usb_rcvctrlpipe(dev, 0),
|
||||||
USB_REQ_GET_REPORT, USB_DIR_IN | USB_TYPE_CLASS | USB_RECIP_INTERFACE,
|
USB_REQ_GET_REPORT, USB_DIR_IN | USB_TYPE_CLASS | USB_RECIP_INTERFACE,
|
||||||
(type << 8) + id, ifnum, buf, size, USB_CNTL_TIMEOUT);
|
(type << 8) + id, ifnum, buf, size, USB_CNTL_TIMEOUT);
|
||||||
@@ -795,6 +804,8 @@ int usb_get_report(struct usb_device *dev, int ifnum, unsigned char type,
|
|||||||
int usb_get_class_descriptor(struct usb_device *dev, int ifnum,
|
int usb_get_class_descriptor(struct usb_device *dev, int ifnum,
|
||||||
unsigned char type, unsigned char id, void *buf, int size)
|
unsigned char type, unsigned char id, void *buf, int size)
|
||||||
{
|
{
|
||||||
|
dbg("get class descriptor of if %d, type %d, id %d\r\n", ifnum, type, id);
|
||||||
|
|
||||||
return usb_control_msg(dev, usb_rcvctrlpipe(dev, 0),
|
return usb_control_msg(dev, usb_rcvctrlpipe(dev, 0),
|
||||||
USB_REQ_GET_DESCRIPTOR, USB_RECIP_INTERFACE | USB_DIR_IN,
|
USB_REQ_GET_DESCRIPTOR, USB_RECIP_INTERFACE | USB_DIR_IN,
|
||||||
(type << 8) + id, ifnum, buf, size, USB_CNTL_TIMEOUT);
|
(type << 8) + id, ifnum, buf, size, USB_CNTL_TIMEOUT);
|
||||||
@@ -895,7 +906,7 @@ static int usb_string_sub(struct usb_device *dev, unsigned int langid, unsigned
|
|||||||
int usb_string(struct usb_device *dev, int index, char *buf, size_t size)
|
int usb_string(struct usb_device *dev, int index, char *buf, size_t size)
|
||||||
{
|
{
|
||||||
unsigned char *tbuf;
|
unsigned char *tbuf;
|
||||||
int err;
|
int error;
|
||||||
unsigned int u, idx;
|
unsigned int u, idx;
|
||||||
|
|
||||||
if (size <= 0 || !buf || !index)
|
if (size <= 0 || !buf || !index)
|
||||||
@@ -915,16 +926,16 @@ int usb_string(struct usb_device *dev, int index, char *buf, size_t size)
|
|||||||
/* get langid for strings if it's not yet known */
|
/* get langid for strings if it's not yet known */
|
||||||
if (!dev->have_langid)
|
if (!dev->have_langid)
|
||||||
{
|
{
|
||||||
err = usb_string_sub(dev, 0, 0, tbuf);
|
error = usb_string_sub(dev, 0, 0, tbuf);
|
||||||
if (err < 0)
|
if (error < 0)
|
||||||
{
|
{
|
||||||
dbg("error getting string descriptor 0 (error=%lx)\r\n", dev->status);
|
err("error getting string descriptor 0 (error=%lx)\r\n", dev->status);
|
||||||
driver_mem_free(tbuf);
|
driver_mem_free(tbuf);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
else if (tbuf[0] < 4)
|
else if (tbuf[0] < 4)
|
||||||
{
|
{
|
||||||
dbg("string descriptor 0 too short\r\n");
|
err("string descriptor 0 too short\r\n");
|
||||||
driver_mem_free(tbuf);
|
driver_mem_free(tbuf);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@@ -936,15 +947,16 @@ int usb_string(struct usb_device *dev, int index, char *buf, size_t size)
|
|||||||
dbg("USB device number %d default language ID 0x%x\r\n", dev->devnum, dev->string_langid);
|
dbg("USB device number %d default language ID 0x%x\r\n", dev->devnum, dev->string_langid);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
err = usb_string_sub(dev, dev->string_langid, index, tbuf);
|
error = usb_string_sub(dev, dev->string_langid, index, tbuf);
|
||||||
if (err < 0)
|
if (error < 0)
|
||||||
{
|
{
|
||||||
|
err("failed to get lang id\r\n");
|
||||||
driver_mem_free(tbuf);
|
driver_mem_free(tbuf);
|
||||||
return err;
|
return error;
|
||||||
}
|
}
|
||||||
|
|
||||||
size--; /* leave room for trailing NULL char in output buffer */
|
size--; /* leave room for trailing NULL char in output buffer */
|
||||||
for (idx = 0, u = 2; u < err; u += 2)
|
for (idx = 0, u = 2; u < error; u += 2)
|
||||||
{
|
{
|
||||||
if (idx >= size)
|
if (idx >= size)
|
||||||
{
|
{
|
||||||
@@ -960,9 +972,9 @@ int usb_string(struct usb_device *dev, int index, char *buf, size_t size)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
buf[idx] = 0;
|
buf[idx] = 0;
|
||||||
err = idx;
|
error = idx;
|
||||||
driver_mem_free(tbuf);
|
driver_mem_free(tbuf);
|
||||||
return err;
|
return error;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -1078,12 +1090,10 @@ struct usb_device *usb_alloc_new_device(int bus, void *priv)
|
|||||||
int usb_new_device(struct usb_device *dev)
|
int usb_new_device(struct usb_device *dev)
|
||||||
{
|
{
|
||||||
int addr;
|
int addr;
|
||||||
int err;
|
int error;
|
||||||
int tmp;
|
int tmp;
|
||||||
unsigned char *tmpbuf;
|
unsigned char *tmpbuf;
|
||||||
|
|
||||||
dbg("\r\n");
|
|
||||||
|
|
||||||
#ifndef CONFIG_LEGACY_USB_INIT_SEQ
|
#ifndef CONFIG_LEGACY_USB_INIT_SEQ
|
||||||
struct usb_device_descriptor *desc;
|
struct usb_device_descriptor *desc;
|
||||||
int port = -1;
|
int port = -1;
|
||||||
@@ -1093,7 +1103,7 @@ int usb_new_device(struct usb_device *dev)
|
|||||||
|
|
||||||
if (dev == NULL)
|
if (dev == NULL)
|
||||||
{
|
{
|
||||||
dbg("called with NULL device\r\n");
|
err("called with NULL device\r\n");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1104,7 +1114,7 @@ int usb_new_device(struct usb_device *dev)
|
|||||||
tmpbuf = (unsigned char *) driver_mem_alloc(USB_BUFSIZ);
|
tmpbuf = (unsigned char *) driver_mem_alloc(USB_BUFSIZ);
|
||||||
if (tmpbuf == NULL)
|
if (tmpbuf == NULL)
|
||||||
{
|
{
|
||||||
dbg("malloc failure\r\n");
|
err("malloc failure\r\n");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1121,10 +1131,10 @@ int usb_new_device(struct usb_device *dev)
|
|||||||
dev->maxpacketsize = PACKET_SIZE_8;
|
dev->maxpacketsize = PACKET_SIZE_8;
|
||||||
dev->epmaxpacketin[0] = 8;
|
dev->epmaxpacketin[0] = 8;
|
||||||
dev->epmaxpacketout[0] = 8;
|
dev->epmaxpacketout[0] = 8;
|
||||||
err = usb_get_descriptor(dev, USB_DT_DEVICE, 0, &dev->descriptor, 8);
|
error = usb_get_descriptor(dev, USB_DT_DEVICE, 0, &dev->descriptor, 8);
|
||||||
if (err < 8)
|
if (err < 8)
|
||||||
{
|
{
|
||||||
dbg("\r\nUSB device not responding, giving up (status=%lX)\r\n", dev->status);
|
err("\r\nUSB device not responding, giving up (status=%lX)\r\n", dev->status);
|
||||||
driver_mem_free(tmpbuf);
|
driver_mem_free(tmpbuf);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@@ -1151,11 +1161,11 @@ int usb_new_device(struct usb_device *dev)
|
|||||||
dev->maxpacketsize = PACKET_SIZE_64;
|
dev->maxpacketsize = PACKET_SIZE_64;
|
||||||
dev->epmaxpacketin[0] = 64;
|
dev->epmaxpacketin[0] = 64;
|
||||||
dev->epmaxpacketout[0] = 64;
|
dev->epmaxpacketout[0] = 64;
|
||||||
err = usb_get_descriptor(dev, USB_DT_DEVICE, 0, desc, 64);
|
error = usb_get_descriptor(dev, USB_DT_DEVICE, 0, desc, 64);
|
||||||
|
|
||||||
if (err < 0)
|
if (error < 0)
|
||||||
{
|
{
|
||||||
dbg("usb_new_device: usb_get_descriptor() failed\r\n");
|
err("usb_new_device: usb_get_descriptor() failed\r\n");
|
||||||
driver_mem_free(tmpbuf);
|
driver_mem_free(tmpbuf);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@@ -1177,17 +1187,17 @@ int usb_new_device(struct usb_device *dev)
|
|||||||
|
|
||||||
if (port < 0)
|
if (port < 0)
|
||||||
{
|
{
|
||||||
dbg("usb_new_device: cannot locate device's port.\r\n");
|
err("usb_new_device: cannot locate device's port.\r\n");
|
||||||
driver_mem_free(tmpbuf);
|
driver_mem_free(tmpbuf);
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* reset the port for the second time */
|
/* reset the port for the second time */
|
||||||
err = hub_port_reset(dev->parent, port, &portstatus);
|
error = hub_port_reset(dev->parent, port, &portstatus);
|
||||||
if (err < 0)
|
if (error < 0)
|
||||||
{
|
{
|
||||||
dbg("\r\nCouldn't reset port %d\r\n", port);
|
err("\r\nCouldn't reset port %d\r\n", port);
|
||||||
driver_mem_free(tmpbuf);
|
driver_mem_free(tmpbuf);
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
@@ -1206,28 +1216,28 @@ int usb_new_device(struct usb_device *dev)
|
|||||||
}
|
}
|
||||||
|
|
||||||
dev->devnum = addr;
|
dev->devnum = addr;
|
||||||
err = usb_set_address(dev); /* set address */
|
error = usb_set_address(dev); /* set address */
|
||||||
|
|
||||||
if (err < 0)
|
if (error < 0)
|
||||||
{
|
{
|
||||||
dbg("\r\nUSB device not accepting new address (error=%lX)\r\n", dev->status);
|
err("\r\nUSB device not accepting new address (error=%lX)\r\n", dev->status);
|
||||||
driver_mem_free(tmpbuf);
|
driver_mem_free(tmpbuf);
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
wait(10); /* Let the SET_ADDRESS settle */
|
wait_us(10); /* Let the SET_ADDRESS settle */
|
||||||
tmp = sizeof(dev->descriptor);
|
tmp = sizeof(dev->descriptor);
|
||||||
err = usb_get_descriptor(dev, USB_DT_DEVICE, 0, &dev->descriptor, sizeof(dev->descriptor));
|
error = usb_get_descriptor(dev, USB_DT_DEVICE, 0, &dev->descriptor, sizeof(dev->descriptor));
|
||||||
if (err < tmp)
|
if (error < tmp)
|
||||||
{
|
{
|
||||||
if (err < 0)
|
if (error < 0)
|
||||||
{
|
{
|
||||||
dbg("unable to get device descriptor (error=%d)\r\n", err);
|
err("unable to get device descriptor (error=%d)\r\n", error);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
dbg("USB device descriptor short read (expected %i, got %i)\r\n", tmp, err);
|
err("USB device descriptor short read (expected %i, got %i)\r\n", tmp, error);
|
||||||
}
|
}
|
||||||
driver_mem_free(tmpbuf);
|
driver_mem_free(tmpbuf);
|
||||||
|
|
||||||
@@ -1253,9 +1263,10 @@ int usb_new_device(struct usb_device *dev)
|
|||||||
{
|
{
|
||||||
dbg("failed to set default configuration len %d, status %lX\r\n", dev->act_len, dev->status);
|
dbg("failed to set default configuration len %d, status %lX\r\n", dev->act_len, dev->status);
|
||||||
driver_mem_free(tmpbuf);
|
driver_mem_free(tmpbuf);
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
dbg("new device strings: Mfr=%d, Product=%d, SerialNumber=%d\r\n",
|
dbg("new device strings: Manufacturer=%d, Product=%d, SerialNumber=%d\r\n",
|
||||||
dev->descriptor.iManufacturer, dev->descriptor.iProduct,
|
dev->descriptor.iManufacturer, dev->descriptor.iProduct,
|
||||||
dev->descriptor.iSerialNumber);
|
dev->descriptor.iSerialNumber);
|
||||||
|
|
||||||
@@ -1275,9 +1286,9 @@ int usb_new_device(struct usb_device *dev)
|
|||||||
{
|
{
|
||||||
usb_string(dev, dev->descriptor.iSerialNumber, dev->serial, sizeof(dev->serial));
|
usb_string(dev, dev->descriptor.iSerialNumber, dev->serial, sizeof(dev->serial));
|
||||||
}
|
}
|
||||||
dbg("Manufacturer %s\r\n", dev->mf);
|
inf("Manufacturer %s\r\n", dev->mf);
|
||||||
dbg("Product %s\r\n", dev->prod);
|
inf("Product %s\r\n", dev->prod);
|
||||||
dbg("SerialNumber %s\r\n", dev->serial);
|
inf("SerialNumber %s\r\n", dev->serial);
|
||||||
|
|
||||||
/* now probe if the device is a hub */
|
/* now probe if the device is a hub */
|
||||||
usb_hub_probe(dev, 0);
|
usb_hub_probe(dev, 0);
|
||||||
|
|||||||
@@ -27,13 +27,8 @@
|
|||||||
|
|
||||||
#include "usb.h"
|
#include "usb.h"
|
||||||
|
|
||||||
//// #define DEBUG_USBKBD
|
// #define DEBUG
|
||||||
#ifdef DEBUG_USBKBD
|
#include "debug.h"
|
||||||
#define dbg(format, arg...) do { xprintf("DEBUG: %s(): " format, __FUNCTION__, ##arg); } while (0)
|
|
||||||
#else
|
|
||||||
#define dbg(format, arg...) do { ; } while (0)
|
|
||||||
#endif /* DEBUG_USBKBD */
|
|
||||||
#define err(format, arg...) do { xprintf("ERROR: %s(): " format, __FUNCTION__, ##arg); } while (0)
|
|
||||||
|
|
||||||
#ifdef USE_COUNTRYCODE
|
#ifdef USE_COUNTRYCODE
|
||||||
static int usb_kbd_get_hid_desc(struct usb_device *dev);
|
static int usb_kbd_get_hid_desc(struct usb_device *dev);
|
||||||
@@ -541,7 +536,7 @@ int usb_kbd_register(struct usb_device *dev)
|
|||||||
{
|
{
|
||||||
if(!kbd_installed && (dev->devnum != -1) && (usb_kbd_probe(dev, 0) == 1))
|
if(!kbd_installed && (dev->devnum != -1) && (usb_kbd_probe(dev, 0) == 1))
|
||||||
{ /* Ok, we found a keyboard */
|
{ /* Ok, we found a keyboard */
|
||||||
//dbg("USB KBD found (iorec: 0x%x, USB: %d, devnum: %d)\r\n", iorec, dev->usbnum, dev->devnum);
|
dbg("USB KBD found (USB: %d, devnum: %d)\r\n", dev->usbnum, dev->devnum);
|
||||||
num_lock = caps_lock = scroll_lock = old_modifier = 0;
|
num_lock = caps_lock = scroll_lock = old_modifier = 0;
|
||||||
flags.s = 0;
|
flags.s = 0;
|
||||||
kbd_installed = 1;
|
kbd_installed = 1;
|
||||||
@@ -809,7 +804,7 @@ static int usb_kbd_translate(unsigned char scancode, unsigned char modifier, int
|
|||||||
flags.b.left_shift_host = 0;
|
flags.b.left_shift_host = 0;
|
||||||
}
|
}
|
||||||
#ifdef CONFIG_USB_INTERRUPT_POLLING
|
#ifdef CONFIG_USB_INTERRUPT_POLLING
|
||||||
level = asm_set_ipl(7); /* mask interrupts for use call_ikbdvec() */
|
level = set_ipl(7); /* mask interrupts for use call_ikbdvec() */
|
||||||
#endif
|
#endif
|
||||||
if(pressed && (flags.b.force_alt_shift))
|
if(pressed && (flags.b.force_alt_shift))
|
||||||
{
|
{
|
||||||
@@ -841,7 +836,7 @@ static int usb_kbd_translate(unsigned char scancode, unsigned char modifier, int
|
|||||||
usb_kbd_send_code(0x38); /* ALT */
|
usb_kbd_send_code(0x38); /* ALT */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if((keycode !=0) && (keycode <= MAX_VALUE_ATARI))
|
if ((keycode !=0) && (keycode <= MAX_VALUE_ATARI))
|
||||||
usb_kbd_send_code(pressed ? keycode : keycode | 0x80);
|
usb_kbd_send_code(pressed ? keycode : keycode | 0x80);
|
||||||
if(!pressed && (flags.b.force_alt_shift))
|
if(!pressed && (flags.b.force_alt_shift))
|
||||||
{
|
{
|
||||||
@@ -874,9 +869,9 @@ static int usb_kbd_translate(unsigned char scancode, unsigned char modifier, int
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
#ifdef CONFIG_USB_INTERRUPT_POLLING
|
#ifdef CONFIG_USB_INTERRUPT_POLLING
|
||||||
asm_set_ipl(level);
|
set_ipl(level);
|
||||||
#endif
|
#endif
|
||||||
if(pressed == 1)
|
if (pressed == 1)
|
||||||
{
|
{
|
||||||
if(scancode == NUM_LOCK)
|
if(scancode == NUM_LOCK)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -283,10 +283,10 @@ static struct radeonfb_info rfb =
|
|||||||
|
|
||||||
static struct fb_var_screeninfo default_fb =
|
static struct fb_var_screeninfo default_fb =
|
||||||
{
|
{
|
||||||
.xres = 1280,
|
.xres = 640,
|
||||||
.yres = 1024,
|
.yres = 480,
|
||||||
.xres_virtual = 1280,
|
.xres_virtual = 640,
|
||||||
.yres_virtual = 1024 * 2, /* ensure we have accel offscreen space */
|
.yres_virtual = 480 * 2, /* ensure we have accel offscreen space */
|
||||||
.bits_per_pixel = 8,
|
.bits_per_pixel = 8,
|
||||||
.grayscale = 0,
|
.grayscale = 0,
|
||||||
.red = { .length = 8 },
|
.red = { .length = 8 },
|
||||||
@@ -295,13 +295,13 @@ static struct fb_var_screeninfo default_fb =
|
|||||||
.activate = FB_ACTIVATE_NOW,
|
.activate = FB_ACTIVATE_NOW,
|
||||||
.height = -1,
|
.height = -1,
|
||||||
.width = -1,
|
.width = -1,
|
||||||
.pixclock = 7407,
|
.pixclock = 39721,
|
||||||
.left_margin = 256,
|
.left_margin = 40,
|
||||||
.right_margin = 32,
|
.right_margin = 24,
|
||||||
.upper_margin = 34,
|
.upper_margin = 32,
|
||||||
.lower_margin = 3,
|
.lower_margin = 11,
|
||||||
.hsync_len = 144,
|
.hsync_len = 96,
|
||||||
.vsync_len = 3,
|
.vsync_len = 2,
|
||||||
.vmode = FB_VMODE_NONINTERLACED,
|
.vmode = FB_VMODE_NONINTERLACED,
|
||||||
.activate = FB_ACTIVATE_ALL | FB_ACTIVATE_FORCE | FB_ACTIVATE_NOW
|
.activate = FB_ACTIVATE_ALL | FB_ACTIVATE_FORCE | FB_ACTIVATE_NOW
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user