Merge remote-tracking branches 'regmap/topic/irq', 'regmap/topic/le', 'regmap/topic/mmio' and 'regmap/topic/rbtree' into regmap-next
This commit is contained in:
commit
522168d178
4 changed files with 86 additions and 12 deletions
|
@ -23,16 +23,16 @@ static int regcache_rbtree_write(struct regmap *map, unsigned int reg,
|
||||||
static int regcache_rbtree_exit(struct regmap *map);
|
static int regcache_rbtree_exit(struct regmap *map);
|
||||||
|
|
||||||
struct regcache_rbtree_node {
|
struct regcache_rbtree_node {
|
||||||
/* the actual rbtree node holding this block */
|
|
||||||
struct rb_node node;
|
|
||||||
/* base register handled by this block */
|
|
||||||
unsigned int base_reg;
|
|
||||||
/* block of adjacent registers */
|
/* block of adjacent registers */
|
||||||
void *block;
|
void *block;
|
||||||
/* Which registers are present */
|
/* Which registers are present */
|
||||||
long *cache_present;
|
long *cache_present;
|
||||||
|
/* base register handled by this block */
|
||||||
|
unsigned int base_reg;
|
||||||
/* number of registers available in the block */
|
/* number of registers available in the block */
|
||||||
unsigned int blklen;
|
unsigned int blklen;
|
||||||
|
/* the actual rbtree node holding this block */
|
||||||
|
struct rb_node node;
|
||||||
} __attribute__ ((packed));
|
} __attribute__ ((packed));
|
||||||
|
|
||||||
struct regcache_rbtree_ctx {
|
struct regcache_rbtree_ctx {
|
||||||
|
|
|
@ -10,13 +10,13 @@
|
||||||
* published by the Free Software Foundation.
|
* published by the Free Software Foundation.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <linux/export.h>
|
|
||||||
#include <linux/device.h>
|
#include <linux/device.h>
|
||||||
#include <linux/regmap.h>
|
#include <linux/export.h>
|
||||||
#include <linux/irq.h>
|
|
||||||
#include <linux/interrupt.h>
|
#include <linux/interrupt.h>
|
||||||
|
#include <linux/irq.h>
|
||||||
#include <linux/irqdomain.h>
|
#include <linux/irqdomain.h>
|
||||||
#include <linux/pm_runtime.h>
|
#include <linux/pm_runtime.h>
|
||||||
|
#include <linux/regmap.h>
|
||||||
#include <linux/slab.h>
|
#include <linux/slab.h>
|
||||||
|
|
||||||
#include "internal.h"
|
#include "internal.h"
|
||||||
|
@ -347,6 +347,9 @@ int regmap_add_irq_chip(struct regmap *map, int irq, int irq_flags,
|
||||||
int ret = -ENOMEM;
|
int ret = -ENOMEM;
|
||||||
u32 reg;
|
u32 reg;
|
||||||
|
|
||||||
|
if (chip->num_regs <= 0)
|
||||||
|
return -EINVAL;
|
||||||
|
|
||||||
for (i = 0; i < chip->num_irqs; i++) {
|
for (i = 0; i < chip->num_irqs; i++) {
|
||||||
if (chip->irqs[i].reg_offset % map->reg_stride)
|
if (chip->irqs[i].reg_offset % map->reg_stride)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
|
@ -66,12 +66,31 @@ static inline void regmap_mmio_count_check(size_t count, u32 offset)
|
||||||
BUG_ON(count <= offset);
|
BUG_ON(count <= offset);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline unsigned int
|
||||||
|
regmap_mmio_get_offset(const void *reg, size_t reg_size)
|
||||||
|
{
|
||||||
|
switch (reg_size) {
|
||||||
|
case 1:
|
||||||
|
return *(u8 *)reg;
|
||||||
|
case 2:
|
||||||
|
return *(u16 *)reg;
|
||||||
|
case 4:
|
||||||
|
return *(u32 *)reg;
|
||||||
|
#ifdef CONFIG_64BIT
|
||||||
|
case 8:
|
||||||
|
return *(u64 *)reg;
|
||||||
|
#endif
|
||||||
|
default:
|
||||||
|
BUG();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static int regmap_mmio_gather_write(void *context,
|
static int regmap_mmio_gather_write(void *context,
|
||||||
const void *reg, size_t reg_size,
|
const void *reg, size_t reg_size,
|
||||||
const void *val, size_t val_size)
|
const void *val, size_t val_size)
|
||||||
{
|
{
|
||||||
struct regmap_mmio_context *ctx = context;
|
struct regmap_mmio_context *ctx = context;
|
||||||
u32 offset;
|
unsigned int offset;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
regmap_mmio_regsize_check(reg_size);
|
regmap_mmio_regsize_check(reg_size);
|
||||||
|
@ -82,7 +101,7 @@ static int regmap_mmio_gather_write(void *context,
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
offset = *(u32 *)reg;
|
offset = regmap_mmio_get_offset(reg, reg_size);
|
||||||
|
|
||||||
while (val_size) {
|
while (val_size) {
|
||||||
switch (ctx->val_bytes) {
|
switch (ctx->val_bytes) {
|
||||||
|
@ -118,7 +137,7 @@ static int regmap_mmio_gather_write(void *context,
|
||||||
static int regmap_mmio_write(void *context, const void *data, size_t count)
|
static int regmap_mmio_write(void *context, const void *data, size_t count)
|
||||||
{
|
{
|
||||||
struct regmap_mmio_context *ctx = context;
|
struct regmap_mmio_context *ctx = context;
|
||||||
u32 offset = ctx->reg_bytes + ctx->pad_bytes;
|
unsigned int offset = ctx->reg_bytes + ctx->pad_bytes;
|
||||||
|
|
||||||
regmap_mmio_count_check(count, offset);
|
regmap_mmio_count_check(count, offset);
|
||||||
|
|
||||||
|
@ -131,7 +150,7 @@ static int regmap_mmio_read(void *context,
|
||||||
void *val, size_t val_size)
|
void *val, size_t val_size)
|
||||||
{
|
{
|
||||||
struct regmap_mmio_context *ctx = context;
|
struct regmap_mmio_context *ctx = context;
|
||||||
u32 offset;
|
unsigned int offset;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
regmap_mmio_regsize_check(reg_size);
|
regmap_mmio_regsize_check(reg_size);
|
||||||
|
@ -142,7 +161,7 @@ static int regmap_mmio_read(void *context,
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
offset = *(u32 *)reg;
|
offset = regmap_mmio_get_offset(reg, reg_size);
|
||||||
|
|
||||||
while (val_size) {
|
while (val_size) {
|
||||||
switch (ctx->val_bytes) {
|
switch (ctx->val_bytes) {
|
||||||
|
|
|
@ -192,6 +192,13 @@ static void regmap_format_16_be(void *buf, unsigned int val, unsigned int shift)
|
||||||
b[0] = cpu_to_be16(val << shift);
|
b[0] = cpu_to_be16(val << shift);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void regmap_format_16_le(void *buf, unsigned int val, unsigned int shift)
|
||||||
|
{
|
||||||
|
__le16 *b = buf;
|
||||||
|
|
||||||
|
b[0] = cpu_to_le16(val << shift);
|
||||||
|
}
|
||||||
|
|
||||||
static void regmap_format_16_native(void *buf, unsigned int val,
|
static void regmap_format_16_native(void *buf, unsigned int val,
|
||||||
unsigned int shift)
|
unsigned int shift)
|
||||||
{
|
{
|
||||||
|
@ -216,6 +223,13 @@ static void regmap_format_32_be(void *buf, unsigned int val, unsigned int shift)
|
||||||
b[0] = cpu_to_be32(val << shift);
|
b[0] = cpu_to_be32(val << shift);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void regmap_format_32_le(void *buf, unsigned int val, unsigned int shift)
|
||||||
|
{
|
||||||
|
__le32 *b = buf;
|
||||||
|
|
||||||
|
b[0] = cpu_to_le32(val << shift);
|
||||||
|
}
|
||||||
|
|
||||||
static void regmap_format_32_native(void *buf, unsigned int val,
|
static void regmap_format_32_native(void *buf, unsigned int val,
|
||||||
unsigned int shift)
|
unsigned int shift)
|
||||||
{
|
{
|
||||||
|
@ -240,6 +254,13 @@ static unsigned int regmap_parse_16_be(const void *buf)
|
||||||
return be16_to_cpu(b[0]);
|
return be16_to_cpu(b[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static unsigned int regmap_parse_16_le(const void *buf)
|
||||||
|
{
|
||||||
|
const __le16 *b = buf;
|
||||||
|
|
||||||
|
return le16_to_cpu(b[0]);
|
||||||
|
}
|
||||||
|
|
||||||
static void regmap_parse_16_be_inplace(void *buf)
|
static void regmap_parse_16_be_inplace(void *buf)
|
||||||
{
|
{
|
||||||
__be16 *b = buf;
|
__be16 *b = buf;
|
||||||
|
@ -247,6 +268,13 @@ static void regmap_parse_16_be_inplace(void *buf)
|
||||||
b[0] = be16_to_cpu(b[0]);
|
b[0] = be16_to_cpu(b[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void regmap_parse_16_le_inplace(void *buf)
|
||||||
|
{
|
||||||
|
__le16 *b = buf;
|
||||||
|
|
||||||
|
b[0] = le16_to_cpu(b[0]);
|
||||||
|
}
|
||||||
|
|
||||||
static unsigned int regmap_parse_16_native(const void *buf)
|
static unsigned int regmap_parse_16_native(const void *buf)
|
||||||
{
|
{
|
||||||
return *(u16 *)buf;
|
return *(u16 *)buf;
|
||||||
|
@ -269,6 +297,13 @@ static unsigned int regmap_parse_32_be(const void *buf)
|
||||||
return be32_to_cpu(b[0]);
|
return be32_to_cpu(b[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static unsigned int regmap_parse_32_le(const void *buf)
|
||||||
|
{
|
||||||
|
const __le32 *b = buf;
|
||||||
|
|
||||||
|
return le32_to_cpu(b[0]);
|
||||||
|
}
|
||||||
|
|
||||||
static void regmap_parse_32_be_inplace(void *buf)
|
static void regmap_parse_32_be_inplace(void *buf)
|
||||||
{
|
{
|
||||||
__be32 *b = buf;
|
__be32 *b = buf;
|
||||||
|
@ -276,6 +311,13 @@ static void regmap_parse_32_be_inplace(void *buf)
|
||||||
b[0] = be32_to_cpu(b[0]);
|
b[0] = be32_to_cpu(b[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void regmap_parse_32_le_inplace(void *buf)
|
||||||
|
{
|
||||||
|
__le32 *b = buf;
|
||||||
|
|
||||||
|
b[0] = le32_to_cpu(b[0]);
|
||||||
|
}
|
||||||
|
|
||||||
static unsigned int regmap_parse_32_native(const void *buf)
|
static unsigned int regmap_parse_32_native(const void *buf)
|
||||||
{
|
{
|
||||||
return *(u32 *)buf;
|
return *(u32 *)buf;
|
||||||
|
@ -608,6 +650,11 @@ struct regmap *regmap_init(struct device *dev,
|
||||||
map->format.parse_val = regmap_parse_16_be;
|
map->format.parse_val = regmap_parse_16_be;
|
||||||
map->format.parse_inplace = regmap_parse_16_be_inplace;
|
map->format.parse_inplace = regmap_parse_16_be_inplace;
|
||||||
break;
|
break;
|
||||||
|
case REGMAP_ENDIAN_LITTLE:
|
||||||
|
map->format.format_val = regmap_format_16_le;
|
||||||
|
map->format.parse_val = regmap_parse_16_le;
|
||||||
|
map->format.parse_inplace = regmap_parse_16_le_inplace;
|
||||||
|
break;
|
||||||
case REGMAP_ENDIAN_NATIVE:
|
case REGMAP_ENDIAN_NATIVE:
|
||||||
map->format.format_val = regmap_format_16_native;
|
map->format.format_val = regmap_format_16_native;
|
||||||
map->format.parse_val = regmap_parse_16_native;
|
map->format.parse_val = regmap_parse_16_native;
|
||||||
|
@ -629,6 +676,11 @@ struct regmap *regmap_init(struct device *dev,
|
||||||
map->format.parse_val = regmap_parse_32_be;
|
map->format.parse_val = regmap_parse_32_be;
|
||||||
map->format.parse_inplace = regmap_parse_32_be_inplace;
|
map->format.parse_inplace = regmap_parse_32_be_inplace;
|
||||||
break;
|
break;
|
||||||
|
case REGMAP_ENDIAN_LITTLE:
|
||||||
|
map->format.format_val = regmap_format_32_le;
|
||||||
|
map->format.parse_val = regmap_parse_32_le;
|
||||||
|
map->format.parse_inplace = regmap_parse_32_le_inplace;
|
||||||
|
break;
|
||||||
case REGMAP_ENDIAN_NATIVE:
|
case REGMAP_ENDIAN_NATIVE:
|
||||||
map->format.format_val = regmap_format_32_native;
|
map->format.format_val = regmap_format_32_native;
|
||||||
map->format.parse_val = regmap_parse_32_native;
|
map->format.parse_val = regmap_parse_32_native;
|
||||||
|
|
Loading…
Reference in a new issue