|
@@ -158,6 +158,26 @@ static unsigned int regmap_parse_32(void *buf)
|
|
|
return b[0];
|
|
|
}
|
|
|
|
|
|
+static void regmap_lock_mutex(struct regmap *map)
|
|
|
+{
|
|
|
+ mutex_lock(&map->mutex);
|
|
|
+}
|
|
|
+
|
|
|
+static void regmap_unlock_mutex(struct regmap *map)
|
|
|
+{
|
|
|
+ mutex_unlock(&map->mutex);
|
|
|
+}
|
|
|
+
|
|
|
+static void regmap_lock_spinlock(struct regmap *map)
|
|
|
+{
|
|
|
+ spin_lock(&map->spinlock);
|
|
|
+}
|
|
|
+
|
|
|
+static void regmap_unlock_spinlock(struct regmap *map)
|
|
|
+{
|
|
|
+ spin_unlock(&map->spinlock);
|
|
|
+}
|
|
|
+
|
|
|
/**
|
|
|
* regmap_init(): Initialise register map
|
|
|
*
|
|
@@ -187,7 +207,15 @@ struct regmap *regmap_init(struct device *dev,
|
|
|
goto err;
|
|
|
}
|
|
|
|
|
|
- mutex_init(&map->lock);
|
|
|
+ if (bus->fast_io) {
|
|
|
+ spin_lock_init(&map->spinlock);
|
|
|
+ map->lock = regmap_lock_spinlock;
|
|
|
+ map->unlock = regmap_unlock_spinlock;
|
|
|
+ } else {
|
|
|
+ mutex_init(&map->mutex);
|
|
|
+ map->lock = regmap_lock_mutex;
|
|
|
+ map->unlock = regmap_unlock_mutex;
|
|
|
+ }
|
|
|
map->format.buf_size = (config->reg_bits + config->val_bits) / 8;
|
|
|
map->format.reg_bytes = DIV_ROUND_UP(config->reg_bits, 8);
|
|
|
map->format.pad_bytes = config->pad_bits / 8;
|
|
@@ -365,7 +393,7 @@ int regmap_reinit_cache(struct regmap *map, const struct regmap_config *config)
|
|
|
{
|
|
|
int ret;
|
|
|
|
|
|
- mutex_lock(&map->lock);
|
|
|
+ map->lock(map);
|
|
|
|
|
|
regcache_exit(map);
|
|
|
regmap_debugfs_exit(map);
|
|
@@ -384,7 +412,7 @@ int regmap_reinit_cache(struct regmap *map, const struct regmap_config *config)
|
|
|
|
|
|
ret = regcache_init(map, config);
|
|
|
|
|
|
- mutex_unlock(&map->lock);
|
|
|
+ map->unlock(map);
|
|
|
|
|
|
return ret;
|
|
|
}
|
|
@@ -536,11 +564,11 @@ int regmap_write(struct regmap *map, unsigned int reg, unsigned int val)
|
|
|
{
|
|
|
int ret;
|
|
|
|
|
|
- mutex_lock(&map->lock);
|
|
|
+ map->lock(map);
|
|
|
|
|
|
ret = _regmap_write(map, reg, val);
|
|
|
|
|
|
- mutex_unlock(&map->lock);
|
|
|
+ map->unlock(map);
|
|
|
|
|
|
return ret;
|
|
|
}
|
|
@@ -567,11 +595,11 @@ int regmap_raw_write(struct regmap *map, unsigned int reg,
|
|
|
{
|
|
|
int ret;
|
|
|
|
|
|
- mutex_lock(&map->lock);
|
|
|
+ map->lock(map);
|
|
|
|
|
|
ret = _regmap_raw_write(map, reg, val, val_len);
|
|
|
|
|
|
- mutex_unlock(&map->lock);
|
|
|
+ map->unlock(map);
|
|
|
|
|
|
return ret;
|
|
|
}
|
|
@@ -601,7 +629,7 @@ int regmap_bulk_write(struct regmap *map, unsigned int reg, const void *val,
|
|
|
if (!map->format.parse_val)
|
|
|
return -EINVAL;
|
|
|
|
|
|
- mutex_lock(&map->lock);
|
|
|
+ map->lock(map);
|
|
|
|
|
|
/* No formatting is require if val_byte is 1 */
|
|
|
if (val_bytes == 1) {
|
|
@@ -622,7 +650,7 @@ int regmap_bulk_write(struct regmap *map, unsigned int reg, const void *val,
|
|
|
kfree(wval);
|
|
|
|
|
|
out:
|
|
|
- mutex_unlock(&map->lock);
|
|
|
+ map->unlock(map);
|
|
|
return ret;
|
|
|
}
|
|
|
EXPORT_SYMBOL_GPL(regmap_bulk_write);
|
|
@@ -696,11 +724,11 @@ int regmap_read(struct regmap *map, unsigned int reg, unsigned int *val)
|
|
|
{
|
|
|
int ret;
|
|
|
|
|
|
- mutex_lock(&map->lock);
|
|
|
+ map->lock(map);
|
|
|
|
|
|
ret = _regmap_read(map, reg, val);
|
|
|
|
|
|
- mutex_unlock(&map->lock);
|
|
|
+ map->unlock(map);
|
|
|
|
|
|
return ret;
|
|
|
}
|
|
@@ -725,7 +753,7 @@ int regmap_raw_read(struct regmap *map, unsigned int reg, void *val,
|
|
|
unsigned int v;
|
|
|
int ret, i;
|
|
|
|
|
|
- mutex_lock(&map->lock);
|
|
|
+ map->lock(map);
|
|
|
|
|
|
if (regmap_volatile_range(map, reg, val_count) || map->cache_bypass ||
|
|
|
map->cache_type == REGCACHE_NONE) {
|
|
@@ -746,7 +774,7 @@ int regmap_raw_read(struct regmap *map, unsigned int reg, void *val,
|
|
|
}
|
|
|
|
|
|
out:
|
|
|
- mutex_unlock(&map->lock);
|
|
|
+ map->unlock(map);
|
|
|
|
|
|
return ret;
|
|
|
}
|
|
@@ -799,7 +827,7 @@ static int _regmap_update_bits(struct regmap *map, unsigned int reg,
|
|
|
int ret;
|
|
|
unsigned int tmp, orig;
|
|
|
|
|
|
- mutex_lock(&map->lock);
|
|
|
+ map->lock(map);
|
|
|
|
|
|
ret = _regmap_read(map, reg, &orig);
|
|
|
if (ret != 0)
|
|
@@ -816,7 +844,7 @@ static int _regmap_update_bits(struct regmap *map, unsigned int reg,
|
|
|
}
|
|
|
|
|
|
out:
|
|
|
- mutex_unlock(&map->lock);
|
|
|
+ map->unlock(map);
|
|
|
|
|
|
return ret;
|
|
|
}
|
|
@@ -883,7 +911,7 @@ int regmap_register_patch(struct regmap *map, const struct reg_default *regs,
|
|
|
if (map->patch)
|
|
|
return -EBUSY;
|
|
|
|
|
|
- mutex_lock(&map->lock);
|
|
|
+ map->lock(map);
|
|
|
|
|
|
bypass = map->cache_bypass;
|
|
|
|
|
@@ -911,7 +939,7 @@ int regmap_register_patch(struct regmap *map, const struct reg_default *regs,
|
|
|
out:
|
|
|
map->cache_bypass = bypass;
|
|
|
|
|
|
- mutex_unlock(&map->lock);
|
|
|
+ map->unlock(map);
|
|
|
|
|
|
return ret;
|
|
|
}
|