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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
|
// SPDX-License-Identifier: GPL-2.0
/*
* Copyright (c) 2019 Sartura Ltd.
*
* Author: Robert Marko <robert.marko@sartura.hr>
*
* Based on Linux driver
*/
#include <clk.h>
#include <common.h>
#include <dm.h>
#include <generic-phy.h>
#include <log.h>
#include <reset.h>
#include <asm/io.h>
#include <linux/delay.h>
struct ipq4019_usb_phy {
phys_addr_t base;
struct reset_ctl por_rst;
struct reset_ctl srif_rst;
};
static int ipq4019_ss_phy_power_off(struct phy *_phy)
{
struct ipq4019_usb_phy *phy = dev_get_priv(_phy->dev);
reset_assert(&phy->por_rst);
mdelay(10);
return 0;
}
static int ipq4019_ss_phy_power_on(struct phy *_phy)
{
struct ipq4019_usb_phy *phy = dev_get_priv(_phy->dev);
ipq4019_ss_phy_power_off(_phy);
reset_deassert(&phy->por_rst);
return 0;
}
static struct phy_ops ipq4019_usb_ss_phy_ops = {
.power_on = ipq4019_ss_phy_power_on,
.power_off = ipq4019_ss_phy_power_off,
};
static int ipq4019_usb_ss_phy_probe(struct udevice *dev)
{
struct ipq4019_usb_phy *phy = dev_get_priv(dev);
int ret;
phy->base = dev_read_addr(dev);
if (phy->base == FDT_ADDR_T_NONE)
return -EINVAL;
ret = reset_get_by_name(dev, "por_rst", &phy->por_rst);
if (ret)
return ret;
return 0;
}
static const struct udevice_id ipq4019_usb_ss_phy_ids[] = {
{ .compatible = "qcom,usb-ss-ipq4019-phy" },
{ }
};
U_BOOT_DRIVER(ipq4019_usb_ss_phy) = {
.name = "ipq4019-usb-ss-phy",
.id = UCLASS_PHY,
.of_match = ipq4019_usb_ss_phy_ids,
.ops = &ipq4019_usb_ss_phy_ops,
.probe = ipq4019_usb_ss_phy_probe,
.priv_auto = sizeof(struct ipq4019_usb_phy),
};
static int ipq4019_hs_phy_power_off(struct phy *_phy)
{
struct ipq4019_usb_phy *phy = dev_get_priv(_phy->dev);
reset_assert(&phy->por_rst);
mdelay(10);
reset_assert(&phy->srif_rst);
mdelay(10);
return 0;
}
static int ipq4019_hs_phy_power_on(struct phy *_phy)
{
struct ipq4019_usb_phy *phy = dev_get_priv(_phy->dev);
ipq4019_hs_phy_power_off(_phy);
reset_deassert(&phy->srif_rst);
mdelay(10);
reset_deassert(&phy->por_rst);
return 0;
}
static struct phy_ops ipq4019_usb_hs_phy_ops = {
.power_on = ipq4019_hs_phy_power_on,
.power_off = ipq4019_hs_phy_power_off,
};
static int ipq4019_usb_hs_phy_probe(struct udevice *dev)
{
struct ipq4019_usb_phy *phy = dev_get_priv(dev);
int ret;
phy->base = dev_read_addr(dev);
if (phy->base == FDT_ADDR_T_NONE)
return -EINVAL;
ret = reset_get_by_name(dev, "por_rst", &phy->por_rst);
if (ret)
return ret;
ret = reset_get_by_name(dev, "srif_rst", &phy->srif_rst);
if (ret)
return ret;
return 0;
}
static const struct udevice_id ipq4019_usb_hs_phy_ids[] = {
{ .compatible = "qcom,usb-hs-ipq4019-phy" },
{ }
};
U_BOOT_DRIVER(ipq4019_usb_hs_phy) = {
.name = "ipq4019-usb-hs-phy",
.id = UCLASS_PHY,
.of_match = ipq4019_usb_hs_phy_ids,
.ops = &ipq4019_usb_hs_phy_ops,
.probe = ipq4019_usb_hs_phy_probe,
.priv_auto = sizeof(struct ipq4019_usb_phy),
};
|