Merge tag 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mst/vhost
[firefly-linux-kernel-4.4.55.git] / drivers / extcon / extcon-max77693.c
index 77460f2c1ca1602ed3a6948c56d9389e0c508a4f..740a14d35072a5aaf2d657d6dae628cade715200 100644 (file)
@@ -232,7 +232,7 @@ static const char *max77693_extcon_cable[] = {
        [EXTCON_CABLE_JIG_USB_ON]               = "JIG-USB-ON",
        [EXTCON_CABLE_JIG_USB_OFF]              = "JIG-USB-OFF",
        [EXTCON_CABLE_JIG_UART_OFF]             = "JIG-UART-OFF",
-       [EXTCON_CABLE_JIG_UART_ON]              = "Dock-Car",
+       [EXTCON_CABLE_JIG_UART_ON]              = "JIG-UART-ON",
        [EXTCON_CABLE_DOCK_SMART]               = "Dock-Smart",
        [EXTCON_CABLE_DOCK_DESK]                = "Dock-Desk",
        [EXTCON_CABLE_DOCK_AUDIO]               = "Dock-Audio",
@@ -255,10 +255,14 @@ static int max77693_muic_set_debounce_time(struct max77693_muic_info *info,
        case ADC_DEBOUNCE_TIME_10MS:
        case ADC_DEBOUNCE_TIME_25MS:
        case ADC_DEBOUNCE_TIME_38_62MS:
-               ret = regmap_update_bits(info->max77693->regmap_muic,
-                                         MAX77693_MUIC_REG_CTRL3,
-                                         CONTROL3_ADCDBSET_MASK,
-                                         time << CONTROL3_ADCDBSET_SHIFT);
+               /*
+                * Don't touch BTLDset, JIGset when you want to change adc
+                * debounce time. If it writes other than 0 to BTLDset, JIGset
+                * muic device will be reset and loose current state.
+                */
+               ret = regmap_write(info->max77693->regmap_muic,
+                                 MAX77693_MUIC_REG_CTRL3,
+                                 time << CONTROL3_ADCDBSET_SHIFT);
                if (ret) {
                        dev_err(info->dev, "failed to set ADC debounce time\n");
                        return ret;
@@ -528,9 +532,6 @@ static int max77693_muic_dock_handler(struct max77693_muic_info *info,
                extcon_set_cable_state(info->edev, "Dock-Smart", attached);
                extcon_set_cable_state(info->edev, "MHL", attached);
                goto out;
-       case MAX77693_MUIC_ADC_FACTORY_MODE_UART_ON:    /* Dock-Car */
-               strcpy(dock_name, "Dock-Car");
-               break;
        case MAX77693_MUIC_ADC_AUDIO_MODE_REMOTE:       /* Dock-Desk */
                strcpy(dock_name, "Dock-Desk");
                break;
@@ -665,6 +666,11 @@ static int max77693_muic_jig_handler(struct max77693_muic_info *info,
                strcpy(cable_name, "JIG-UART-OFF");
                path = CONTROL1_SW_UART;
                break;
+       case MAX77693_MUIC_ADC_FACTORY_MODE_UART_ON:    /* ADC_JIG_UART_ON */
+               /* PATH:AP_UART */
+               strcpy(cable_name, "JIG-UART-ON");
+               path = CONTROL1_SW_UART;
+               break;
        default:
                dev_err(info->dev, "failed to detect %s jig cable\n",
                        attached ? "attached" : "detached");
@@ -704,13 +710,13 @@ static int max77693_muic_adc_handler(struct max77693_muic_info *info)
        case MAX77693_MUIC_ADC_FACTORY_MODE_USB_OFF:
        case MAX77693_MUIC_ADC_FACTORY_MODE_USB_ON:
        case MAX77693_MUIC_ADC_FACTORY_MODE_UART_OFF:
+       case MAX77693_MUIC_ADC_FACTORY_MODE_UART_ON:
                /* JIG */
                ret = max77693_muic_jig_handler(info, cable_type, attached);
                if (ret < 0)
                        return ret;
                break;
        case MAX77693_MUIC_ADC_RESERVED_ACC_3:          /* Dock-Smart */
-       case MAX77693_MUIC_ADC_FACTORY_MODE_UART_ON:    /* Dock-Car */
        case MAX77693_MUIC_ADC_AUDIO_MODE_REMOTE:       /* Dock-Desk */
        case MAX77693_MUIC_ADC_AV_CABLE_NOLOAD:         /* Dock-Audio */
                /*
@@ -1155,13 +1161,11 @@ static int max77693_muic_probe(struct platform_device *pdev)
 
                virq = regmap_irq_get_virq(max77693->irq_data_muic,
                                        muic_irq->irq);
-               if (!virq) {
-                       ret = -EINVAL;
-                       goto err_irq;
-               }
+               if (!virq)
+                       return -EINVAL;
                muic_irq->virq = virq;
 
-               ret = request_threaded_irq(virq, NULL,
+               ret = devm_request_threaded_irq(&pdev->dev, virq, NULL,
                                max77693_muic_irq_handler,
                                IRQF_NO_SUSPEND,
                                muic_irq->name, info);
@@ -1170,7 +1174,7 @@ static int max77693_muic_probe(struct platform_device *pdev)
                                "failed: irq request (IRQ: %d,"
                                " error :%d)\n",
                                muic_irq->irq, ret);
-                       goto err_irq;
+                       return ret;
                }
        }
 
@@ -1179,15 +1183,14 @@ static int max77693_muic_probe(struct platform_device *pdev)
                                              max77693_extcon_cable);
        if (IS_ERR(info->edev)) {
                dev_err(&pdev->dev, "failed to allocate memory for extcon\n");
-               ret = -ENOMEM;
-               goto err_irq;
+               return -ENOMEM;
        }
        info->edev->name = DEV_NAME;
 
        ret = devm_extcon_dev_register(&pdev->dev, info->edev);
        if (ret) {
                dev_err(&pdev->dev, "failed to register extcon device\n");
-               goto err_irq;
+               return ret;
        }
 
        /* Initialize MUIC register by using platform data or default data */
@@ -1265,7 +1268,7 @@ static int max77693_muic_probe(struct platform_device *pdev)
                        MAX77693_MUIC_REG_ID, &id);
        if (ret < 0) {
                dev_err(&pdev->dev, "failed to read revision number\n");
-               goto err_irq;
+               return ret;
        }
        dev_info(info->dev, "device ID : 0x%x\n", id);
 
@@ -1285,20 +1288,12 @@ static int max77693_muic_probe(struct platform_device *pdev)
                        delay_jiffies);
 
        return ret;
-
-err_irq:
-       while (--i >= 0)
-               free_irq(muic_irqs[i].virq, info);
-       return ret;
 }
 
 static int max77693_muic_remove(struct platform_device *pdev)
 {
        struct max77693_muic_info *info = platform_get_drvdata(pdev);
-       int i;
 
-       for (i = 0; i < ARRAY_SIZE(muic_irqs); i++)
-               free_irq(muic_irqs[i].virq, info);
        cancel_work_sync(&info->irq_work);
        input_unregister_device(info->dock);
 
@@ -1308,7 +1303,6 @@ static int max77693_muic_remove(struct platform_device *pdev)
 static struct platform_driver max77693_muic_driver = {
        .driver         = {
                .name   = DEV_NAME,
-               .owner  = THIS_MODULE,
        },
        .probe          = max77693_muic_probe,
        .remove         = max77693_muic_remove,