Lines Matching +full:db8500 +full:- +full:prcmu
1 // SPDX-License-Identifier: GPL-2.0-only
3 * Copyright (C) ST-Ericsson SA 2010
22 #include <linux/mfd/dbx500-prcmu.h>
146 0, 1, 2, 3, 4, -1, -1, -1, -1, 11, 18, 19, 20, 21, 12, 13, 24, 5, 22,
163 dev_err(ab8500->dev, "prcmu i2c error %d\n", ret); in ab8500_prcmu_write()
175 dev_err(ab8500->dev, "prcmu i2c error %d\n", ret); in ab8500_prcmu_write_masked()
186 dev_err(ab8500->dev, "prcmu i2c error %d\n", ret); in ab8500_prcmu_read()
197 return -EINVAL; in ab8500_get_chip_id()
198 ab8500 = dev_get_drvdata(dev->parent); in ab8500_get_chip_id()
199 return ab8500 ? (int)ab8500->chip_id : -EINVAL; in ab8500_get_chip_id()
212 dev_vdbg(ab8500->dev, "wr: addr %#x <= %#x\n", addr, data); in set_register_interruptible()
214 mutex_lock(&ab8500->lock); in set_register_interruptible()
216 ret = ab8500->write(ab8500, addr, data); in set_register_interruptible()
218 dev_err(ab8500->dev, "failed to write reg %#x: %d\n", in set_register_interruptible()
220 mutex_unlock(&ab8500->lock); in set_register_interruptible()
229 struct ab8500 *ab8500 = dev_get_drvdata(dev->parent); in ab8500_set_register()
231 atomic_inc(&ab8500->transfer_ongoing); in ab8500_set_register()
233 atomic_dec(&ab8500->transfer_ongoing); in ab8500_set_register()
243 mutex_lock(&ab8500->lock); in get_register_interruptible()
245 ret = ab8500->read(ab8500, addr); in get_register_interruptible()
247 dev_err(ab8500->dev, "failed to read reg %#x: %d\n", in get_register_interruptible()
252 mutex_unlock(&ab8500->lock); in get_register_interruptible()
253 dev_vdbg(ab8500->dev, "rd: addr %#x => data %#x\n", addr, ret); in get_register_interruptible()
262 struct ab8500 *ab8500 = dev_get_drvdata(dev->parent); in ab8500_get_register()
264 atomic_inc(&ab8500->transfer_ongoing); in ab8500_get_register()
266 atomic_dec(&ab8500->transfer_ongoing); in ab8500_get_register()
276 mutex_lock(&ab8500->lock); in mask_and_set_register_interruptible()
278 if (ab8500->write_masked == NULL) { in mask_and_set_register_interruptible()
281 ret = ab8500->read(ab8500, addr); in mask_and_set_register_interruptible()
283 dev_err(ab8500->dev, "failed to read reg %#x: %d\n", in mask_and_set_register_interruptible()
291 ret = ab8500->write(ab8500, addr, data); in mask_and_set_register_interruptible()
293 dev_err(ab8500->dev, "failed to write reg %#x: %d\n", in mask_and_set_register_interruptible()
296 dev_vdbg(ab8500->dev, "mask: addr %#x => data %#x\n", addr, in mask_and_set_register_interruptible()
300 ret = ab8500->write_masked(ab8500, addr, bitmask, bitvalues); in mask_and_set_register_interruptible()
302 dev_err(ab8500->dev, "failed to modify reg %#x: %d\n", addr, in mask_and_set_register_interruptible()
305 mutex_unlock(&ab8500->lock); in mask_and_set_register_interruptible()
313 struct ab8500 *ab8500 = dev_get_drvdata(dev->parent); in ab8500_mask_and_set_register()
315 atomic_inc(&ab8500->transfer_ongoing); in ab8500_mask_and_set_register()
318 atomic_dec(&ab8500->transfer_ongoing); in ab8500_mask_and_set_register()
338 mutex_lock(&ab8500->irq_lock); in ab8500_irq_lock()
339 atomic_inc(&ab8500->transfer_ongoing); in ab8500_irq_lock()
347 for (i = 0; i < ab8500->mask_size; i++) { in ab8500_irq_sync_unlock()
348 u8 old = ab8500->oldmask[i]; in ab8500_irq_sync_unlock()
349 u8 new = ab8500->mask[i]; in ab8500_irq_sync_unlock()
359 if (ab8500->irq_reg_offset[i] == 11 && in ab8500_irq_sync_unlock()
363 if (ab8500->irq_reg_offset[i] < 0) in ab8500_irq_sync_unlock()
366 ab8500->oldmask[i] = new; in ab8500_irq_sync_unlock()
368 reg = AB8500_IT_MASK1_REG + ab8500->irq_reg_offset[i]; in ab8500_irq_sync_unlock()
371 atomic_dec(&ab8500->transfer_ongoing); in ab8500_irq_sync_unlock()
372 mutex_unlock(&ab8500->irq_lock); in ab8500_irq_sync_unlock()
378 int offset = data->hwirq; in ab8500_irq_mask()
382 ab8500->mask[index] |= mask; in ab8500_irq_mask()
386 ab8500->mask[index + 2] |= mask; in ab8500_irq_mask()
388 ab8500->mask[index + 1] |= mask; in ab8500_irq_mask()
391 ab8500->mask[index] |= (mask << 1); in ab8500_irq_mask()
398 int offset = data->hwirq; in ab8500_irq_unmask()
403 ab8500->mask[index] &= ~mask; in ab8500_irq_unmask()
408 ab8500->mask[index + 2] &= ~mask; in ab8500_irq_unmask()
411 ab8500->mask[index + 1] &= ~mask; in ab8500_irq_unmask()
415 ab8500->mask[index] &= ~(mask << 1); in ab8500_irq_unmask()
417 ab8500->mask[index] &= ~mask; in ab8500_irq_unmask()
420 ab8500->mask[index] &= ~mask; in ab8500_irq_unmask()
456 for (i = 0; i < ab8500->mask_size; i++) in ab8500_handle_hierarchical_line()
457 if (ab8500->irq_reg_offset[i] == latch_offset) in ab8500_handle_hierarchical_line()
460 if (i >= ab8500->mask_size) { in ab8500_handle_hierarchical_line()
461 dev_err(ab8500->dev, "Register offset 0x%2x not declared\n", in ab8500_handle_hierarchical_line()
463 return -ENXIO; in ab8500_handle_hierarchical_line()
467 latch_val &= ~ab8500->mask[i]; in ab8500_handle_hierarchical_line()
481 line -= 16; in ab8500_handle_hierarchical_line()
483 line -= 8; in ab8500_handle_hierarchical_line()
487 handle_nested_irq(irq_find_mapping(ab8500->domain, line)); in ab8500_handle_hierarchical_line()
528 dev_vdbg(ab8500->dev, "interrupt\n"); in ab8500_hierarchical_irq()
531 for (i = 0; i < (ab8500->it_latchhier_num); i++) { in ab8500_hierarchical_irq()
550 struct ab8500 *ab8500 = d->host_data; in ab8500_irq_map()
553 return -EINVAL; in ab8500_irq_map()
582 /* If ->irq_base is zero this will give a linear mapping */ in ab8500_irq_init()
583 ab8500->domain = irq_domain_add_simple(ab8500->dev->of_node, in ab8500_irq_init()
587 if (!ab8500->domain) { in ab8500_irq_init()
588 dev_err(ab8500->dev, "Failed to create irqdomain\n"); in ab8500_irq_init()
589 return -ENODEV; in ab8500_irq_init()
597 if (atomic_read(&ab8500->transfer_ongoing)) in ab8500_suspend()
598 return -EINVAL; in ab8500_suspend()
604 MFD_CELL_OF("ab8500-charger", NULL, NULL, 0, 0,
605 "stericsson,ab8500-charger"),
606 MFD_CELL_OF("ab8500-btemp", NULL, NULL, 0, 0,
607 "stericsson,ab8500-btemp"),
608 MFD_CELL_OF("ab8500-fg", NULL, NULL, 0, 0,
609 "stericsson,ab8500-fg"),
610 MFD_CELL_OF("ab8500-chargalg", NULL, NULL, 0, 0,
611 "stericsson,ab8500-chargalg"),
615 MFD_CELL_OF("ab8500-sysctrl",
616 NULL, NULL, 0, 0, "stericsson,ab8500-sysctrl"),
617 MFD_CELL_OF("ab8500-ext-regulator",
618 NULL, NULL, 0, 0, "stericsson,ab8500-ext-regulator"),
619 MFD_CELL_OF("ab8500-regulator",
620 NULL, NULL, 0, 0, "stericsson,ab8500-regulator"),
621 MFD_CELL_OF("ab8500-clk",
622 NULL, NULL, 0, 0, "stericsson,ab8500-clk"),
623 MFD_CELL_OF("ab8500-gpadc",
624 NULL, NULL, 0, 0, "stericsson,ab8500-gpadc"),
625 MFD_CELL_OF("ab8500-rtc",
626 NULL, NULL, 0, 0, "stericsson,ab8500-rtc"),
627 MFD_CELL_OF("ab8500-acc-det",
628 NULL, NULL, 0, 0, "stericsson,ab8500-acc-det"),
629 MFD_CELL_OF("ab8500-poweron-key",
630 NULL, NULL, 0, 0, "stericsson,ab8500-poweron-key"),
631 MFD_CELL_OF("ab8500-pwm",
632 NULL, NULL, 0, 1, "stericsson,ab8500-pwm"),
633 MFD_CELL_OF("ab8500-pwm",
634 NULL, NULL, 0, 2, "stericsson,ab8500-pwm"),
635 MFD_CELL_OF("ab8500-pwm",
636 NULL, NULL, 0, 3, "stericsson,ab8500-pwm"),
637 MFD_CELL_OF("ab8500-denc",
638 NULL, NULL, 0, 0, "stericsson,ab8500-denc"),
639 MFD_CELL_OF("pinctrl-ab8500",
640 NULL, NULL, 0, 0, "stericsson,ab8500-gpio"),
641 MFD_CELL_OF("abx500-temp",
642 NULL, NULL, 0, 0, "stericsson,abx500-temp"),
643 MFD_CELL_OF("ab8500-usb",
644 NULL, NULL, 0, 0, "stericsson,ab8500-usb"),
645 MFD_CELL_OF("ab8500-codec",
646 NULL, NULL, 0, 0, "stericsson,ab8500-codec"),
651 .name = "ab8500-sysctrl",
654 .name = "ab8500-ext-regulator",
657 .name = "ab8500-regulator",
660 .name = "abx500-clk",
661 .of_compatible = "stericsson,abx500-clk",
664 .name = "ab8500-gpadc",
665 .of_compatible = "stericsson,ab8500-gpadc",
668 .name = "ab8500-rtc",
671 .name = "ab8500-acc-det",
674 .name = "ab8500-poweron-key",
677 .name = "ab8500-pwm",
681 .name = "abx500-temp",
684 .name = "pinctrl-ab9540",
685 .of_compatible = "stericsson,ab9540-gpio",
688 .name = "ab9540-usb",
691 .name = "ab9540-codec",
694 .name = "ab-iddet",
701 .name = "ab8500-sysctrl",
702 .of_compatible = "stericsson,ab8500-sysctrl",
705 .name = "ab8500-regulator",
706 .of_compatible = "stericsson,ab8505-regulator",
709 .name = "abx500-clk",
710 .of_compatible = "stericsson,ab8500-clk",
713 .name = "ab8500-gpadc",
714 .of_compatible = "stericsson,ab8500-gpadc",
717 .name = "ab8500-rtc",
718 .of_compatible = "stericsson,ab8500-rtc",
721 .name = "ab8500-acc-det",
722 .of_compatible = "stericsson,ab8500-acc-det",
725 .name = "ab8500-poweron-key",
726 .of_compatible = "stericsson,ab8500-poweron-key",
729 .name = "ab8500-pwm",
730 .of_compatible = "stericsson,ab8500-pwm",
734 .name = "pinctrl-ab8505",
735 .of_compatible = "stericsson,ab8505-gpio",
738 .name = "ab8500-usb",
739 .of_compatible = "stericsson,ab8500-usb",
742 .name = "ab8500-codec",
743 .of_compatible = "stericsson,ab8500-codec",
746 .name = "ab-iddet",
752 .name = "ab8500-sysctrl",
755 .name = "ab8500-ext-regulator",
758 .name = "ab8500-regulator",
761 .name = "abx500-clk",
762 .of_compatible = "stericsson,abx500-clk",
765 .name = "ab8500-gpadc",
766 .of_compatible = "stericsson,ab8500-gpadc",
769 .name = "ab8500-acc-det",
772 .name = "ab8500-poweron-key",
775 .name = "ab8500-pwm",
779 .name = "abx500-temp",
782 .name = "pinctrl-ab8540",
785 .name = "ab8540-usb",
788 .name = "ab8540-codec",
791 .name = "ab-iddet",
797 .name = "ab8500-rtc",
798 .of_compatible = "stericsson,ab8500-rtc",
804 .name = "ab8540-rtc",
805 .of_compatible = "stericsson,ab8540-rtc",
816 return sprintf(buf, "%#x\n", ab8500 ? ab8500->chip_id : -EINVAL); in chip_id_show()
828 * 0x80 DB8500 thermal shutdown
953 dev_info(ab8500->dev, in dbbrstn_store()
1010 "DB8500 thermal shutdown"}; in ab8500_probe()
1022 struct device_node *np = pdev->dev.of_node; in ab8500_probe()
1029 ab8500 = devm_kzalloc(&pdev->dev, sizeof(*ab8500), GFP_KERNEL); in ab8500_probe()
1031 return -ENOMEM; in ab8500_probe()
1033 ab8500->dev = &pdev->dev; in ab8500_probe()
1039 ab8500->irq = irq; in ab8500_probe()
1041 ab8500->read = ab8500_prcmu_read; in ab8500_probe()
1042 ab8500->write = ab8500_prcmu_write; in ab8500_probe()
1043 ab8500->write_masked = ab8500_prcmu_write_masked; in ab8500_probe()
1045 mutex_init(&ab8500->lock); in ab8500_probe()
1046 mutex_init(&ab8500->irq_lock); in ab8500_probe()
1047 atomic_set(&ab8500->transfer_ongoing, 0); in ab8500_probe()
1052 version = platid->driver_data; in ab8500_probe()
1055 ab8500->version = version; in ab8500_probe()
1060 dev_err(&pdev->dev, "could not probe HW\n"); in ab8500_probe()
1064 ab8500->version = value; in ab8500_probe()
1072 ab8500->chip_id = value; in ab8500_probe()
1074 dev_info(ab8500->dev, "detected chip, %s rev. %1x.%1x\n", in ab8500_probe()
1075 ab8500_version_str[ab8500->version], in ab8500_probe()
1076 ab8500->chip_id >> 4, in ab8500_probe()
1077 ab8500->chip_id & 0x0F); in ab8500_probe()
1081 ab8500->mask_size = AB8540_NUM_IRQ_REGS; in ab8500_probe()
1082 ab8500->irq_reg_offset = ab8540_irq_regoffset; in ab8500_probe()
1083 ab8500->it_latchhier_num = AB8540_IT_LATCHHIER_NUM; in ab8500_probe()
1086 ab8500->mask_size = AB9540_NUM_IRQ_REGS; in ab8500_probe()
1087 ab8500->irq_reg_offset = ab9540_irq_regoffset; in ab8500_probe()
1088 ab8500->it_latchhier_num = AB8500_IT_LATCHHIER_NUM; in ab8500_probe()
1090 ab8500->mask_size = AB8500_NUM_IRQ_REGS; in ab8500_probe()
1091 ab8500->irq_reg_offset = ab8500_irq_regoffset; in ab8500_probe()
1092 ab8500->it_latchhier_num = AB8500_IT_LATCHHIER_NUM; in ab8500_probe()
1094 ab8500->mask = devm_kzalloc(&pdev->dev, ab8500->mask_size, in ab8500_probe()
1096 if (!ab8500->mask) in ab8500_probe()
1097 return -ENOMEM; in ab8500_probe()
1098 ab8500->oldmask = devm_kzalloc(&pdev->dev, ab8500->mask_size, in ab8500_probe()
1100 if (!ab8500->oldmask) in ab8500_probe()
1101 return -ENOMEM; in ab8500_probe()
1112 * 0x80 DB8500 thermal shutdown in ab8500_probe()
1119 dev_info(ab8500->dev, "switch off cause(s) (%#x): ", value); in ab8500_probe()
1136 dev_info(ab8500->dev, "turn on reason(s) (%#x): ", value); in ab8500_probe()
1160 for (i = 0; i < ab8500->mask_size; i++) { in ab8500_probe()
1165 if (ab8500->irq_reg_offset[i] == 11 && in ab8500_probe()
1169 if (ab8500->irq_reg_offset[i] < 0) in ab8500_probe()
1173 AB8500_IT_LATCH1_REG + ab8500->irq_reg_offset[i], in ab8500_probe()
1176 AB8500_IT_MASK1_REG + ab8500->irq_reg_offset[i], 0xff); in ab8500_probe()
1179 ret = abx500_register_ops(ab8500->dev, &ab8500_ops); in ab8500_probe()
1183 for (i = 0; i < ab8500->mask_size; i++) in ab8500_probe()
1184 ab8500->mask[i] = ab8500->oldmask[i] = 0xff; in ab8500_probe()
1190 ret = devm_request_threaded_irq(&pdev->dev, ab8500->irq, NULL, in ab8500_probe()
1198 ret = mfd_add_devices(ab8500->dev, 0, ab9540_devs, in ab8500_probe()
1200 0, ab8500->domain); in ab8500_probe()
1202 ret = mfd_add_devices(ab8500->dev, 0, ab8540_devs, in ab8500_probe()
1204 0, ab8500->domain); in ab8500_probe()
1209 ret = mfd_add_devices(ab8500->dev, 0, ab8540_cut1_devs, in ab8500_probe()
1211 0, ab8500->domain); in ab8500_probe()
1213 ret = mfd_add_devices(ab8500->dev, 0, ab8540_cut2_devs, in ab8500_probe()
1215 0, ab8500->domain); in ab8500_probe()
1217 ret = mfd_add_devices(ab8500->dev, 0, ab8505_devs, in ab8500_probe()
1219 0, ab8500->domain); in ab8500_probe()
1221 ret = mfd_add_devices(ab8500->dev, 0, ab8500_devs, in ab8500_probe()
1223 0, ab8500->domain); in ab8500_probe()
1228 ret = mfd_add_devices(ab8500->dev, 0, ab8500_bm_devs, in ab8500_probe()
1230 0, ab8500->domain); in ab8500_probe()
1232 dev_err(ab8500->dev, "error adding bm devices\n"); in ab8500_probe()
1235 ab8500->chip_id >= AB8500_CUT2P0) || is_ab8540(ab8500)) in ab8500_probe()
1236 ret = sysfs_create_group(&ab8500->dev->kobj, in ab8500_probe()
1239 ret = sysfs_create_group(&ab8500->dev->kobj, in ab8500_probe()
1243 ab8500->chip_id >= AB8500_CUT2P0) in ab8500_probe()
1244 ret = sysfs_create_group(&ab8500->dev->kobj, in ab8500_probe()
1248 dev_err(ab8500->dev, "error creating sysfs entries\n"); in ab8500_probe()
1254 { "ab8500-core", AB8500_VERSION_AB8500 },
1255 { "ab8505-core", AB8500_VERSION_AB8505 },
1256 { "ab9540-i2c", AB8500_VERSION_AB9540 },
1257 { "ab8540-i2c", AB8500_VERSION_AB8540 },
1263 .name = "ab8500-core",