]> git.proxmox.com Git - mirror_ubuntu-hirsute-kernel.git/blobdiff - drivers/mfd/ab8500-core.c
Merge branch 'for-anton' of git://git.linaro.org/people/ljones/linux-3.0-ux500
[mirror_ubuntu-hirsute-kernel.git] / drivers / mfd / ab8500-core.c
index bbd49d7969029741a39523fde2d89df066d2d5aa..30b92652fce929a722dce85eb40a04d1312e8ad2 100644 (file)
@@ -565,15 +565,10 @@ static int ab8500_irq_init(struct ab8500 *ab8500, struct device_node *np)
        else
                num_irqs = AB8500_NR_IRQS;
 
-       if (ab8500->irq_base) {
-               ab8500->domain = irq_domain_add_legacy(
-                       NULL, num_irqs, ab8500->irq_base,
-                       0, &ab8500_irq_ops, ab8500);
-       }
-       else {
-               ab8500->domain = irq_domain_add_linear(
-                       np, num_irqs, &ab8500_irq_ops, ab8500);
-       }
+       /* If ->irq_base is zero this will give a linear mapping */
+       ab8500->domain = irq_domain_add_simple(NULL,
+                       num_irqs, ab8500->irq_base,
+                       &ab8500_irq_ops, ab8500);
 
        if (!ab8500->domain) {
                dev_err(ab8500->dev, "Failed to create irqdomain\n");
@@ -591,39 +586,7 @@ int ab8500_suspend(struct ab8500 *ab8500)
                return 0;
 }
 
