i.mx6 fec driver and micrel switch&phy driver

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

i.mx6 fec driver and micrel switch&phy driver

4,220 Views
coilnpark
Contributor IV

Hi~ I am colin.

Nowadays, I am very confuzed because of FEC and micrel drivers.

I have plan to use spi slave mode of micrel ksz8873 ethernet switch driver with imx6solo.

I checked that SPI interface worked correctly. I could check that by spidev default driver.

So, I wanted to use the provided micrel ethernet switch driver (SPI) instead of spidev driver.

Finally I turn off the fec driver in the menuconfig and the kernel couldn't find ethernet mac.

DO I have to keep the fec driver for mac and I have to use micrel driver for switch configuration with phy?

Or do I have to turn off FEC driver and I have to use only micrel driver for switch, phy and mac.

I guess, i.mx6solo has MAC, not switch. so I think I have to use FEC driver for MAC....

I am very confused. 

/arch/ar/mach-imx/mach-imx6q.c

static inline void imx6q_enet_init(void)
{
//imx6_enet_mac_init("fsl,imx6q-fec", "fsl,imx6q-ocotp");
imx6_enet_mac_init("micrel,ksz8873", "fsl,imx6q-ocotp");
imx6q_enet_phy_init();
imx6q_1588_init();
if (cpu_is_imx6q() && imx_get_soc_revision() == IMX_CHIP_REVISION_2_0)
imx6q_enet_clk_sel();
}

To use micrel switch ksz8873, what things I have to change in first.

Could you help me? 

Labels (5)
4 Replies

1,851 Views
art
NXP Employee
NXP Employee

You have to use the regular FEC driver to manage the network access, and, maybe, some Micrel code to manage the switch chip through the SPI bus.


Have a great day,
Artur

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

1,851 Views
erdani80
Contributor III

You need the FEC driver, this is the driver that provides ethernet on imx6 (MAC), the micrel switch is only for the physical part of the network (PHY).

It doesn't matter if you have a switch or a single phy for the phisical layer, the mac is the same. The micrel driver has to provide the phy interface, probably compatible with phylib in order to use the functions that report link status.

Also looking at the micrel driver in the kernel tree it seems that the driver is prepared for MDIO, not for SPI, probably you are trying to add an external driver to give the support.

1,851 Views
coilnpark
Contributor IV

Thank you Daniel ~

You made me clear.

Could you give me some advice?

Even I changed these sources, they didn't work.

What's wrong with me...

&ecspi1 {
fsl,spi-num-chipselects = <1>;
cs-gpios = <0>;
pinctrl-names = "default";
pinctrl-0 = <&pinctrl_ecspi1>;
status = "okay";


ethernet-switch@0 {
compatible = "micrel,ksz886x";
spi-max-frequency = <1000000>;
reg = <0>;
};

};

 

/* I checked SPI1 is working */

pinctrl_ecspi1: ecspi1grp {
fsl,pins = <
MX6QDL_PAD_DISP0_DAT20__ECSPI1_SCLK 0x100b1
MX6QDL_PAD_DISP0_DAT22__ECSPI1_MISO 0x100b1
MX6QDL_PAD_DISP0_DAT21__ECSPI1_MOSI 0x100b1
MX6QDL_PAD_DISP0_DAT23__ECSPI1_SS0 0x100b1
>;
};

 

/* How to connect this pins with ethernet switch? */

pinctrl_enet: enetgrp {
fsl,pins = <
MX6QDL_PAD_ENET_MDIO__ENET_MDIO 0x1b0b0
MX6QDL_PAD_ENET_MDC__ENET_MDC 0x1b0b0
MX6QDL_PAD_ENET_REF_CLK__ENET_TX_CLK 0x00001
MX6QDL_PAD_ENET_CRS_DV__ENET_RX_EN 0x1b0b0
MX6QDL_PAD_ENET_RXD0__ENET_RX_DATA0 0x1b0b0
MX6QDL_PAD_ENET_RXD1__ENET_RX_DATA1 0x1b0b0
MX6QDL_PAD_ENET_RX_ER__ENET_RX_ER 0x1b0b0
MX6QDL_PAD_ENET_TXD0__ENET_TX_DATA0 0x1b0b0
MX6QDL_PAD_ENET_TXD1__ENET_TX_DATA1 0x1b0b0
MX6QDL_PAD_ENET_TX_EN__ENET_TX_EN 0x1b0b0

MX6QDL_PAD_KEY_COL0__ENET_RX_DATA3 0x1b0b0
MX6QDL_PAD_KEY_ROW0__ENET_TX_DATA3 0x1b0b0
MX6QDL_PAD_KEY_ROW1__ENET_COL 0x1b0b0
MX6QDL_PAD_KEY_COL2__ENET_RX_DATA2 0x1b0b0
MX6QDL_PAD_KEY_ROW2__ENET_TX_DATA2 0x1b0b0
MX6QDL_PAD_KEY_COL3__ENET_CRS 0x1b0b0
MX6QDL_PAD_GPIO_18__ENET_RX_CLK 0x1b0b0
MX6QDL_PAD_GPIO_19__ENET_TX_ER 0x1b0b0
>;
};

 

 

in the "mach-imx6q.c" source file.

 

static void __init imx6q_enet_phy_init(void)
{
if (IS_BUILTIN(CONFIG_PHYLIB)) {
// phy_register_fixup_for_uid(PHY_ID_KSZ8873MLL, MICREL_PHY_ID_MASK, ksz8873mll_phy_fixup); //colin
// phy_register_fixup_for_uid(PHY_ID_KSZ886X, MICREL_PHY_ID_MASK, ksz886x_phy_fixup); //colin
phy_register_fixup_for_uid(PHY_ID_KSZ9021, MICREL_PHY_ID_MASK, ksz9021rn_phy_fixup);
phy_register_fixup_for_uid(PHY_ID_KSZ9031, MICREL_PHY_ID_MASK, ksz9031rn_phy_fixup);
phy_register_fixup_for_uid(PHY_ID_AR8031, 0xffffffff, ar8031_phy_fixup);
phy_register_fixup_for_uid(PHY_ID_AR8035, 0xffffffef, ar8035_phy_fixup);
}
}

 

 

static int ksz886x_phy_fixup(struct phy_device *dev)
{
if (dev && dev->interface == PHY_INTERFACE_MODE_MII) {
phy_write(dev, 0x1f, 0x8110);
phy_write(dev, 0x16, 0x201);
printk("ksz886x_phy_fixup in_colin\n");
}
printk("ksz886x_phy_fixup out_colin\n");

return 0;
}

0 Kudos

1,851 Views
erdani80
Contributor III

You registered the switch on the spi bus, probably that must show some traces (i don't have this driver).

Chech the dts bindings in the driver to see how to connect it to the mac. In the DTS node for the FEC you can add phy information.

Probably this would be easier if you connected the MDIO of the FEC to the MDIO in the switch. If this is not possible another solution is:

- add a fixed phy, that is a dummy phy thta has a code that allways returns the link, speed and duplex you need

- configure the switch from userspace using an application you can write using spidev to manage the bus

This way you can bypass the kernel rquirements regarding the phy (usefful also if you don't have a driver for the switch) but all the swtch management has to be done on userspace.