• Home
  • Raw
  • Download

Lines Matching refs:ab8500

162 static int ab8500_prcmu_write(struct ab8500 *ab8500, u16 addr, u8 data)  in ab8500_prcmu_write()  argument
168 dev_err(ab8500->dev, "prcmu i2c error %d\n", ret); in ab8500_prcmu_write()
172 static int ab8500_prcmu_write_masked(struct ab8500 *ab8500, u16 addr, u8 mask, in ab8500_prcmu_write_masked() argument
180 dev_err(ab8500->dev, "prcmu i2c error %d\n", ret); in ab8500_prcmu_write_masked()
184 static int ab8500_prcmu_read(struct ab8500 *ab8500, u16 addr) in ab8500_prcmu_read() argument
191 dev_err(ab8500->dev, "prcmu i2c error %d\n", ret); in ab8500_prcmu_read()
199 struct ab8500 *ab8500; in ab8500_get_chip_id() local
203 ab8500 = dev_get_drvdata(dev->parent); in ab8500_get_chip_id()
204 return ab8500 ? (int)ab8500->chip_id : -EINVAL; in ab8500_get_chip_id()
207 static int set_register_interruptible(struct ab8500 *ab8500, u8 bank, in set_register_interruptible() argument
217 dev_vdbg(ab8500->dev, "wr: addr %#x <= %#x\n", addr, data); in set_register_interruptible()
219 mutex_lock(&ab8500->lock); in set_register_interruptible()
221 ret = ab8500->write(ab8500, addr, data); in set_register_interruptible()
223 dev_err(ab8500->dev, "failed to write reg %#x: %d\n", in set_register_interruptible()
225 mutex_unlock(&ab8500->lock); in set_register_interruptible()
234 struct ab8500 *ab8500 = dev_get_drvdata(dev->parent); in ab8500_set_register() local
236 atomic_inc(&ab8500->transfer_ongoing); in ab8500_set_register()
237 ret = set_register_interruptible(ab8500, bank, reg, value); in ab8500_set_register()
238 atomic_dec(&ab8500->transfer_ongoing); in ab8500_set_register()
242 static int get_register_interruptible(struct ab8500 *ab8500, u8 bank, in get_register_interruptible() argument
250 mutex_lock(&ab8500->lock); in get_register_interruptible()
252 ret = ab8500->read(ab8500, addr); in get_register_interruptible()
254 dev_err(ab8500->dev, "failed to read reg %#x: %d\n", in get_register_interruptible()
259 mutex_unlock(&ab8500->lock); in get_register_interruptible()
260 dev_vdbg(ab8500->dev, "rd: addr %#x => data %#x\n", addr, ret); in get_register_interruptible()
269 struct ab8500 *ab8500 = dev_get_drvdata(dev->parent); in ab8500_get_register() local
271 atomic_inc(&ab8500->transfer_ongoing); in ab8500_get_register()
272 ret = get_register_interruptible(ab8500, bank, reg, value); in ab8500_get_register()
273 atomic_dec(&ab8500->transfer_ongoing); in ab8500_get_register()
277 static int mask_and_set_register_interruptible(struct ab8500 *ab8500, u8 bank, in mask_and_set_register_interruptible() argument
285 mutex_lock(&ab8500->lock); in mask_and_set_register_interruptible()
287 if (ab8500->write_masked == NULL) { in mask_and_set_register_interruptible()
290 ret = ab8500->read(ab8500, addr); in mask_and_set_register_interruptible()
292 dev_err(ab8500->dev, "failed to read reg %#x: %d\n", in mask_and_set_register_interruptible()
300 ret = ab8500->write(ab8500, addr, data); in mask_and_set_register_interruptible()
302 dev_err(ab8500->dev, "failed to write reg %#x: %d\n", in mask_and_set_register_interruptible()
305 dev_vdbg(ab8500->dev, "mask: addr %#x => data %#x\n", addr, in mask_and_set_register_interruptible()
309 ret = ab8500->write_masked(ab8500, addr, bitmask, bitvalues); in mask_and_set_register_interruptible()
311 dev_err(ab8500->dev, "failed to modify reg %#x: %d\n", addr, in mask_and_set_register_interruptible()
314 mutex_unlock(&ab8500->lock); in mask_and_set_register_interruptible()
322 struct ab8500 *ab8500 = dev_get_drvdata(dev->parent); in ab8500_mask_and_set_register() local
324 atomic_inc(&ab8500->transfer_ongoing); in ab8500_mask_and_set_register()
325 ret = mask_and_set_register_interruptible(ab8500, bank, reg, in ab8500_mask_and_set_register()
327 atomic_dec(&ab8500->transfer_ongoing); in ab8500_mask_and_set_register()
345 struct ab8500 *ab8500 = irq_data_get_irq_chip_data(data); in ab8500_irq_lock() local
347 mutex_lock(&ab8500->irq_lock); in ab8500_irq_lock()
348 atomic_inc(&ab8500->transfer_ongoing); in ab8500_irq_lock()
353 struct ab8500 *ab8500 = irq_data_get_irq_chip_data(data); in ab8500_irq_sync_unlock() local
356 for (i = 0; i < ab8500->mask_size; i++) { in ab8500_irq_sync_unlock()
357 u8 old = ab8500->oldmask[i]; in ab8500_irq_sync_unlock()
358 u8 new = ab8500->mask[i]; in ab8500_irq_sync_unlock()
368 if (ab8500->irq_reg_offset[i] == 11 && in ab8500_irq_sync_unlock()
369 is_ab8500_1p1_or_earlier(ab8500)) in ab8500_irq_sync_unlock()
372 if (ab8500->irq_reg_offset[i] < 0) in ab8500_irq_sync_unlock()
375 ab8500->oldmask[i] = new; in ab8500_irq_sync_unlock()
377 reg = AB8500_IT_MASK1_REG + ab8500->irq_reg_offset[i]; in ab8500_irq_sync_unlock()
378 set_register_interruptible(ab8500, AB8500_INTERRUPT, reg, new); in ab8500_irq_sync_unlock()
380 atomic_dec(&ab8500->transfer_ongoing); in ab8500_irq_sync_unlock()
381 mutex_unlock(&ab8500->irq_lock); in ab8500_irq_sync_unlock()
386 struct ab8500 *ab8500 = irq_data_get_irq_chip_data(data); in ab8500_irq_mask() local
391 ab8500->mask[index] |= mask; in ab8500_irq_mask()
395 ab8500->mask[index + 2] |= mask; in ab8500_irq_mask()
397 ab8500->mask[index + 1] |= mask; in ab8500_irq_mask()
400 ab8500->mask[index] |= (mask << 1); in ab8500_irq_mask()
405 struct ab8500 *ab8500 = irq_data_get_irq_chip_data(data); in ab8500_irq_unmask() local
412 ab8500->mask[index] &= ~mask; in ab8500_irq_unmask()
417 ab8500->mask[index + 2] &= ~mask; in ab8500_irq_unmask()
420 ab8500->mask[index + 1] &= ~mask; in ab8500_irq_unmask()
424 ab8500->mask[index] &= ~(mask << 1); in ab8500_irq_unmask()
426 ab8500->mask[index] &= ~mask; in ab8500_irq_unmask()
429 ab8500->mask[index] &= ~mask; in ab8500_irq_unmask()
460 static int ab8500_handle_hierarchical_line(struct ab8500 *ab8500, in ab8500_handle_hierarchical_line() argument
465 for (i = 0; i < ab8500->mask_size; i++) in ab8500_handle_hierarchical_line()
466 if (ab8500->irq_reg_offset[i] == latch_offset) in ab8500_handle_hierarchical_line()
469 if (i >= ab8500->mask_size) { in ab8500_handle_hierarchical_line()
470 dev_err(ab8500->dev, "Register offset 0x%2x not declared\n", in ab8500_handle_hierarchical_line()
476 latch_val &= ~ab8500->mask[i]; in ab8500_handle_hierarchical_line()
496 handle_nested_irq(irq_create_mapping(ab8500->domain, line)); in ab8500_handle_hierarchical_line()
502 static int ab8500_handle_hierarchical_latch(struct ab8500 *ab8500, in ab8500_handle_hierarchical_latch() argument
514 status = get_register_interruptible(ab8500, in ab8500_handle_hierarchical_latch()
521 status = ab8500_handle_hierarchical_line(ab8500, in ab8500_handle_hierarchical_latch()
534 struct ab8500 *ab8500 = dev; in ab8500_hierarchical_irq() local
537 dev_vdbg(ab8500->dev, "interrupt\n"); in ab8500_hierarchical_irq()
540 for (i = 0; i < (ab8500->it_latchhier_num); i++) { in ab8500_hierarchical_irq()
544 status = get_register_interruptible(ab8500, AB8500_INTERRUPT, in ab8500_hierarchical_irq()
549 status = ab8500_handle_hierarchical_latch(ab8500, i, hier_val); in ab8500_hierarchical_irq()
559 struct ab8500 *ab8500 = d->host_data; in ab8500_irq_map() local
561 if (!ab8500) in ab8500_irq_map()
564 irq_set_chip_data(virq, ab8500); in ab8500_irq_map()
578 static int ab8500_irq_init(struct ab8500 *ab8500, struct device_node *np) in ab8500_irq_init() argument
582 if (is_ab8540(ab8500)) in ab8500_irq_init()
584 else if (is_ab9540(ab8500)) in ab8500_irq_init()
586 else if (is_ab8505(ab8500)) in ab8500_irq_init()
592 ab8500->domain = irq_domain_add_simple(ab8500->dev->of_node, in ab8500_irq_init()
594 &ab8500_irq_ops, ab8500); in ab8500_irq_init()
596 if (!ab8500->domain) { in ab8500_irq_init()
597 dev_err(ab8500->dev, "Failed to create irqdomain\n"); in ab8500_irq_init()
604 int ab8500_suspend(struct ab8500 *ab8500) in ab8500_suspend() argument
606 if (atomic_read(&ab8500->transfer_ongoing)) in ab8500_suspend()
1361 struct ab8500 *ab8500; in show_chip_id() local
1363 ab8500 = dev_get_drvdata(dev); in show_chip_id()
1365 return sprintf(buf, "%#x\n", ab8500 ? ab8500->chip_id : -EINVAL); in show_chip_id()
1384 struct ab8500 *ab8500; in show_switch_off_status() local
1386 ab8500 = dev_get_drvdata(dev); in show_switch_off_status()
1387 ret = get_register_interruptible(ab8500, AB8500_RTC, in show_switch_off_status()
1419 struct ab8500 *ab8500; in show_turn_on_status() local
1421 ab8500 = dev_get_drvdata(dev); in show_turn_on_status()
1422 ret = get_register_interruptible(ab8500, AB8500_SYS_CTRL1_BLOCK, in show_turn_on_status()
1434 if (is_ab9540(ab8500)) { in show_turn_on_status()
1448 struct ab8500 *ab8500; in show_turn_on_status_2() local
1450 ab8500 = dev_get_drvdata(dev); in show_turn_on_status_2()
1451 ret = get_register_interruptible(ab8500, AB8500_SYS_CTRL1_BLOCK, in show_turn_on_status_2()
1461 struct ab8500 *ab8500; in show_ab9540_dbbrstn() local
1465 ab8500 = dev_get_drvdata(dev); in show_ab9540_dbbrstn()
1467 ret = get_register_interruptible(ab8500, AB8500_REGU_CTRL2, in show_ab9540_dbbrstn()
1479 struct ab8500 *ab8500; in store_ab9540_dbbrstn() local
1484 ab8500 = dev_get_drvdata(dev); in store_ab9540_dbbrstn()
1498 err = mask_and_set_register_interruptible(ab8500, in store_ab9540_dbbrstn()
1502 dev_info(ab8500->dev, in store_ab9540_dbbrstn()
1574 struct ab8500 *ab8500; in ab8500_probe() local
1580 ab8500 = devm_kzalloc(&pdev->dev, sizeof(*ab8500), GFP_KERNEL); in ab8500_probe()
1581 if (!ab8500) in ab8500_probe()
1584 ab8500->dev = &pdev->dev; in ab8500_probe()
1592 ab8500->irq = resource->start; in ab8500_probe()
1594 ab8500->read = ab8500_prcmu_read; in ab8500_probe()
1595 ab8500->write = ab8500_prcmu_write; in ab8500_probe()
1596 ab8500->write_masked = ab8500_prcmu_write_masked; in ab8500_probe()
1598 mutex_init(&ab8500->lock); in ab8500_probe()
1599 mutex_init(&ab8500->irq_lock); in ab8500_probe()
1600 atomic_set(&ab8500->transfer_ongoing, 0); in ab8500_probe()
1602 platform_set_drvdata(pdev, ab8500); in ab8500_probe()
1608 ab8500->version = version; in ab8500_probe()
1610 ret = get_register_interruptible(ab8500, AB8500_MISC, in ab8500_probe()
1617 ab8500->version = value; in ab8500_probe()
1620 ret = get_register_interruptible(ab8500, AB8500_MISC, in ab8500_probe()
1625 ab8500->chip_id = value; in ab8500_probe()
1627 dev_info(ab8500->dev, "detected chip, %s rev. %1x.%1x\n", in ab8500_probe()
1628 ab8500_version_str[ab8500->version], in ab8500_probe()
1629 ab8500->chip_id >> 4, in ab8500_probe()
1630 ab8500->chip_id & 0x0F); in ab8500_probe()
1633 if (is_ab8540(ab8500)) { in ab8500_probe()
1634 ab8500->mask_size = AB8540_NUM_IRQ_REGS; in ab8500_probe()
1635 ab8500->irq_reg_offset = ab8540_irq_regoffset; in ab8500_probe()
1636 ab8500->it_latchhier_num = AB8540_IT_LATCHHIER_NUM; in ab8500_probe()
1638 else if (is_ab9540(ab8500) || is_ab8505(ab8500)) { in ab8500_probe()
1639 ab8500->mask_size = AB9540_NUM_IRQ_REGS; in ab8500_probe()
1640 ab8500->irq_reg_offset = ab9540_irq_regoffset; in ab8500_probe()
1641 ab8500->it_latchhier_num = AB8500_IT_LATCHHIER_NUM; in ab8500_probe()
1643 ab8500->mask_size = AB8500_NUM_IRQ_REGS; in ab8500_probe()
1644 ab8500->irq_reg_offset = ab8500_irq_regoffset; in ab8500_probe()
1645 ab8500->it_latchhier_num = AB8500_IT_LATCHHIER_NUM; in ab8500_probe()
1647 ab8500->mask = devm_kzalloc(&pdev->dev, ab8500->mask_size, in ab8500_probe()
1649 if (!ab8500->mask) in ab8500_probe()
1651 ab8500->oldmask = devm_kzalloc(&pdev->dev, ab8500->mask_size, in ab8500_probe()
1653 if (!ab8500->oldmask) in ab8500_probe()
1668 ret = get_register_interruptible(ab8500, AB8500_RTC, in ab8500_probe()
1672 dev_info(ab8500->dev, "switch off cause(s) (%#x): ", value); in ab8500_probe()
1685 ret = get_register_interruptible(ab8500, AB8500_SYS_CTRL1_BLOCK, in ab8500_probe()
1689 dev_info(ab8500->dev, "turn on reason(s) (%#x): ", value); in ab8500_probe()
1703 plat->init(ab8500); in ab8500_probe()
1705 if (is_ab9540(ab8500)) { in ab8500_probe()
1706 ret = get_register_interruptible(ab8500, AB8500_CHARGER, in ab8500_probe()
1716 for (i = 0; i < ab8500->mask_size; i++) { in ab8500_probe()
1721 if (ab8500->irq_reg_offset[i] == 11 && in ab8500_probe()
1722 is_ab8500_1p1_or_earlier(ab8500)) in ab8500_probe()
1725 if (ab8500->irq_reg_offset[i] < 0) in ab8500_probe()
1728 get_register_interruptible(ab8500, AB8500_INTERRUPT, in ab8500_probe()
1729 AB8500_IT_LATCH1_REG + ab8500->irq_reg_offset[i], in ab8500_probe()
1731 set_register_interruptible(ab8500, AB8500_INTERRUPT, in ab8500_probe()
1732 AB8500_IT_MASK1_REG + ab8500->irq_reg_offset[i], 0xff); in ab8500_probe()
1735 ret = abx500_register_ops(ab8500->dev, &ab8500_ops); in ab8500_probe()
1739 for (i = 0; i < ab8500->mask_size; i++) in ab8500_probe()
1740 ab8500->mask[i] = ab8500->oldmask[i] = 0xff; in ab8500_probe()
1742 ret = ab8500_irq_init(ab8500, np); in ab8500_probe()
1746 ret = devm_request_threaded_irq(&pdev->dev, ab8500->irq, NULL, in ab8500_probe()
1749 "ab8500", ab8500); in ab8500_probe()
1755 ab8500_debug_resources[0].start = ab8500->irq; in ab8500_probe()
1756 ab8500_debug_resources[0].end = ab8500->irq; in ab8500_probe()
1759 if (is_ab9540(ab8500)) in ab8500_probe()
1760 ret = mfd_add_devices(ab8500->dev, 0, ab9540_devs, in ab8500_probe()
1762 0, ab8500->domain); in ab8500_probe()
1763 else if (is_ab8540(ab8500)) { in ab8500_probe()
1764 ret = mfd_add_devices(ab8500->dev, 0, ab8540_devs, in ab8500_probe()
1766 0, ab8500->domain); in ab8500_probe()
1770 if (is_ab8540_1p2_or_earlier(ab8500)) in ab8500_probe()
1771 ret = mfd_add_devices(ab8500->dev, 0, ab8540_cut1_devs, in ab8500_probe()
1773 0, ab8500->domain); in ab8500_probe()
1775 ret = mfd_add_devices(ab8500->dev, 0, ab8540_cut2_devs, in ab8500_probe()
1777 0, ab8500->domain); in ab8500_probe()
1778 } else if (is_ab8505(ab8500)) in ab8500_probe()
1779 ret = mfd_add_devices(ab8500->dev, 0, ab8505_devs, in ab8500_probe()
1781 0, ab8500->domain); in ab8500_probe()
1783 ret = mfd_add_devices(ab8500->dev, 0, ab8500_devs, in ab8500_probe()
1785 0, ab8500->domain); in ab8500_probe()
1791 ret = mfd_add_devices(ab8500->dev, 0, ab8500_bm_devs, in ab8500_probe()
1793 0, ab8500->domain); in ab8500_probe()
1795 dev_err(ab8500->dev, "error adding bm devices\n"); in ab8500_probe()
1798 if (((is_ab8505(ab8500) || is_ab9540(ab8500)) && in ab8500_probe()
1799 ab8500->chip_id >= AB8500_CUT2P0) || is_ab8540(ab8500)) in ab8500_probe()
1800 ret = sysfs_create_group(&ab8500->dev->kobj, in ab8500_probe()
1803 ret = sysfs_create_group(&ab8500->dev->kobj, in ab8500_probe()
1806 if ((is_ab8505(ab8500) || is_ab9540(ab8500)) && in ab8500_probe()
1807 ab8500->chip_id >= AB8500_CUT2P0) in ab8500_probe()
1808 ret = sysfs_create_group(&ab8500->dev->kobj, in ab8500_probe()
1812 dev_err(ab8500->dev, "error creating sysfs entries\n"); in ab8500_probe()
1819 struct ab8500 *ab8500 = platform_get_drvdata(pdev); in ab8500_remove() local
1821 if (((is_ab8505(ab8500) || is_ab9540(ab8500)) && in ab8500_remove()
1822 ab8500->chip_id >= AB8500_CUT2P0) || is_ab8540(ab8500)) in ab8500_remove()
1823 sysfs_remove_group(&ab8500->dev->kobj, &ab9540_attr_group); in ab8500_remove()
1825 sysfs_remove_group(&ab8500->dev->kobj, &ab8500_attr_group); in ab8500_remove()
1827 if ((is_ab8505(ab8500) || is_ab9540(ab8500)) && in ab8500_remove()
1828 ab8500->chip_id >= AB8500_CUT2P0) in ab8500_remove()
1829 sysfs_remove_group(&ab8500->dev->kobj, &ab8505_attr_group); in ab8500_remove()
1831 mfd_remove_devices(ab8500->dev); in ab8500_remove()