2
0
mirror of https://github.com/edk2-porting/linux-next.git synced 2024-12-15 16:53:54 +08:00

Merge remote-tracking branch 'regmap/topic/update-bits' into regmap-next

This commit is contained in:
Mark Brown 2016-03-05 21:30:41 +09:00
commit d25263d917
2 changed files with 89 additions and 227 deletions

View File

@ -1698,100 +1698,63 @@ int regmap_raw_write(struct regmap *map, unsigned int reg,
EXPORT_SYMBOL_GPL(regmap_raw_write); EXPORT_SYMBOL_GPL(regmap_raw_write);
/** /**
* regmap_field_write(): Write a value to a single register field * regmap_field_update_bits_base():
* * Perform a read/modify/write cycle on the register field
* @field: Register field to write to * with change, async, force option
* @val: Value to be written
*
* A value of zero will be returned on success, a negative errno will
* be returned in error cases.
*/
int regmap_field_write(struct regmap_field *field, unsigned int val)
{
return regmap_update_bits(field->regmap, field->reg,
field->mask, val << field->shift);
}
EXPORT_SYMBOL_GPL(regmap_field_write);
/**
* regmap_field_update_bits(): Perform a read/modify/write cycle
* on the register field
* *
* @field: Register field to write to * @field: Register field to write to
* @mask: Bitmask to change * @mask: Bitmask to change
* @val: Value to be written * @val: Value to be written
* @change: Boolean indicating if a write was done
* @async: Boolean indicating asynchronously
* @force: Boolean indicating use force update
* *
* A value of zero will be returned on success, a negative errno will * A value of zero will be returned on success, a negative errno will
* be returned in error cases. * be returned in error cases.
*/ */
int regmap_field_update_bits(struct regmap_field *field, unsigned int mask, unsigned int val) int regmap_field_update_bits_base(struct regmap_field *field,
unsigned int mask, unsigned int val,
bool *change, bool async, bool force)
{ {
mask = (mask << field->shift) & field->mask; mask = (mask << field->shift) & field->mask;
return regmap_update_bits(field->regmap, field->reg, return regmap_update_bits_base(field->regmap, field->reg,
mask, val << field->shift); mask, val << field->shift,
change, async, force);
} }
EXPORT_SYMBOL_GPL(regmap_field_update_bits); EXPORT_SYMBOL_GPL(regmap_field_update_bits_base);
/** /**
* regmap_fields_write(): Write a value to a single register field with port ID * regmap_fields_update_bits_base():
* * Perform a read/modify/write cycle on the register field
* @field: Register field to write to * with change, async, force option
* @id: port ID
* @val: Value to be written
*
* A value of zero will be returned on success, a negative errno will
* be returned in error cases.
*/
int regmap_fields_write(struct regmap_field *field, unsigned int id,
unsigned int val)
{
if (id >= field->id_size)
return -EINVAL;
return regmap_update_bits(field->regmap,
field->reg + (field->id_offset * id),
field->mask, val << field->shift);
}
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
* *
* @field: Register field to write to * @field: Register field to write to
* @id: port ID * @id: port ID
* @mask: Bitmask to change * @mask: Bitmask to change
* @val: Value to be written * @val: Value to be written
* @change: Boolean indicating if a write was done
* @async: Boolean indicating asynchronously
* @force: Boolean indicating use force update
* *
* A value of zero will be returned on success, a negative errno will * A value of zero will be returned on success, a negative errno will
* be returned in error cases. * be returned in error cases.
*/ */
int regmap_fields_update_bits(struct regmap_field *field, unsigned int id, int regmap_fields_update_bits_base(struct regmap_field *field, unsigned int id,
unsigned int mask, unsigned int val) unsigned int mask, unsigned int val,
bool *change, bool async, bool force)
{ {
if (id >= field->id_size) if (id >= field->id_size)
return -EINVAL; return -EINVAL;
mask = (mask << field->shift) & field->mask; mask = (mask << field->shift) & field->mask;
return regmap_update_bits(field->regmap, return regmap_update_bits_base(field->regmap,
field->reg + (field->id_offset * id), field->reg + (field->id_offset * id),
mask, val << field->shift); mask, val << field->shift,
change, async, force);
} }
EXPORT_SYMBOL_GPL(regmap_fields_update_bits); EXPORT_SYMBOL_GPL(regmap_fields_update_bits_base);
/* /*
* regmap_bulk_write(): Write multiple registers to the device * regmap_bulk_write(): Write multiple registers to the device
@ -2660,76 +2623,36 @@ static int _regmap_update_bits(struct regmap *map, unsigned int reg,
} }
/** /**
* regmap_update_bits: Perform a read/modify/write cycle on the register map * regmap_update_bits_base:
* * Perform a read/modify/write cycle on the
* @map: Register map to update * register map with change, async, force option
* @reg: Register to update
* @mask: Bitmask to change
* @val: New value for bitmask
*
* Returns zero for success, a negative number on error.
*/
int regmap_update_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, 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
* *
* @map: Register map to update * @map: Register map to update
* @reg: Register to update * @reg: Register to update
* @mask: Bitmask to change * @mask: Bitmask to change
* @val: New value for bitmask * @val: New value for bitmask
* @change: Boolean indicating if a write was done
* @async: Boolean indicating asynchronously
* @force: Boolean indicating use force update
* *
* if async was true,
* With most buses the read must be done synchronously so this is most * With most buses the read must be done synchronously so this is most
* useful for devices with a cache which do not need to interact with * useful for devices with a cache which do not need to interact with
* the hardware to determine the current register value. * the hardware to determine the current register value.
* *
* Returns zero for success, a negative number on error. * Returns zero for success, a negative number on error.
*/ */
int regmap_update_bits_async(struct regmap *map, unsigned int reg, int regmap_update_bits_base(struct regmap *map, unsigned int reg,
unsigned int mask, unsigned int val) unsigned int mask, unsigned int val,
bool *change, bool async, bool force)
{ {
int ret; int ret;
map->lock(map->lock_arg); map->lock(map->lock_arg);
map->async = true; map->async = async;
ret = _regmap_update_bits(map, reg, mask, val, NULL, false); ret = _regmap_update_bits(map, reg, mask, val, change, force);
map->async = false; map->async = false;
@ -2737,69 +2660,7 @@ int regmap_update_bits_async(struct regmap *map, unsigned int reg,
return ret; return ret;
} }
EXPORT_SYMBOL_GPL(regmap_update_bits_async); EXPORT_SYMBOL_GPL(regmap_update_bits_base);
/**
* regmap_update_bits_check: Perform a read/modify/write cycle on the
* register map and report if updated
*
* @map: Register map to update
* @reg: Register to update
* @mask: Bitmask to change
* @val: New value for bitmask
* @change: Boolean indicating if a write was done
*
* Returns zero for success, a negative number on error.
*/
int regmap_update_bits_check(struct regmap *map, unsigned int reg,
unsigned int mask, unsigned int val,
bool *change)
{
int ret;
map->lock(map->lock_arg);
ret = _regmap_update_bits(map, reg, mask, val, change, false);
map->unlock(map->lock_arg);
return ret;
}
EXPORT_SYMBOL_GPL(regmap_update_bits_check);
/**
* regmap_update_bits_check_async: Perform a read/modify/write cycle on the
* register map asynchronously and report if
* updated
*
* @map: Register map to update
* @reg: Register to update
* @mask: Bitmask to change
* @val: New value for bitmask
* @change: Boolean indicating if a write was done
*
* With most buses the read must be done synchronously so this is most
* useful for devices with a cache which do not need to interact with
* the hardware to determine the current register value.
*
* Returns zero for success, a negative number on error.
*/
int regmap_update_bits_check_async(struct regmap *map, unsigned int reg,
unsigned int mask, unsigned int val,
bool *change)
{
int ret;
map->lock(map->lock_arg);
map->async = true;
ret = _regmap_update_bits(map, reg, mask, val, change, false);
map->async = false;
map->unlock(map->lock_arg);
return ret;
}
EXPORT_SYMBOL_GPL(regmap_update_bits_check_async);
void regmap_async_complete_cb(struct regmap_async *async, int ret) void regmap_async_complete_cb(struct regmap_async *async, int ret)
{ {

View File

@ -65,6 +65,36 @@ struct reg_sequence {
unsigned int delay_us; unsigned int delay_us;
}; };
#define regmap_update_bits(map, reg, mask, val) \
regmap_update_bits_base(map, reg, mask, val, NULL, false, false)
#define regmap_update_bits_async(map, reg, mask, val)\
regmap_update_bits_base(map, reg, mask, val, NULL, true, false)
#define regmap_update_bits_check(map, reg, mask, val, change)\
regmap_update_bits_base(map, reg, mask, val, change, false, false)
#define regmap_update_bits_check_async(map, reg, mask, val, change)\
regmap_update_bits_base(map, reg, mask, val, change, true, false)
#define regmap_write_bits(map, reg, mask, val) \
regmap_update_bits_base(map, reg, mask, val, NULL, false, true)
#define regmap_field_write(field, val) \
regmap_field_update_bits_base(field, ~0, val, NULL, false, false)
#define regmap_field_force_write(field, val) \
regmap_field_update_bits_base(field, ~0, val, NULL, false, true)
#define regmap_field_update_bits(field, mask, val)\
regmap_field_update_bits_base(field, mask, val, NULL, false, false)
#define regmap_field_force_update_bits(field, mask, val) \
regmap_field_update_bits_base(field, mask, val, NULL, false, true)
#define regmap_fields_write(field, id, val) \
regmap_fields_update_bits_base(field, id, ~0, val, NULL, false, false)
#define regmap_fields_force_write(field, id, val) \
regmap_fields_update_bits_base(field, id, ~0, val, NULL, false, true)
#define regmap_fields_update_bits(field, id, mask, val)\
regmap_fields_update_bits_base(field, id, mask, val, NULL, false, false)
#define regmap_fields_force_update_bits(field, id, mask, val) \
regmap_fields_update_bits_base(field, id, mask, val, NULL, false, true)
#ifdef CONFIG_REGMAP #ifdef CONFIG_REGMAP
enum regmap_endian { enum regmap_endian {
@ -691,18 +721,9 @@ int regmap_raw_read(struct regmap *map, unsigned int reg,
void *val, size_t val_len); void *val, size_t val_len);
int regmap_bulk_read(struct regmap *map, unsigned int reg, void *val, int regmap_bulk_read(struct regmap *map, unsigned int reg, void *val,
size_t val_count); size_t val_count);
int regmap_update_bits(struct regmap *map, unsigned int reg, int regmap_update_bits_base(struct regmap *map, unsigned int reg,
unsigned int mask, unsigned int val); unsigned int mask, unsigned int val,
int regmap_write_bits(struct regmap *map, unsigned int reg, bool *change, bool async, bool force);
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,
unsigned int mask, unsigned int val,
bool *change);
int regmap_update_bits_check_async(struct regmap *map, unsigned int reg,
unsigned int mask, unsigned int val,
bool *change);
int regmap_get_val_bytes(struct regmap *map); int regmap_get_val_bytes(struct regmap *map);
int regmap_get_max_register(struct regmap *map); int regmap_get_max_register(struct regmap *map);
int regmap_get_reg_stride(struct regmap *map); int regmap_get_reg_stride(struct regmap *map);
@ -770,18 +791,14 @@ struct regmap_field *devm_regmap_field_alloc(struct device *dev,
void devm_regmap_field_free(struct device *dev, struct regmap_field *field); void devm_regmap_field_free(struct device *dev, struct regmap_field *field);
int regmap_field_read(struct regmap_field *field, unsigned int *val); int regmap_field_read(struct regmap_field *field, unsigned int *val);
int regmap_field_write(struct regmap_field *field, unsigned int val); int regmap_field_update_bits_base(struct regmap_field *field,
int regmap_field_update_bits(struct regmap_field *field, unsigned int mask, unsigned int val,
unsigned int mask, unsigned int val); bool *change, bool async, bool force);
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, int regmap_fields_read(struct regmap_field *field, unsigned int id,
unsigned int *val); unsigned int *val);
int regmap_fields_update_bits(struct regmap_field *field, unsigned int id, int regmap_fields_update_bits_base(struct regmap_field *field, unsigned int id,
unsigned int mask, unsigned int val); unsigned int mask, unsigned int val,
bool *change, bool async, bool force);
/** /**
* Description of an IRQ for the generic regmap irq_chip. * Description of an IRQ for the generic regmap irq_chip.
@ -945,42 +962,26 @@ static inline int regmap_bulk_read(struct regmap *map, unsigned int reg,
return -EINVAL; return -EINVAL;
} }
static inline int regmap_update_bits(struct regmap *map, unsigned int reg, static inline int regmap_update_bits_base(struct regmap *map, unsigned int reg,
unsigned int mask, unsigned int val) unsigned int mask, unsigned int val,
bool *change, bool async, bool force)
{ {
WARN_ONCE(1, "regmap API is disabled"); WARN_ONCE(1, "regmap API is disabled");
return -EINVAL; return -EINVAL;
} }
static inline int regmap_write_bits(struct regmap *map, unsigned int reg, static inline int regmap_field_update_bits_base(struct regmap_field *field,
unsigned int mask, unsigned int val) unsigned int mask, unsigned int val,
bool *change, bool async, bool force)
{ {
WARN_ONCE(1, "regmap API is disabled"); WARN_ONCE(1, "regmap API is disabled");
return -EINVAL; return -EINVAL;
} }
static inline int regmap_update_bits_async(struct regmap *map, static inline int regmap_fields_update_bits_base(struct regmap_field *field,
unsigned int reg, unsigned int id,
unsigned int mask, unsigned int val) unsigned int mask, unsigned int val,
{ bool *change, bool async, bool force)
WARN_ONCE(1, "regmap API is disabled");
return -EINVAL;
}
static inline int regmap_update_bits_check(struct regmap *map,
unsigned int reg,
unsigned int mask, unsigned int val,
bool *change)
{
WARN_ONCE(1, "regmap API is disabled");
return -EINVAL;
}
static inline int regmap_update_bits_check_async(struct regmap *map,
unsigned int reg,
unsigned int mask,
unsigned int val,
bool *change)
{ {
WARN_ONCE(1, "regmap API is disabled"); WARN_ONCE(1, "regmap API is disabled");
return -EINVAL; return -EINVAL;