aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/extcon/extcon-max77693.c
diff options
context:
space:
mode:
authorChanwoo Choi <cw00.choi@samsung.com>2012-12-10 05:07:53 -0500
committerChanwoo Choi <cw00.choi@samsung.com>2013-01-15 01:42:16 -0500
commita162629859a03c07b9603ea59a0b7ae24f695689 (patch)
tree7e0744ff2dadfc6c78347981c17baaa49acc3856 /drivers/extcon/extcon-max77693.c
parent0e2738f59c6db185a70a683059980bd2296571ca (diff)
extcon: max77693: Add support Dock-Smart device for desktop mode
This patch support the detection of Dock-Smart device which include three type of port(HDMI, USB for mouse/keyboard and Micro-USB for USB/TA cable).The Dock-Smart device need always exteranl power supply (USB/TA cable through micro-usb cable). Dock-Smart device support screen output of target to separate monitor and mouse/keyboard for desktop mode. Features of 'Dock-Smart device' - Support HDMI - Support external output feature of audio - Support charging through micro-usb port without data connection if TA cable is connected to target. - Support charging and data connection through micro-usb port if USB cable is connected between target and host device. - Support OTG device (Mouse/Keyboard) Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com> Signed-off-by: Myungjoo Ham <myungjoo.ham@samsung.com>
Diffstat (limited to 'drivers/extcon/extcon-max77693.c')
-rw-r--r--drivers/extcon/extcon-max77693.c200
1 files changed, 138 insertions, 62 deletions
diff --git a/drivers/extcon/extcon-max77693.c b/drivers/extcon/extcon-max77693.c
index 28eff88fca18..fb6527607a11 100644
--- a/drivers/extcon/extcon-max77693.c
+++ b/drivers/extcon/extcon-max77693.c
@@ -442,6 +442,8 @@ static int max77693_muic_dock_handler(struct max77693_muic_info *info,
442 int cable_type, bool attached) 442 int cable_type, bool attached)
443{ 443{
444 int ret = 0; 444 int ret = 0;
445 int vbvolt;
446 bool cable_attached;
445 char dock_name[CABLE_NAME_MAX]; 447 char dock_name[CABLE_NAME_MAX];
446 448
447 dev_info(info->dev, 449 dev_info(info->dev,
@@ -450,14 +452,45 @@ static int max77693_muic_dock_handler(struct max77693_muic_info *info,
450 452
451 switch (cable_type) { 453 switch (cable_type) {
452 case MAX77693_MUIC_ADC_RESERVED_ACC_3: /* Dock-Smart */ 454 case MAX77693_MUIC_ADC_RESERVED_ACC_3: /* Dock-Smart */
453 /* PATH:AP_USB */ 455 /*
454 ret = max77693_muic_set_path(info, 456 * Check power cable whether attached or detached state.
455 CONTROL1_SW_USB, attached); 457 * The Dock-Smart device need surely external power supply.
458 * If power cable(USB/TA) isn't connected to Dock device,
459 * user can't use Dock-Smart for desktop mode.
460 */
461 vbvolt = max77693_muic_get_cable_type(info,
462 MAX77693_CABLE_GROUP_VBVOLT, &cable_attached);
463 if (attached && !vbvolt) {
464 dev_warn(info->dev,
465 "Cannot detect external power supply\n");
466 return 0;
467 }
468
469 /*
470 * Notify Dock-Smart/MHL state.
471 * - Dock-Smart device include three type of cable which
472 * are HDMI, USB for mouse/keyboard and micro-usb port
473 * for USB/TA cable. Dock-Smart device need always exteranl
474 * power supply(USB/TA cable through micro-usb cable). Dock-
475 * Smart device support screen output of target to separate
476 * monitor and mouse/keyboard for desktop mode.
477 *
478 * Features of 'USB/TA cable with Dock-Smart device'
479 * - Support MHL
480 * - Support external output feature of audio
481 * - Support charging through micro-usb port without data
482 * connection if TA cable is connected to target.
483 * - Support charging and data connection through micro-usb port
484 * if USB cable is connected between target and host
485 * device.
486 * - Support OTG device (Mouse/Keyboard)
487 */
488 ret = max77693_muic_set_path(info, info->path_usb, attached);
456 if (ret < 0) 489 if (ret < 0)
457 goto out; 490 return ret;
458 491
459 /* Dock-Smart */
460 extcon_set_cable_state(info->edev, "Dock-Smart", attached); 492 extcon_set_cable_state(info->edev, "Dock-Smart", attached);
493 extcon_set_cable_state(info->edev, "MHL", attached);
461 goto out; 494 goto out;
462 case MAX77693_MUIC_ADC_FACTORY_MODE_UART_ON: /* Dock-Car */ 495 case MAX77693_MUIC_ADC_FACTORY_MODE_UART_ON: /* Dock-Car */
463 strcpy(dock_name, "Dock-Car"); 496 strcpy(dock_name, "Dock-Car");
@@ -475,11 +508,11 @@ static int max77693_muic_dock_handler(struct max77693_muic_info *info,
475 /* Dock-Car/Desk/Audio, PATH:AUDIO */ 508 /* Dock-Car/Desk/Audio, PATH:AUDIO */
476 ret = max77693_muic_set_path(info, CONTROL1_SW_AUDIO, attached); 509 ret = max77693_muic_set_path(info, CONTROL1_SW_AUDIO, attached);
477 if (ret < 0) 510 if (ret < 0)
478 goto out; 511 return ret;
479 extcon_set_cable_state(info->edev, dock_name, attached); 512 extcon_set_cable_state(info->edev, dock_name, attached);
480 513
481out: 514out:
482 return ret; 515 return 0;
483} 516}
484 517
485static int max77693_muic_dock_button_handler(struct max77693_muic_info *info, 518static int max77693_muic_dock_button_handler(struct max77693_muic_info *info,
@@ -737,80 +770,125 @@ static int max77693_muic_chg_handler(struct max77693_muic_info *info)
737 770
738 switch (chg_type) { 771 switch (chg_type) {
739 case MAX77693_CHARGER_TYPE_USB: 772 case MAX77693_CHARGER_TYPE_USB:
773 case MAX77693_CHARGER_TYPE_DEDICATED_CHG:
740 case MAX77693_CHARGER_TYPE_NONE: 774 case MAX77693_CHARGER_TYPE_NONE:
741 /* 775 /* Check MAX77693_CABLE_GROUP_ADC_GND type */
742 * MHL_TA(USB/TA) with MHL cable
743 * - MHL cable include two port(HDMI line and separate micro
744 * -usb port. When the target connect MHL cable, extcon driver
745 * check whether MHL_TA(USB/TA) cable is connected. If MHL_TA
746 * cable is connected, extcon driver notify state to notifiee
747 * for charging battery.
748 */
749 cable_type_gnd = max77693_muic_get_cable_type(info, 776 cable_type_gnd = max77693_muic_get_cable_type(info,
750 MAX77693_CABLE_GROUP_ADC_GND, 777 MAX77693_CABLE_GROUP_ADC_GND,
751 &cable_attached); 778 &cable_attached);
752 if (cable_type_gnd == MAX77693_MUIC_GND_MHL 779 switch (cable_type_gnd) {
753 || cable_type_gnd == MAX77693_MUIC_GND_MHL_VB) { 780 case MAX77693_MUIC_GND_MHL:
781 case MAX77693_MUIC_GND_MHL_VB:
782 /*
783 * MHL cable with MHL_TA(USB/TA) cable
784 * - MHL cable include two port(HDMI line and separate micro-
785 * usb port. When the target connect MHL cable, extcon driver
786 * check whether MHL_TA(USB/TA) cable is connected. If MHL_TA
787 * cable is connected, extcon driver notify state to notifiee
788 * for charging battery.
789 *
790 * Features of 'MHL_TA(USB/TA) with MHL cable'
791 * - Support MHL
792 * - Support charging through micro-usb port without data connection
793 */
754 extcon_set_cable_state(info->edev, "MHL_TA", attached); 794 extcon_set_cable_state(info->edev, "MHL_TA", attached);
755
756 if (!cable_attached) 795 if (!cable_attached)
757 extcon_set_cable_state(info->edev, 796 extcon_set_cable_state(info->edev, "MHL", cable_attached);
758 "MHL", false); 797 break;
759 goto out;
760 } 798 }
761 799
762 /* 800 /* Check MAX77693_CABLE_GROUP_ADC type */
763 * USB/TA cable with Dock-Audio device
764 * - Dock device include two port(Dock-Audio and micro-usb
765 * port). When the target connect Dock-Audio device, extcon
766 * driver check whether USB/TA cable is connected.
767 * If USB/TA cable is connected, extcon driver notify state
768 * to notifiee for charging battery.
769 */
770 cable_type = max77693_muic_get_cable_type(info, 801 cable_type = max77693_muic_get_cable_type(info,
771 MAX77693_CABLE_GROUP_ADC, 802 MAX77693_CABLE_GROUP_ADC,
772 &cable_attached); 803 &cable_attached);
773 if (cable_type == MAX77693_MUIC_ADC_AV_CABLE_NOLOAD) { 804 switch (cable_type) {
805 case MAX77693_MUIC_ADC_AV_CABLE_NOLOAD: /* Dock-Audio */
806 /*
807 * Dock-Audio device with USB/TA cable
808 * - Dock device include two port(Dock-Audio and micro-usb
809 * port). When the target connect Dock-Audio device, extcon
810 * driver check whether USB/TA cable is connected. If USB/TA
811 * cable is connected, extcon driver notify state to notifiee
812 * for charging battery.
813 *
814 * Features of 'USB/TA cable with Dock-Audio device'
815 * - Support external output feature of audio.
816 * - Support charging through micro-usb port without data
817 * connection.
818 */
774 extcon_set_cable_state(info->edev, "USB", attached); 819 extcon_set_cable_state(info->edev, "USB", attached);
775 820
776 if (!cable_attached) 821 if (!cable_attached)
777 extcon_set_cable_state(info->edev, 822 extcon_set_cable_state(info->edev, "Dock-Audio", cable_attached);
778 "Dock-Audio", false); 823 break;
779 goto out; 824 case MAX77693_MUIC_ADC_RESERVED_ACC_3: /* Dock-Smart */
825 /*
826 * Dock-Smart device with USB/TA cable
827 * - Dock-Desk device include three type of cable which
828 * are HDMI, USB for mouse/keyboard and micro-usb port
829 * for USB/TA cable. Dock-Smart device need always exteranl
830 * power supply(USB/TA cable through micro-usb cable). Dock-
831 * Smart device support screen output of target to separate
832 * monitor and mouse/keyboard for desktop mode.
833 *
834 * Features of 'USB/TA cable with Dock-Smart device'
835 * - Support MHL
836 * - Support external output feature of audio
837 * - Support charging through micro-usb port without data
838 * connection if TA cable is connected to target.
839 * - Support charging and data connection through micro-usb port
840 * if USB cable is connected between target and host
841 * device.
842 * - Support OTG device (Mouse/Keyboard)
843 */
844 ret = max77693_muic_set_path(info, info->path_usb, attached);
845 if (ret < 0)
846 return ret;
847
848 extcon_set_cable_state(info->edev, "Dock-Smart", attached);
849 extcon_set_cable_state(info->edev, "MHL", attached);
850
851 break;
780 } 852 }
781 853
782 /* 854 /* Check MAX77693_CABLE_GROUP_CHG type */
783 * When MHL(with USB/TA cable) or Dock-Audio with USB/TA cable 855 switch (chg_type) {
784 * is attached, muic device happen below two interrupt. 856 case MAX77693_CHARGER_TYPE_NONE:
785 * - 'MAX77693_MUIC_IRQ_INT1_ADC' for detecting MHL/Dock-Audio. 857 /*
786 * - 'MAX77693_MUIC_IRQ_INT2_CHGTYP' for detecting USB/TA cable 858 * When MHL(with USB/TA cable) or Dock-Audio with USB/TA cable
787 * connected to MHL or Dock-Audio. 859 * is attached, muic device happen below two interrupt.
788 * Always, happen eariler MAX77693_MUIC_IRQ_INT1_ADC interrupt 860 * - 'MAX77693_MUIC_IRQ_INT1_ADC' for detecting MHL/Dock-Audio.
789 * than MAX77693_MUIC_IRQ_INT2_CHGTYP interrupt. 861 * - 'MAX77693_MUIC_IRQ_INT2_CHGTYP' for detecting USB/TA cable
790 * 862 * connected to MHL or Dock-Audio.
791 * If user attach MHL (with USB/TA cable and immediately detach 863 * Always, happen eariler MAX77693_MUIC_IRQ_INT1_ADC interrupt
792 * MHL with USB/TA cable before MAX77693_MUIC_IRQ_INT2_CHGTYP 864 * than MAX77693_MUIC_IRQ_INT2_CHGTYP interrupt.
793 * interrupt is happened, USB/TA cable remain connected state to 865 *
794 * target. But USB/TA cable isn't connected to target. The user 866 * If user attach MHL (with USB/TA cable and immediately detach
795 * be face with unusual action. So, driver should check this 867 * MHL with USB/TA cable before MAX77693_MUIC_IRQ_INT2_CHGTYP
796 * situation in spite of, that previous charger type is N/A. 868 * interrupt is happened, USB/TA cable remain connected state to
797 */ 869 * target. But USB/TA cable isn't connected to target. The user
798 if (chg_type == MAX77693_CHARGER_TYPE_NONE) 870 * be face with unusual action. So, driver should check this
871 * situation in spite of, that previous charger type is N/A.
872 */
799 break; 873 break;
874 case MAX77693_CHARGER_TYPE_USB:
875 /* Only USB cable, PATH:AP_USB */
876 ret = max77693_muic_set_path(info, info->path_usb, attached);
877 if (ret < 0)
878 return ret;
800 879
801 /* Only USB cable, PATH:AP_USB */ 880 extcon_set_cable_state(info->edev, "USB", attached);
802 ret = max77693_muic_set_path(info, CONTROL1_SW_USB, attached); 881 break;
803 if (ret < 0) 882 case MAX77693_CHARGER_TYPE_DEDICATED_CHG:
804 goto out; 883 /* Only TA cable */
805 extcon_set_cable_state(info->edev, "USB", attached); 884 extcon_set_cable_state(info->edev, "TA", attached);
885 break;
886 }
806 break; 887 break;
807 case MAX77693_CHARGER_TYPE_DOWNSTREAM_PORT: 888 case MAX77693_CHARGER_TYPE_DOWNSTREAM_PORT:
808 extcon_set_cable_state(info->edev, 889 extcon_set_cable_state(info->edev,
809 "Charge-downstream", attached); 890 "Charge-downstream", attached);
810 break; 891 break;
811 case MAX77693_CHARGER_TYPE_DEDICATED_CHG:
812 extcon_set_cable_state(info->edev, "TA", attached);
813 break;
814 case MAX77693_CHARGER_TYPE_APPLE_500MA: 892 case MAX77693_CHARGER_TYPE_APPLE_500MA:
815 extcon_set_cable_state(info->edev, "Slow-charger", attached); 893 extcon_set_cable_state(info->edev, "Slow-charger", attached);
816 break; 894 break;
@@ -823,12 +901,10 @@ static int max77693_muic_chg_handler(struct max77693_muic_info *info)
823 dev_err(info->dev, 901 dev_err(info->dev,
824 "failed to detect %s accessory (chg_type:0x%x)\n", 902 "failed to detect %s accessory (chg_type:0x%x)\n",
825 attached ? "attached" : "detached", chg_type); 903 attached ? "attached" : "detached", chg_type);
826 ret = -EINVAL; 904 return -EINVAL;
827 goto out;
828 } 905 }
829 906
830out: 907 return 0;
831 return ret;
832} 908}
833 909
834static void max77693_muic_irq_work(struct work_struct *work) 910static void max77693_muic_irq_work(struct work_struct *work)