Skip to content

Commit 5037e3a

Browse files
fabiobaltiericarlescufi
authored andcommitted
ethernet: sam-gmac: make phy a phandle of the ethernet device
Make ethernet phys childs of the mdio device and move the mdio device up a level on the tree. That makes the device hierarchy coherent with the required initialization priority and allows keeping the sequence in check with CHECK_INIT_PRIORITIES. Signed-off-by: Fabio Baltieri <[email protected]>
1 parent 4f61303 commit 5037e3a

File tree

10 files changed

+52
-45
lines changed

10 files changed

+52
-45
lines changed

boards/arm/atsame54_xpro/atsame54_xpro.dts

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -121,18 +121,19 @@ zephyr_udc0: &usb0 {
121121
pinctrl-names = "default";
122122

123123
mac-eeprom = <&eeprom>;
124-
125-
phy: phy {
126-
compatible = "ethernet-phy";
127-
status = "okay";
128-
address = <0>;
129-
mdio = <&mdio>;
130-
};
124+
phy-handle = <&phy>;
131125
};
132126

133127
&mdio {
134128
status = "okay";
135129

136130
pinctrl-0 = <&mdio_default>;
137131
pinctrl-names = "default";
132+
133+
phy: phy {
134+
compatible = "ethernet-phy";
135+
status = "okay";
136+
address = <0>;
137+
mdio = <&mdio>;
138+
};
138139
};

boards/arm/sam4e_xpro/sam4e_xpro.dts

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -187,19 +187,21 @@
187187

188188
zephyr,random-mac-address;
189189

190-
phy: phy {
191-
compatible = "ethernet-phy";
192-
status = "okay";
193-
address = <0>;
194-
mdio = <&mdio>;
195-
};
190+
phy-handle = <&phy>;
196191
};
197192

198193
&mdio {
199194
status = "okay";
200195

201196
pinctrl-0 = <&mdio_default>;
202197
pinctrl-names = "default";
198+
199+
phy: phy {
200+
compatible = "ethernet-phy";
201+
status = "okay";
202+
address = <0>;
203+
mdio = <&mdio>;
204+
};
203205
};
204206

205207
&pwm0 {

boards/arm/sam_e70_xplained/sam_e70_xplained-common.dtsi

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -125,20 +125,21 @@ zephyr_udc0: &usbhs {
125125
pinctrl-names = "default";
126126

127127
mac-eeprom = <&eeprom>;
128-
129-
phy: phy {
130-
compatible = "ethernet-phy";
131-
status = "okay";
132-
address = <0>;
133-
mdio = <&mdio>;
134-
};
128+
phy-handle = <&phy>;
135129
};
136130

137131
&mdio {
138132
status = "okay";
139133

140134
pinctrl-0 = <&mdio_default>;
141135
pinctrl-names = "default";
136+
137+
phy: phy {
138+
compatible = "ethernet-phy";
139+
status = "okay";
140+
address = <0>;
141+
mdio = <&mdio>;
142+
};
142143
};
143144

144145
&pwm0 {

boards/arm/sam_v71_xult/sam_v71_xult-common.dtsi

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -233,20 +233,21 @@ zephyr_udc0: &usbhs {
233233
pinctrl-names = "default";
234234

235235
mac-eeprom = <&eeprom>;
236-
237-
phy: phy {
238-
compatible = "ethernet-phy";
239-
status = "okay";
240-
address = <0>;
241-
mdio = <&mdio>;
242-
};
236+
phy-handle = <&phy>;
243237
};
244238

245239
&mdio {
246240
status = "okay";
247241

248242
pinctrl-0 = <&mdio_default>;
249243
pinctrl-names = "default";
244+
245+
phy: phy {
246+
compatible = "ethernet-phy";
247+
status = "okay";
248+
address = <0>;
249+
mdio = <&mdio>;
250+
};
250251
};
251252

252253
&pwm0 {

drivers/ethernet/eth_sam_gmac.c

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2222,11 +2222,7 @@ static const struct eth_sam_dev_cfg eth0_config = {
22222222
.clock_cfg = SAM_DT_INST_CLOCK_PMC_CFG(0),
22232223
#endif
22242224
.config_func = eth0_irq_config,
2225-
#if DT_NODE_EXISTS(DT_INST_CHILD(0, phy))
2226-
.phy_dev = DEVICE_DT_GET(DT_INST_CHILD(0, phy))
2227-
#else
2228-
#error "No PHY driver specified"
2229-
#endif
2225+
.phy_dev = DEVICE_DT_GET(DT_INST_PHANDLE(0, phy_handle))
22302226
};
22312227

22322228
static struct eth_sam_dev_data eth0_data = {

drivers/mdio/mdio_sam.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ static const struct mdio_driver_api mdio_sam_driver_api = {
132132

133133
#define MDIO_SAM_CONFIG(n) \
134134
static const struct mdio_sam_dev_config mdio_sam_dev_config_##n = { \
135-
.regs = (Gmac *)DT_REG_ADDR(DT_INST_PARENT(n)), \
135+
.regs = (Gmac *)DT_INST_REG_ADDR(n), \
136136
.pcfg = PINCTRL_DT_INST_DEV_CONFIG_GET(n), \
137137
.protocol = DT_INST_ENUM_IDX(n, protocol), \
138138
};

dts/arm/atmel/sam4e.dtsi

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -166,11 +166,12 @@
166166
num-queues = <1>;
167167
phy-connection-type = "mii";
168168
status = "disabled";
169+
};
169170

170-
mdio: mdio {
171-
compatible = "atmel,sam-mdio";
172-
status = "disabled";
173-
};
171+
mdio: mdio@40034000 {
172+
compatible = "atmel,sam-mdio";
173+
reg = <0x40034000 0x4000>;
174+
status = "disabled";
174175
};
175176

176177
pinctrl: pinctrl@400e0e00 {

dts/arm/atmel/same5x.dtsi

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,12 @@
1616
num-queues = <1>;
1717
local-mac-address = [00 00 00 00 00 00];
1818
status = "disabled";
19+
};
1920

20-
mdio: mdio {
21-
compatible = "atmel,sam-mdio";
22-
status = "disabled";
23-
};
21+
mdio: mdio@42000800 {
22+
compatible = "atmel,sam-mdio";
23+
reg = <0x42000800 0x400>;
24+
status = "disabled";
2425
};
2526
};
2627
};

dts/arm/atmel/same70.dtsi

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -328,11 +328,12 @@
328328
num-queues = <3>;
329329
local-mac-address = [00 00 00 00 00 00];
330330
status = "disabled";
331+
};
331332

332-
mdio: mdio {
333-
compatible = "atmel,sam-mdio";
334-
status = "disabled";
335-
};
333+
mdio: mdio@40050000 {
334+
compatible = "atmel,sam-mdio";
335+
reg = <0x40050000 0x4000>;
336+
status = "disabled";
336337
};
337338

338339
tc0: tc@4000c000 {

dts/bindings/ethernet/atmel,gmac-common.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ properties:
1010
reg:
1111
required: true
1212

13+
phy-handle:
14+
required: true
15+
1316
num-queues:
1417
type: int
1518
required: true

0 commit comments

Comments
 (0)