blob: 10b2e132eb07359b0e863a5714fa05621b99dde9 [file] [log] [blame]
Jiandong Zheng88bb7c02015-07-09 14:26:39 -07001/*
2 * Copyright 2015 Broadcom Corporation.
3 *
4 * SPDX-License-Identifier: GPL-2.0+
5 */
6
7#include <config.h>
8#include <common.h>
9#include <asm/io.h>
10#include <asm/arch/sysmap.h>
11
Marek Vasut4811c662015-12-04 02:32:22 +010012#include "dwc2_udc_otg_priv.h"
Jiandong Zheng88bb7c02015-07-09 14:26:39 -070013#include "bcm_udc_otg.h"
14
Marek Vasut1a639ff2015-12-04 00:57:58 +010015void otg_phy_init(struct dwc2_udc *dev)
Jiandong Zheng88bb7c02015-07-09 14:26:39 -070016{
17 /* set Phy to driving mode */
18 wfld_clear(HSOTG_CTRL_BASE_ADDR + HSOTG_CTRL_PHY_P1CTL_OFFSET,
19 HSOTG_CTRL_PHY_P1CTL_NON_DRIVING_MASK);
20
21 udelay(100);
22
23 /* clear Soft Disconnect */
24 wfld_clear(HSOTG_BASE_ADDR + HSOTG_DCTL_OFFSET,
25 HSOTG_DCTL_SFTDISCON_MASK);
26
27 /* invoke Reset (active low) */
28 wfld_clear(HSOTG_CTRL_BASE_ADDR + HSOTG_CTRL_PHY_P1CTL_OFFSET,
29 HSOTG_CTRL_PHY_P1CTL_SOFT_RESET_MASK);
30
31 /* Reset needs to be asserted for 2ms */
32 udelay(2000);
33
34 /* release Reset */
35 wfld_set(HSOTG_CTRL_BASE_ADDR + HSOTG_CTRL_PHY_P1CTL_OFFSET,
36 HSOTG_CTRL_PHY_P1CTL_SOFT_RESET_MASK,
37 HSOTG_CTRL_PHY_P1CTL_SOFT_RESET_MASK);
38}
39
Marek Vasut1a639ff2015-12-04 00:57:58 +010040void otg_phy_off(struct dwc2_udc *dev)
Jiandong Zheng88bb7c02015-07-09 14:26:39 -070041{
42 /* Soft Disconnect */
43 wfld_set(HSOTG_BASE_ADDR + HSOTG_DCTL_OFFSET,
44 HSOTG_DCTL_SFTDISCON_MASK,
45 HSOTG_DCTL_SFTDISCON_MASK);
46
47 /* set Phy to non-driving (reset) mode */
48 wfld_set(HSOTG_CTRL_BASE_ADDR + HSOTG_CTRL_PHY_P1CTL_OFFSET,
49 HSOTG_CTRL_PHY_P1CTL_NON_DRIVING_MASK,
50 HSOTG_CTRL_PHY_P1CTL_NON_DRIVING_MASK);
51}