[OpenWrt-Devel] [PATCH v2] kernel: rtl8366-smi: add Realtek switch management via mii-bus
Florian Fainelli
f.fainelli at gmail.com
Tue Apr 3 13:22:05 EDT 2018
On 04/03/2018 10:13 AM, Сергей Василюгин wrote:
> Current version of rtl8366-smi module support Realtek switch
> managment via two gpio lines only. This patch add Realtek switch
> management via mii_bus. For my board Tp-link Archer C2 v1 (Mediatek
> SoC mt7620a based) dts-file configuration looks like:
>
> rtl8367rb {
> compatible = "realtek,rtl8367b", "rtl8367b";
> realtek,extif1 = <1 0 1 1 1 1 1 1 2>;
> mii-bus = <&mdio0>;
The switch node should be moved under the mdio controller node below,
parent/child relationships imply the control bus.
> };
>
> ðernet {
> status = "okay";
> mtd-mac-address = <&rom 0xf100>;
> pinctrl-names = "default";
> pinctrl-0 = <&rgmii1_pins &rgmii2_pins &mdio_pins>;
>
> port at 5 {
> status = "okay";
> mediatek,fixed-link = <1000 1 1 1>;
> phy-mode = "rgmii";
> };
>
> mdio0: mdio-bus {
> status = "okay";
> };
> };
>
> Realtek rtl8367rb switch is ok.
> Other Realtek switches and archs are untested but must work too.
>
> Version 2: add mii_bus mutex_lock
>
> Signed-off-by: Serge Vasilugin <vasilugin at yandex.ru>
> --
>
[snip]
> @@ -1416,7 +1520,24 @@ int rtl8366_smi_probe_of(struct platform_device *pdev, struct rtl8366_smi *smi)
> {
> int sck = of_get_named_gpio(pdev->dev.of_node, "gpio-sck", 0);
> int sda = of_get_named_gpio(pdev->dev.of_node, "gpio-sda", 0);
> + struct device_node *np = pdev->dev.of_node;;
> + struct device_node *mdio_node = NULL;
> +
> + mdio_node = of_parse_phandle(np, "mii-bus", 0);
> + if (!mdio_node) {
> + dev_err(&pdev->dev, "cannot find mdio node phandle");
> + goto try_gpio;
> + }
You should have two entry points for your driver, and have shared code,
one entry point is a gpio/platform_driver and the other one is a
mdio_device/driver. They would both call into the same code that does
the register read/write code, but how they are probed should be different.
See drivers/net/dsa/b53/ for an example of a driver that can deal with
multiple control buses.
--
Florian
_______________________________________________
openwrt-devel mailing list
openwrt-devel at lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel
More information about the openwrt-devel
mailing list