Linux Kernel : v4.1.6, Driver selected for the device : smsc.c
Processor : AM3358 - 800 Mhz, running on Custom Board
Pin Mux / DTS has following entries for LAN8820 PHY Chip:-
AM335x-bone-common.dtsi:-
cpsw_default: cpsw_default {
pinctrl-single,pins = <
0x114 ( PIN_OUTPUT | MUX_MODE2 ) /* (J16) gmii1_txen.rgmii1_tctl */
0x118 ( PIN_INPUT | MUX_MODE2 ) /* (J17) gmii1_rxdv.rgmii1_rctl */
0x12c ( PIN_OUTPUT | MUX_MODE2 ) /* (K18) gmii1_txclk.rgmii1_tclk */
0x130 ( PIN_INPUT | MUX_MODE2 ) /* (L18) gmii1_rxclk.rgmii1_rclk */
0x128 ( PIN_OUTPUT | MUX_MODE2 ) /* (K17) gmii1_txd0.rgmii1_td0 */
0x124 ( PIN_OUTPUT | MUX_MODE2 ) /* (K16) gmii1_txd1.rgmii1_td1 */
0x120 ( PIN_OUTPUT | MUX_MODE2 ) /* (K15) gmii1_txd2.rgmii1_td2 */
0x11c ( PIN_OUTPUT | MUX_MODE2 ) /* (J18) gmii1_txd3.rgmii1_td3 */
0x140 ( PIN_INPUT | MUX_MODE2 ) /* (M16) gmii1_rxd0.rgmii1_rd0 */
0x13c ( PIN_INPUT | MUX_MODE2 ) /* (L15) gmii1_rxd1.rgmii1_rd1 */
0x138 ( PIN_INPUT | MUX_MODE2 ) /* (L16) gmii1_rxd2.rgmii1_rd2 */
0x134 ( PIN_INPUT | MUX_MODE2 ) /* (L17) gmii1_rxd3.rgmii1_rd3 */
>;
};
cpsw_sleep: cpsw_sleep {
pinctrl-single,pins = <
0x114 (PIN_INPUT_PULLDOWN | MUX_MODE7)
0x118 (PIN_INPUT_PULLDOWN | MUX_MODE7)
0x11c (PIN_INPUT_PULLDOWN | MUX_MODE7)
0x120 (PIN_INPUT_PULLDOWN | MUX_MODE7)
0x124 (PIN_INPUT_PULLDOWN | MUX_MODE7)
0x128 (PIN_INPUT_PULLDOWN | MUX_MODE7)
0x12c (PIN_INPUT_PULLDOWN | MUX_MODE7)
0x130 (PIN_INPUT_PULLDOWN | MUX_MODE7)
0x134 (PIN_INPUT_PULLDOWN | MUX_MODE7)
0x138 (PIN_INPUT_PULLDOWN | MUX_MODE7)
0x13c (PIN_INPUT_PULLDOWN | MUX_MODE7)
0x140 (PIN_INPUT_PULLDOWN | MUX_MODE7)
>;
};
davinci_mdio_default: davinci_mdio_default {
pinctrl-single,pins = <
0x14c ( PIN_OUTPUT | MUX_MODE0 ) /* (M18) mdio_clk.mdio_clk */
0x148 ( PIN_INPUT | MUX_MODE0 ) /* (M17) mdio_data.mdio_data */
0x108 ( PIN_INPUT | MUX_MODE0 ) /* (H16) gmii1_col.gmii1_col */
>;
};
davinci_mdio_sleep: davinci_mdio_sleep {
pinctrl-single,pins = <
0x148 (PIN_INPUT_PULLDOWN | MUX_MODE7)
0x14c (PIN_INPUT_PULLDOWN | MUX_MODE7)
0x108 (PIN_INPUT_PULLDOWN | MUX_MODE0 ) /* (H16) gmii1_col.gmii1_col */
>;
};
&cpsw_emac0 {
phy_id = <&davinci_mdio>, <0>;
phy-mode = "rgmii";
};
&cpsw_emac1 {
phy_id = <&davinci_mdio>, <1>;
phy-mode = "rgmii";
};
&mac {
pinctrl-names = "default", "sleep";
pinctrl-0 = <&cpsw_default>;
pinctrl-1 = <&cpsw_sleep>;
status = "okay";
};
&davinci_mdio {
pinctrl-names = "default", "sleep";
pinctrl-0 = <&davinci_mdio_default>;
pinctrl-1 = <&davinci_mdio_sleep>;
status = "okay";
};
-------------------------------------------------------------------------------------------
AM33xx.dtsi:-
mac: ethernet@4a100000 {
compatible = "ti,am335x-cpsw","ti,cpsw";
ti,hwmods = "cpgmac0";
clocks = <&cpsw_125mhz_gclk>, <&cpsw_cpts_rft_clk>;
clock-names = "fck", "cpts";
cpdma_channels = <8>;
ale_entries = <1024>;
bd_ram_size = <0x2000>;
no_bd_ram = <0>;
rx_descs = <64>;
mac_control = <0x20>;
slaves = <2>;
active_slave = <0>;
cpts_clock_mult = <0x80000000>;
cpts_clock_shift = <29>;
reg = <0x4a100000 0x800
0x4a101200 0x100>;
#address-cells = <1>;
#size-cells = <1>;
interrupt-parent = <&intc>;
/*
* c0_rx_thresh_pend
* c0_rx_pend
* c0_tx_pend
* c0_misc_pend
*/
interrupts = <40 41 42 43>;
ranges;
syscon = <&scm_conf>;
status = "disabled";
davinci_mdio: mdio@4a101000 {
compatible = "ti,davinci_mdio";
#address-cells = <1>;
#size-cells = <0>;
ti,hwmods = "davinci_mdio";
bus_freq = <1000000>;
reg = <0x4a101000 0x100>;
status = "disabled";
};
cpsw_emac0: slave@4a100200 {
/* Filled in by U-Boot */
mac-address = [ 00 00 00 00 00 00 ];
};
cpsw_emac1: slave@4a100300 {
/* Filled in by U-Boot */
mac-address = [ 00 00 00 00 00 00 ];
};
phy_sel: cpsw-phy-sel@44e10650 {
compatible = "ti,am3352-cpsw-phy-sel";
reg= <0x44e10650 0x4>;
reg-names = "gmii-sel";
};
};
---------------------------------------------------------------------------------------------------
And Driver changes are as follows:-
Kernel:- v4.1.6
Source file:- drivers/net/phy/smsc.c
Modifications:-
static struct phy_driver smsc_phy_driver[] =
{
.phy_id = 0x0007c0e0, /* OUI=0x00800f, Model#=0x0e */
.phy_id_mask = 0xfffffff0,
.name = "SMSC LAN8820 / LAN8820i",
.features = (PHY_BASIC_FEATURES | SUPPORTED_Pause | SUPPORTED_Asym_Pause),
.flags = (PHY_HAS_INTERRUPT | PHY_HAS_MAGICANEG),
/* basic functions */
.config_aneg = genphy_config_aneg,
.read_status = genphy_read_status,
.config_init = smsc_phy_config_init,
.soft_reset = smsc_phy_reset,
/* IRQ related */
.ack_interrupt = smsc_phy_ack_interrupt,
.config_intr = smsc_phy_config_intr,
.suspend = genphy_suspend,
.resume = genphy_resume,
.driver = { .owner = THIS_MODULE, }
}
and .....
static struct mdio_device_id __maybe_unused smsc_tbl[] = {
....
{ 0x0007c0d0, 0xfffffff0 },
{ 0x0007c0e0, 0xfffffff0 }, /* for LAN8820 */
{ 0x0007c0f0, 0xfffffff0 },
{ }
};
------------------------------------------------------------------------------------------------------
Hardware connection are like this->> AM3358 <<--->> LAN8820 <<---->> RJ Connector.
after re-building and loading the kernel on board, i can see my driver getting detected and loaded in "dmesg".
[ 4.489091] davinci_mdio 4a101000.mdio: davinci mdio revision 1.6
[ 4.495237] davinci_mdio 4a101000.mdio: detected phy mask fffffffd
[ 4.503332] libphy: 4a101000.mdio: probed
[ 4.507392] davinci_mdio 4a101000.mdio: phy[1]: device 4a101000.mdio:01, driver SMSC LAN8820 / LAN8820i
[ 4.518222] cpsw 4a100000.ethernet: Detected MACID = 68:c9:0b:f0:46:36
Then from root prompt on board if i set static ip address in /etc/network/interface or on command line:-
# ifconfig eth0 10.1.24.175 netmask 255.255.252.0 up
[ 48.841786] net eth0: initializing cpsw version 1.12 (0)
[ 48.848850] libphy: PHY 4a101000.mdio:00 not found
[ 48.854513] net eth0: phy 4a101000.mdio:00 not found on slave 0
[ 48.861489] net eth0: phy found : id is : 0x7c0ec
[ 48.873346] IPv6: ADDRCONF(NETDEV_UP): eth0: link is not ready
[ 50.860020] cpsw 4a100000.ethernet eth0: Link is Up - 1Gbps/Full - flow control rx/tx
[ 50.867946] IPv6: ADDRCONF(NETDEV_CHANGE): eth0: link becomes ready
# ifconfig
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 10.1.24.175 netmask 255.255.252.0 broadcast 10.1.27.255
inet6 fe80::6ac9:bff:fef0:2483 prefixlen 64 scopeid 0x20<link>
ether 68:c9:0b:f0:24:83 txqueuelen 1000 (Ethernet)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 6 bytes 508 (508.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
device interrupt 170
lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10<host>
loop txqueuelen 0 (Local Loopback)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 0 bytes 0 (0.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
Here is output of mii-tool >
# mii-tool -vv eth0
Using SIOCGMIIPHY=0x8947
SIOCGMIIPHY on 'eth0' failed: Operation not supported
# mii-tool –vv eth0
SIOCGMIIPHY on '–vv' failed: No such device
SIOCGMIIPHY on 'eth0' failed: Operation not supported
#
Here is output of ethtool >
# ethtool eth0
Settings for eth0:
Supports Wake-on: d
Wake-on: d
Current message level: 0x00000000 (0)
Link detected: yes
#
I cannot ping or communicate with any IP now. Please help me setting up and configuring the dtb / driver properly for LAN8820...