OpenCores
URL https://opencores.org/ocsvn/openrisc_me/openrisc_me/trunk

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [orpsocv2/] [boards/] [actel/] [ordb1a3pe1500/] [sw/] [drivers/] [usbhostslave/] [usbhostslave-slave.c] - Blame information for rev 408

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 408 julius
/*
2
 *
3
 * USB usbhostslave core slave functions, very basic
4
 *
5
 * Julius Baxter, julius@opencores.org
6
 *
7
 */
8
 
9
#include "cpu-utils.h"
10
#include "board.h"
11
#include "usbhostslave-slave.h"
12
 
13
const int USBHOSTSLAVE_SLAVE_CORE_ADR[2] = { USB0_BASE, USB1_BASE };
14
 
15
void usb_slave_set_addr(int core, char addr)
16
{
17
        REG8(USBHOSTSLAVE_SLAVE_CORE_ADR[core] + USBSLAVE_SC_ADDRESS) = addr;
18
}
19
 
20
void usb_slave_global_enable_endpoints(int core)
21
{
22
        REG8(USBHOSTSLAVE_SLAVE_CORE_ADR[core] + USBSLAVE_SC_CONTROL_REG) |=
23
            USBSLAVE_SC_CONTROL_REG_GLOBAL_ENABLE;
24
}
25
 
26
void usb_slave_global_disable_endpoints(int core)
27
{
28
        REG8(USBHOSTSLAVE_SLAVE_CORE_ADR[core] + USBSLAVE_SC_CONTROL_REG) &=
29
            ~USBSLAVE_SC_CONTROL_REG_GLOBAL_ENABLE;
30
}
31
 
32
void usb_slave_endpoint_enable(int core, int ep)
33
{
34
        REG8(USBHOSTSLAVE_SLAVE_CORE_ADR[core] + USBSLAVE_EP0_CONTROL_REG +
35
             (ep << 2)) |= USBSLAVE_CONTROL_REG_ENDPOINT_ENABLE;
36
}
37
 
38
void usb_slave_endpoint_disable(int core, int ep)
39
{
40
        REG8(USBHOSTSLAVE_SLAVE_CORE_ADR[core] + USBSLAVE_EP0_CONTROL_REG +
41
             (ep << 2)) &= ~USBSLAVE_CONTROL_REG_ENDPOINT_ENABLE;
42
}
43
 
44
void usb_slave_endpoint_ready(int core, int ep)
45
{
46
        REG8(USBHOSTSLAVE_SLAVE_CORE_ADR[core] + USBSLAVE_EP0_CONTROL_REG +
47
             (ep << 2)) |= USBSLAVE_CONTROL_REG_ENDPOINT_READY;
48
}
49
 
50
void usb_slave_endpoint_unready(int core, int ep)
51
{
52
        REG8(USBHOSTSLAVE_SLAVE_CORE_ADR[core] + USBSLAVE_EP0_CONTROL_REG +
53
             (ep << 2)) &= ~USBSLAVE_CONTROL_REG_ENDPOINT_READY;
54
}
55
 
56
void usb_slave_endpoint_outdataseqset(int core, int ep, int outdata)
57
{
58
        if (outdata)
59
                REG8(USBHOSTSLAVE_SLAVE_CORE_ADR[core] +
60
                     USBSLAVE_EP0_CONTROL_REG + (ep << 2)) |=
61
                    USBSLAVE_CONTROL_REG_ENDPOINT_OUTDATA_SEQ;
62
        else
63
                REG8(USBHOSTSLAVE_SLAVE_CORE_ADR[core] +
64
                     USBSLAVE_EP0_CONTROL_REG + (ep << 2)) &=
65
                    ~USBSLAVE_CONTROL_REG_ENDPOINT_OUTDATA_SEQ;
66
}
67
 
68
void usb_slave_endpoint_sendstallset(int core, int ep, int sendstall)
69
{
70
        if (sendstall)
71
                REG8(USBHOSTSLAVE_SLAVE_CORE_ADR[core] +
72
                     USBSLAVE_EP0_CONTROL_REG + (ep << 2)) |=
73
                    USBSLAVE_CONTROL_REG_ENDPOINT_SEND_STALL;
74
        else
75
                REG8(USBHOSTSLAVE_SLAVE_CORE_ADR[core] +
76
                     USBSLAVE_EP0_CONTROL_REG + (ep << 2)) &=
77
                    ~USBSLAVE_CONTROL_REG_ENDPOINT_SEND_STALL;
78
}
79
 
80
void usb_slave_endpoint_isoset(int core, int ep, int iso)
81
{
82
        if (iso)
83
                REG8(USBHOSTSLAVE_SLAVE_CORE_ADR[core] +
84
                     USBSLAVE_EP0_CONTROL_REG + (ep << 2)) |=
85
                    USBSLAVE_CONTROL_REG_ENDPOINT_ISO_ENABLE;
86
        else
87
                REG8(USBHOSTSLAVE_SLAVE_CORE_ADR[core] +
88
                     USBSLAVE_EP0_CONTROL_REG + (ep << 2)) &=
89
                    ~USBSLAVE_CONTROL_REG_ENDPOINT_ISO_ENABLE;
90
}
91
 
92
int usb_slave_get_frame_num(int core)
93
{
94
        int framenum = (int)REG8(USBHOSTSLAVE_SLAVE_CORE_ADR[core] +
95
                                 USBSLAVE_SC_FRAME_NUM_LSP);
96
        framenum |= (int)(REG8(USBHOSTSLAVE_SLAVE_CORE_ADR[core] +
97
                               USBSLAVE_SC_FRAME_NUM_MSP) << 8);
98
        return framenum;
99
}
100
 
101
void usb_slave_endpoint_tx_fifo_write(int core, int ep, char data)
102
{
103
        REG8(USBHOSTSLAVE_SLAVE_CORE_ADR[core] + USBSLAVE_EP0_TX_FIFO_DATA +
104
             (ep << 5)) = data;
105
}
106
 
107
char usb_slave_endpoint_rx_fifo_read_data(int core, int ep)
108
{
109
        return REG8(USBHOSTSLAVE_SLAVE_CORE_ADR[core] +
110
                    USBSLAVE_EP0_RX_FIFO_DATA + (ep << 5));
111
}
112
 
113
int usb_slave_endpoint_rx_fifo_read_count(int core, int ep)
114
{
115
        int count;
116
        count = (int)REG8(USBHOSTSLAVE_SLAVE_CORE_ADR[core] +
117
                          USBSLAVE_EP0_RX_FIFO_DATA_CNT_LSB + (ep << 5));
118
        count |= (int)(REG8(USBHOSTSLAVE_SLAVE_CORE_ADR[core] +
119
                            USBSLAVE_EP0_RX_FIFO_DATA_CNT_MSB +
120
                            (ep << 5)) << 8);
121
        return count;
122
}
123
 
124
void usb_slave_endpoint_rx_fifo_clear(int core, int ep)
125
{
126
        REG8(USBHOSTSLAVE_SLAVE_CORE_ADR[core] +
127
             USBSLAVE_EP3_RX_FIFO_CONTROL_REG + (ep << 5)) =
128
            USBSLAVE_FIFO_CONTROL_REG_FORCE_EMPTY;
129
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.