20180619_jeffrey - silenceuncrio/diary GitHub Wiki

0920

開始進行 5200Z 的 project

1540

目前將 compile 完 UFW6.1 所得到的 image 載入到板子之後會看到 linux 有被帶起來

Starting kernel ...

[    0.000000] Linux version 3.10.12 (user@8de9e3d5af60) (gcc version 4.8.1 20130401 (prerelease) (Linaro GCC 4.8-2013.04) ) #1 Tue Jun 19 06:51:37 UTC 2018
[    0.000000] SoC: xRX200 rev 1.2
[    0.000000] bootconsole [early0] enabled
[    0.000000] CPU0 revision is: 00019556 (MIPS 34Kc)
[    0.000000] adding memory size:66060288 from DT
[    0.000000] Determined physical RAM map:
[    0.000000]  memory: 03f00000 @ 00000000 (usable)
[    0.690000] pcie_wait_phy_link_up port 0 timeout
[    1.200000] pcie_wait_phy_link_up port 0 timeout
[    1.710000] pcie_wait_phy_link_up port 0 timeout
[    2.220000] pcie_wait_phy_link_up port 0 timeout
[    2.730000] pcie_wait_phy_link_up port 0 timeout
[    2.740000] pcie_rc_initialize port 0 link up failed!!!!!
[    2.780000] ts-xway 1f103000.ts: temp sensor not supported in this chip !!
[    2.890000] Switch API: PCE MicroCode loaded !!
[    2.890000] gphy_driver_init: fw_mode:22F-FW, no of phys:2, mode:0

不過在 show 出 gphy_driver_init: fw_mode:22F-FW, no of phys:2, mode:0 後的三到四秒就會重新開機了

先 grep 一下

➜  build_dir git:(feature/UGW6.1) grep -r "gphy_driver_init" .
Binary file ./linux-lantiq_xrx200_vrx288_gw_he_vdsl_lte/vmlinux-EASY80920NAND matches
Binary file ./linux-lantiq_xrx200_vrx288_gw_he_vdsl_lte/vmlinux.elf matches
Binary file ./linux-lantiq_xrx200_vrx288_gw_he_vdsl_lte/linux-3.10.12/drivers/built-in.o matches
Binary file ./linux-lantiq_xrx200_vrx288_gw_he_vdsl_lte/linux-3.10.12/drivers/net/built-in.o matches
Binary file ./linux-lantiq_xrx200_vrx288_gw_he_vdsl_lte/linux-3.10.12/drivers/net/ethernet/built-in.o matches
Binary file ./linux-lantiq_xrx200_vrx288_gw_he_vdsl_lte/linux-3.10.12/drivers/net/ethernet/lantiq/switch-api/ltq_gphy_fw.o matches
Binary file ./linux-lantiq_xrx200_vrx288_gw_he_vdsl_lte/linux-3.10.12/drivers/net/ethernet/lantiq/switch-api/built-in.o matches
./linux-lantiq_xrx200_vrx288_gw_he_vdsl_lte/linux-3.10.12/drivers/net/ethernet/lantiq/switch-api/ltq_gphy_fw.c:static int __init gphy_driver_init (struct platform_device *pdev)
./linux-lantiq_xrx200_vrx288_gw_he_vdsl_lte/linux-3.10.12/drivers/net/ethernet/lantiq/switch-api/ltq_gphy_fw.c: gphy_driver_init(pdev);
Binary file ./linux-lantiq_xrx200_vrx288_gw_he_vdsl_lte/linux-3.10.12/drivers/net/ethernet/lantiq/switch-api/drv_switch_api.o matches
Binary file ./linux-lantiq_xrx200_vrx288_gw_he_vdsl_lte/linux-3.10.12/drivers/net/ethernet/lantiq/built-in.o matches
Binary file ./linux-lantiq_xrx200_vrx288_gw_he_vdsl_lte/linux-3.10.12/.tmp_vmlinux1 matches
Binary file ./linux-lantiq_xrx200_vrx288_gw_he_vdsl_lte/linux-3.10.12/vmlinux.o matches
./linux-lantiq_xrx200_vrx288_gw_he_vdsl_lte/linux-3.10.12/.tmp_System.map:ffffffff8050f7d0 t xway_gphy_driver_init
./linux-lantiq_xrx200_vrx288_gw_he_vdsl_lte/linux-3.10.12/.tmp_System.map:ffffffff80530fa8 t __initcall_xway_gphy_driver_init6
Binary file ./linux-lantiq_xrx200_vrx288_gw_he_vdsl_lte/linux-3.10.12/.tmp_vmlinux2 matches
Binary file ./linux-lantiq_xrx200_vrx288_gw_he_vdsl_lte/linux-3.10.12/vmlinux matches
./linux-lantiq_xrx200_vrx288_gw_he_vdsl_lte/linux-3.10.12/System.map:ffffffff8050f7d0 t xway_gphy_driver_init
./linux-lantiq_xrx200_vrx288_gw_he_vdsl_lte/linux-3.10.12/System.map:ffffffff80530fa8 t __initcall_xway_gphy_driver_init6
Binary file ./linux-lantiq_xrx200_vrx288_gw_he_vdsl_lte/vmlinux matches
➜  build_dir git:(feature/UGW6.1)

