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 |
#include <linux/of_gpio.h>
#include <linux/io.h>
***********
static int smsc_phy_reset(struct phy_device *phydev)
{
int err, phy_reset;
int msec = 1;
struct device_node *np;
int timeout = 50000;
int rc;
if (phydev->mdio.addr == 0) {
np = of_find_node_by_path("/soc/aips-bus@02100000/ethernet@02188000");
} else if (phydev->mdio.addr == 1) {
np = of_find_node_by_path("/soc/aips-bus@02000000/ethernet@020b4000");
}
if (!np) {
return -1;
}
err = of_property_read_u32(np, "phy-reset-duration", &msec);
if (!err && msec > 1000)
msec = 1;
phy_reset = of_get_named_gpio(np, "phy-reset-gpios", 0);
if (!gpio_is_valid(phy_reset))
return -1;
gpio_direction_output(phy_reset, 0);
gpio_set_value(phy_reset, 0);
msleep(msec);
gpio_set_value(phy_reset, 1);
int rc = phy_read(phydev, MII_LAN83C185_SPECIAL_MODES);
if (rc < 0)
return rc;
|