summaryrefslogtreecommitdiff
path: root/EmbeddedPkg/Drivers/Isp1761UsbDxe/Isp1761UsbDxe.h
blob: 9e60e155d703d2d0f551a40e704e9c7f22dc9cbd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
/** @file

  Copyright (c) 2013-2014, ARM Ltd. All rights reserved.<BR>

  This program and the accompanying materials
  are licensed and made available under the terms and conditions of the BSD License
  which accompanies this distribution.  The full text of the license may be found at
  http://opensource.org/licenses/bsd-license.php

  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.

**/

#ifndef __ISP1761_USB_DXE_H__
#define __ISP1761_USB_DXE_H__

#define ISP1761_USB_BASE FixedPcdGet32 (PcdIsp1761BaseAddress)

#define READ_REG32(Offset) MmioRead32 (ISP1761_USB_BASE + Offset)
#define READ_REG16(Offset) (UINT16) READ_REG32 (Offset)
#define WRITE_REG32(Offset, Val)  MmioWrite32 (ISP1761_USB_BASE + Offset, Val)
#define WRITE_REG16(Offset, Val)  MmioWrite32 (ISP1761_USB_BASE + Offset, (UINT32) Val)
#define WRITE_REG8(Offset, Val)   MmioWrite32 (ISP1761_USB_BASE + Offset, (UINT32) Val)

// Max packet size in bytes (For Full Speed USB 64 is the only valid value)
#define MAX_PACKET_SIZE_CONTROL     64

#define MAX_PACKET_SIZE_BULK        512

// 8 Endpoints, in and out. Don't count the Endpoint 0 setup buffer
#define ISP1761_NUM_ENDPOINTS               16

// Endpoint Indexes
#define ISP1761_EP0SETUP                    0x20
#define ISP1761_EP0RX                       0x00
#define ISP1761_EP0TX                       0x01
#define ISP1761_EP1RX                       0x02
#define ISP1761_EP1TX                       0x03

// DcInterrupt bits
#define ISP1761_DC_INTERRUPT_BRESET         BIT0
#define ISP1761_DC_INTERRUPT_SOF            BIT1
#define ISP1761_DC_INTERRUPT_PSOF           BIT2
#define ISP1761_DC_INTERRUPT_SUSP           BIT3
#define ISP1761_DC_INTERRUPT_RESUME         BIT4
#define ISP1761_DC_INTERRUPT_HS_STAT        BIT5
#define ISP1761_DC_INTERRUPT_DMA            BIT6
#define ISP1761_DC_INTERRUPT_VBUS           BIT7
#define ISP1761_DC_INTERRUPT_EP0SETUP       BIT8
#define ISP1761_DC_INTERRUPT_EP0RX          BIT10
#define ISP1761_DC_INTERRUPT_EP0TX          BIT11
#define ISP1761_DC_INTERRUPT_EP1RX          BIT12
#define ISP1761_DC_INTERRUPT_EP1TX          BIT13
// All valid peripheral controller interrupts
#define ISP1761_DC_INTERRUPT_MASK           0x003FFFDFF

#define ISP1761_ADDRESS                     0x200
#define ISP1761_ADDRESS_DEVEN               BIT7

#define ISP1761_MODE                        0x20C
#define ISP1761_MODE_DATA_BUS_WIDTH         BIT8
#define ISP1761_MODE_CLKAON                 BIT7
#define ISP1761_MODE_SFRESET                BIT4
#define ISP1761_MODE_WKUPCS                 BIT2

#define ISP1761_ENDPOINT_MAX_PACKET_SIZE    0x204

#define ISP1761_ENDPOINT_TYPE               0x208
#define ISP1761_ENDPOINT_TYPE_NOEMPKT       BIT4
#define ISP1761_ENDPOINT_TYPE_ENABLE        BIT3

#define ISP1761_INTERRUPT_CONFIG            0x210
// Interrupt config value to only interrupt on ACK of IN and OUT tokens
#define ISP1761_INTERRUPT_CONFIG_ACK_ONLY   BIT2 | BIT5 | BIT6

#define ISP1761_DC_INTERRUPT                0x218
#define ISP1761_DC_INTERRUPT_ENABLE         0x214

#define ISP1761_CTRL_FUNCTION               0x228
#define ISP1761_CTRL_FUNCTION_VENDP         BIT3
#define ISP1761_CTRL_FUNCTION_DSEN          BIT2
#define ISP1761_CTRL_FUNCTION_STATUS        BIT1

#define ISP1761_DEVICE_UNLOCK               0x27C
#define ISP1761_DEVICE_UNLOCK_MAGIC         0xAA37

#define ISP1761_SW_RESET_REG                0x30C
#define ISP1761_SW_RESET_ALL                BIT0

#define ISP1761_DEVICE_ID                   0x370

#define ISP1761_OTG_CTRL_SET                0x374
#define ISP1761_OTG_CTRL_CLR                OTG_CTRL_SET + 2
#define ISP1761_OTG_CTRL_OTG_DISABLE        BIT10
#define ISP1761_OTG_CTRL_VBUS_CHRG          BIT6
#define ISP1761_OTG_CTRL_VBUS_DISCHRG       BIT5
#define ISP1761_OTG_CTRL_DM_PULLDOWN        BIT2
#define ISP1761_OTG_CTRL_DP_PULLDOWN        BIT1
#define ISP1761_OTG_CTRL_DP_PULLUP          BIT0

#define ISP1761_OTG_STATUS                  0x378
#define ISP1761_OTG_STATUS_B_SESS_END       BIT7
#define ISP1761_OTG_STATUS_A_B_SESS_VLD     BIT1

#define ISP1761_OTG_INTERRUPT_LATCH_SET     0x37C
#define ISP1761_OTG_INTERRUPT_LATCH_CLR     0x37E
#define ISP1761_OTG_INTERRUPT_ENABLE_RISE   0x384

#define ISP1761_DMA_ENDPOINT_INDEX          0x258

#define ISP1761_ENDPOINT_INDEX              0x22c
#define ISP1761_DATA_PORT                   0x220
#define ISP1761_BUFFER_LENGTH               0x21c

// Device ID Values
#define PHILLIPS_VENDOR_ID_VAL 0x04cc
#define ISP1761_PRODUCT_ID_VAL 0x1761
#define ISP1761_DEVICE_ID_VAL ((ISP1761_PRODUCT_ID_VAL << 16) |\
                               PHILLIPS_VENDOR_ID_VAL)

#endif //ifndef __ISP1761_USB_DXE_H__