View | Details | Raw Unified | Return to bug 261355 | Differences between
and this patch

Collapse All | Expand All

(-)b/sys/arm/allwinner/aw_if_dwc.c (-24 / +39 lines)
Lines 32-42 __FBSDID("$FreeBSD$"); Link Here
32
#include <sys/bus.h>
32
#include <sys/bus.h>
33
#include <sys/kernel.h>
33
#include <sys/kernel.h>
34
#include <sys/module.h>
34
#include <sys/module.h>
35
#include <sys/socket.h>
36
37
#include <net/if.h>
38
#include <net/if_media.h>
35
39
36
#include <machine/bus.h>
40
#include <machine/bus.h>
37
41
38
#include <dev/dwc/if_dwc.h>
42
#include <dev/dwc/if_dwc.h>
39
#include <dev/dwc/if_dwcvar.h>
43
#include <dev/dwc/if_dwcvar.h>
44
#include <dev/mii/mii.h>
45
#include <dev/mii/miivar.h>
46
#include <dev/mii/mii_fdt.h>
40
#include <dev/ofw/ofw_bus.h>
47
#include <dev/ofw/ofw_bus.h>
41
#include <dev/ofw/ofw_bus_subr.h>
48
#include <dev/ofw/ofw_bus_subr.h>
42
49
Lines 63-69 static int Link Here
63
a20_if_dwc_init(device_t dev)
70
a20_if_dwc_init(device_t dev)
64
{
71
{
65
	const char *tx_parent_name;
72
	const char *tx_parent_name;
66
	char *phy_type;
67
	clk_t clk_tx, clk_tx_parent;
73
	clk_t clk_tx, clk_tx_parent;
68
	regulator_t reg;
74
	regulator_t reg;
69
	phandle_t node;
75
	phandle_t node;
Lines 72-104 a20_if_dwc_init(device_t dev) Link Here
72
	node = ofw_bus_get_node(dev);
78
	node = ofw_bus_get_node(dev);
73
79
74
	/* Configure PHY for MII or RGMII mode */
80
	/* Configure PHY for MII or RGMII mode */
75
	if (OF_getprop_alloc(node, "phy-mode", (void **)&phy_type)) {
81
	switch(mii_fdt_get_contype(node)) {
76
		error = clk_get_by_ofw_name(dev, 0, "allwinner_gmac_tx", &clk_tx);
82
	case MII_CONTYPE_RGMII:
77
		if (error != 0) {
83
	case MII_CONTYPE_RGMII_ID:
78
			device_printf(dev, "could not get tx clk\n");
84
	case MII_CONTYPE_RGMII_RXID:
79
			return (error);
85
	case MII_CONTYPE_RGMII_TXID:
80
		}
86
		tx_parent_name = "gmac_int_tx";
81
87
		break;
82
		if (strcmp(phy_type, "rgmii") == 0)
88
	case MII_CONTYPE_MII:
83
			tx_parent_name = "gmac_int_tx";
89
		tx_parent_name = "mii_phy_tx";
84
		else
90
		break;
85
			tx_parent_name = "mii_phy_tx";
91
	case MII_CONTYPE_UNKNOWN:
86
92
		goto regulator;
87
		error = clk_get_by_name(dev, tx_parent_name, &clk_tx_parent);
93
	default:
88
		if (error != 0) {
94
		device_printf(dev, "unsupported PHY connection type!");
89
			device_printf(dev, "could not get clock '%s'\n",
95
		return (ENXIO);
90
			    tx_parent_name);
96
	}
91
			return (error);
92
		}
93
97
94
		error = clk_set_parent_by_clk(clk_tx, clk_tx_parent);
98
	error = clk_get_by_ofw_name(dev, 0, "allwinner_gmac_tx", &clk_tx);
95
		if (error != 0) {
99
	if (error != 0) {
96
			device_printf(dev, "could not set tx clk parent\n");
100
		device_printf(dev, "could not get tx clk\n");
97
			return (error);
101
		return (error);
98
		}
102
	}
103
	error = clk_get_by_name(dev, tx_parent_name, &clk_tx_parent);
104
	if (error != 0) {
105
		device_printf(dev, "could not get clock '%s'\n",
106
		    tx_parent_name);
107
		return (error);
108
	}
109
	error = clk_set_parent_by_clk(clk_tx, clk_tx_parent);
110
	if (error != 0) {
111
		device_printf(dev, "could not set tx clk parent\n");
112
		return (error);
99
	}
113
	}
100
114
101
	/* Enable PHY regulator if applicable */
115
	/* Enable PHY regulator if applicable */
116
regulator:
102
	if (regulator_get_by_ofw_property(dev, 0, "phy-supply", &reg) == 0) {
117
	if (regulator_get_by_ofw_property(dev, 0, "phy-supply", &reg) == 0) {
103
		error = regulator_enable(reg);
118
		error = regulator_enable(reg);
104
		if (error != 0) {
119
		if (error != 0) {

Return to bug 261355