Skip to content

Commit 0e1632e

Browse files
committed
Adding USB Clock and Reset
1 parent 0b664f2 commit 0e1632e

File tree

1 file changed

+21
-2
lines changed

1 file changed

+21
-2
lines changed

a64_usbhost.c

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
#include "hardware/a64_usbotg.h"
4646
// TODO #include "a64_periphclks.h"
4747
// TODO #include "a641020-evk.h"
48+
#include "arm64_arch.h"
4849

4950
#include <arch/board/board.h> /* Must always be included last */
5051

@@ -127,55 +128,66 @@ static int ehci_waiter(int argc, char *argv[])
127128
// #define BUS_SOFT_RST_REG1 (A64_CCU_ADDR + 0x02c4)
128129
// #define DE_RST (1 << 12)
129130

131+
// Set the bit
130132
static void set_bit(unsigned long addr, uint8_t bit)
131133
{
134+
_info("0x%lx Bit %d\n", addr, bit);
132135
modreg32(1 << bit, 1 << bit, addr);
133136
}
134137

138+
// Enable USB Clocks
135139
// https://github.com/lupyuen/pinephone-nuttx-usb#usb-controller-clocks
136140
// https://github.com/lupyuen/pinephone-nuttx-usb#enable-usb-controller-clocks
137-
static void a64_usbhost_clk_enable()
141+
static void a64_usbhost_clk_enable(void)
138142
{
139143
// usb0_phy: CLK_USB_PHY0
140144
// 0x0cc BIT(8)
145+
_info("CLK_USB_PHY0\n");
141146
#define CLK_USB_PHY0 (A64_CCU_ADDR + 0x0cc)
142147
#define CLK_USB_PHY0_BIT 8
143148
set_bit(CLK_USB_PHY0, CLK_USB_PHY0_BIT);
144149

145150
// usb1_phy: CLK_USB_PHY1
146151
// 0x0cc BIT(9)
152+
_info("CLK_USB_PHY1\n");
147153
#define CLK_USB_PHY1 (A64_CCU_ADDR + 0x0cc)
148154
#define CLK_USB_PHY1_BIT 9
149155
set_bit(CLK_USB_PHY1, CLK_USB_PHY1_BIT);
150156

151157
// EHCI0: CLK_BUS_OHCI0, CLK_BUS_EHCI0, CLK_USB_OHCI0
152158
// 0x060 BIT(28)
159+
_info("CLK_BUS_OHCI0\n");
153160
#define CLK_BUS_OHCI0 (A64_CCU_ADDR + 0x060)
154161
#define CLK_BUS_OHCI0_BIT 28
155162
set_bit(CLK_BUS_OHCI0, CLK_BUS_OHCI0_BIT);
156163

157164
// 0x060 BIT(24)
165+
_info("CLK_BUS_EHCI0\n");
158166
#define CLK_BUS_EHCI0 (A64_CCU_ADDR + 0x060)
159167
#define CLK_BUS_EHCI0_BIT 24
160168
set_bit(CLK_BUS_EHCI0, CLK_BUS_EHCI0_BIT);
161169

162170
// 0x0cc BIT(16)
171+
_info("CLK_USB_OHCI0\n");
163172
#define CLK_USB_OHCI0 (A64_CCU_ADDR + 0x0cc)
164173
#define CLK_USB_OHCI0_BIT 16
165174
set_bit(CLK_USB_OHCI0, CLK_USB_OHCI0_BIT);
166175

167176
// EHCI1: CLK_BUS_OHCI1, CLK_BUS_EHCI1, CLK_USB_OHCI1
168177
// 0x060 BIT(29)
178+
_info("CLK_BUS_OHCI1\n");
169179
#define CLK_BUS_OHCI1 (A64_CCU_ADDR + 0x060)
170180
#define CLK_BUS_OHCI1_BIT 29
171181
set_bit(CLK_BUS_OHCI1, CLK_BUS_OHCI1_BIT);
172182

173183
// 0x060 BIT(25)
184+
_info("CLK_BUS_EHCI1\n");
174185
#define CLK_BUS_EHCI1 (A64_CCU_ADDR + 0x060)
175186
#define CLK_BUS_EHCI1_BIT 25
176187
set_bit(CLK_BUS_EHCI1, CLK_BUS_EHCI1_BIT);
177188

178189
// 0x0cc BIT(17)
190+
_info("CLK_USB_OHCI1\n");
179191
#define CLK_USB_OHCI1 (A64_CCU_ADDR + 0x0cc)
180192
#define CLK_USB_OHCI1_BIT 17
181193
set_bit(CLK_USB_OHCI1, CLK_USB_OHCI1_BIT);
@@ -191,40 +203,47 @@ static void a64_usbhost_clk_enable()
191203
// modreg32(clk, clk_mask, DE_CLK_REG);
192204
}
193205

206+
// Deassert USB Resets
194207
// https://github.com/lupyuen/pinephone-nuttx-usb#usb-controller-reset
195208
// https://github.com/lupyuen/pinephone-nuttx-usb#reset-usb-controller
196-
static void a64_usbhost_reset_deassert()
209+
static void a64_usbhost_reset_deassert(void)
197210
{
198211
// usb0_reset: RST_USB_PHY0
199212
// 0x0cc BIT(0)
213+
_info("RST_USB_PHY0\n");
200214
#define RST_USB_PHY0 (A64_CCU_ADDR + 0x0cc)
201215
#define RST_USB_PHY0_BIT 0
202216
set_bit(RST_USB_PHY0, RST_USB_PHY0_BIT);
203217

204218
// usb1_reset: RST_USB_PHY1
205219
// 0x0cc BIT(1)
220+
_info("RST_USB_PHY1\n");
206221
#define RST_USB_PHY1 (A64_CCU_ADDR + 0x0cc)
207222
#define RST_USB_PHY1_BIT 1
208223
set_bit(RST_USB_PHY1, RST_USB_PHY1_BIT);
209224

210225
// EHCI0: RST_BUS_OHCI0, RST_BUS_EHCI0
211226
// 0x2c0 BIT(28)
227+
_info("RST_BUS_OHCI0\n");
212228
#define RST_BUS_OHCI0 (A64_CCU_ADDR + 0x2c0)
213229
#define RST_BUS_OHCI0_BIT 28
214230
set_bit(RST_BUS_OHCI0, RST_BUS_OHCI0_BIT);
215231

216232
// 0x2c0 BIT(24)
233+
_info("RST_BUS_EHCI0\n");
217234
#define RST_BUS_EHCI0 (A64_CCU_ADDR + 0x2c0)
218235
#define RST_BUS_EHCI0_BIT 24
219236
set_bit(RST_BUS_EHCI0, RST_BUS_EHCI0_BIT);
220237

221238
// EHCI1: RST_BUS_OHCI1, RST_BUS_EHCI1
222239
// 0x2c0 BIT(29)
240+
_info("RST_BUS_OHCI1\n");
223241
#define RST_BUS_OHCI1 (A64_CCU_ADDR + 0x2c0)
224242
#define RST_BUS_OHCI1_BIT 29
225243
set_bit(RST_BUS_OHCI1, RST_BUS_OHCI1_BIT);
226244

227245
// 0x2c0 BIT(25)
246+
_info("RST_BUS_EHCI1\n");
228247
#define RST_BUS_EHCI1 (A64_CCU_ADDR + 0x2c0)
229248
#define RST_BUS_EHCI1_BIT 25
230249
set_bit(RST_BUS_EHCI1, RST_BUS_EHCI1_BIT);

0 commit comments

Comments
 (0)