mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-12-05 10:04:12 +08:00
regmap: Force write support
This allows users to use _update_bits() without the write suppression, useful for some hardware. -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQEcBAABAgAGBQJVn6DOAAoJECTWi3JdVIfQIb8H+wVh2/P7OJNL+GjESuzCMg24 sBbM6dqqBtb9eYvuKIioRAvSsOqKtwEZ06ntQIWI+Yyb7k0DuvOZ26iJMTabwZys nCokCiCnA42LWortts6H0NvdDwrJNlKMB55SLh8eFJIv1ZVFvMC+fcj+HOxL02Sn 0I0jhTgphhSau8WBBzLsGokVs34UcNTnS3F5SxuOw4HDS9c/HZIDE64ykNqAliD/ +xGW0jcUlx/FCoAPFTZVOmUzfeQTbeXD2s21KmUfG+ObeMuJyyFrbdeVb6IxPlTM vg6426H+jRXJFTq0v5Ozy0xpOS12lAxnFb+xmNzTpNJhzmJxKTcBXMVYmT//MoI= =fNFo -----END PGP SIGNATURE----- Merge tag 'regmap-force' into asoc-rcar regmap: Force write support This allows users to use _update_bits() without the write suppression, useful for some hardware.
This commit is contained in:
commit
d1b080290f
@ -34,7 +34,7 @@
|
||||
|
||||
static int _regmap_update_bits(struct regmap *map, unsigned int reg,
|
||||
unsigned int mask, unsigned int val,
|
||||
bool *change);
|
||||
bool *change, bool force_write);
|
||||
|
||||
static int _regmap_bus_reg_read(void *context, unsigned int reg,
|
||||
unsigned int *val);
|
||||
@ -1178,7 +1178,7 @@ static int _regmap_select_page(struct regmap *map, unsigned int *reg,
|
||||
ret = _regmap_update_bits(map, range->selector_reg,
|
||||
range->selector_mask,
|
||||
win_page << range->selector_shift,
|
||||
&page_chg);
|
||||
&page_chg, false);
|
||||
|
||||
map->work_buf = orig_work_buf;
|
||||
|
||||
@ -1624,6 +1624,18 @@ int regmap_fields_write(struct regmap_field *field, unsigned int id,
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(regmap_fields_write);
|
||||
|
||||
int regmap_fields_force_write(struct regmap_field *field, unsigned int id,
|
||||
unsigned int val)
|
||||
{
|
||||
if (id >= field->id_size)
|
||||
return -EINVAL;
|
||||
|
||||
return regmap_write_bits(field->regmap,
|
||||
field->reg + (field->id_offset * id),
|
||||
field->mask, val << field->shift);
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(regmap_fields_force_write);
|
||||
|
||||
/**
|
||||
* regmap_fields_update_bits(): Perform a read/modify/write cycle
|
||||
* on the register field
|
||||
@ -2327,7 +2339,7 @@ EXPORT_SYMBOL_GPL(regmap_bulk_read);
|
||||
|
||||
static int _regmap_update_bits(struct regmap *map, unsigned int reg,
|
||||
unsigned int mask, unsigned int val,
|
||||
bool *change)
|
||||
bool *change, bool force_write)
|
||||
{
|
||||
int ret;
|
||||
unsigned int tmp, orig;
|
||||
@ -2339,7 +2351,7 @@ static int _regmap_update_bits(struct regmap *map, unsigned int reg,
|
||||
tmp = orig & ~mask;
|
||||
tmp |= val & mask;
|
||||
|
||||
if (tmp != orig) {
|
||||
if (force_write || (tmp != orig)) {
|
||||
ret = _regmap_write(map, reg, tmp);
|
||||
if (change)
|
||||
*change = true;
|
||||
@ -2367,13 +2379,36 @@ int regmap_update_bits(struct regmap *map, unsigned int reg,
|
||||
int ret;
|
||||
|
||||
map->lock(map->lock_arg);
|
||||
ret = _regmap_update_bits(map, reg, mask, val, NULL);
|
||||
ret = _regmap_update_bits(map, reg, mask, val, NULL, false);
|
||||
map->unlock(map->lock_arg);
|
||||
|
||||
return ret;
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(regmap_update_bits);
|
||||
|
||||
/**
|
||||
* regmap_write_bits: Perform a read/modify/write cycle on the register map
|
||||
*
|
||||
* @map: Register map to update
|
||||
* @reg: Register to update
|
||||
* @mask: Bitmask to change
|
||||
* @val: New value for bitmask
|
||||
*
|
||||
* Returns zero for success, a negative number on error.
|
||||
*/
|
||||
int regmap_write_bits(struct regmap *map, unsigned int reg,
|
||||
unsigned int mask, unsigned int val)
|
||||
{
|
||||
int ret;
|
||||
|
||||
map->lock(map->lock_arg);
|
||||
ret = _regmap_update_bits(map, reg, mask, val, NULL, true);
|
||||
map->unlock(map->lock_arg);
|
||||
|
||||
return ret;
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(regmap_write_bits);
|
||||
|
||||
/**
|
||||
* regmap_update_bits_async: Perform a read/modify/write cycle on the register
|
||||
* map asynchronously
|
||||
@ -2398,7 +2433,7 @@ int regmap_update_bits_async(struct regmap *map, unsigned int reg,
|
||||
|
||||
map->async = true;
|
||||
|
||||
ret = _regmap_update_bits(map, reg, mask, val, NULL);
|
||||
ret = _regmap_update_bits(map, reg, mask, val, NULL, false);
|
||||
|
||||
map->async = false;
|
||||
|
||||
@ -2427,7 +2462,7 @@ int regmap_update_bits_check(struct regmap *map, unsigned int reg,
|
||||
int ret;
|
||||
|
||||
map->lock(map->lock_arg);
|
||||
ret = _regmap_update_bits(map, reg, mask, val, change);
|
||||
ret = _regmap_update_bits(map, reg, mask, val, change, false);
|
||||
map->unlock(map->lock_arg);
|
||||
return ret;
|
||||
}
|
||||
@ -2460,7 +2495,7 @@ int regmap_update_bits_check_async(struct regmap *map, unsigned int reg,
|
||||
|
||||
map->async = true;
|
||||
|
||||
ret = _regmap_update_bits(map, reg, mask, val, change);
|
||||
ret = _regmap_update_bits(map, reg, mask, val, change, false);
|
||||
|
||||
map->async = false;
|
||||
|
||||
|
@ -424,6 +424,8 @@ int regmap_bulk_read(struct regmap *map, unsigned int reg, void *val,
|
||||
size_t val_count);
|
||||
int regmap_update_bits(struct regmap *map, unsigned int reg,
|
||||
unsigned int mask, unsigned int val);
|
||||
int regmap_write_bits(struct regmap *map, unsigned int reg,
|
||||
unsigned int mask, unsigned int val);
|
||||
int regmap_update_bits_async(struct regmap *map, unsigned int reg,
|
||||
unsigned int mask, unsigned int val);
|
||||
int regmap_update_bits_check(struct regmap *map, unsigned int reg,
|
||||
@ -503,6 +505,8 @@ int regmap_field_update_bits(struct regmap_field *field,
|
||||
|
||||
int regmap_fields_write(struct regmap_field *field, unsigned int id,
|
||||
unsigned int val);
|
||||
int regmap_fields_force_write(struct regmap_field *field, unsigned int id,
|
||||
unsigned int val);
|
||||
int regmap_fields_read(struct regmap_field *field, unsigned int id,
|
||||
unsigned int *val);
|
||||
int regmap_fields_update_bits(struct regmap_field *field, unsigned int id,
|
||||
@ -645,6 +649,13 @@ static inline int regmap_update_bits(struct regmap *map, unsigned int reg,
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
static inline int regmap_write_bits(struct regmap *map, unsigned int reg,
|
||||
unsigned int mask, unsigned int val)
|
||||
{
|
||||
WARN_ONCE(1, "regmap API is disabled");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
static inline int regmap_update_bits_async(struct regmap *map,
|
||||
unsigned int reg,
|
||||
unsigned int mask, unsigned int val)
|
||||
|
Loading…
Reference in New Issue
Block a user