diff options
Diffstat (limited to 'drivers/extcon/extcon-max77693.c')
-rw-r--r-- | drivers/extcon/extcon-max77693.c | 46 |
1 files changed, 34 insertions, 12 deletions
diff --git a/drivers/extcon/extcon-max77693.c b/drivers/extcon/extcon-max77693.c index e21387e2da5c..a17d0d91ada2 100644 --- a/drivers/extcon/extcon-max77693.c +++ b/drivers/extcon/extcon-max77693.c | |||
@@ -239,25 +239,19 @@ const char *max77693_extcon_cable[] = { | |||
239 | static int max77693_muic_set_debounce_time(struct max77693_muic_info *info, | 239 | static int max77693_muic_set_debounce_time(struct max77693_muic_info *info, |
240 | enum max77693_muic_adc_debounce_time time) | 240 | enum max77693_muic_adc_debounce_time time) |
241 | { | 241 | { |
242 | int ret = 0; | 242 | int ret; |
243 | u8 ctrl3; | ||
244 | 243 | ||
245 | switch (time) { | 244 | switch (time) { |
246 | case ADC_DEBOUNCE_TIME_5MS: | 245 | case ADC_DEBOUNCE_TIME_5MS: |
247 | case ADC_DEBOUNCE_TIME_10MS: | 246 | case ADC_DEBOUNCE_TIME_10MS: |
248 | case ADC_DEBOUNCE_TIME_25MS: | 247 | case ADC_DEBOUNCE_TIME_25MS: |
249 | case ADC_DEBOUNCE_TIME_38_62MS: | 248 | case ADC_DEBOUNCE_TIME_38_62MS: |
250 | ret = max77693_read_reg(info->max77693->regmap_muic, | 249 | ret = max77693_update_reg(info->max77693->regmap_muic, |
251 | MAX77693_MUIC_REG_CTRL3, &ctrl3); | 250 | MAX77693_MUIC_REG_CTRL3, |
252 | ctrl3 &= ~CONTROL3_ADCDBSET_MASK; | 251 | time << CONTROL3_ADCDBSET_SHIFT, |
253 | ctrl3 |= (time << CONTROL3_ADCDBSET_SHIFT); | 252 | CONTROL3_ADCDBSET_MASK); |
254 | 253 | if (ret) | |
255 | ret = max77693_write_reg(info->max77693->regmap_muic, | ||
256 | MAX77693_MUIC_REG_CTRL3, ctrl3); | ||
257 | if (ret) { | ||
258 | dev_err(info->dev, "failed to set ADC debounce time\n"); | 254 | dev_err(info->dev, "failed to set ADC debounce time\n"); |
259 | ret = -EINVAL; | ||
260 | } | ||
261 | break; | 255 | break; |
262 | default: | 256 | default: |
263 | dev_err(info->dev, "invalid ADC debounce time\n"); | 257 | dev_err(info->dev, "invalid ADC debounce time\n"); |
@@ -657,6 +651,8 @@ out: | |||
657 | static int __devinit max77693_muic_probe(struct platform_device *pdev) | 651 | static int __devinit max77693_muic_probe(struct platform_device *pdev) |
658 | { | 652 | { |
659 | struct max77693_dev *max77693 = dev_get_drvdata(pdev->dev.parent); | 653 | struct max77693_dev *max77693 = dev_get_drvdata(pdev->dev.parent); |
654 | struct max77693_platform_data *pdata = dev_get_platdata(max77693->dev); | ||
655 | struct max77693_muic_platform_data *muic_pdata = pdata->muic_data; | ||
660 | struct max77693_muic_info *info; | 656 | struct max77693_muic_info *info; |
661 | int ret, i; | 657 | int ret, i; |
662 | u8 id; | 658 | u8 id; |
@@ -727,6 +723,31 @@ static int __devinit max77693_muic_probe(struct platform_device *pdev) | |||
727 | goto err_extcon; | 723 | goto err_extcon; |
728 | } | 724 | } |
729 | 725 | ||
726 | /* Initialize MUIC register by using platform data */ | ||
727 | for (i = 0 ; i < muic_pdata->num_init_data ; i++) { | ||
728 | enum max77693_irq_source irq_src = MAX77693_IRQ_GROUP_NR; | ||
729 | |||
730 | max77693_write_reg(info->max77693->regmap_muic, | ||
731 | muic_pdata->init_data[i].addr, | ||
732 | muic_pdata->init_data[i].data); | ||
733 | |||
734 | switch (muic_pdata->init_data[i].addr) { | ||
735 | case MAX77693_MUIC_REG_INTMASK1: | ||
736 | irq_src = MUIC_INT1; | ||
737 | break; | ||
738 | case MAX77693_MUIC_REG_INTMASK2: | ||
739 | irq_src = MUIC_INT2; | ||
740 | break; | ||
741 | case MAX77693_MUIC_REG_INTMASK3: | ||
742 | irq_src = MUIC_INT3; | ||
743 | break; | ||
744 | } | ||
745 | |||
746 | if (irq_src < MAX77693_IRQ_GROUP_NR) | ||
747 | info->max77693->irq_masks_cur[irq_src] | ||
748 | = muic_pdata->init_data[i].data; | ||
749 | } | ||
750 | |||
730 | /* Check revision number of MUIC device*/ | 751 | /* Check revision number of MUIC device*/ |
731 | ret = max77693_read_reg(info->max77693->regmap_muic, | 752 | ret = max77693_read_reg(info->max77693->regmap_muic, |
732 | MAX77693_MUIC_REG_ID, &id); | 753 | MAX77693_MUIC_REG_ID, &id); |
@@ -762,6 +783,7 @@ static int __devexit max77693_muic_remove(struct platform_device *pdev) | |||
762 | free_irq(muic_irqs[i].virq, info); | 783 | free_irq(muic_irqs[i].virq, info); |
763 | cancel_work_sync(&info->irq_work); | 784 | cancel_work_sync(&info->irq_work); |
764 | extcon_dev_unregister(info->edev); | 785 | extcon_dev_unregister(info->edev); |
786 | kfree(info->edev); | ||
765 | kfree(info); | 787 | kfree(info); |
766 | 788 | ||
767 | return 0; | 789 | return 0; |