Commit 3272dd9b0fe4bc09321219ab65dc5eda3e82445c
Committed by
David S. Miller
1 parent
8495c0da20
Exists in
smarc-l5.0.0_1.0.0-ga
and in
5 other branches
of/net/mdio-gpio: Fix pdev->id issue when using devicetrees.
When the mdio-gpio driver is probed via device trees, the platform device id is set as -1, However the pdev->id is re-used as bus-id for while creating mdio gpio bus. So For device tree case the mdio-gpio bus name appears as "gpio-ffffffff" where as for non-device tree case the bus name appears as "gpio-<bus-num>" Which means the bus_id is fixed in device tree case, so we can't have two mdio gpio buses via device trees. Assigning a logical bus number via device tree solves the problem and the bus name is much consistent with non-device tree bus name. Without this patch 1. we can't support two mdio-gpio buses via device trees. 2. we should always pass gpio-ffffffff as bus name to phy_connect, very different to non-device tree bus name. So, setting up the bus_id via aliases from device tree is the right solution and other drivers do similar thing. Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@st.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Showing 2 changed files with 15 additions and 5 deletions Side-by-side Diff
Documentation/devicetree/bindings/net/mdio-gpio.txt
... | ... | @@ -8,9 +8,16 @@ |
8 | 8 | |
9 | 9 | MDC, MDIO. |
10 | 10 | |
11 | +Note: Each gpio-mdio bus should have an alias correctly numbered in "aliases" | |
12 | +node. | |
13 | + | |
11 | 14 | Example: |
12 | 15 | |
13 | -mdio { | |
16 | +aliases { | |
17 | + mdio-gpio0 = <&mdio0>; | |
18 | +}; | |
19 | + | |
20 | +mdio0: mdio { | |
14 | 21 | compatible = "virtual,mdio-gpio"; |
15 | 22 | #address-cells = <1>; |
16 | 23 | #size-cells = <0>; |
drivers/net/phy/mdio-gpio.c
... | ... | @@ -185,17 +185,20 @@ |
185 | 185 | { |
186 | 186 | struct mdio_gpio_platform_data *pdata; |
187 | 187 | struct mii_bus *new_bus; |
188 | - int ret; | |
188 | + int ret, bus_id; | |
189 | 189 | |
190 | - if (pdev->dev.of_node) | |
190 | + if (pdev->dev.of_node) { | |
191 | 191 | pdata = mdio_gpio_of_get_data(pdev); |
192 | - else | |
192 | + bus_id = of_alias_get_id(pdev->dev.of_node, "mdio-gpio"); | |
193 | + } else { | |
193 | 194 | pdata = pdev->dev.platform_data; |
195 | + bus_id = pdev->id; | |
196 | + } | |
194 | 197 | |
195 | 198 | if (!pdata) |
196 | 199 | return -ENODEV; |
197 | 200 | |
198 | - new_bus = mdio_gpio_bus_init(&pdev->dev, pdata, pdev->id); | |
201 | + new_bus = mdio_gpio_bus_init(&pdev->dev, pdata, bus_id); | |
199 | 202 | if (!new_bus) |
200 | 203 | return -ENODEV; |
201 | 204 |