Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b7d845f8 authored by Linus Torvalds's avatar Linus Torvalds
Browse files
* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/regmap: (36 commits)
  mfd: Clearing events requires event registers to be writable for da9052-core
  mfd: Fix annotations in da9052-core
  gpiolib: Mark da9052 driver broken
  mfd: Declare da9052_regmap_config for the bus drivers
  MFD: DA9052/53 MFD core module add SPI support v2
  MFD: DA9052/53 MFD core module
  regmap: Add irq_base accessor to regmap_irq
  regmap: Allow drivers to reinitialise the register cache at runtime
  regmap: Add trace event for successful cache reads
  regmap: Allow regmap_update_bits() users to detect changes
  regmap: Report if we actually handled an interrupt in regmap-irq
  regmap: Fix rbtreee build when not using debugfs
  regmap: Provide debugfs dump of the rbtree cache data
  regmap: Do debugfs init before cache init
  regmap: Suppress noop writes in regmap_update_bits()
  regmap: Remove indexed cache type
  regmap: Drop check whether a register is readable in regcache_read
  regmap: Properly round cache_word_size
  regmap: Add support for 10/14 register formating
  regmap: Try cached read before checking if a hardware read is possible
  ...
parents 2943c833 0a92815d
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -13,3 +13,6 @@ config REGMAP_I2C

config REGMAP_SPI
	tristate

config REGMAP_IRQ
	bool
+3 −1
Original line number Diff line number Diff line
obj-$(CONFIG_REGMAP) += regmap.o regcache.o regcache-indexed.o regcache-rbtree.o regcache-lzo.o
obj-$(CONFIG_REGMAP) += regmap.o regcache.o
obj-$(CONFIG_REGMAP) += regcache-rbtree.o regcache-lzo.o
obj-$(CONFIG_DEBUG_FS) += regmap-debugfs.o
obj-$(CONFIG_REGMAP_I2C) += regmap-i2c.o
obj-$(CONFIG_REGMAP_SPI) += regmap-spi.o
obj-$(CONFIG_REGMAP_IRQ) += regmap-irq.o
+2 −4
Original line number Diff line number Diff line
@@ -74,6 +74,7 @@ struct regmap {
	struct reg_default *reg_defaults;
	const void *reg_defaults_raw;
	void *cache;
	bool cache_dirty;
};

