Merge remote-tracking branches 'regmap/topic/const' and 'regmap/topic/hwspinlock' into regmap-next
This commit is contained in:
commit
a15fdc340d
|
@ -5,6 +5,7 @@
|
||||||
config REGMAP
|
config REGMAP
|
||||||
default y if (REGMAP_I2C || REGMAP_SPI || REGMAP_SPMI || REGMAP_W1 || REGMAP_AC97 || REGMAP_MMIO || REGMAP_IRQ)
|
default y if (REGMAP_I2C || REGMAP_SPI || REGMAP_SPMI || REGMAP_W1 || REGMAP_AC97 || REGMAP_MMIO || REGMAP_IRQ)
|
||||||
select IRQ_DOMAIN if REGMAP_IRQ
|
select IRQ_DOMAIN if REGMAP_IRQ
|
||||||
|
select REGMAP_HWSPINLOCK if HWSPINLOCK=y
|
||||||
bool
|
bool
|
||||||
|
|
||||||
config REGCACHE_COMPRESSED
|
config REGCACHE_COMPRESSED
|
||||||
|
@ -36,3 +37,6 @@ config REGMAP_MMIO
|
||||||
|
|
||||||
config REGMAP_IRQ
|
config REGMAP_IRQ
|
||||||
bool
|
bool
|
||||||
|
|
||||||
|
config REGMAP_HWSPINLOCK
|
||||||
|
bool
|
||||||
|
|
|
@ -157,6 +157,8 @@ struct regmap {
|
||||||
|
|
||||||
struct rb_root range_tree;
|
struct rb_root range_tree;
|
||||||
void *selector_work_buf; /* Scratch buffer used for selector */
|
void *selector_work_buf; /* Scratch buffer used for selector */
|
||||||
|
|
||||||
|
struct hwspinlock *hwlock;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct regcache_ops {
|
struct regcache_ops {
|
||||||
|
|
|
@ -102,7 +102,7 @@ static int regmap_spi_read(void *context,
|
||||||
return spi_write_then_read(spi, reg, reg_size, val, val_size);
|
return spi_write_then_read(spi, reg, reg_size, val, val_size);
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct regmap_bus regmap_spi = {
|
static const struct regmap_bus regmap_spi = {
|
||||||
.write = regmap_spi_write,
|
.write = regmap_spi_write,
|
||||||
.gather_write = regmap_spi_gather_write,
|
.gather_write = regmap_spi_gather_write,
|
||||||
.async_write = regmap_spi_async_write,
|
.async_write = regmap_spi_async_write,
|
||||||
|
|
|
@ -83,7 +83,7 @@ static int regmap_spmi_base_write(void *context, const void *data,
|
||||||
count - 1);
|
count - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct regmap_bus regmap_spmi_base = {
|
static const struct regmap_bus regmap_spmi_base = {
|
||||||
.read = regmap_spmi_base_read,
|
.read = regmap_spmi_base_read,
|
||||||
.write = regmap_spmi_base_write,
|
.write = regmap_spmi_base_write,
|
||||||
.gather_write = regmap_spmi_base_gather_write,
|
.gather_write = regmap_spmi_base_gather_write,
|
||||||
|
@ -203,7 +203,7 @@ static int regmap_spmi_ext_write(void *context, const void *data,
|
||||||
count - 2);
|
count - 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct regmap_bus regmap_spmi_ext = {
|
static const struct regmap_bus regmap_spmi_ext = {
|
||||||
.read = regmap_spmi_ext_read,
|
.read = regmap_spmi_ext_read,
|
||||||
.write = regmap_spmi_ext_write,
|
.write = regmap_spmi_ext_write,
|
||||||
.gather_write = regmap_spmi_ext_gather_write,
|
.gather_write = regmap_spmi_ext_gather_write,
|
||||||
|
|
|
@ -20,6 +20,7 @@
|
||||||
#include <linux/sched.h>
|
#include <linux/sched.h>
|
||||||
#include <linux/delay.h>
|
#include <linux/delay.h>
|
||||||
#include <linux/log2.h>
|
#include <linux/log2.h>
|
||||||
|
#include <linux/hwspinlock.h>
|
||||||
|
|
||||||
#define CREATE_TRACE_POINTS
|
#define CREATE_TRACE_POINTS
|
||||||
#include "trace.h"
|
#include "trace.h"
|
||||||
|
@ -413,6 +414,51 @@ static unsigned int regmap_parse_64_native(const void *buf)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef REGMAP_HWSPINLOCK
|
||||||
|
static void regmap_lock_hwlock(void *__map)
|
||||||
|
{
|
||||||
|
struct regmap *map = __map;
|
||||||
|
|
||||||
|
hwspin_lock_timeout(map->hwlock, UINT_MAX);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void regmap_lock_hwlock_irq(void *__map)
|
||||||
|
{
|
||||||
|
struct regmap *map = __map;
|
||||||
|
|
||||||
|
hwspin_lock_timeout_irq(map->hwlock, UINT_MAX);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void regmap_lock_hwlock_irqsave(void *__map)
|
||||||
|
{
|
||||||
|
struct regmap *map = __map;
|
||||||
|
|
||||||
|
hwspin_lock_timeout_irqsave(map->hwlock, UINT_MAX,
|
||||||
|
&map->spinlock_flags);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void regmap_unlock_hwlock(void *__map)
|
||||||
|
{
|
||||||
|
struct regmap *map = __map;
|
||||||
|
|
||||||
|
hwspin_unlock(map->hwlock);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void regmap_unlock_hwlock_irq(void *__map)
|
||||||
|
{
|
||||||
|
struct regmap *map = __map;
|
||||||
|
|
||||||
|
hwspin_unlock_irq(map->hwlock);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void regmap_unlock_hwlock_irqrestore(void *__map)
|
||||||
|
{
|
||||||
|
struct regmap *map = __map;
|
||||||
|
|
||||||
|
hwspin_unlock_irqrestore(map->hwlock, &map->spinlock_flags);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
static void regmap_lock_mutex(void *__map)
|
static void regmap_lock_mutex(void *__map)
|
||||||
{
|
{
|
||||||
struct regmap *map = __map;
|
struct regmap *map = __map;
|
||||||
|
@ -627,6 +673,34 @@ struct regmap *__regmap_init(struct device *dev,
|
||||||
map->lock = config->lock;
|
map->lock = config->lock;
|
||||||
map->unlock = config->unlock;
|
map->unlock = config->unlock;
|
||||||
map->lock_arg = config->lock_arg;
|
map->lock_arg = config->lock_arg;
|
||||||
|
} else if (config->hwlock_id) {
|
||||||
|
#ifdef REGMAP_HWSPINLOCK
|
||||||
|
map->hwlock = hwspin_lock_request_specific(config->hwlock_id);
|
||||||
|
if (!map->hwlock) {
|
||||||
|
ret = -ENXIO;
|
||||||
|
goto err_map;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (config->hwlock_mode) {
|
||||||
|
case HWLOCK_IRQSTATE:
|
||||||
|
map->lock = regmap_lock_hwlock_irqsave;
|
||||||
|
map->unlock = regmap_unlock_hwlock_irqrestore;
|
||||||
|
break;
|
||||||
|
case HWLOCK_IRQ:
|
||||||
|
map->lock = regmap_lock_hwlock_irq;
|
||||||
|
map->unlock = regmap_unlock_hwlock_irq;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
map->lock = regmap_lock_hwlock;
|
||||||
|
map->unlock = regmap_unlock_hwlock;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
map->lock_arg = map;
|
||||||
|
#else
|
||||||
|
ret = -EINVAL;
|
||||||
|
goto err_map;
|
||||||
|
#endif
|
||||||
} else {
|
} else {
|
||||||
if ((bus && bus->fast_io) ||
|
if ((bus && bus->fast_io) ||
|
||||||
config->fast_io) {
|
config->fast_io) {
|
||||||
|
@ -729,7 +803,7 @@ struct regmap *__regmap_init(struct device *dev,
|
||||||
map->format.format_write = regmap_format_2_6_write;
|
map->format.format_write = regmap_format_2_6_write;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
goto err_map;
|
goto err_hwlock;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -739,7 +813,7 @@ struct regmap *__regmap_init(struct device *dev,
|
||||||
map->format.format_write = regmap_format_4_12_write;
|
map->format.format_write = regmap_format_4_12_write;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
goto err_map;
|
goto err_hwlock;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -749,7 +823,7 @@ struct regmap *__regmap_init(struct device *dev,
|
||||||
map->format.format_write = regmap_format_7_9_write;
|
map->format.format_write = regmap_format_7_9_write;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
goto err_map;
|
goto err_hwlock;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -759,7 +833,7 @@ struct regmap *__regmap_init(struct device *dev,
|
||||||
map->format.format_write = regmap_format_10_14_write;
|
map->format.format_write = regmap_format_10_14_write;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
goto err_map;
|
goto err_hwlock;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -779,13 +853,13 @@ struct regmap *__regmap_init(struct device *dev,
|
||||||
map->format.format_reg = regmap_format_16_native;
|
map->format.format_reg = regmap_format_16_native;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
goto err_map;
|
goto err_hwlock;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 24:
|
case 24:
|
||||||
if (reg_endian != REGMAP_ENDIAN_BIG)
|
if (reg_endian != REGMAP_ENDIAN_BIG)
|
||||||
goto err_map;
|
goto err_hwlock;
|
||||||
map->format.format_reg = regmap_format_24;
|
map->format.format_reg = regmap_format_24;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -801,7 +875,7 @@ struct regmap *__regmap_init(struct device *dev,
|
||||||
map->format.format_reg = regmap_format_32_native;
|
map->format.format_reg = regmap_format_32_native;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
goto err_map;
|
goto err_hwlock;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -818,13 +892,13 @@ struct regmap *__regmap_init(struct device *dev,
|
||||||
map->format.format_reg = regmap_format_64_native;
|
map->format.format_reg = regmap_format_64_native;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
goto err_map;
|
goto err_hwlock;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
default:
|
default:
|
||||||
goto err_map;
|
goto err_hwlock;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (val_endian == REGMAP_ENDIAN_NATIVE)
|
if (val_endian == REGMAP_ENDIAN_NATIVE)
|
||||||
|
@ -853,12 +927,12 @@ struct regmap *__regmap_init(struct device *dev,
|
||||||
map->format.parse_val = regmap_parse_16_native;
|
map->format.parse_val = regmap_parse_16_native;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
goto err_map;
|
goto err_hwlock;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 24:
|
case 24:
|
||||||
if (val_endian != REGMAP_ENDIAN_BIG)
|
if (val_endian != REGMAP_ENDIAN_BIG)
|
||||||
goto err_map;
|
goto err_hwlock;
|
||||||
map->format.format_val = regmap_format_24;
|
map->format.format_val = regmap_format_24;
|
||||||
map->format.parse_val = regmap_parse_24;
|
map->format.parse_val = regmap_parse_24;
|
||||||
break;
|
break;
|
||||||
|
@ -879,7 +953,7 @@ struct regmap *__regmap_init(struct device *dev,
|
||||||
map->format.parse_val = regmap_parse_32_native;
|
map->format.parse_val = regmap_parse_32_native;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
goto err_map;
|
goto err_hwlock;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
#ifdef CONFIG_64BIT
|
#ifdef CONFIG_64BIT
|
||||||
|
@ -900,7 +974,7 @@ struct regmap *__regmap_init(struct device *dev,
|
||||||
map->format.parse_val = regmap_parse_64_native;
|
map->format.parse_val = regmap_parse_64_native;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
goto err_map;
|
goto err_hwlock;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
|
@ -909,18 +983,18 @@ struct regmap *__regmap_init(struct device *dev,
|
||||||
if (map->format.format_write) {
|
if (map->format.format_write) {
|
||||||
if ((reg_endian != REGMAP_ENDIAN_BIG) ||
|
if ((reg_endian != REGMAP_ENDIAN_BIG) ||
|
||||||
(val_endian != REGMAP_ENDIAN_BIG))
|
(val_endian != REGMAP_ENDIAN_BIG))
|
||||||
goto err_map;
|
goto err_hwlock;
|
||||||
map->use_single_write = true;
|
map->use_single_write = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!map->format.format_write &&
|
if (!map->format.format_write &&
|
||||||
!(map->format.format_reg && map->format.format_val))
|
!(map->format.format_reg && map->format.format_val))
|
||||||
goto err_map;
|
goto err_hwlock;
|
||||||
|
|
||||||
map->work_buf = kzalloc(map->format.buf_size, GFP_KERNEL);
|
map->work_buf = kzalloc(map->format.buf_size, GFP_KERNEL);
|
||||||
if (map->work_buf == NULL) {
|
if (map->work_buf == NULL) {
|
||||||
ret = -ENOMEM;
|
ret = -ENOMEM;
|
||||||
goto err_map;
|
goto err_hwlock;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (map->format.format_write) {
|
if (map->format.format_write) {
|
||||||
|
@ -1041,6 +1115,9 @@ struct regmap *__regmap_init(struct device *dev,
|
||||||
err_range:
|
err_range:
|
||||||
regmap_range_exit(map);
|
regmap_range_exit(map);
|
||||||
kfree(map->work_buf);
|
kfree(map->work_buf);
|
||||||
|
err_hwlock:
|
||||||
|
if (IS_ENABLED(REGMAP_HWSPINLOCK) && map->hwlock)
|
||||||
|
hwspin_lock_free(map->hwlock);
|
||||||
err_map:
|
err_map:
|
||||||
kfree(map);
|
kfree(map);
|
||||||
err:
|
err:
|
||||||
|
@ -1228,6 +1305,8 @@ void regmap_exit(struct regmap *map)
|
||||||
kfree(async->work_buf);
|
kfree(async->work_buf);
|
||||||
kfree(async);
|
kfree(async);
|
||||||
}
|
}
|
||||||
|
if (IS_ENABLED(REGMAP_HWSPINLOCK) && map->hwlock)
|
||||||
|
hwspin_lock_free(map->hwlock);
|
||||||
kfree(map);
|
kfree(map);
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL_GPL(regmap_exit);
|
EXPORT_SYMBOL_GPL(regmap_exit);
|
||||||
|
|
|
@ -317,6 +317,9 @@ typedef void (*regmap_unlock)(void *);
|
||||||
*
|
*
|
||||||
* @ranges: Array of configuration entries for virtual address ranges.
|
* @ranges: Array of configuration entries for virtual address ranges.
|
||||||
* @num_ranges: Number of range configuration entries.
|
* @num_ranges: Number of range configuration entries.
|
||||||
|
* @hwlock_id: Specify the hardware spinlock id.
|
||||||
|
* @hwlock_mode: The hardware spinlock mode, should be HWLOCK_IRQSTATE,
|
||||||
|
* HWLOCK_IRQ or 0.
|
||||||
*/
|
*/
|
||||||
struct regmap_config {
|
struct regmap_config {
|
||||||
const char *name;
|
const char *name;
|
||||||
|
@ -361,6 +364,9 @@ struct regmap_config {
|
||||||
|
|
||||||
const struct regmap_range_cfg *ranges;
|
const struct regmap_range_cfg *ranges;
|
||||||
unsigned int num_ranges;
|
unsigned int num_ranges;
|
||||||
|
|
||||||
|
unsigned int hwlock_id;
|
||||||
|
unsigned int hwlock_mode;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue