From 5e64e45d3f647d8aac838d1eaba6618b57a29aa2 Mon Sep 17 00:00:00 2001 From: kfx Date: Wed, 31 Oct 2012 09:30:22 +0800 Subject: [PATCH] rk2928_defconfig: host_drv gpio control --- arch/arm/mach-rk2928/board-rk2928-config.c | 34 ++++++++++++++- arch/arm/mach-rk2928/include/mach/config.h | 50 +++++++++++++++++++--- drivers/usb/dwc_otg/usbdev_rk2928.c | 31 ++++++++++++-- 3 files changed, 105 insertions(+), 10 deletions(-) diff --git a/arch/arm/mach-rk2928/board-rk2928-config.c b/arch/arm/mach-rk2928/board-rk2928-config.c index e3f690d567fb..b16d609a8514 100644 --- a/arch/arm/mach-rk2928/board-rk2928-config.c +++ b/arch/arm/mach-rk2928/board-rk2928-config.c @@ -74,7 +74,39 @@ static inline int check_bl_param(void) } return 0; } - +/* usb */ +static int otg_drv = DEF_OTG_DRV; +module_param(otg_drv, int, 0644); +static int host_drv = DEF_HOST_DRV; +module_param(host_drv, int, 0644); +static inline int check_usb_param(void) +{ + return 0; +} +int inline otg_drv_init(int on) +{ + return port_output_init(otg_drv, on, "otg_drv"); +} +void inline otg_drv_on(void) +{ + port_output_on(otg_drv); +} +void inline otg_drv_off(void) +{ + port_output_off(otg_drv); +} +int inline host_drv_init(int on) +{ + return port_output_init(host_drv, on, "host_drv"); +} +void inline host_drv_on(void) +{ + port_output_on(host_drv); +} +void inline host_drv_off(void) +{ + port_output_off(host_drv); +} /* lcd */ static int lcd_cabc = DEF_LCD_CABC; module_param(lcd_cabc, int, 0644); diff --git a/arch/arm/mach-rk2928/include/mach/config.h b/arch/arm/mach-rk2928/include/mach/config.h index f79a53c0cc41..cc698dfa93ea 100644 --- a/arch/arm/mach-rk2928/include/mach/config.h +++ b/arch/arm/mach-rk2928/include/mach/config.h @@ -41,12 +41,12 @@ enum { enum{ DEF_KEY_ADC = 1, DEF_PLAY_KEY = 0x000101a4, - DEF_VOLDN_KEY = 0x000102b4, + DEF_VOLDN_KEY = 0x000102b6, DEF_VOLUP_KEY = 1 | (1<<31), - DEF_MENU_KEY = 135 | (1<<31), - DEF_ESC_KEY = 334 | (1<<31), - DEF_HOME_KEY = 550 | (1<<31), - DEF_CAM_KEY = 700 | (1<<31), + DEF_MENU_KEY = 100 | (1<<31), + DEF_ESC_KEY = 255 | (1<<31), + DEF_HOME_KEY = 425 | (1<<31), + DEF_CAM_KEY = 576 | (1<<31), }; /* backlight */ enum{ @@ -55,6 +55,11 @@ enum{ DEF_BL_MIN = 60, DEF_BL_EN = 0x000002c1, }; +/* usb */ +enum { + DEF_OTG_DRV = -1, + DEF_HOST_DRV = 0x000002b4, +}; /* lcd */ enum { DEF_LCD_CABC = 0x000002c3, @@ -165,6 +170,11 @@ enum{ DEF_BL_MIN = 60, DEF_BL_EN = 0x000003c4, }; +/* usb */ +enum { + DEF_OTG_DRV = -1, + DEF_HOST_DRV = 0x000001b2, +}; /* lcd */ enum { DEF_LCD_CABC = 0x000002d1, @@ -277,6 +287,12 @@ enum{ DEF_BL_MIN = 80, DEF_BL_EN = -1, }; + +/* usb */ +enum { + DEF_OTG_DRV = -1, + DEF_HOST_DRV = -1, +}; /* lcd */ enum { DEF_LCD_CABC = -1, @@ -388,6 +404,11 @@ enum{ DEF_BL_MIN = 80, DEF_BL_EN = 0x000003c5, }; +/* usb */ +enum { + DEF_OTG_DRV = -1, + DEF_HOST_DRV = -1, +}; /* lcd */ enum { DEF_LCD_CABC = -1, @@ -499,6 +520,11 @@ enum{ DEF_BL_MIN = 80, DEF_BL_EN = 0x000001b0, }; +/* usb */ +enum { + DEF_OTG_DRV = -1, + DEF_HOST_DRV = -1, +}; /* lcd */ enum { DEF_LCD_CABC = -1, @@ -612,6 +638,11 @@ enum{ DEF_BL_MIN = 0, DEF_BL_EN = -1, }; +/* usb */ +enum { + DEF_OTG_DRV = -1, + DEF_HOST_DRV = -1, +}; /* lcd */ enum { DEF_LCD_CABC = -1, @@ -703,7 +734,14 @@ enum { enum { DEF_PWR_ON = -1, }; - #endif +int inline otg_drv_init(int on); +void inline otg_drv_on(void); +void inline otg_drv_off(void); + +int inline host_drv_init(int on); +void inline host_drv_on(void); +void inline host_drv_off(void); + #endif diff --git a/drivers/usb/dwc_otg/usbdev_rk2928.c b/drivers/usb/dwc_otg/usbdev_rk2928.c index 2885e166b666..51c8aec42760 100755 --- a/drivers/usb/dwc_otg/usbdev_rk2928.c +++ b/drivers/usb/dwc_otg/usbdev_rk2928.c @@ -8,6 +8,7 @@ #include #include #include +#include #include "usbdev_rk.h" #include "dwc_otg_regs.h" @@ -98,7 +99,11 @@ void usb20otg_hw_init(void) *(unsigned int *)(USBGRF_UOC0_CON0) = 0x07e70350; // other hardware init +#ifdef CONFIG_RK_CONFIG + otg_drv_init(0); +#else rk30_mux_api_set(GPIO3C1_OTG_DRVVBUS_NAME, GPIO3C_OTG_DRVVBUS); +#endif } void usb20otg_phy_suspend(void* pdata, int suspend) { @@ -199,6 +204,12 @@ void dwc_otg_uart_mode(void* pdata, int enter_usb_uart_mode) void usb20otg_power_enable(int enable) { +#ifdef CONFIG_RK_CONFIG + if(enable) + otg_drv_on(); + else + otg_drv_off(); +#endif } struct dwc_otg_platform_data usb20otg_pdata = { .phyclk = NULL, @@ -244,7 +255,9 @@ void usb20host_hw_init(void) // usb phy config init *(unsigned int *)(USBGRF_UOC1_CON0) = 0x07e70350; // other haredware init - +#ifdef CONFIG_RK_CONFIG + host_drv_init(1); +#endif } void usb20host_phy_suspend(void* pdata, int suspend) { @@ -321,6 +334,12 @@ int usb20host_get_status(int id) } void usb20host_power_enable(int enable) { +#ifdef CONFIG_RK_CONFIG + if(enable) + host_drv_on(); + else + host_drv_off(); +#endif } struct dwc_otg_platform_data usb20host_pdata = { .phyclk = NULL, @@ -347,12 +366,18 @@ struct platform_device device_usb20_host = { #endif static int __init usbdev_init_devices(void) { + int ret = 0; #ifdef CONFIG_USB20_OTG - platform_device_register(&device_usb20_otg); + ret = platform_device_register(&device_usb20_otg); + if(ret < 0){ + printk("%s: platform_device_register(usb20_otg) failed\n", __func__); + return ret; + } #endif #ifdef CONFIG_USB20_HOST - platform_device_register(&device_usb20_host); + ret = platform_device_register(&device_usb20_host); #endif + return ret; } arch_initcall(usbdev_init_devices); #endif -- 2.34.1