struct regcache_ops {
@@ -105,7 +106,7 @@ static inline void regmap_debugfs_exit(struct regmap *map) { }
#endif

/* regcache core declarations */
int regcache_init(struct regmap *map);
int regcache_init(struct regmap *map, const struct regmap_config *config);
void regcache_exit(struct regmap *map);
int regcache_read(struct regmap *map,
		       unsigned int reg, unsigned int *value);
@@ -118,10 +119,7 @@ unsigned int regcache_get_val(const void *base, unsigned int idx,
bool regcache_set_val(void *base, unsigned int idx,
		      unsigned int val, unsigned int word_size);
int regcache_lookup_reg(struct regmap *map, unsigned int reg);
int regcache_insert_reg(struct regmap *map, unsigned int reg,
			unsigned int val);

extern struct regcache_ops regcache_indexed_ops;
extern struct regcache_ops regcache_rbtree_ops;
extern struct regcache_ops regcache_lzo_ops;

+0 −64
Original line number Diff line number Diff line
/*
 * Register cache access API - indexed caching support
 *
 * Copyright 2011 Wolfson Microelectronics plc
 *
 * Author: Dimitris Papastamos <dp@opensource.wolfsonmicro.com>
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 as
 * published by the Free Software Foundation.
 */

#include <linux/slab.h>

#include "internal.h"

static int regcache_indexed_read(struct regmap *map, unsigned int reg,
				 unsigned int *value)
{
	int ret;

	ret = regcache_lookup_reg(map, reg);
	if (ret >= 0)
		*value = map->reg_defaults[ret].def;

	return ret;
}

static int regcache_indexed_write(struct regmap *map, unsigned int reg,
				  unsigned int value)
{
	int ret;

	ret = regcache_lookup_reg(map, reg);
	if (ret < 0)
		return regcache_insert_reg(map, reg, value);
	map->reg_defaults[ret].def = value;
	return 0;
}

static int regcache_indexed_sync(struct regmap *map)
{
	unsigned int i;
	int ret;

	for (i = 0; i < map->num_reg_defaults; i++) {
		ret = _regmap_write(map, map->reg_defaults[i].reg,
				    map->reg_defaults[i].def);
		if (ret < 0)
			return ret;
		dev_dbg(map->dev, "Synced register %#x, value %#x\n",
			map->reg_defaults[i].reg,
			map->reg_defaults[i].def);
	}
	return 0;
}

struct regcache_ops regcache_indexed_ops = {
	.type = REGCACHE_INDEXED,
	.name = "indexed",
	.read = regcache_indexed_read,
	.write = regcache_indexed_write,
	.sync = regcache_indexed_sync
};
+13 −8
Original line number Diff line number Diff line
@@ -15,6 +15,8 @@

#include "internal.h"

static int regcache_lzo_exit(struct regmap *map);

struct regcache_lzo_ctx {
	void *wmem;
	void *dst;
@@ -27,7 +29,7 @@ struct regcache_lzo_ctx {
};

#define LZO_BLOCK_NUM 8
static int regcache_lzo_block_count(void)
static int regcache_lzo_block_count(struct regmap *map)
{
	return LZO_BLOCK_NUM;
}
@@ -106,19 +108,22 @@ static inline int regcache_lzo_get_blkindex(struct regmap *map,
					    unsigned int reg)
{
	return (reg * map->cache_word_size) /
		DIV_ROUND_UP(map->cache_size_raw, regcache_lzo_block_count());
		DIV_ROUND_UP(map->cache_size_raw,
			     regcache_lzo_block_count(map));
}

static inline int regcache_lzo_get_blkpos(struct regmap *map,
					  unsigned int reg)
{
	return reg % (DIV_ROUND_UP(map->cache_size_raw, regcache_lzo_block_count()) /
	return reg % (DIV_ROUND_UP(map->cache_size_raw,
				   regcache_lzo_block_count(map)) /
		      map->cache_word_size);
}

static inline int regcache_lzo_get_blksize(struct regmap *map)
{
	return DIV_ROUND_UP(map->cache_size_raw, regcache_lzo_block_count());
	return DIV_ROUND_UP(map->cache_size_raw,
			    regcache_lzo_block_count(map));
}

static int regcache_lzo_init(struct regmap *map)
@@ -131,7 +136,7 @@ static int regcache_lzo_init(struct regmap *map)

	ret = 0;

	blkcount = regcache_lzo_block_count();
	blkcount = regcache_lzo_block_count(map);
	map->cache = kzalloc(blkcount * sizeof *lzo_blocks,
			     GFP_KERNEL);
	if (!map->cache)
@@ -190,7 +195,7 @@ static int regcache_lzo_init(struct regmap *map)

	return 0;
err:
	regcache_exit(map);
	regcache_lzo_exit(map);
	return ret;
}

@@ -203,7 +208,7 @@ static int regcache_lzo_exit(struct regmap *map)
	if (!lzo_blocks)
		return 0;

	blkcount = regcache_lzo_block_count();
	blkcount = regcache_lzo_block_count(map);
	/*
	 * the pointer to the bitmap used for syncing the cache
	 * is shared amongst all lzo_blocks.  Ensure it is freed
@@ -351,7 +356,7 @@ static int regcache_lzo_sync(struct regmap *map)
}

struct regcache_ops regcache_lzo_ops = {
	.type = REGCACHE_LZO,
	.type = REGCACHE_COMPRESSED,
	.name = "lzo",
	.init = regcache_lzo_init,
	.exit = regcache_lzo_exit,
Loading