From 274ddfd23b84b206a3209252ea10da4815f0defe Mon Sep 17 00:00:00 2001 From: Ziyan Date: Fri, 13 May 2016 21:45:16 +0200 Subject: espresso: fix connector if CONFIG_BATTERY_MANAGER is not set --- arch/arm/mach-omap2/board-espresso-connector.c | 35 +++++++++++++++++++++++++- arch/arm/mach-omap2/board-espresso-power.c | 3 +-- arch/arm/mach-omap2/board-espresso.h | 3 +++ 3 files changed, 38 insertions(+), 3 deletions(-) (limited to 'arch') diff --git a/arch/arm/mach-omap2/board-espresso-connector.c b/arch/arm/mach-omap2/board-espresso-connector.c index 16d0b40..d292f12 100644 --- a/arch/arm/mach-omap2/board-espresso-connector.c +++ b/arch/arm/mach-omap2/board-espresso-connector.c @@ -579,14 +579,19 @@ static void espresso_30pin_detected(int device, bool connected) break; case P30_JIG: if (connected) { +#ifdef CONFIG_BATTERY_MANAGER check_jig_status(1); +#endif if (espresso_otg->uart_manual_mode == ESPRESSO_MANUAL_UART_MODEM) espresso_cp_uart_actions(); else espresso_ap_uart_actions(); - } else + } else { +#ifdef CONFIG_BATTERY_MANAGER check_jig_status(0); +#endif + } break; case P30_USB: if (connected) @@ -907,6 +912,9 @@ static irqreturn_t ta_nconnected_irq(int irq, void *_otg) { struct omap4_otg *otg = _otg; int val; +#ifndef CONFIG_BATTERY_MANAGER + int cable_type; +#endif val = gpio_get_value(GPIO_TA_NCONNECTED); if (val < 0) { @@ -924,6 +932,17 @@ static irqreturn_t ta_nconnected_irq(int irq, void *_otg) else /* disconnected */ espresso_ap_usb_detach(otg); +#ifndef CONFIG_BATTERY_MANAGER + if (!val) { + cable_type = check_charger_type(); + } else { + cable_type = CABLE_TYPE_NONE; + } + + omap4_espresso_usb_detected(cable_type); + omap4_espresso_tsp_ta_detect(cable_type); +#endif + return IRQ_HANDLED; } @@ -1077,6 +1096,9 @@ void __init omap4_espresso_connector_init(void) { struct omap4_otg *espresso_otg = &espresso_otg_xceiv; int ret; +#ifndef CONFIG_BATTERY_MANAGER + int cable_type; +#endif connector_gpio_init(); mutex_init(&espresso_otg->lock); @@ -1153,4 +1175,15 @@ switch_dev_fail: switch_dev_register(&espresso_otg->audio_switch); espresso_otg->current_device = 0; + +#ifndef CONFIG_BATTERY_MANAGER + if (!gpio_get_value(GPIO_TA_NCONNECTED)) { + cable_type = CABLE_TYPE_USB; + } else { + cable_type = CABLE_TYPE_NONE; + } + + omap4_espresso_usb_detected(cable_type); + omap4_espresso_tsp_ta_detect(cable_type); +#endif } diff --git a/arch/arm/mach-omap2/board-espresso-power.c b/arch/arm/mach-omap2/board-espresso-power.c index c7de5a0..fb76a6f 100644 --- a/arch/arm/mach-omap2/board-espresso-power.c +++ b/arch/arm/mach-omap2/board-espresso-power.c @@ -45,7 +45,6 @@ #define CHARGER_STATUS_FULL 0x1 -#define CABLE_DETECT_VALUE 1150 #define HIGH_BLOCK_TEMP 500 #define HIGH_RECOVER_TEMP 420 #define LOW_BLOCK_TEMP (-50) @@ -263,7 +262,7 @@ static int read_fuel_value(enum fuel_property fg_prop) return 0; } -static int check_charger_type(void) +int check_charger_type(void) { int cable_type; short adc; diff --git a/arch/arm/mach-omap2/board-espresso.h b/arch/arm/mach-omap2/board-espresso.h index 74a0aa7..35a280c 100644 --- a/arch/arm/mach-omap2/board-espresso.h +++ b/arch/arm/mach-omap2/board-espresso.h @@ -23,6 +23,8 @@ extern struct class *sec_class; #define SEC_MACHINE_ESPRESSO10 0x02 #define SEC_MACHINE_ESPRESSO10_USA_BBY 0x06 +#define CABLE_DETECT_VALUE 1150 + enum espresso_adc_ch { REMOTE_SENSE = 0, ADC_CHECK_1, /* TA detection */ @@ -53,6 +55,7 @@ void omap4_espresso_jack_init(void); /** @category Charger, Battery */ void omap4_espresso_power_init(void); +int check_charger_type(void); /** @category Motion Sensor */ void omap4_espresso_sensors_init(void); -- cgit v1.1