--- zzzz-none-000/linux-3.10.107/drivers/mfd/ab8500-core.c 2017-06-27 09:49:32.000000000 +0000 +++ scorpion-7490-727/linux-3.10.107/drivers/mfd/ab8500-core.c 2021-02-04 17:41:59.000000000 +0000 @@ -148,8 +148,8 @@ /* AB8540 support */ static const int ab8540_irq_regoffset[AB8540_NUM_IRQ_REGS] = { - 0, 1, 2, 3, 4, -1, -1, -1, -1, 11, 18, 19, 20, 21, 12, 13, 24, 5, 22, 23, - 25, 26, 27, 28, 29, 30, 31, + 0, 1, 2, 3, 4, -1, -1, -1, -1, 11, 18, 19, 20, 21, 12, 13, 24, 5, 22, + 23, 25, 26, 27, 28, 29, 30, 31, }; static const char ab8500_version_str[][7] = { @@ -322,7 +322,7 @@ struct ab8500 *ab8500 = dev_get_drvdata(dev->parent); atomic_inc(&ab8500->transfer_ongoing); - ret= mask_and_set_register_interruptible(ab8500, bank, reg, + ret = mask_and_set_register_interruptible(ab8500, bank, reg, bitmask, bitvalues); atomic_dec(&ab8500->transfer_ongoing); return ret; @@ -415,9 +415,11 @@ if (type & IRQ_TYPE_EDGE_FALLING) { if (offset >= AB8500_INT_GPIO6R && offset <= AB8500_INT_GPIO41R) ab8500->mask[index + 2] &= ~mask; - else if (offset >= AB9540_INT_GPIO50R && offset <= AB9540_INT_GPIO54R) + else if (offset >= AB9540_INT_GPIO50R && + offset <= AB9540_INT_GPIO54R) ab8500->mask[index + 1] &= ~mask; - else if (offset == AB8540_INT_GPIO43R || offset == AB8540_INT_GPIO44R) + else if (offset == AB8540_INT_GPIO43R || + offset == AB8540_INT_GPIO44R) /* Here the falling IRQ is one bit lower */ ab8500->mask[index] &= ~(mask << 1); else @@ -451,7 +453,7 @@ /* Fix inconsistent ab8540 bit mapping... */ if (unlikely(*offset == 16)) *offset = 25; - if ((i==3) && (*offset >= 24)) + if ((i == 3) && (*offset >= 24)) *offset += 2; } @@ -491,7 +493,7 @@ if (line == AB8540_INT_GPIO43F || line == AB8540_INT_GPIO44F) line += 1; - handle_nested_irq(ab8500->irq_base + line); + handle_nested_irq(irq_create_mapping(ab8500->domain, line)); } return 0; @@ -563,18 +565,14 @@ irq_set_chip_and_handler(virq, &ab8500_irq_chip, handle_simple_irq); irq_set_nested_thread(virq, 1); -#ifdef CONFIG_ARM - set_irq_flags(virq, IRQF_VALID); -#else irq_set_noprobe(virq); -#endif return 0; } -static struct irq_domain_ops ab8500_irq_ops = { - .map = ab8500_irq_map, - .xlate = irq_domain_xlate_twocell, +static const struct irq_domain_ops ab8500_irq_ops = { + .map = ab8500_irq_map, + .xlate = irq_domain_xlate_twocell, }; static int ab8500_irq_init(struct ab8500 *ab8500, struct device_node *np) @@ -591,8 +589,8 @@ num_irqs = AB8500_NR_IRQS; /* If ->irq_base is zero this will give a linear mapping */ - ab8500->domain = irq_domain_add_simple(NULL, - num_irqs, ab8500->irq_base, + ab8500->domain = irq_domain_add_simple(ab8500->dev->of_node, + num_irqs, 0, &ab8500_irq_ops, ab8500); if (!ab8500->domain) { @@ -607,8 +605,8 @@ { if (atomic_read(&ab8500->transfer_ongoing)) return -EINVAL; - else - return 0; + + return 0; } static struct resource ab8500_gpadc_resources[] = { @@ -650,6 +648,21 @@ }, }; +static struct resource ab8540_rtc_resources[] = { + { + .name = "1S", + .start = AB8540_INT_RTC_1S, + .end = AB8540_INT_RTC_1S, + .flags = IORESOURCE_IRQ, + }, + { + .name = "ALARM", + .start = AB8500_INT_RTC_ALARM, + .end = AB8500_INT_RTC_ALARM, + .flags = IORESOURCE_IRQ, + }, +}; + static struct resource ab8500_poweronkey_db_resources[] = { { .name = "ONKEY_DBF", @@ -1002,7 +1015,7 @@ }, }; -static struct mfd_cell ab8500_bm_devs[] = { +static const struct mfd_cell ab8500_bm_devs[] = { { .name = "ab8500-charger", .of_compatible = "stericsson,ab8500-charger", @@ -1037,7 +1050,7 @@ }, }; -static struct mfd_cell ab8500_devs[] = { +static const struct mfd_cell ab8500_devs[] = { #ifdef CONFIG_DEBUG_FS { .name = "ab8500-debug", @@ -1051,6 +1064,10 @@ .of_compatible = "stericsson,ab8500-sysctrl", }, { + .name = "ab8500-ext-regulator", + .of_compatible = "stericsson,ab8500-ext-regulator", + }, + { .name = "ab8500-regulator", .of_compatible = "stericsson,ab8500-regulator", }, @@ -1099,10 +1116,6 @@ .id = 3, }, { - .name = "ab8500-leds", - .of_compatible = "stericsson,ab8500-leds", - }, - { .name = "ab8500-denc", .of_compatible = "stericsson,ab8500-denc", }, @@ -1124,10 +1137,11 @@ }, { .name = "ab8500-codec", + .of_compatible = "stericsson,ab8500-codec", }, }; -static struct mfd_cell ab9540_devs[] = { +static const struct mfd_cell ab9540_devs[] = { #ifdef CONFIG_DEBUG_FS { .name = "ab8500-debug", @@ -1139,6 +1153,9 @@ .name = "ab8500-sysctrl", }, { + .name = "ab8500-ext-regulator", + }, + { .name = "ab8500-regulator", }, { @@ -1171,9 +1188,6 @@ .id = 1, }, { - .name = "ab8500-leds", - }, - { .name = "abx500-temp", .num_resources = ARRAY_SIZE(ab8500_temp_resources), .resources = ab8500_temp_resources, @@ -1198,7 +1212,7 @@ }; /* Device list for ab8505 */ -static struct mfd_cell ab8505_devs[] = { +static const struct mfd_cell ab8505_devs[] = { #ifdef CONFIG_DEBUG_FS { .name = "ab8500-debug", @@ -1242,9 +1256,6 @@ .id = 1, }, { - .name = "ab8500-leds", - }, - { .name = "pinctrl-ab8505", }, { @@ -1262,7 +1273,7 @@ }, }; -static struct mfd_cell ab8540_devs[] = { +static const struct mfd_cell ab8540_devs[] = { #ifdef CONFIG_DEBUG_FS { .name = "ab8500-debug", @@ -1274,6 +1285,9 @@ .name = "ab8500-sysctrl", }, { + .name = "ab8500-ext-regulator", + }, + { .name = "ab8500-regulator", }, { @@ -1287,11 +1301,6 @@ .resources = ab8505_gpadc_resources, }, { - .name = "ab8500-rtc", - .num_resources = ARRAY_SIZE(ab8500_rtc_resources), - .resources = ab8500_rtc_resources, - }, - { .name = "ab8500-acc-det", .num_resources = ARRAY_SIZE(ab8500_av_acc_detect_resources), .resources = ab8500_av_acc_detect_resources, @@ -1306,9 +1315,6 @@ .id = 1, }, { - .name = "ab8500-leds", - }, - { .name = "abx500-temp", .num_resources = ARRAY_SIZE(ab8500_temp_resources), .resources = ab8500_temp_resources, @@ -1331,6 +1337,24 @@ }, }; +static const struct mfd_cell ab8540_cut1_devs[] = { + { + .name = "ab8500-rtc", + .of_compatible = "stericsson,ab8500-rtc", + .num_resources = ARRAY_SIZE(ab8500_rtc_resources), + .resources = ab8500_rtc_resources, + }, +}; + +static const struct mfd_cell ab8540_cut2_devs[] = { + { + .name = "ab8540-rtc", + .of_compatible = "stericsson,ab8540-rtc", + .num_resources = ARRAY_SIZE(ab8540_rtc_resources), + .resources = ab8540_rtc_resources, + }, +}; + static ssize_t show_chip_id(struct device *dev, struct device_attribute *attr, char *buf) { @@ -1525,7 +1549,7 @@ static int ab8500_probe(struct platform_device *pdev) { - static char *switch_off_status[] = { + static const char *switch_off_status[] = { "Swoff bit programming", "Thermal protection activation", "Vbat lower then BattOk falling threshold", @@ -1534,7 +1558,7 @@ "Battery level lower than power on reset threshold", "Power on key 1 pressed longer than 10 seconds", "DB8500 thermal shutdown"}; - static char *turn_on_status[] = { + static const char *turn_on_status[] = { "Battery rising (Vbat)", "Power On Key 1 dbF", "Power On Key 2 dbF", @@ -1553,18 +1577,17 @@ int i; u8 value; - ab8500 = devm_kzalloc(&pdev->dev, sizeof *ab8500, GFP_KERNEL); + ab8500 = devm_kzalloc(&pdev->dev, sizeof(*ab8500), GFP_KERNEL); if (!ab8500) return -ENOMEM; - if (plat) - ab8500->irq_base = plat->irq_base; - ab8500->dev = &pdev->dev; resource = platform_get_resource(pdev, IORESOURCE_IRQ, 0); - if (!resource) + if (!resource) { + dev_err(&pdev->dev, "no IRQ resource\n"); return -ENODEV; + } ab8500->irq = resource->start; @@ -1586,8 +1609,10 @@ else { ret = get_register_interruptible(ab8500, AB8500_MISC, AB8500_IC_NAME_REG, &value); - if (ret < 0) + if (ret < 0) { + dev_err(&pdev->dev, "could not probe HW\n"); return ret; + } ab8500->version = value; } @@ -1609,7 +1634,7 @@ ab8500->mask_size = AB8540_NUM_IRQ_REGS; ab8500->irq_reg_offset = ab8540_irq_regoffset; ab8500->it_latchhier_num = AB8540_IT_LATCHHIER_NUM; - }/* Configure AB8500 or AB9540 IRQ */ + } /* Configure AB8500 or AB9540 IRQ */ else if (is_ab9540(ab8500) || is_ab8505(ab8500)) { ab8500->mask_size = AB9540_NUM_IRQ_REGS; ab8500->irq_reg_offset = ab9540_irq_regoffset; @@ -1619,10 +1644,12 @@ ab8500->irq_reg_offset = ab8500_irq_regoffset; ab8500->it_latchhier_num = AB8500_IT_LATCHHIER_NUM; } - ab8500->mask = devm_kzalloc(&pdev->dev, ab8500->mask_size, GFP_KERNEL); + ab8500->mask = devm_kzalloc(&pdev->dev, ab8500->mask_size, + GFP_KERNEL); if (!ab8500->mask) return -ENOMEM; - ab8500->oldmask = devm_kzalloc(&pdev->dev, ab8500->mask_size, GFP_KERNEL); + ab8500->oldmask = devm_kzalloc(&pdev->dev, ab8500->mask_size, + GFP_KERNEL); if (!ab8500->oldmask) return -ENOMEM; @@ -1647,14 +1674,13 @@ if (value) { for (i = 0; i < ARRAY_SIZE(switch_off_status); i++) { if (value & 1) - printk(KERN_CONT " \"%s\"", - switch_off_status[i]); + pr_cont(" \"%s\"", switch_off_status[i]); value = value >> 1; } - printk(KERN_CONT "\n"); + pr_cont("\n"); } else { - printk(KERN_CONT " None\n"); + pr_cont(" None\n"); } ret = get_register_interruptible(ab8500, AB8500_SYS_CTRL1_BLOCK, AB8500_TURN_ON_STATUS, &value); @@ -1665,12 +1691,12 @@ if (value) { for (i = 0; i < ARRAY_SIZE(turn_on_status); i++) { if (value & 1) - printk("\"%s\" ", turn_on_status[i]); + pr_cont("\"%s\" ", turn_on_status[i]); value = value >> 1; } - printk("\n"); + pr_cont("\n"); } else { - printk("None\n"); + pr_cont("None\n"); } if (plat && plat->init) @@ -1724,7 +1750,7 @@ if (ret) return ret; -#if CONFIG_DEBUG_FS +#ifdef CONFIG_DEBUG_FS /* Pass to debugfs */ ab8500_debug_resources[0].start = ab8500->irq; ab8500_debug_resources[0].end = ab8500->irq; @@ -1733,19 +1759,30 @@ if (is_ab9540(ab8500)) ret = mfd_add_devices(ab8500->dev, 0, ab9540_devs, ARRAY_SIZE(ab9540_devs), NULL, - ab8500->irq_base, ab8500->domain); - else if (is_ab8540(ab8500)) + 0, ab8500->domain); + else if (is_ab8540(ab8500)) { ret = mfd_add_devices(ab8500->dev, 0, ab8540_devs, ARRAY_SIZE(ab8540_devs), NULL, - ab8500->irq_base, ab8500->domain); - else if (is_ab8505(ab8500)) + 0, ab8500->domain); + if (ret) + return ret; + + if (is_ab8540_1p2_or_earlier(ab8500)) + ret = mfd_add_devices(ab8500->dev, 0, ab8540_cut1_devs, + ARRAY_SIZE(ab8540_cut1_devs), NULL, + 0, ab8500->domain); + else /* ab8540 >= cut2 */ + ret = mfd_add_devices(ab8500->dev, 0, ab8540_cut2_devs, + ARRAY_SIZE(ab8540_cut2_devs), NULL, + 0, ab8500->domain); + } else if (is_ab8505(ab8500)) ret = mfd_add_devices(ab8500->dev, 0, ab8505_devs, ARRAY_SIZE(ab8505_devs), NULL, - ab8500->irq_base, ab8500->domain); + 0, ab8500->domain); else ret = mfd_add_devices(ab8500->dev, 0, ab8500_devs, ARRAY_SIZE(ab8500_devs), NULL, - ab8500->irq_base, ab8500->domain); + 0, ab8500->domain); if (ret) return ret; @@ -1753,7 +1790,7 @@ /* Add battery management devices */ ret = mfd_add_devices(ab8500->dev, 0, ab8500_bm_devs, ARRAY_SIZE(ab8500_bm_devs), NULL, - ab8500->irq_base, ab8500->domain); + 0, ab8500->domain); if (ret) dev_err(ab8500->dev, "error adding bm devices\n"); } @@ -1807,7 +1844,6 @@ static struct platform_driver ab8500_core_driver = { .driver = { .name = "ab8500-core", - .owner = THIS_MODULE, }, .probe = ab8500_probe, .remove = ab8500_remove,