1 //$_FOR_ROCKCHIP_RBOX_$
3 static int rk30_vmac_register_set(void)
5 //config rk30 vmac as rmii
6 writel_relaxed(0x3 << 16 | 0x2, RK30_GRF_BASE + GRF_SOC_CON1);
7 int val = readl_relaxed(RK30_GRF_BASE + GRF_IO_CON3);
8 writel_relaxed(val | 0xf << 16 | 0xf, RK30_GRF_BASE + GRF_IO_CON3);
12 static int rk30_rmii_io_init(void)
15 printk("enter %s ",__func__);
22 iomux_set(RMII_CLKOUT);
23 iomux_set(RMII_RXERR);
26 iomux_set(RMII_MDCLK);
28 if(INVALID_GPIO != PHY_PWR_EN_GPIO)
30 //phy power gpio request
31 iomux_set(PHY_PWR_EN_IOMUX);
32 err = gpio_request(PHY_PWR_EN_GPIO, "phy_power_en");
34 printk("request phy power en pin faile ! \n");
38 gpio_direction_output(PHY_PWR_EN_GPIO, !PHY_PWR_EN_VALUE);
44 static int rk30_rmii_io_deinit(void)
47 printk("enter %s ",__func__);
49 if(INVALID_GPIO != PHY_PWR_EN_GPIO)
51 gpio_direction_output(PHY_PWR_EN_GPIO, !PHY_PWR_EN_VALUE);
53 gpio_free(PHY_PWR_EN_GPIO);
59 static int rk30_rmii_power_control(int enable)
61 printk("enter %s ,enable = %d ",__func__,enable);
69 iomux_set(RMII_CLKOUT);
70 iomux_set(RMII_RXERR);
73 iomux_set(RMII_MDCLK);
75 if(INVALID_GPIO != PHY_PWR_EN_GPIO)
78 gpio_direction_output(PHY_PWR_EN_GPIO, !PHY_PWR_EN_VALUE);
80 gpio_direction_output(PHY_PWR_EN_GPIO, PHY_PWR_EN_VALUE);
83 if(INVALID_GPIO != PHY_PWR_EN_GPIO)
85 gpio_direction_output(PHY_PWR_EN_GPIO, !PHY_PWR_EN_VALUE);
92 #define BIT_EMAC_SPEED (1 << 1)
93 static int rk29_vmac_speed_switch(int speed)
95 //printk("%s--speed=%d\n", __FUNCTION__, speed);
97 writel_relaxed(readl_relaxed(RK30_GRF_BASE + GRF_SOC_CON1) & (~BIT_EMAC_SPEED) | (BIT_EMAC_SPEED << 16), RK30_GRF_BASE + GRF_SOC_CON1);
99 writel_relaxed(readl_relaxed(RK30_GRF_BASE + GRF_SOC_CON1) | ( BIT_EMAC_SPEED) | (BIT_EMAC_SPEED << 16), RK30_GRF_BASE + GRF_SOC_CON1);
103 struct rk29_vmac_platform_data board_vmac_data = {
104 .vmac_register_set = rk30_vmac_register_set,
105 .rmii_io_init = rk30_rmii_io_init,
106 .rmii_io_deinit = rk30_rmii_io_deinit,
107 .rmii_power_control = rk30_rmii_power_control,
108 .rmii_speed_switch = rk29_vmac_speed_switch,