目前找到相關的 source code 如下

static int __init gphy_driver_init (struct platform_device *pdev)
{	
	const __be32 *no_phys;
	gphy_dev = &pdev->dev;
	gphy_node = pdev->dev.of_node;

	off_interval = 3;
	on_interval = 3;
	pw_save_mode = 0;
	dev_id = 0;
	if (of_property_read_string(pdev->dev.of_node, "fw-mode", &g_gphy_fw_mode)) {
		dev_err(&pdev->dev, "failed to read  firmware mode\n");
		return 0;
	}
	no_phys = of_get_property(gphy_node, "no_of_phys", NULL);
	if (!no_phys) {
		dev_err(&pdev->dev, "failed to get maximum number of internal gphys ports\n");
		return 0;
	}
	g_no_phys = (*no_phys);
	
	if (of_machine_is_compatible("lantiq,vr9") || of_machine_is_compatible("lantiq,xrx220") ) {
		int type = ltq_get_soc_type();
		if (type == SOC_TYPE_VR9) /*SOC_TYPE_VR9_2*/
			dev_id = 0;
		else
			dev_id = 1;
	} else if (of_machine_is_compatible("lantiq,ar10")) {
		dev_id = 1;
		no_phys = of_get_property(gphy_node, "pw_save_mode", NULL);
		if (no_phys)
			pw_save_mode = (*no_phys);
	} else if (of_machine_is_compatible("lantiq,grx390")) {
		dev_id = 1;
		no_phys = of_get_property(gphy_node, "pw_save_mode", NULL);
		if (no_phys)
			pw_save_mode = (*no_phys);
	}
	proc_file_create();
	pr_err("%s: fw_mode:%s, no of phys:%d, mode:%d\n", \
		__func__, g_gphy_fw_mode, g_no_phys, pw_save_mode);
	
	if ( pw_save_mode == 1 ) {
		swithc_api_fd = ltq_ethsw_api_kopen("/dev/switch_api/0");
		if (swithc_api_fd == 0) {
			pr_err("%s: Open SWAPI device FAILED !!\n", __func__ );
			return -EIO;
		}
		init_waitqueue_head(&gphy_pw_wait);
		gphy_pw_id = kthread_create(gphy_pw_save_thread, NULL, "gphy_pw_save");
		if (!IS_ERR(gphy_pw_id)) {
			wake_up_process(gphy_pw_id);
		}
	}
        //For VRX220 SW control PHY LED
	if (of_machine_is_compatible("lantiq,xrx220"))
	    AR10_F2_GPHY_LED_init();
	return 0;
}