code compiles - not tested yet
This commit is contained in:
106
include/ohci.h
106
include/ohci.h
@@ -72,24 +72,24 @@ static const char *cc_to_string[16] = {
|
||||
|
||||
/* usb_ohci_ed */
|
||||
struct ed {
|
||||
__u32 hwINFO;
|
||||
__u32 hwTailP;
|
||||
__u32 hwHeadP;
|
||||
__u32 hwNextED;
|
||||
uint32_t hwINFO;
|
||||
uint32_t hwTailP;
|
||||
uint32_t hwHeadP;
|
||||
uint32_t hwNextED;
|
||||
|
||||
struct ed *ed_prev;
|
||||
__u8 int_period;
|
||||
__u8 int_branch;
|
||||
__u8 int_load;
|
||||
__u8 int_interval;
|
||||
__u8 state;
|
||||
__u8 type;
|
||||
__u16 last_iso;
|
||||
uint8_t int_period;
|
||||
uint8_t int_branch;
|
||||
uint8_t int_load;
|
||||
uint8_t int_interval;
|
||||
uint8_t state;
|
||||
uint8_t type;
|
||||
uint16_t last_iso;
|
||||
struct ed *ed_rm_list;
|
||||
|
||||
struct usb_device *usb_dev;
|
||||
void *purb;
|
||||
__u32 unused[2];
|
||||
uint32_t unused[2];
|
||||
} __attribute__((aligned(16)));
|
||||
typedef struct ed ed_t;
|
||||
|
||||
@@ -133,21 +133,21 @@ typedef struct ed ed_t;
|
||||
#define MAXPSW 1
|
||||
|
||||
struct td {
|
||||
__u32 hwINFO;
|
||||
__u32 hwCBP; /* Current Buffer Pointer */
|
||||
__u32 hwNextTD; /* Next TD Pointer */
|
||||
__u32 hwBE; /* Memory Buffer End Pointer */
|
||||
uint32_t hwINFO;
|
||||
uint32_t hwCBP; /* Current Buffer Pointer */
|
||||
uint32_t hwNextTD; /* Next TD Pointer */
|
||||
uint32_t hwBE; /* Memory Buffer End Pointer */
|
||||
|
||||
__u16 hwPSW[MAXPSW];
|
||||
__u8 unused;
|
||||
__u8 index;
|
||||
uint16_t hwPSW[MAXPSW];
|
||||
uint8_t unused;
|
||||
uint8_t index;
|
||||
struct ed *ed;
|
||||
struct td *next_dl_td;
|
||||
struct usb_device *usb_dev;
|
||||
int transfer_len;
|
||||
__u32 data;
|
||||
uint32_t data;
|
||||
|
||||
__u32 unused2[2];
|
||||
uint32_t unused2[2];
|
||||
} __attribute__((aligned(32)));
|
||||
typedef struct td td_t;
|
||||
|
||||
@@ -161,15 +161,15 @@ typedef struct td td_t;
|
||||
|
||||
#define NUM_INTS 32 /* part of the OHCI standard */
|
||||
struct ohci_hcca {
|
||||
__u32 int_table[NUM_INTS]; /* Interrupt ED table */
|
||||
uint32_t int_table[NUM_INTS]; /* Interrupt ED table */
|
||||
#if defined(CONFIG_MPC5200)
|
||||
__u16 pad1; /* set to 0 on each frame_no change */
|
||||
__u16 frame_no; /* current frame number */
|
||||
uint16_t pad1; /* set to 0 on each frame_no change */
|
||||
uint16_t frame_no; /* current frame number */
|
||||
#else
|
||||
__u16 frame_no; /* current frame number */
|
||||
__u16 pad1; /* set to 0 on each frame_no change */
|
||||
uint16_t frame_no; /* current frame number */
|
||||
uint16_t pad1; /* set to 0 on each frame_no change */
|
||||
#endif
|
||||
__u32 done_head; /* info returned for an interrupt */
|
||||
uint32_t done_head; /* info returned for an interrupt */
|
||||
u8 reserved_for_hc[116];
|
||||
} __attribute__((aligned(256)));
|
||||
|
||||
@@ -180,32 +180,32 @@ struct ohci_hcca {
|
||||
*/
|
||||
struct ohci_regs {
|
||||
/* control and status registers */
|
||||
__u32 revision;
|
||||
__u32 control;
|
||||
__u32 cmdstatus;
|
||||
__u32 intrstatus;
|
||||
__u32 intrenable;
|
||||
__u32 intrdisable;
|
||||
uint32_t revision;
|
||||
uint32_t control;
|
||||
uint32_t cmdstatus;
|
||||
uint32_t intrstatus;
|
||||
uint32_t intrenable;
|
||||
uint32_t intrdisable;
|
||||
/* memory pointers */
|
||||
__u32 hcca;
|
||||
__u32 ed_periodcurrent;
|
||||
__u32 ed_controlhead;
|
||||
__u32 ed_controlcurrent;
|
||||
__u32 ed_bulkhead;
|
||||
__u32 ed_bulkcurrent;
|
||||
__u32 donehead;
|
||||
uint32_t hcca;
|
||||
uint32_t ed_periodcurrent;
|
||||
uint32_t ed_controlhead;
|
||||
uint32_t ed_controlcurrent;
|
||||
uint32_t ed_bulkhead;
|
||||
uint32_t ed_bulkcurrent;
|
||||
uint32_t donehead;
|
||||
/* frame counters */
|
||||
__u32 fminterval;
|
||||
__u32 fmremaining;
|
||||
__u32 fmnumber;
|
||||
__u32 periodicstart;
|
||||
__u32 lsthresh;
|
||||
uint32_t fminterval;
|
||||
uint32_t fmremaining;
|
||||
uint32_t fmnumber;
|
||||
uint32_t periodicstart;
|
||||
uint32_t lsthresh;
|
||||
/* Root hub ports */
|
||||
struct ohci_roothub_regs {
|
||||
__u32 a;
|
||||
__u32 b;
|
||||
__u32 status;
|
||||
__u32 portstatus[USB_OHCI_MAX_ROOT_PORTS];
|
||||
uint32_t a;
|
||||
uint32_t b;
|
||||
uint32_t status;
|
||||
uint32_t portstatus[USB_OHCI_MAX_ROOT_PORTS];
|
||||
} roothub;
|
||||
} __attribute__((aligned(32)));
|
||||
|
||||
@@ -365,8 +365,8 @@ struct virt_root_hub {
|
||||
typedef struct
|
||||
{
|
||||
ed_t *ed;
|
||||
__u16 length; /* number of tds associated with this request */
|
||||
__u16 td_cnt; /* number of tds already serviced */
|
||||
uint16_t length; /* number of tds associated with this request */
|
||||
uint16_t td_cnt; /* number of tds already serviced */
|
||||
struct usb_device *dev;
|
||||
int state;
|
||||
unsigned long pipe;
|
||||
@@ -425,8 +425,8 @@ typedef struct ohci {
|
||||
ed_t *ed_bulktail; /* last endpoint of bulk list */
|
||||
ed_t *ed_controltail; /* last endpoint of control list */
|
||||
int intrstatus;
|
||||
__u32 hc_control; /* copy of the hc control reg */
|
||||
__u32 ndp; /* copy NDP from roothub_a */
|
||||
uint32_t hc_control; /* copy of the hc control reg */
|
||||
uint32_t ndp; /* copy NDP from roothub_a */
|
||||
struct virt_root_hub rh;
|
||||
|
||||
const char *slot_name;
|
||||
|
||||
@@ -200,6 +200,25 @@ extern void init_xlbus_arbiter(void);
|
||||
extern void init_pci(void);
|
||||
|
||||
extern int pci_find_device(uint16_t device_id, uint16_t vendor_id, int index);
|
||||
/* FIXME: parameters missing */
|
||||
|
||||
extern uint32_t pci_read_config_longword(uint16_t handle, uint16_t offset);
|
||||
extern uint16_t pci_read_config_word(uint16_t handle, uint16_t offset);
|
||||
extern uint8_t pci_read_config_byte(uint16_t handle, uint16_t offset);
|
||||
|
||||
extern void pci_write_config_longword(uint16_t handle, uint16_t offset, uint32_t value);
|
||||
extern void pci_write_config_word(uint16_t handle, uint16_t offset, uint16_t value);
|
||||
extern void pci_write_config_byte(uint16_t handle, uint16_t offset, uint8_t value);
|
||||
|
||||
extern void *pci_get_resource();
|
||||
extern void pci_hook_interrupt();
|
||||
extern void pci_unhook_interrupt();
|
||||
|
||||
|
||||
|
||||
#define PCI_HANDLE(bus, slot, function) (0 | ((bus & 0xff) << 8 | (slot & 0x1f) << 3 | (function & 7)))
|
||||
#define PCI_BUS_FROM_HANDLE(h) (((h) & 0xff00) >> 8)
|
||||
#define PCI_SLOT_FROM_HANDLE(h) (((h) & 0xf8) >> 3)
|
||||
#define PCI_FUNCTION_FROM_HANDLE(h) (((h) & 0x7))
|
||||
|
||||
#endif /* _PCI_H_ */
|
||||
|
||||
@@ -233,28 +233,16 @@ int ohci_usb_lowlevel_stop(void *priv);
|
||||
int ohci_submit_bulk_msg(struct usb_device *dev, unsigned long pipe, void *buffer, int transfer_len);
|
||||
int ohci_submit_control_msg(struct usb_device *dev, unsigned long pipe, void *buffer, int transfer_len, struct devrequest *setup);
|
||||
int ohci_submit_int_msg(struct usb_device *dev, unsigned long pipe, void *buffer, int transfer_len, int interval);
|
||||
#ifdef CONFIG_USB_INTERRUPT_POLLING
|
||||
void ohci_usb_event_poll(int interrupt);
|
||||
#else
|
||||
void ohci_usb_enable_interrupt(int enable);
|
||||
#endif /* CONFIG_USB_INTERRUPT_POLLING */
|
||||
|
||||
int ehci_usb_lowlevel_init(long handle, const struct pci_device_id *ent, void **priv);
|
||||
int ehci_usb_lowlevel_stop(void *priv);
|
||||
int ehci_submit_bulk_msg(struct usb_device *dev, unsigned long pipe, void *buffer, int transfer_len);
|
||||
int ehci_submit_control_msg(struct usb_device *dev, unsigned long pipe, void *buffer, int transfer_len, struct devrequest *setup);
|
||||
int ehci_submit_int_msg(struct usb_device *dev, unsigned long pipe, void *buffer, int transfer_len, int interval);
|
||||
#ifdef CONFIG_USB_INTERRUPT_POLLING
|
||||
void ehci_usb_event_poll(int interrupt);
|
||||
#else
|
||||
void ehci_usb_enable_interrupt(int enable);
|
||||
#endif /* CONFIG_USB_INTERRUPT_POLLING */
|
||||
|
||||
#ifdef CONFIG_USB_INTERRUPT_POLLING
|
||||
void usb_event_poll(int interrupt);
|
||||
#else
|
||||
void usb_enable_interrupt(int enable);
|
||||
#endif /* CONFIG_USB_INTERRUPT_POLLING */
|
||||
|
||||
#define USB_MAX_STOR_DEV 5
|
||||
block_dev_desc_t *usb_stor_get_dev(int index);
|
||||
@@ -302,55 +290,6 @@ int usb_clear_halt(struct usb_device *dev, int pipe);
|
||||
int usb_string(struct usb_device *dev, int index, char *buf, size_t size);
|
||||
int usb_set_interface(struct usb_device *dev, int interface, int alternate);
|
||||
|
||||
extern unsigned short swap_short(unsigned short val);
|
||||
extern unsigned long swap_long(unsigned long val);
|
||||
|
||||
#if 1
|
||||
#define __swap_16(x) swap_short(x)
|
||||
#define __swap_32(x) swap_long(x)
|
||||
#else
|
||||
/* big endian -> little endian conversion */
|
||||
/* some CPUs are already little endian e.g. the ARM920T */
|
||||
#define __swap_16(x) \
|
||||
({ unsigned short x_ = (unsigned short)x; \
|
||||
(unsigned short)( \
|
||||
((x_ & 0x00FFU) << 8) | ((x_ & 0xFF00U) >> 8)); \
|
||||
})
|
||||
#define __swap_32(x) \
|
||||
({ unsigned long x_ = (unsigned long)x; \
|
||||
(unsigned long)( \
|
||||
((x_ & 0x000000FFUL) << 24) | \
|
||||
((x_ & 0x0000FF00UL) << 8) | \
|
||||
((x_ & 0x00FF0000UL) >> 8) | \
|
||||
((x_ & 0xFF000000UL) >> 24)); \
|
||||
})
|
||||
#endif
|
||||
|
||||
#define swap_16(x) __swap_16(x)
|
||||
#define swap_32(x) __swap_32(x)
|
||||
|
||||
#define le16_to_cpu cpu_to_le16
|
||||
#define le32_to_cpu cpu_to_le32
|
||||
#define cpu_to_be32(a) a
|
||||
|
||||
static inline unsigned short cpu_to_le16(unsigned short val)
|
||||
{
|
||||
return(swap_short(val));
|
||||
}
|
||||
static inline unsigned long cpu_to_le32(unsigned long val)
|
||||
{
|
||||
return(swap_long(val));
|
||||
}
|
||||
|
||||
static inline void le16_to_cpus(unsigned short *val)
|
||||
{
|
||||
*val = le16_to_cpu(*val);
|
||||
}
|
||||
static inline void le32_to_cpus(unsigned long *val)
|
||||
{
|
||||
*val = le32_to_cpu(*val);
|
||||
}
|
||||
|
||||
/*
|
||||
* Calling this entity a "pipe" is glorifying it. A USB pipe
|
||||
* is something embarrassingly simple: it basically consists
|
||||
|
||||
@@ -25,48 +25,54 @@
|
||||
#ifndef UTIL_H_
|
||||
#define UTIL_H_
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
/*
|
||||
* WORD swpw(WORD val);
|
||||
* uint16_t swpw(uint16_t val);
|
||||
* swap endianess of val, 16 bits only.
|
||||
*/
|
||||
|
||||
#define swpw(a) \
|
||||
__extension__ \
|
||||
({long _tmp; \
|
||||
__asm__ __volatile__ \
|
||||
("move.w %0,%1\n\t" \
|
||||
"lsl.l #8,%0\n\t" \
|
||||
"lsr.l #8,%1\n\t" \
|
||||
"move.b %1,%0" \
|
||||
: "=d"(a), "=d"(_tmp) /* outputs */ \
|
||||
: "0"(a) /* inputs */ \
|
||||
: "cc" /* clobbered */ \
|
||||
); \
|
||||
})
|
||||
|
||||
inline uint16_t swpw(uint16_t w)
|
||||
{
|
||||
register uint32_t result asm("d0");
|
||||
__asm__ __volatile__
|
||||
(
|
||||
"lea %[input],a0\n\t" \
|
||||
"mvz.b 3(a0),%[output]\n\t" \
|
||||
"lsl.l #8,%[output]\n\t" \
|
||||
"move.b 2(a0),%[output]\n\t" \
|
||||
: [output] "=d" (result) /* output */
|
||||
: [input] "o" (w) /* input */
|
||||
: "cc", "a0", "memory" /* clobbered */
|
||||
);
|
||||
return result;
|
||||
}
|
||||
|
||||
/*
|
||||
* WORD swpl(LONG val);
|
||||
* uint32_t swpl(uint32_t val);
|
||||
* swap endianess of val, 32 bits only.
|
||||
* e.g. ABCD => DCBA
|
||||
*/
|
||||
inline uint32_t swpl(uint32_t l)
|
||||
{
|
||||
register uint32_t result asm("d0");
|
||||
|
||||
#define swpl(a) \
|
||||
__extension__ \
|
||||
({long _tmp; \
|
||||
__asm__ __volatile__ \
|
||||
("move.b (%1),%0\n\t" \
|
||||
"move.b 3(%1),(%1)\n\t" \
|
||||
"move.b %0,3(%1)\n\t" \
|
||||
"move.b 1(%1),%0\n\t" \
|
||||
"move.b 2(%1),1(%1)\n\t" \
|
||||
"move.b %0,2(%1)" \
|
||||
: "=d"(_tmp) /* outputs */ \
|
||||
: "a"(&a) /* inputs */ \
|
||||
: "cc", "memory" /* clobbered */ \
|
||||
); \
|
||||
})
|
||||
|
||||
__asm__ __volatile__
|
||||
(
|
||||
"lea %[input],a0\n\t" \
|
||||
"mvz.b 3(a0),%[output]\n\t" \
|
||||
"lsl.l #8,%[output]\n\t" \
|
||||
"move.b 2(a0),%[output]\n\t" \
|
||||
"lsl.l #8,%[output]\n\t" \
|
||||
"move.b 1(a0),%[output]\n\t" \
|
||||
"lsl.l #8,%[output]\n\t" \
|
||||
"move.b (a0),%[output]\n\t" \
|
||||
: [output] "=d" (result) /* output */
|
||||
: [input] "o" (l) /* input */
|
||||
: "cc", "a0", "memory" /* clobbered */
|
||||
);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* WORD swpw2(ULONG val);
|
||||
|
||||
Reference in New Issue
Block a user