When I inserted number of logs, I found mdio_register
I debug up to where it was called --> list_for_each(entry, &mii_devs) {
And I realized, it doesn't enter to list_for_each and I also check mii_devs has been initiallized.
I am not sure whatelse I can do? Could you please help me debug further?
int mdio_register(struct mii_dev *bus)
{
if (!bus || !bus->read || !bus->write)
return -1;
printf("mdio_register called\n");
/* check if we have unique name */
if (miiphy_get_dev_by_name(bus->name)) {
printf("mdio_register: non unique device name '%s'\n",
bus->name);
return -1;
}
/* add it to the list */
list_add_tail(&bus->link, &mii_devs);
if (!current_mii)
current_mii = bus;
printf("mdio_register end\n");
return 0;
}
struct mii_dev *miiphy_get_dev_by_name(const char *devname)
{
struct list_head *entry;
struct mii_dev *dev;
printf("miiphy_get_dev_by_name was called\n");
if (!devname) {
printf("NULL device name!\n");
return NULL;
}
printf("list_for_each checking %s\n", devname);
list_for_each(entry, &mii_devs) {
printf("list_for_each check entered %s\n", devname);
dev = list_entry(entry, struct mii_dev, link);
if (strcmp(dev->name, devname) == 0)
return dev;
}
return NULL;
}
已解决! 转到解答。
FYI.
https://community.nxp.com/t5/i-MX-Processors-Knowledge-Base/Porting-KSZ9031-to-i-MX-BSP/ta-p/1112601
Hope this could help you.
I am using MCIMX6D7
Looks like it failed to register. Further checking fdt_first_subnode it keeps on failed to return the node.
I have been double checking fdt file but I cannot figure it out. Anything can help could you please let me know.
Under the u-boot I set, fdt addr <fdt_blob addr> and I was able to get fdt print /soc/aips-bus@02100000/ethernet@02188000
#ifdef CONFIG_PHY_FIXED
#ifdef CONFIG_DM_ETH
static struct phy_device *phy_connect_fixed(struct mii_dev *bus, struct udevice *dev, phy_interface_t interface)
#else
static struct phy_device *phy_connect_fixed(struct mii_dev *bus, struct eth_device *dev, phy_interface_t interface)
#endif
{
struct phy_device *phydev = NULL;
int sn;
const char *name;
sn = fdt_first_subnode(gd->fdt_blob, dev_of_offset(dev)); // sn returns as -1
while (sn > 0) {
name = fdt_get_name(gd->fdt_blob, sn, NULL);
if (name && strcmp(name, "fixed-link") == 0) {
phydev = phy_device_create(bus, sn, PHY_FIXED_ID, false,
interface);
break;
}
sn = fdt_next_subnode(gd->fdt_blob, sn);
}
return phydev;
]
Here is my fec, but the initialization still doesn't works. I am not sure what I am doing wrong.
&fec {
phy-handle = <ðphy>;
phy-mode = "rgmii";
phy-reset-gpios = GP_ENET_PHY_RESET;
pinctrl-names = "default";
pinctrl-0 = <&pinctrl_enet>;
rxc-skew-ps = <3000>;
rxd0-skew-ps = <0>;
rxd1-skew-ps = <0>;
rxd2-skew-ps = <0>;
rxd3-skew-ps = <0>;
rxdv-skew-ps = <0>;
status = "okay";
txc-skew-ps = <3000>;
txd0-skew-ps = <0>;
txd1-skew-ps = <0>;
txd2-skew-ps = <0>;
txd3-skew-ps = <0>;
txen-skew-ps = <0>;
mdio {
#address-cells = <0>;
#size-cells = <1>;
ethphy: ethernet-phy@7 {
interrupts-extended = GPIRQ_ENET_PHY;
};
};
};
Please check the phy address. Please read the datasheet of the phy ksz9031.
for example, if the phy address on your hardware board is 7. so, you set the same phy address in device tree to 7.
ethphy0: ethernet-phy@7 {
compatible = "ethernet-phy-ieee802.3-c22";
reg = <7>;
Another need to check is which gpio pin you connected to the reset pin of the phy. Then write it in the device tree.
e.g. phy-reset-gpios = <&gpio1 7 GPIO_ACTIVE_LOW>;
Also, put the IOMUX setting of the gpio pin the in pinctrl_fec1.
e.g. MX8MM_IOMUXC_GPIO1_IO07_GPIO1_IO7 0x19
I am Grateful for your continued support. Yes. I already have been working on below two. but I continue to have some issues and it doesn't looks like u-boot has been picking up from dtb file so I have a couple of Q. I hope that you could answer it.
ethphy0: ethernet-phy@7 {
compatible = "ethernet-phy-ieee802.3-c22";
reg = <7>;
do I need both reg = <7> and ethernet-phy@7 and are they HW specific? or can I set by chose one of number. And is this same with phy_id? for some reason, uboot variable phy_id was failed to read.
e.g. phy-reset-gpios = <&gpio1 7 GPIO_ACTIVE_LOW>;
e.g. MX8MM_IOMUXC_GPIO1_IO07_GPIO1_IO7 0x19
I also give phy-reset-gpio, how can I verify this? during eth_initialize, looks like gpio was called but it doesn't looks like executing. I don't think it is picking up from dtb file.
During uboot boot up where does get the DTB files? Looks like uboot read dtb file twice once as soon as u-boot boot and once before jump to Kernel, dtb file has been loaded so do I need two dtb files?