aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
Diffstat (limited to 'drivers')
-rw-r--r--drivers/base/regmap/regmap.c206
1 files changed, 45 insertions, 161 deletions
diff --git a/drivers/base/regmap/regmap.c b/drivers/base/regmap/regmap.c
index e2f68807d970..4b89c95a5dec 100644
--- a/drivers/base/regmap/regmap.c
+++ b/drivers/base/regmap/regmap.c
@@ -1692,100 +1692,63 @@ int regmap_raw_write(struct regmap *map, unsigned int reg,
1692EXPORT_SYMBOL_GPL(regmap_raw_write); 1692EXPORT_SYMBOL_GPL(regmap_raw_write);
1693 1693
1694/** 1694/**
1695 * regmap_field_write(): Write a value to a single register field 1695 * regmap_field_update_bits_base():
1696 * 1696 * Perform a read/modify/write cycle on the register field
1697 * @field: Register field to write to 1697 * with change, async, force option
1698 * @val: Value to be written
1699 *
1700 * A value of zero will be returned on success, a negative errno will
1701 * be returned in error cases.
1702 */
1703int regmap_field_write(struct regmap_field *field, unsigned int val)
1704{
1705 return regmap_update_bits(field->regmap, field->reg,
1706 field->mask, val << field->shift);
1707}
1708EXPORT_SYMBOL_GPL(regmap_field_write);
1709
1710/**
1711 * regmap_field_update_bits(): Perform a read/modify/write cycle
1712 * on the register field
1713 * 1698 *
1714 * @field: Register field to write to 1699 * @field: Register field to write to
1715 * @mask: Bitmask to change 1700 * @mask: Bitmask to change
1716 * @val: Value to be written 1701 * @val: Value to be written
1702 * @change: Boolean indicating if a write was done
1703 * @async: Boolean indicating asynchronously
1704 * @force: Boolean indicating use force update
1717 * 1705 *
1718 * A value of zero will be returned on success, a negative errno will 1706 * A value of zero will be returned on success, a negative errno will
1719 * be returned in error cases. 1707 * be returned in error cases.
1720 */ 1708 */
1721int regmap_field_update_bits(struct regmap_field *field, unsigned int mask, unsigned int val) 1709int regmap_field_update_bits_base(struct regmap_field *field,
1710 unsigned int mask, unsigned int val,
1711 bool *change, bool async, bool force)
1722{ 1712{
1723 mask = (mask << field->shift) & field->mask; 1713 mask = (mask << field->shift) & field->mask;
1724 1714
1725 return regmap_update_bits(field->regmap, field->reg, 1715 return regmap_update_bits_base(field->regmap, field->reg,
1726 mask, val << field->shift); 1716 mask, val << field->shift,
1717 change, async, force);
1727} 1718}
1728EXPORT_SYMBOL_GPL(regmap_field_update_bits); 1719EXPORT_SYMBOL_GPL(regmap_field_update_bits_base);
1729 1720
1730/** 1721/**
1731 * regmap_fields_write(): Write a value to a single register field with port ID 1722 * regmap_fields_update_bits_base():
1732 * 1723 * Perform a read/modify/write cycle on the register field
1733 * @field: Register field to write to 1724 * with change, async, force option
1734 * @id: port ID
1735 * @val: Value to be written
1736 *
1737 * A value of zero will be returned on success, a negative errno will
1738 * be returned in error cases.
1739 */
1740int regmap_fields_write(struct regmap_field *field, unsigned int id,
1741 unsigned int val)
1742{
1743 if (id >= field->id_size)
1744 return -EINVAL;
1745
1746 return regmap_update_bits(field->regmap,
1747 field->reg + (field->id_offset * id),
1748 field->mask, val << field->shift);
1749}
1750EXPORT_SYMBOL_GPL(regmap_fields_write);
1751
1752int regmap_fields_force_write(struct regmap_field *field, unsigned int id,
1753 unsigned int val)
1754{
1755 if (id >= field->id_size)
1756 return -EINVAL;
1757
1758 return regmap_write_bits(field->regmap,
1759 field->reg + (field->id_offset * id),
1760 field->mask, val << field->shift);
1761}
1762EXPORT_SYMBOL_GPL(regmap_fields_force_write);
1763
1764/**
1765 * regmap_fields_update_bits(): Perform a read/modify/write cycle
1766 * on the register field
1767 * 1725 *
1768 * @field: Register field to write to 1726 * @field: Register field to write to
1769 * @id: port ID 1727 * @id: port ID
1770 * @mask: Bitmask to change 1728 * @mask: Bitmask to change
1771 * @val: Value to be written 1729 * @val: Value to be written
1730 * @change: Boolean indicating if a write was done
1731 * @async: Boolean indicating asynchronously
1732 * @force: Boolean indicating use force update
1772 * 1733 *
1773 * A value of zero will be returned on success, a negative errno will 1734 * A value of zero will be returned on success, a negative errno will
1774 * be returned in error cases. 1735 * be returned in error cases.
1775 */ 1736 */
1776int regmap_fields_update_bits(struct regmap_field *field, unsigned int id, 1737int regmap_fields_update_bits_base(struct regmap_field *field, unsigned int id,
1777 unsigned int mask, unsigned int val) 1738 unsigned int mask, unsigned int val,
1739 bool *change, bool async, bool force)
1778{ 1740{
1779 if (id >= field->id_size) 1741 if (id >= field->id_size)
1780 return -EINVAL; 1742 return -EINVAL;
1781 1743
1782 mask = (mask << field->shift) & field->mask; 1744 mask = (mask << field->shift) & field->mask;
1783 1745
1784 return regmap_update_bits(field->regmap, 1746 return regmap_update_bits_base(field->regmap,
1785 field->reg + (field->id_offset * id), 1747 field->reg + (field->id_offset * id),
1786 mask, val << field->shift); 1748 mask, val << field->shift,
1749 change, async, force);
1787} 1750}
1788EXPORT_SYMBOL_GPL(regmap_fields_update_bits); 1751EXPORT_SYMBOL_GPL(regmap_fields_update_bits_base);
1789 1752
1790/* 1753/*
1791 * regmap_bulk_write(): Write multiple registers to the device 1754 * regmap_bulk_write(): Write multiple registers to the device
@@ -2653,76 +2616,36 @@ static int _regmap_update_bits(struct regmap *map, unsigned int reg,
2653} 2616}
2654 2617
2655/** 2618/**
2656 * regmap_update_bits: Perform a read/modify/write cycle on the register map 2619 * regmap_update_bits_base:
2657 * 2620 * Perform a read/modify/write cycle on the
2658 * @map: Register map to update 2621 * register map with change, async, force option
2659 * @reg: Register to update
2660 * @mask: Bitmask to change
2661 * @val: New value for bitmask
2662 *
2663 * Returns zero for success, a negative number on error.
2664 */
2665int regmap_update_bits(struct regmap *map, unsigned int reg,
2666 unsigned int mask, unsigned int val)
2667{
2668 int ret;
2669
2670 map->lock(map->lock_arg);
2671 ret = _regmap_update_bits(map, reg, mask, val, NULL, false);
2672 map->unlock(map->lock_arg);
2673
2674 return ret;
2675}
2676EXPORT_SYMBOL_GPL(regmap_update_bits);
2677
2678/**
2679 * regmap_write_bits: Perform a read/modify/write cycle on the register map
2680 *
2681 * @map: Register map to update
2682 * @reg: Register to update
2683 * @mask: Bitmask to change
2684 * @val: New value for bitmask
2685 *
2686 * Returns zero for success, a negative number on error.
2687 */
2688int regmap_write_bits(struct regmap *map, unsigned int reg,
2689 unsigned int mask, unsigned int val)
2690{
2691 int ret;
2692
2693 map->lock(map->lock_arg);
2694 ret = _regmap_update_bits(map, reg, mask, val, NULL, true);
2695 map->unlock(map->lock_arg);
2696
2697 return ret;
2698}
2699EXPORT_SYMBOL_GPL(regmap_write_bits);
2700
2701/**
2702 * regmap_update_bits_async: Perform a read/modify/write cycle on the register
2703 * map asynchronously
2704 * 2622 *
2705 * @map: Register map to update 2623 * @map: Register map to update
2706 * @reg: Register to update 2624 * @reg: Register to update
2707 * @mask: Bitmask to change 2625 * @mask: Bitmask to change
2708 * @val: New value for bitmask 2626 * @val: New value for bitmask
2627 * @change: Boolean indicating if a write was done
2628 * @async: Boolean indicating asynchronously
2629 * @force: Boolean indicating use force update
2709 * 2630 *
2631 * if async was true,
2710 * With most buses the read must be done synchronously so this is most 2632 * With most buses the read must be done synchronously so this is most
2711 * useful for devices with a cache which do not need to interact with 2633 * useful for devices with a cache which do not need to interact with
2712 * the hardware to determine the current register value. 2634 * the hardware to determine the current register value.
2713 * 2635 *
2714 * Returns zero for success, a negative number on error. 2636 * Returns zero for success, a negative number on error.
2715 */ 2637 */
2716int regmap_update_bits_async(struct regmap *map, unsigned int reg, 2638int regmap_update_bits_base(struct regmap *map, unsigned int reg,
2717 unsigned int mask, unsigned int val) 2639 unsigned int mask, unsigned int val,
2640 bool *change, bool async, bool force)
2718{ 2641{
2719 int ret; 2642 int ret;
2720 2643
2721 map->lock(map->lock_arg); 2644 map->lock(map->lock_arg);
2722 2645
2723 map->async = true; 2646 map->async = async;
2724 2647
2725 ret = _regmap_update_bits(map, reg, mask, val, NULL, false); 2648 ret = _regmap_update_bits(map, reg, mask, val, change, force);
2726 2649
2727 map->async = false; 2650 map->async = false;
2728 2651
@@ -2730,69 +2653,30 @@ int regmap_update_bits_async(struct regmap *map, unsigned int reg,
2730 2653
2731 return ret; 2654 return ret;
2732} 2655}
2733EXPORT_SYMBOL_GPL(regmap_update_bits_async); 2656EXPORT_SYMBOL_GPL(regmap_update_bits_base);
2734
2735/**
2736 * regmap_update_bits_check: Perform a read/modify/write cycle on the
2737 * register map and report if updated
2738 *
2739 * @map: Register map to update
2740 * @reg: Register to update
2741 * @mask: Bitmask to change
2742 * @val: New value for bitmask
2743 * @change: Boolean indicating if a write was done
2744 *
2745 * Returns zero for success, a negative number on error.
2746 */
2747int regmap_update_bits_check(struct regmap *map, unsigned int reg,
2748 unsigned int mask, unsigned int val,
2749 bool *change)
2750{
2751 int ret;
2752
2753 map->lock(map->lock_arg);
2754 ret = _regmap_update_bits(map, reg, mask, val, change, false);
2755 map->unlock(map->lock_arg);
2756 return ret;
2757}
2758EXPORT_SYMBOL_GPL(regmap_update_bits_check);
2759 2657
2760/** 2658/**
2761 * regmap_update_bits_check_async: Perform a read/modify/write cycle on the 2659 * regmap_write_bits: Perform a read/modify/write cycle on the register map
2762 * register map asynchronously and report if
2763 * updated
2764 * 2660 *
2765 * @map: Register map to update 2661 * @map: Register map to update
2766 * @reg: Register to update 2662 * @reg: Register to update
2767 * @mask: Bitmask to change 2663 * @mask: Bitmask to change
2768 * @val: New value for bitmask 2664 * @val: New value for bitmask
2769 * @change: Boolean indicating if a write was done
2770 *
2771 * With most buses the read must be done synchronously so this is most
2772 * useful for devices with a cache which do not need to interact with
2773 * the hardware to determine the current register value.
2774 * 2665 *
2775 * Returns zero for success, a negative number on error. 2666 * Returns zero for success, a negative number on error.
2776 */ 2667 */
2777int regmap_update_bits_check_async(struct regmap *map, unsigned int reg, 2668int regmap_write_bits(struct regmap *map, unsigned int reg,
2778 unsigned int mask, unsigned int val, 2669 unsigned int mask, unsigned int val)
2779 bool *change)
2780{ 2670{
2781 int ret; 2671 int ret;
2782 2672
2783 map->lock(map->lock_arg); 2673 map->lock(map->lock_arg);
2784 2674 ret = _regmap_update_bits(map, reg, mask, val, NULL, true);
2785 map->async = true;
2786
2787 ret = _regmap_update_bits(map, reg, mask, val, change, false);
2788
2789 map->async = false;
2790
2791 map->unlock(map->lock_arg); 2675 map->unlock(map->lock_arg);
2792 2676
2793 return ret; 2677 return ret;
2794} 2678}
2795EXPORT_SYMBOL_GPL(regmap_update_bits_check_async); 2679EXPORT_SYMBOL_GPL(regmap_write_bits);
2796 2680
2797void regmap_async_complete_cb(struct regmap_async *async, int ret) 2681void regmap_async_complete_cb(struct regmap_async *async, int ret)
2798{ 2682{