From e62ccadcb5d5b94c6f844b0b2d47bd2d9c3f1f18 Mon Sep 17 00:00:00 2001 From: =?utf8?q?=E9=BB=84=E6=B6=9B?= Date: Mon, 7 May 2012 20:23:04 +0800 Subject: [PATCH] rk30: sdk: add vmac support --- arch/arm/mach-rk30/board-rk30-sdk-vmac.c | 80 ++++++++++++++++++++++++ arch/arm/mach-rk30/board-rk30-sdk.c | 15 +++-- 2 files changed, 90 insertions(+), 5 deletions(-) create mode 100644 arch/arm/mach-rk30/board-rk30-sdk-vmac.c diff --git a/arch/arm/mach-rk30/board-rk30-sdk-vmac.c b/arch/arm/mach-rk30/board-rk30-sdk-vmac.c new file mode 100644 index 000000000000..5ec8866c0766 --- /dev/null +++ b/arch/arm/mach-rk30/board-rk30-sdk-vmac.c @@ -0,0 +1,80 @@ +static int rk30_vmac_register_set(void) +{ + //config rk30 vmac as rmii + writel_relaxed(0x3 << 16 | 0x2, RK30_GRF_BASE + GRF_SOC_CON1); + return 0; +} + +static int rk30_rmii_io_init(void) +{ + int err; + rk30_mux_api_set(GPIO1D6_CIF1DATA11_NAME, GPIO1D_GPIO1D6); + + rk30_mux_api_set(GPIO1D2_CIF1CLKIN_NAME, GPIO1D_GPIO1D2); + rk30_mux_api_set(GPIO1D1_CIF1HREF_MIIMDCLK_NAME, GPIO1D_MII_MDCLK); + rk30_mux_api_set(GPIO1D0_CIF1VSYNC_MIIMD_NAME, GPIO1D_MII_MD); + + rk30_mux_api_set(GPIO1C7_CIFDATA9_RMIIRXD0_NAME, GPIO1C_RMII_RXD0); + rk30_mux_api_set(GPIO1C6_CIFDATA8_RMIIRXD1_NAME, GPIO1C_RMII_RXD1); + rk30_mux_api_set(GPIO1C5_CIFDATA7_RMIICRSDVALID_NAME, GPIO1C_RMII_CRS_DVALID); + rk30_mux_api_set(GPIO1C4_CIFDATA6_RMIIRXERR_NAME, GPIO1C_RMII_RX_ERR); + rk30_mux_api_set(GPIO1C3_CIFDATA5_RMIITXD0_NAME, GPIO1C_RMII_TXD0); + rk30_mux_api_set(GPIO1C2_CIF1DATA4_RMIITXD1_NAME, GPIO1C_RMII_TXD1); + rk30_mux_api_set(GPIO1C1_CIFDATA3_RMIITXEN_NAME, GPIO1C_RMII_TX_EN); + rk30_mux_api_set(GPIO1C0_CIF1DATA2_RMIICLKOUT_RMIICLKIN_NAME, GPIO1C_RMII_CLKOUT); + + //phy power gpio + err = gpio_request(PHY_PWR_EN_GPIO, "phy_power_en"); + if (err) { + return -1; + } + //phy power down + gpio_direction_output(PHY_PWR_EN_GPIO, GPIO_LOW); + gpio_set_value(PHY_PWR_EN_GPIO, GPIO_LOW); + return 0; +} + +static int rk30_rmii_io_deinit(void) +{ + //phy power down + gpio_direction_output(PHY_PWR_EN_GPIO, GPIO_LOW); + gpio_set_value(PHY_PWR_EN_GPIO, GPIO_LOW); + //free + gpio_free(PHY_PWR_EN_GPIO); + return 0; +} + +static int rk30_rmii_power_control(int enable) +{ + if (enable) { + //enable phy power + printk("power on phy\n"); + rk30_mux_api_set(GPIO1D6_CIF1DATA11_NAME, GPIO1D_GPIO1D6); + + rk30_mux_api_set(GPIO1D2_CIF1CLKIN_NAME, GPIO1D_GPIO1D2); + rk30_mux_api_set(GPIO1D1_CIF1HREF_MIIMDCLK_NAME, GPIO1D_MII_MDCLK); + rk30_mux_api_set(GPIO1D0_CIF1VSYNC_MIIMD_NAME, GPIO1D_MII_MD); + + rk30_mux_api_set(GPIO1C7_CIFDATA9_RMIIRXD0_NAME, GPIO1C_RMII_RXD0); + rk30_mux_api_set(GPIO1C6_CIFDATA8_RMIIRXD1_NAME, GPIO1C_RMII_RXD1); + rk30_mux_api_set(GPIO1C5_CIFDATA7_RMIICRSDVALID_NAME, GPIO1C_RMII_CRS_DVALID); + rk30_mux_api_set(GPIO1C4_CIFDATA6_RMIIRXERR_NAME, GPIO1C_RMII_RX_ERR); + rk30_mux_api_set(GPIO1C3_CIFDATA5_RMIITXD0_NAME, GPIO1C_RMII_TXD0); + rk30_mux_api_set(GPIO1C2_CIF1DATA4_RMIITXD1_NAME, GPIO1C_RMII_TXD1); + rk30_mux_api_set(GPIO1C1_CIFDATA3_RMIITXEN_NAME, GPIO1C_RMII_TX_EN); + 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); + }else { + gpio_direction_output(PHY_PWR_EN_GPIO, GPIO_LOW); + gpio_set_value(PHY_PWR_EN_GPIO, GPIO_LOW); + } + return 0; +} + +struct rk29_vmac_platform_data board_vmac_data = { + .vmac_register_set = rk30_vmac_register_set, + .rmii_io_init = rk30_rmii_io_init, + .rmii_io_deinit = rk30_rmii_io_deinit, + .rmii_power_control = rk30_rmii_power_control, +}; diff --git a/arch/arm/mach-rk30/board-rk30-sdk.c b/arch/arm/mach-rk30/board-rk30-sdk.c index 0a35bc83ca46..6cef0f9bbbbd 100755 --- a/arch/arm/mach-rk30/board-rk30-sdk.c +++ b/arch/arm/mach-rk30/board-rk30-sdk.c @@ -1127,6 +1127,10 @@ struct rk29_sdmmc_platform_data default_sdmmc1_data = { }; #endif //endif--#ifdef CONFIG_SDMMC1_RK29 +/************************************************************************************************** + * the end of setting for SDMMC devices +**************************************************************************************************/ + /* bluetooth rfkill device */ static struct platform_device rk29sdk_rfkill = { .name = "rk29sdk_rfkill", @@ -1152,9 +1156,10 @@ static struct platform_device rk30_device_adc_battery = { }; #endif -/************************************************************************************************** - * the end of setting for SDMMC devices -**************************************************************************************************/ +#ifdef CONFIG_RK29_VMAC +#define PHY_PWR_EN_GPIO RK30_PIN1_PD6 +#include "board-rk30-sdk-vmac.c" +#endif static struct platform_device *devices[] __initdata = { #ifdef CONFIG_BACKLIGHT_RK29_BL @@ -1179,10 +1184,10 @@ static struct platform_device *devices[] __initdata = { &rk29sdk_wifi_device, #endif #ifdef CONFIG_BT - &rk29sdk_rfkill, + &rk29sdk_rfkill, #endif #ifdef CONFIG_RK29_SUPPORT_MODEM - &rk30_device_modem, + &rk30_device_modem, #endif #ifdef CONFIG_BATTERY_RK30_ADC &rk30_device_adc_battery, -- 2.34.1