-/* AB8500 GPIO Resources */
-static struct resource __devinitdata ab8500_gpio_resources[] = {
-       {
-               .name   = "GPIO_INT6",
-               .start  = AB8500_INT_GPIO6R,
-               .end    = AB8500_INT_GPIO41F,
-               .flags  = IORESOURCE_IRQ,
-       }
-};
-
-/* AB9540 GPIO Resources */
-static struct resource __devinitdata ab9540_gpio_resources[] = {
-       {
-               .name   = "GPIO_INT6",
-               .start  = AB8500_INT_GPIO6R,
-               .end    = AB8500_INT_GPIO41F,
-               .flags  = IORESOURCE_IRQ,
-       },
-       {
-               .name   = "GPIO_INT14",
-               .start  = AB9540_INT_GPIO50R,
-               .end    = AB9540_INT_GPIO54R,
-               .flags  = IORESOURCE_IRQ,
-       },
-       {
-               .name   = "GPIO_INT15",
-               .start  = AB9540_INT_GPIO50F,
-               .end    = AB9540_INT_GPIO54F,
-               .flags  = IORESOURCE_IRQ,
-       }
-};
-
-static struct resource __devinitdata ab8500_gpadc_resources[] = {
+static struct resource ab8500_gpadc_resources[] = {
        {
                .name   = "HW_CONV_END",
                .start  = AB8500_INT_GP_HW_ADC_CONV_END,
@@ -638,7 +601,7 @@ static struct resource __devinitdata ab8500_gpadc_resources[] = {
        },
 };
 
-static struct resource __devinitdata ab8500_rtc_resources[] = {
+static struct resource ab8500_rtc_resources[] = {
        {
                .name   = "60S",
                .start  = AB8500_INT_RTC_60S,
@@ -653,7 +616,7 @@ static struct resource __devinitdata ab8500_rtc_resources[] = {
        },
 };
 
-static struct resource __devinitdata ab8500_poweronkey_db_resources[] = {
+static struct resource ab8500_poweronkey_db_resources[] = {
        {
                .name   = "ONKEY_DBF",
                .start  = AB8500_INT_PON_KEY1DB_F,
@@ -668,7 +631,7 @@ static struct resource __devinitdata ab8500_poweronkey_db_resources[] = {
        },
 };
 
-static struct resource __devinitdata ab8500_av_acc_detect_resources[] = {
+static struct resource ab8500_av_acc_detect_resources[] = {
        {
               .name = "ACC_DETECT_1DB_F",
               .start = AB8500_INT_ACC_DETECT_1DB_F,
@@ -707,7 +670,7 @@ static struct resource __devinitdata ab8500_av_acc_detect_resources[] = {
        },
 };
 
-static struct resource __devinitdata ab8500_charger_resources[] = {
+static struct resource ab8500_charger_resources[] = {
        {
                .name = "MAIN_CH_UNPLUG_DET",
                .start = AB8500_INT_MAIN_CH_UNPLUG_DET,
@@ -788,7 +751,7 @@ static struct resource __devinitdata ab8500_charger_resources[] = {
        },
 };
 
-static struct resource __devinitdata ab8500_btemp_resources[] = {
+static struct resource ab8500_btemp_resources[] = {
        {
                .name = "BAT_CTRL_INDB",
                .start = AB8500_INT_BAT_CTRL_INDB,
@@ -821,7 +784,7 @@ static struct resource __devinitdata ab8500_btemp_resources[] = {
        },
 };
 
-static struct resource __devinitdata ab8500_fg_resources[] = {
+static struct resource ab8500_fg_resources[] = {
        {
                .name = "NCONV_ACCU",
                .start = AB8500_INT_CCN_CONV_ACC,
@@ -860,10 +823,10 @@ static struct resource __devinitdata ab8500_fg_resources[] = {
        },
 };
 
-static struct resource __devinitdata ab8500_chargalg_resources[] = {};
+static struct resource ab8500_chargalg_resources[] = {};
 
 #ifdef CONFIG_DEBUG_FS
-static struct resource __devinitdata ab8500_debug_resources[] = {
+static struct resource ab8500_debug_resources[] = {
        {
                .name   = "IRQ_FIRST",
                .start  = AB8500_INT_MAIN_EXT_CH_NOT_OK,
@@ -879,7 +842,7 @@ static struct resource __devinitdata ab8500_debug_resources[] = {
 };
 #endif
 
-static struct resource __devinitdata ab8500_usb_resources[] = {
+static struct resource ab8500_usb_resources[] = {
        {
                .name = "ID_WAKEUP_R",
                .start = AB8500_INT_ID_WAKEUP_R,
@@ -924,7 +887,7 @@ static struct resource __devinitdata ab8500_usb_resources[] = {
        },
 };
 
-static struct resource __devinitdata ab8505_iddet_resources[] = {
+static struct resource ab8505_iddet_resources[] = {
        {
                .name  = "KeyDeglitch",
                .start = AB8505_INT_KEYDEGLITCH,
@@ -957,7 +920,7 @@ static struct resource __devinitdata ab8505_iddet_resources[] = {
        },
 };
 
-static struct resource __devinitdata ab8500_temp_resources[] = {
+static struct resource ab8500_temp_resources[] = {
        {
                .name  = "AB8500_TEMP_WARM",
                .start = AB8500_INT_TEMP_WARM,
@@ -966,7 +929,7 @@ static struct resource __devinitdata ab8500_temp_resources[] = {
        },
 };
 
-static struct mfd_cell __devinitdata abx500_common_devs[] = {
+static struct mfd_cell abx500_common_devs[] = {
 #ifdef CONFIG_DEBUG_FS
        {
                .name = "ab8500-debug",
@@ -983,6 +946,10 @@ static struct mfd_cell __devinitdata abx500_common_devs[] = {
                .name = "ab8500-regulator",
                .of_compatible = "stericsson,ab8500-regulator",
        },
+       {
+               .name = "abx500-clk",
+               .of_compatible = "stericsson,abx500-clk",
+       },
        {
                .name = "ab8500-gpadc",
                .of_compatible = "stericsson,ab8500-gpadc",
@@ -1038,7 +1005,7 @@ static struct mfd_cell __devinitdata abx500_common_devs[] = {
        },
 };
 
-static struct mfd_cell __devinitdata ab8500_bm_devs[] = {
+static struct mfd_cell ab8500_bm_devs[] = {
        {
                .name = "ab8500-charger",
                .of_compatible = "stericsson,ab8500-charger",
@@ -1073,12 +1040,10 @@ static struct mfd_cell __devinitdata ab8500_bm_devs[] = {
        },
 };
 
-static struct mfd_cell __devinitdata ab8500_devs[] = {
+static struct mfd_cell ab8500_devs[] = {
        {
                .name = "ab8500-gpio",
                .of_compatible = "stericsson,ab8500-gpio",
-               .num_resources = ARRAY_SIZE(ab8500_gpio_resources),
-               .resources = ab8500_gpio_resources,
        },
        {
                .name = "ab8500-usb",
@@ -1092,11 +1057,9 @@ static struct mfd_cell __devinitdata ab8500_devs[] = {
        },
 };
 
-static struct mfd_cell __devinitdata ab9540_devs[] = {
+static struct mfd_cell ab9540_devs[] = {
        {
                .name = "ab8500-gpio",
-               .num_resources = ARRAY_SIZE(ab9540_gpio_resources),
-               .resources = ab9540_gpio_resources,
        },
        {
                .name = "ab9540-usb",
@@ -1109,7 +1072,7 @@ static struct mfd_cell __devinitdata ab9540_devs[] = {
 };
 
 /* Device list common to ab9540 and ab8505 */
-static struct mfd_cell __devinitdata ab9540_ab8505_devs[] = {
+static struct mfd_cell ab9540_ab8505_devs[] = {
        {
                .name = "ab-iddet",
                .num_resources = ARRAY_SIZE(ab8505_iddet_resources),
@@ -1260,7 +1223,7 @@ static struct attribute_group ab9540_attr_group = {
        .attrs  = ab9540_sysfs_entries,
 };
 
-static int __devinit ab8500_probe(struct platform_device *pdev)
+static int ab8500_probe(struct platform_device *pdev)
 {
        static char *switch_off_status[] = {
                "Swoff bit programming",
@@ -1281,7 +1244,7 @@ static int __devinit ab8500_probe(struct platform_device *pdev)
        int i;
        u8 value;
 
-       ab8500 = kzalloc(sizeof *ab8500, GFP_KERNEL);
+       ab8500 = devm_kzalloc(&pdev->dev, sizeof *ab8500, GFP_KERNEL);
        if (!ab8500)
                return -ENOMEM;
 
@@ -1291,10 +1254,8 @@ static int __devinit ab8500_probe(struct platform_device *pdev)
        ab8500->dev = &pdev->dev;
 
        resource = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
-       if (!resource) {
-               ret = -ENODEV;
-               goto out_free_ab8500;
-       }
+       if (!resource)
+               return -ENODEV;
 
        ab8500->irq = resource->start;
 
@@ -1317,7 +1278,7 @@ static int __devinit ab8500_probe(struct platform_device *pdev)
                ret = get_register_interruptible(ab8500, AB8500_MISC,
                        AB8500_IC_NAME_REG, &value);
                if (ret < 0)
-                       goto out_free_ab8500;
+                       return ret;
 
                ab8500->version = value;
        }
@@ -1325,7 +1286,7 @@ static int __devinit ab8500_probe(struct platform_device *pdev)
        ret = get_register_interruptible(ab8500, AB8500_MISC,
                AB8500_REV_REG, &value);
        if (ret < 0)
-               goto out_free_ab8500;
+               return ret;
 
        ab8500->chip_id = value;
 
@@ -1342,14 +1303,13 @@ static int __devinit ab8500_probe(struct platform_device *pdev)
                ab8500->mask_size = AB8500_NUM_IRQ_REGS;
                ab8500->irq_reg_offset = ab8500_irq_regoffset;
        }
-       ab8500->mask = kzalloc(ab8500->mask_size, GFP_KERNEL);
+       ab8500->mask = devm_kzalloc(&pdev->dev, ab8500->mask_size, GFP_KERNEL);
        if (!ab8500->mask)
                return -ENOMEM;
-       ab8500->oldmask = kzalloc(ab8500->mask_size, GFP_KERNEL);
-       if (!ab8500->oldmask) {
-               ret = -ENOMEM;
-               goto out_freemask;
-       }
+       ab8500->oldmask = devm_kzalloc(&pdev->dev, ab8500->mask_size, GFP_KERNEL);
+       if (!ab8500->oldmask)
+               return -ENOMEM;
+
        /*
         * ab8500 has switched off due to (SWITCH_OFF_STATUS):
         * 0x01 Swoff bit programming
@@ -1403,37 +1363,37 @@ static int __devinit ab8500_probe(struct platform_device *pdev)
 
        ret = abx500_register_ops(ab8500->dev, &ab8500_ops);
        if (ret)
-               goto out_freeoldmask;
+               return ret;
 
        for (i = 0; i < ab8500->mask_size; i++)
                ab8500->mask[i] = ab8500->oldmask[i] = 0xff;
 
        ret = ab8500_irq_init(ab8500, np);
        if (ret)
-               goto out_freeoldmask;
+               return ret;
 
        /*  Activate this feature only in ab9540 */
        /*  till tests are done on ab8500 1p2 or later*/
        if (is_ab9540(ab8500)) {
-               ret = request_threaded_irq(ab8500->irq, NULL,
-                                       ab8500_hierarchical_irq,
-                                       IRQF_ONESHOT | IRQF_NO_SUSPEND,
-                                       "ab8500", ab8500);
+               ret = devm_request_threaded_irq(&pdev->dev, ab8500->irq, NULL,
+                                               ab8500_hierarchical_irq,
+                                               IRQF_ONESHOT | IRQF_NO_SUSPEND,
+                                               "ab8500", ab8500);
        }
        else {
-               ret = request_threaded_irq(ab8500->irq, NULL,
-                                       ab8500_irq,
-                                       IRQF_ONESHOT | IRQF_NO_SUSPEND,
-                                       "ab8500", ab8500);
+               ret = devm_request_threaded_irq(&pdev->dev, ab8500->irq, NULL,
+                                               ab8500_irq,
+                                               IRQF_ONESHOT | IRQF_NO_SUSPEND,
+                                               "ab8500", ab8500);
                if (ret)
-                       goto out_freeoldmask;
+                       return ret;
        }
 
        ret = mfd_add_devices(ab8500->dev, 0, abx500_common_devs,
                        ARRAY_SIZE(abx500_common_devs), NULL,
                        ab8500->irq_base, ab8500->domain);
        if (ret)
-               goto out_freeirq;
+               return ret;
 
        if (is_ab9540(ab8500))
                ret = mfd_add_devices(ab8500->dev, 0, ab9540_devs,
@@ -1444,14 +1404,14 @@ static int __devinit ab8500_probe(struct platform_device *pdev)
                                ARRAY_SIZE(ab8500_devs), NULL,
                                ab8500->irq_base, ab8500->domain);
        if (ret)
-               goto out_freeirq;
+               return ret;
 
        if (is_ab9540(ab8500) || is_ab8505(ab8500))
                ret = mfd_add_devices(ab8500->dev, 0, ab9540_ab8505_devs,
                                ARRAY_SIZE(ab9540_ab8505_devs), NULL,
                                ab8500->irq_base, ab8500->domain);
        if (ret)
-               goto out_freeirq;
+               return ret;
 
        if (!no_bm) {
                /* Add battery management devices */
@@ -1472,20 +1432,9 @@ static int __devinit ab8500_probe(struct platform_device *pdev)
                dev_err(ab8500->dev, "error creating sysfs entries\n");
 
        return ret;
-
-out_freeirq:
-       free_irq(ab8500->irq, ab8500);
-out_freeoldmask:
-       kfree(ab8500->oldmask);
-out_freemask:
-       kfree(ab8500->mask);
-out_free_ab8500:
-       kfree(ab8500);
-
-       return ret;
 }
 
-static int __devexit ab8500_remove(struct platform_device *pdev)
+static int ab8500_remove(struct platform_device *pdev)
 {
        struct ab8500 *ab8500 = platform_get_drvdata(pdev);
 
@@ -1495,11 +1444,6 @@ static int __devexit ab8500_remove(struct platform_device *pdev)
                sysfs_remove_group(&ab8500->dev->kobj, &ab8500_attr_group);
 
        mfd_remove_devices(ab8500->dev);
-       free_irq(ab8500->irq, ab8500);
-
-       kfree(ab8500->oldmask);
-       kfree(ab8500->mask);
-       kfree(ab8500);
 
        return 0;
 }
@@ -1518,7 +1462,7 @@ static struct platform_driver ab8500_core_driver = {
                .owner = THIS_MODULE,
        },
        .probe  = ab8500_probe,
-       .remove = __devexit_p(ab8500_remove),
+       .remove = ab8500_remove,
        .id_table = ab8500_id,
 };