-
Notifications
You must be signed in to change notification settings - Fork 0
/
ulpi.c
63 lines (59 loc) · 2.26 KB
/
ulpi.c
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
/*
*
* Copyright 2019 The wookey project team <[email protected]>
* - Ryad Benadjila
* - Arnauld Michelizza
* - Mathieu Renard
* - Philippe Thierry
* - Philippe Trebuchet
*
* This package is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published
* the Free Software Foundation; either version 3 of the License, or (at
* ur option) any later version.
*
* This package is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
* PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this package; if not, write to the Free Software Foundation, Inc., 51
* Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
*/
#include "api/libusbotghs.h"
#include "usbotghs.h"
#include "ulpi.h"
/*
* Initialize the USB PHY through ULPI interface
*/
/*@
@ assigns \nothing ;
@ ensures \result == MBED_ERROR_NONE || \result == MBED_ERROR_INITFAIL ;
*/
mbed_error_t usbotghs_ulpi_reset(void)
{
mbed_error_t errcode = MBED_ERROR_NONE;
uint32_t err;
log_printf("[USB HS] %s\n", __FUNCTION__);
log_printf("[USB HS] Resetting ULPI through PE13 pin ...\n");
/* Resetting the ULPI PHY is performed by setting the PE13 pin to 1 during
* some milliseconds.
*/
if ((err = sys_cfg(CFG_GPIO_SET, (uint8_t)(((usb_otg_hs_dev_infos.gpios[USB_HS_RESET].port << 4) + usb_otg_hs_dev_infos.gpios[USB_HS_RESET].pin)), 1)) != SYS_E_DONE) {
errcode = MBED_ERROR_INITFAIL;
log_printf("failed to reset ULPI: GPIO set syscall returns %d\n", err);
goto end;
}
/* waiting at least 5 milliseconds */
sys_sleep(SLEEP_MODE_DEEP, 5);
if ((err = sys_cfg(CFG_GPIO_SET, (uint8_t)(((usb_otg_hs_dev_infos.gpios[USB_HS_RESET].port << 4) + usb_otg_hs_dev_infos.gpios[USB_HS_RESET].pin)), 0)) != SYS_E_DONE) {
errcode = MBED_ERROR_INITFAIL;
log_printf("failed to reset ULPI: GPIO clear syscall returns %d\n", err);
goto end;
}
/*@ assert errcode == MBED_ERROR_NONE; */
end:
/* @ assert (errcode == MBED_ERROR_NONE || errcode == MBED_ERROR_INITFAIL); */
return errcode;
}