From: Mark Brown Date: Sun, 13 May 2012 18:20:47 +0000 (+0100) Subject: Merge branches 'regmap-core', 'regmap-stride', 'regmap-mmio' and 'regmap-irq' into... X-Git-Url: http://git.cdn.openwrt.org/?a=commitdiff_plain;h=06e65cb322f91dc20fbcfc1a7ee2fb105ecc417b;p=openwrt%2Fstaging%2Fblogic.git Merge branches 'regmap-core', 'regmap-stride', 'regmap-mmio' and 'regmap-irq' into regmap-next --- 06e65cb322f91dc20fbcfc1a7ee2fb105ecc417b diff --cc drivers/base/regmap/internal.h index 606b83d75458,2eb719704885,c994bc9bc04f,fcafc5b2e651..b986b8660b0c --- a/drivers/base/regmap/internal.h +++ b/drivers/base/regmap/internal.h @@@@@ -38,6 -44,7 -44,8 -38,6 +44,8 @@@@@ struct regmap void *work_buf; /* Scratch buffer used to format I/O */ struct regmap_format format; /* Buffer format */ const struct regmap_bus *bus; + + void *bus_context; ++ + const char *name; #ifdef CONFIG_DEBUG_FS struct dentry *debugfs; @@@@@ -52,9 -60,10 -60,6 -52,6 +61,10 @@@@@ u8 read_flag_mask; u8 write_flag_mask; ++ /* number of bits to (left) shift the reg value when formatting*/ ++ int reg_shift; + ++ int reg_stride; ++ /* regcache specific members */ const struct regcache_ops *cache_ops; enum regcache_type cache_type; diff --cc drivers/base/regmap/regmap.c index 3e551223f4df,357294905793,618173e4c2b1,7a3f535e481c..0bcda488f11c --- a/drivers/base/regmap/regmap.c +++ b/drivers/base/regmap/regmap.c @@@@@ -179,6 -179,26 -158,35 -158,6 +179,35 @@@@@ static unsigned int regmap_parse_32(voi 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); + +} + + ++ +static void dev_get_regmap_release(struct device *dev, void *res) ++ +{ ++ + /* ++ + * We don't actually have anything to do here; the goal here ++ + * is not to manage the regmap but to provide a simple way to ++ + * get the regmap back given a struct device. ++ + */ ++ +} ++ + /** * regmap_init(): Initialise register map * @@@@@ -192,9 -213,10 -201,10 -171,9 +222,10 @@@@@ */ struct regmap *regmap_init(struct device *dev, const struct regmap_bus *bus, + + void *bus_context, const struct regmap_config *config) { -- - struct regmap *map; ++ + struct regmap *map, **m; int ret = -EINVAL; if (!bus || !config) @@@@@ -212,9 -242,15 -230,9 -191,8 +251,15 @@@@@ map->format.pad_bytes = config->pad_bits / 8; map->format.val_bytes = DIV_ROUND_UP(config->val_bits, 8); map->format.buf_size += map->format.pad_bytes; ++ map->reg_shift = config->pad_bits % 8; + ++ if (config->reg_stride) + ++ map->reg_stride = config->reg_stride; + ++ else + ++ map->reg_stride = 1; + ++ map->use_single_rw = config->use_single_rw; map->dev = dev; map->bus = bus; + + map->bus_context = bus_context; map->max_register = config->max_register; map->writeable_reg = config->writeable_reg; map->readable_reg = config->readable_reg; @@@@@ -555,7 -600,10 -623,7 -529,7 +659,10 @@@@@ int regmap_write(struct regmap *map, un { int ret; - - mutex_lock(&map->lock); + ++ if (reg % map->reg_stride) + ++ return -EINVAL; + ++ + + map->lock(map); ret = _regmap_write(map, reg, val); @@@@@ -586,7 -634,12 -654,10 -560,7 +693,12 @@@@@ int regmap_raw_write(struct regmap *map { int ret; - - mutex_lock(&map->lock); + + if (val_len % map->format.val_bytes) + + return -EINVAL; + ++ if (reg % map->reg_stride) + ++ return -EINVAL; + + + + map->lock(map); ret = _regmap_raw_write(map, reg, val, val_len); @@@@@ -619,8 -672,10 -690,8 -593,8 +731,10 @@@@@ int regmap_bulk_write(struct regmap *ma if (!map->format.parse_val) return -EINVAL; + ++ if (reg % map->reg_stride) + ++ return -EINVAL; - - mutex_lock(&map->lock); + + map->lock(map); /* No formatting is require if val_byte is 1 */ if (val_bytes == 1) { @@@@@ -718,7 -785,10 -786,7 -689,7 +847,10 @@@@@ int regmap_read(struct regmap *map, uns { int ret; - - mutex_lock(&map->lock); + ++ if (reg % map->reg_stride) + ++ return -EINVAL; + ++ + + map->lock(map); ret = _regmap_read(map, reg, val); @@@@@ -747,7 -817,12 -815,10 -718,7 +879,12 @@@@@ int regmap_raw_read(struct regmap *map unsigned int v; int ret, i; - - mutex_lock(&map->lock); + + if (val_len % map->format.val_bytes) + + return -EINVAL; + ++ if (reg % map->reg_stride) + ++ return -EINVAL; + + + + map->lock(map); if (regmap_volatile_range(map, reg, val_count) || map->cache_bypass || map->cache_type == REGCACHE_NONE) { diff --cc include/linux/regmap.h index a90abb6bfa64,ae797b142aa8,90a4652eaaea,a90abb6bfa64..9dbc9a1bec43 --- a/include/linux/regmap.h +++ b/include/linux/regmap.h @@@@@ -95,16 -107,19 -95,17 -95,16 +107,19 @@@@@ struct regmap_config u8 read_flag_mask; u8 write_flag_mask; + ++ + ++ bool use_single_rw; }; - -typedef int (*regmap_hw_write)(struct device *dev, const void *data, + +typedef int (*regmap_hw_write)(void *context, const void *data, size_t count); - -typedef int (*regmap_hw_gather_write)(struct device *dev, + +typedef int (*regmap_hw_gather_write)(void *context, const void *reg, size_t reg_len, const void *val, size_t val_len); - -typedef int (*regmap_hw_read)(struct device *dev, + +typedef int (*regmap_hw_read)(void *context, const void *reg_buf, size_t reg_size, void *val_buf, size_t val_size); + +typedef void (*regmap_hw_free_context)(void *context); /** * Description of a hardware bus for the register map infrastructure.