Lines 62-101
a20_if_dwc_probe(device_t dev)
Link Here
|
62 |
static int |
62 |
static int |
63 |
a20_if_dwc_init(device_t dev) |
63 |
a20_if_dwc_init(device_t dev) |
64 |
{ |
64 |
{ |
|
|
65 |
struct dwc_softc *sc; |
65 |
const char *tx_parent_name; |
66 |
const char *tx_parent_name; |
66 |
char *phy_type; |
|
|
67 |
clk_t clk_tx, clk_tx_parent; |
67 |
clk_t clk_tx, clk_tx_parent; |
68 |
regulator_t reg; |
68 |
regulator_t reg; |
69 |
phandle_t node; |
|
|
70 |
int error; |
69 |
int error; |
71 |
|
70 |
|
72 |
node = ofw_bus_get_node(dev); |
71 |
sc = device_get_softc(dev); |
73 |
|
72 |
|
74 |
/* Configure PHY for MII or RGMII mode */ |
73 |
/* Configure PHY for MII or RGMII mode */ |
75 |
if (OF_getprop_alloc(node, "phy-mode", (void **)&phy_type)) { |
74 |
switch(sc->phy_mode) { |
76 |
error = clk_get_by_ofw_name(dev, 0, "allwinner_gmac_tx", &clk_tx); |
75 |
case PHY_MODE_RGMII: |
77 |
if (error != 0) { |
76 |
tx_parent_name = "gmac_int_tx"; |
78 |
device_printf(dev, "could not get tx clk\n"); |
77 |
break; |
79 |
return (error); |
78 |
case PHY_MODE_MII: |
80 |
} |
79 |
tx_parent_name = "mii_phy_tx"; |
81 |
|
80 |
break; |
82 |
if (strcmp(phy_type, "rgmii") == 0) |
81 |
default: |
83 |
tx_parent_name = "gmac_int_tx"; |
82 |
device_printf(dev, "unsupported PHY connection type: %d", |
84 |
else |
83 |
sc->phy_mode); |
85 |
tx_parent_name = "mii_phy_tx"; |
84 |
return (ENXIO); |
86 |
|
85 |
} |
87 |
error = clk_get_by_name(dev, tx_parent_name, &clk_tx_parent); |
|
|
88 |
if (error != 0) { |
89 |
device_printf(dev, "could not get clock '%s'\n", |
90 |
tx_parent_name); |
91 |
return (error); |
92 |
} |
93 |
|
86 |
|
94 |
error = clk_set_parent_by_clk(clk_tx, clk_tx_parent); |
87 |
error = clk_get_by_ofw_name(dev, 0, "allwinner_gmac_tx", &clk_tx); |
95 |
if (error != 0) { |
88 |
if (error != 0) { |
96 |
device_printf(dev, "could not set tx clk parent\n"); |
89 |
device_printf(dev, "could not get tx clk\n"); |
97 |
return (error); |
90 |
return (error); |
98 |
} |
91 |
} |
|
|
92 |
error = clk_get_by_name(dev, tx_parent_name, &clk_tx_parent); |
93 |
if (error != 0) { |
94 |
device_printf(dev, "could not get clock '%s'\n", |
95 |
tx_parent_name); |
96 |
return (error); |
97 |
} |
98 |
error = clk_set_parent_by_clk(clk_tx, clk_tx_parent); |
99 |
if (error != 0) { |
100 |
device_printf(dev, "could not set tx clk parent\n"); |
101 |
return (error); |
99 |
} |
102 |
} |
100 |
|
103 |
|
101 |
/* Enable PHY regulator if applicable */ |
104 |
/* Enable PHY regulator if applicable */ |