Solved the ethernet network can' t work after reboot system, solution: power off the rmii of pmu for

--- ics/kernel/arch/arm/mach-rk30/board-rk30-sdk-vmac.c	2013-01-17 02:52:35 UTC (rev 263)
+++ ics/kernel/arch/arm/mach-rk30/board-rk30-sdk-vmac.c	2013-01-17 07:54:24 UTC (rev 264)
@@ -46,9 +46,17 @@
 
 static int rk30_rmii_power_control(int enable)
 {
+        struct regulator *ldo_rmii;
+        ldo_rmii = regulator_get(NULL, "ldo9");
+
+        if (ldo_rmii == NULL || IS_ERR(ldo_rmii)){
+            printk("get rmii ldo failed!\n");
+            return -1;
+        }
+
 	if (enable) {
 		//enable phy power
-		printk("power on phy\n");
+		printk("rk30_rmii_power_control:(add_pmu_yes10_reset))power on phy\n");
 		rk30_mux_api_set(GPIO1D6_CIF1DATA11_NAME, GPIO1D_GPIO1D6);
 
 		rk30_mux_api_set(GPIO1D2_CIF1CLKIN_NAME, GPIO1D_GPIO1D2);
@@ -65,9 +73,34 @@
 		rk30_mux_api_set(GPIO1C0_CIF1DATA2_RMIICLKOUT_RMIICLKIN_NAME, GPIO1C_RMII_CLKOUT);
 		gpio_direction_output(PHY_PWR_EN_GPIO, GPIO_HIGH);
 		gpio_set_value(PHY_PWR_EN_GPIO, GPIO_HIGH);
+
+// power control by pmu
+// _begin
+                printk("ldo_rmii=%d\n", regulator_is_enabled(ldo_rmii));
+                if(!regulator_is_enabled(ldo_rmii)) {
+                      printk("rk30_rmii_power_control: not enabled, reset it \n");
+                    regulator_set_voltage(ldo_rmii, 3300000, 3300000);
+                    regulator_enable(ldo_rmii);
+                    regulator_put(ldo_rmii);
+                    mdelay(500);
+                }
+// _end
+
 	}else {
+		printk("rk30_rmii_power_control:(add_pmu_yes10_reset)power off phy\n");
 		gpio_direction_output(PHY_PWR_EN_GPIO, GPIO_LOW);
 		gpio_set_value(PHY_PWR_EN_GPIO, GPIO_LOW);
+
+// power control by pmu
+// _begin
+                if(regulator_is_enabled(ldo_rmii)) {
+                      printk("rk30_rmii_power_control: enabled, disable it \n");
+                    regulator_disable(ldo_rmii);
+                    regulator_put(ldo_rmii);
+                    mdelay(500);
+                }
+// _end
+
 	}
 	return 0;
 }
@@ -77,16 +110,16 @@
 #define grf_writel(v, offset)	writel(v, RK30_GRF_BASE + offset)
 static int rk30_vmac_speed_switch(int speed)
 {
-        static int old_speed = -1;
+//        static int old_speed = -1;
 	//printk("%s--speed=%d\n", __FUNCTION__, speed);
-        if (old_speed != speed)
-        {
+//        if (old_speed != speed)
+//        {
 	if (10 == speed) {
             grf_writel((grf_readl(GRF_SOC_CON1) | (2<<16)) & (~BIT_EMAC_SPEED), GRF_SOC_CON1);
         } else {
             grf_writel((grf_readl(GRF_SOC_CON1) | (2<<16)) | BIT_EMAC_SPEED, GRF_SOC_CON1);
         }
-        }
+//        }
 }
 
 

Modified: ics/kernel/drivers/net/rk29_vmac.c (263 => 264)

--- ics/kernel/drivers/net/rk29_vmac.c	2013-01-17 02:52:35 UTC (rev 263)
+++ ics/kernel/drivers/net/rk29_vmac.c	2013-01-17 07:54:24 UTC (rev 264)
@@ -1138,10 +1138,35 @@
 	clk_enable(clk_get(NULL,"hclk_mac"));
 	clk_enable(clk_get(NULL,"mac_ref"));
 
+// xiaofeng: power off the rmii of pmu for reset the ethernet device (Just for rk3066 module)
+#ifdef CONFIG_MACH_RK30_BOX
+	//phy power off
+	if (pdata && pdata->rmii_power_control){
+	        //printk("xiaofeng: power off ethernet before power on\n");
+		pdata->rmii_power_control(0);
+        }
+       
+#if 0
+        printk("\n ************************ sleeping 10 seconds *************************\n"); 
+	msleep(1000);
+	msleep(1000);
+	msleep(1000);
+	msleep(1000);
+	msleep(1000);
+	msleep(1000);
+	msleep(1000);
+	msleep(1000);
+	msleep(1000);
+	msleep(1000);
+#endif
+	msleep(1000);
+#endif
+
 	//phy power on
-	if (pdata && pdata->rmii_power_control)
+	if (pdata && pdata->rmii_power_control){
+	        //printk("xiaofeng: power on ethernet\n");
 		pdata->rmii_power_control(1);
-
+        }
 	msleep(1000);
 
 	vmac_hw_init(dev);

你可能感兴趣的:(Solved the ethernet network can' t work after reboot system, solution: power off the rmii of pmu for)