Commit c9fadf21 authored by Mark Brown's avatar Mark Brown

Merge remote-tracking branch 'regmap/for-5.9' into regmap-next

parents 2b0f61e2 6611561a
...@@ -541,9 +541,9 @@ static const struct irq_domain_ops regmap_domain_ops = { ...@@ -541,9 +541,9 @@ static const struct irq_domain_ops regmap_domain_ops = {
}; };
/** /**
* regmap_add_irq_chip_np() - Use standard regmap IRQ controller handling * regmap_add_irq_chip_fwnode() - Use standard regmap IRQ controller handling
* *
* @np: The device_node where the IRQ domain should be added to. * @fwnode: The firmware node where the IRQ domain should be added to.
* @map: The regmap for the device. * @map: The regmap for the device.
* @irq: The IRQ the device uses to signal interrupts. * @irq: The IRQ the device uses to signal interrupts.
* @irq_flags: The IRQF_ flags to use for the primary interrupt. * @irq_flags: The IRQF_ flags to use for the primary interrupt.
...@@ -557,7 +557,8 @@ static const struct irq_domain_ops regmap_domain_ops = { ...@@ -557,7 +557,8 @@ static const struct irq_domain_ops regmap_domain_ops = {
* register cache. The chip driver is responsible for restoring the * register cache. The chip driver is responsible for restoring the
* register values used by the IRQ controller over suspend and resume. * register values used by the IRQ controller over suspend and resume.
*/ */
int regmap_add_irq_chip_np(struct device_node *np, struct regmap *map, int irq, int regmap_add_irq_chip_fwnode(struct fwnode_handle *fwnode,
struct regmap *map, int irq,
int irq_flags, int irq_base, int irq_flags, int irq_base,
const struct regmap_irq_chip *chip, const struct regmap_irq_chip *chip,
struct regmap_irq_chip_data **data) struct regmap_irq_chip_data **data)
...@@ -771,10 +772,12 @@ int regmap_add_irq_chip_np(struct device_node *np, struct regmap *map, int irq, ...@@ -771,10 +772,12 @@ int regmap_add_irq_chip_np(struct device_node *np, struct regmap *map, int irq,
} }
if (irq_base) if (irq_base)
d->domain = irq_domain_add_legacy(np, chip->num_irqs, irq_base, d->domain = irq_domain_add_legacy(to_of_node(fwnode),
chip->num_irqs, irq_base,
0, &regmap_domain_ops, d); 0, &regmap_domain_ops, d);
else else
d->domain = irq_domain_add_linear(np, chip->num_irqs, d->domain = irq_domain_add_linear(to_of_node(fwnode),
chip->num_irqs,
&regmap_domain_ops, d); &regmap_domain_ops, d);
if (!d->domain) { if (!d->domain) {
dev_err(map->dev, "Failed to create IRQ domain\n"); dev_err(map->dev, "Failed to create IRQ domain\n");
...@@ -808,7 +811,7 @@ int regmap_add_irq_chip_np(struct device_node *np, struct regmap *map, int irq, ...@@ -808,7 +811,7 @@ int regmap_add_irq_chip_np(struct device_node *np, struct regmap *map, int irq,
kfree(d); kfree(d);
return ret; return ret;
} }
EXPORT_SYMBOL_GPL(regmap_add_irq_chip_np); EXPORT_SYMBOL_GPL(regmap_add_irq_chip_fwnode);
/** /**
* regmap_add_irq_chip() - Use standard regmap IRQ controller handling * regmap_add_irq_chip() - Use standard regmap IRQ controller handling
...@@ -822,15 +825,15 @@ EXPORT_SYMBOL_GPL(regmap_add_irq_chip_np); ...@@ -822,15 +825,15 @@ EXPORT_SYMBOL_GPL(regmap_add_irq_chip_np);
* *
* Returns 0 on success or an errno on failure. * Returns 0 on success or an errno on failure.
* *
* This is the same as regmap_add_irq_chip_np, except that the device * This is the same as regmap_add_irq_chip_fwnode, except that the firmware
* node of the regmap is used. * node of the regmap is used.
*/ */
int regmap_add_irq_chip(struct regmap *map, int irq, int irq_flags, int regmap_add_irq_chip(struct regmap *map, int irq, int irq_flags,
int irq_base, const struct regmap_irq_chip *chip, int irq_base, const struct regmap_irq_chip *chip,
struct regmap_irq_chip_data **data) struct regmap_irq_chip_data **data)
{ {
return regmap_add_irq_chip_np(map->dev->of_node, map, irq, irq_flags, return regmap_add_irq_chip_fwnode(dev_fwnode(map->dev), map, irq,
irq_base, chip, data); irq_flags, irq_base, chip, data);
} }
EXPORT_SYMBOL_GPL(regmap_add_irq_chip); EXPORT_SYMBOL_GPL(regmap_add_irq_chip);
...@@ -899,10 +902,10 @@ static int devm_regmap_irq_chip_match(struct device *dev, void *res, void *data) ...@@ -899,10 +902,10 @@ static int devm_regmap_irq_chip_match(struct device *dev, void *res, void *data)
} }
/** /**
* devm_regmap_add_irq_chip_np() - Resource manager regmap_add_irq_chip_np() * devm_regmap_add_irq_chip_fwnode() - Resource managed regmap_add_irq_chip_fwnode()
* *
* @dev: The device pointer on which irq_chip belongs to. * @dev: The device pointer on which irq_chip belongs to.
* @np: The device_node where the IRQ domain should be added to. * @fwnode: The firmware node where the IRQ domain should be added to.
* @map: The regmap for the device. * @map: The regmap for the device.
* @irq: The IRQ the device uses to signal interrupts * @irq: The IRQ the device uses to signal interrupts
* @irq_flags: The IRQF_ flags to use for the primary interrupt. * @irq_flags: The IRQF_ flags to use for the primary interrupt.
...@@ -915,9 +918,10 @@ static int devm_regmap_irq_chip_match(struct device *dev, void *res, void *data) ...@@ -915,9 +918,10 @@ static int devm_regmap_irq_chip_match(struct device *dev, void *res, void *data)
* The &regmap_irq_chip_data will be automatically released when the device is * The &regmap_irq_chip_data will be automatically released when the device is
* unbound. * unbound.
*/ */
int devm_regmap_add_irq_chip_np(struct device *dev, struct device_node *np, int devm_regmap_add_irq_chip_fwnode(struct device *dev,
struct regmap *map, int irq, int irq_flags, struct fwnode_handle *fwnode,
int irq_base, struct regmap *map, int irq,
int irq_flags, int irq_base,
const struct regmap_irq_chip *chip, const struct regmap_irq_chip *chip,
struct regmap_irq_chip_data **data) struct regmap_irq_chip_data **data)
{ {
...@@ -929,7 +933,7 @@ int devm_regmap_add_irq_chip_np(struct device *dev, struct device_node *np, ...@@ -929,7 +933,7 @@ int devm_regmap_add_irq_chip_np(struct device *dev, struct device_node *np,
if (!ptr) if (!ptr)
return -ENOMEM; return -ENOMEM;
ret = regmap_add_irq_chip_np(np, map, irq, irq_flags, irq_base, ret = regmap_add_irq_chip_fwnode(fwnode, map, irq, irq_flags, irq_base,
chip, &d); chip, &d);
if (ret < 0) { if (ret < 0) {
devres_free(ptr); devres_free(ptr);
...@@ -941,7 +945,7 @@ int devm_regmap_add_irq_chip_np(struct device *dev, struct device_node *np, ...@@ -941,7 +945,7 @@ int devm_regmap_add_irq_chip_np(struct device *dev, struct device_node *np,
*data = d; *data = d;
return 0; return 0;
} }
EXPORT_SYMBOL_GPL(devm_regmap_add_irq_chip_np); EXPORT_SYMBOL_GPL(devm_regmap_add_irq_chip_fwnode);
/** /**
* devm_regmap_add_irq_chip() - Resource manager regmap_add_irq_chip() * devm_regmap_add_irq_chip() - Resource manager regmap_add_irq_chip()
...@@ -964,8 +968,9 @@ int devm_regmap_add_irq_chip(struct device *dev, struct regmap *map, int irq, ...@@ -964,8 +968,9 @@ int devm_regmap_add_irq_chip(struct device *dev, struct regmap *map, int irq,
const struct regmap_irq_chip *chip, const struct regmap_irq_chip *chip,
struct regmap_irq_chip_data **data) struct regmap_irq_chip_data **data)
{ {
return devm_regmap_add_irq_chip_np(dev, map->dev->of_node, map, irq, return devm_regmap_add_irq_chip_fwnode(dev, dev_fwnode(map->dev), map,
irq_flags, irq_base, chip, data); irq, irq_flags, irq_base, chip,
data);
} }
EXPORT_SYMBOL_GPL(devm_regmap_add_irq_chip); EXPORT_SYMBOL_GPL(devm_regmap_add_irq_chip);
......
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
#include <linux/export.h> #include <linux/export.h>
#include <linux/mutex.h> #include <linux/mutex.h>
#include <linux/err.h> #include <linux/err.h>
#include <linux/of.h> #include <linux/property.h>
#include <linux/rbtree.h> #include <linux/rbtree.h>
#include <linux/sched.h> #include <linux/sched.h>
#include <linux/delay.h> #include <linux/delay.h>
...@@ -631,7 +631,7 @@ enum regmap_endian regmap_get_val_endian(struct device *dev, ...@@ -631,7 +631,7 @@ enum regmap_endian regmap_get_val_endian(struct device *dev,
const struct regmap_bus *bus, const struct regmap_bus *bus,
const struct regmap_config *config) const struct regmap_config *config)
{ {
struct device_node *np; struct fwnode_handle *fwnode = dev ? dev_fwnode(dev) : NULL;
enum regmap_endian endian; enum regmap_endian endian;
/* Retrieve the endianness specification from the regmap config */ /* Retrieve the endianness specification from the regmap config */
...@@ -641,22 +641,17 @@ enum regmap_endian regmap_get_val_endian(struct device *dev, ...@@ -641,22 +641,17 @@ enum regmap_endian regmap_get_val_endian(struct device *dev,
if (endian != REGMAP_ENDIAN_DEFAULT) if (endian != REGMAP_ENDIAN_DEFAULT)
return endian; return endian;
/* If the dev and dev->of_node exist try to get endianness from DT */ /* If the firmware node exist try to get endianness from it */
if (dev && dev->of_node) { if (fwnode_property_read_bool(fwnode, "big-endian"))
np = dev->of_node;
/* Parse the device's DT node for an endianness specification */
if (of_property_read_bool(np, "big-endian"))
endian = REGMAP_ENDIAN_BIG; endian = REGMAP_ENDIAN_BIG;
else if (of_property_read_bool(np, "little-endian")) else if (fwnode_property_read_bool(fwnode, "little-endian"))
endian = REGMAP_ENDIAN_LITTLE; endian = REGMAP_ENDIAN_LITTLE;
else if (of_property_read_bool(np, "native-endian")) else if (fwnode_property_read_bool(fwnode, "native-endian"))
endian = REGMAP_ENDIAN_NATIVE; endian = REGMAP_ENDIAN_NATIVE;
/* If the endianness was specified in DT, use that */ /* If the endianness was specified in fwnode, use that */
if (endian != REGMAP_ENDIAN_DEFAULT) if (endian != REGMAP_ENDIAN_DEFAULT)
return endian; return endian;
}
/* Retrieve the endianness specification from the bus config */ /* Retrieve the endianness specification from the bus config */
if (bus && bus->val_format_endian_default) if (bus && bus->val_format_endian_default)
......
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
#include <linux/bug.h> #include <linux/bug.h>
#include <linux/lockdep.h> #include <linux/lockdep.h>
#include <linux/iopoll.h> #include <linux/iopoll.h>
#include <linux/fwnode.h>
struct module; struct module;
struct clk; struct clk;
...@@ -80,36 +81,6 @@ struct reg_sequence { ...@@ -80,36 +81,6 @@ struct reg_sequence {
} }
#define REG_SEQ0(_reg, _def) REG_SEQ(_reg, _def, 0) #define REG_SEQ0(_reg, _def) REG_SEQ(_reg, _def, 0)
#define regmap_update_bits(map, reg, mask, val) \
regmap_update_bits_base(map, reg, mask, val, NULL, false, false)
#define regmap_update_bits_async(map, reg, mask, val)\
regmap_update_bits_base(map, reg, mask, val, NULL, true, false)
#define regmap_update_bits_check(map, reg, mask, val, change)\
regmap_update_bits_base(map, reg, mask, val, change, false, false)
#define regmap_update_bits_check_async(map, reg, mask, val, change)\
regmap_update_bits_base(map, reg, mask, val, change, true, false)
#define regmap_write_bits(map, reg, mask, val) \
regmap_update_bits_base(map, reg, mask, val, NULL, false, true)
#define regmap_field_write(field, val) \
regmap_field_update_bits_base(field, ~0, val, NULL, false, false)
#define regmap_field_force_write(field, val) \
regmap_field_update_bits_base(field, ~0, val, NULL, false, true)
#define regmap_field_update_bits(field, mask, val)\
regmap_field_update_bits_base(field, mask, val, NULL, false, false)
#define regmap_field_force_update_bits(field, mask, val) \
regmap_field_update_bits_base(field, mask, val, NULL, false, true)
#define regmap_fields_write(field, id, val) \
regmap_fields_update_bits_base(field, id, ~0, val, NULL, false, false)
#define regmap_fields_force_write(field, id, val) \
regmap_fields_update_bits_base(field, id, ~0, val, NULL, false, true)
#define regmap_fields_update_bits(field, id, mask, val)\
regmap_fields_update_bits_base(field, id, mask, val, NULL, false, false)
#define regmap_fields_force_update_bits(field, id, mask, val) \
regmap_fields_update_bits_base(field, id, mask, val, NULL, false, true)
/** /**
* regmap_read_poll_timeout - Poll until a condition is met or a timeout occurs * regmap_read_poll_timeout - Poll until a condition is met or a timeout occurs
* *
...@@ -304,7 +275,7 @@ typedef void (*regmap_unlock)(void *); ...@@ -304,7 +275,7 @@ typedef void (*regmap_unlock)(void *);
* readable if it belongs to one of the ranges specified * readable if it belongs to one of the ranges specified
* by rd_noinc_table). * by rd_noinc_table).
* @disable_locking: This regmap is either protected by external means or * @disable_locking: This regmap is either protected by external means or
* is guaranteed not be be accessed from multiple threads. * is guaranteed not to be accessed from multiple threads.
* Don't use any locking mechanisms. * Don't use any locking mechanisms.
* @lock: Optional lock callback (overrides regmap's default lock * @lock: Optional lock callback (overrides regmap's default lock
* function, based on spinlock or mutex). * function, based on spinlock or mutex).
...@@ -1054,6 +1025,42 @@ int regmap_bulk_read(struct regmap *map, unsigned int reg, void *val, ...@@ -1054,6 +1025,42 @@ int regmap_bulk_read(struct regmap *map, unsigned int reg, void *val,
int regmap_update_bits_base(struct regmap *map, unsigned int reg, int regmap_update_bits_base(struct regmap *map, unsigned int reg,
unsigned int mask, unsigned int val, unsigned int mask, unsigned int val,
bool *change, bool async, bool force); bool *change, bool async, bool force);
static inline int regmap_update_bits(struct regmap *map, unsigned int reg,
unsigned int mask, unsigned int val)
{
return regmap_update_bits_base(map, reg, mask, val, NULL, false, false);
}
static inline int regmap_update_bits_async(struct regmap *map, unsigned int reg,
unsigned int mask, unsigned int val)
{
return regmap_update_bits_base(map, reg, mask, val, NULL, true, false);
}
static inline int regmap_update_bits_check(struct regmap *map, unsigned int reg,
unsigned int mask, unsigned int val,
bool *change)
{
return regmap_update_bits_base(map, reg, mask, val,
change, false, false);
}
static inline int
regmap_update_bits_check_async(struct regmap *map, unsigned int reg,
unsigned int mask, unsigned int val,
bool *change)
{
return regmap_update_bits_base(map, reg, mask, val,
change, true, false);
}
static inline int regmap_write_bits(struct regmap *map, unsigned int reg,
unsigned int mask, unsigned int val)
{
return regmap_update_bits_base(map, reg, mask, val, NULL, false, true);
}
int regmap_get_val_bytes(struct regmap *map); int regmap_get_val_bytes(struct regmap *map);
int regmap_get_max_register(struct regmap *map); int regmap_get_max_register(struct regmap *map);
int regmap_get_reg_stride(struct regmap *map); int regmap_get_reg_stride(struct regmap *map);
...@@ -1152,6 +1159,65 @@ int regmap_fields_read(struct regmap_field *field, unsigned int id, ...@@ -1152,6 +1159,65 @@ int regmap_fields_read(struct regmap_field *field, unsigned int id,
int regmap_fields_update_bits_base(struct regmap_field *field, unsigned int id, int regmap_fields_update_bits_base(struct regmap_field *field, unsigned int id,
unsigned int mask, unsigned int val, unsigned int mask, unsigned int val,
bool *change, bool async, bool force); bool *change, bool async, bool force);
static inline int regmap_field_write(struct regmap_field *field,
unsigned int val)
{
return regmap_field_update_bits_base(field, ~0, val,
NULL, false, false);
}
static inline int regmap_field_force_write(struct regmap_field *field,
unsigned int val)
{
return regmap_field_update_bits_base(field, ~0, val, NULL, false, true);
}
static inline int regmap_field_update_bits(struct regmap_field *field,
unsigned int mask, unsigned int val)
{
return regmap_field_update_bits_base(field, mask, val,
NULL, false, false);
}
static inline int
regmap_field_force_update_bits(struct regmap_field *field,
unsigned int mask, unsigned int val)
{
return regmap_field_update_bits_base(field, mask, val,
NULL, false, true);
}
static inline int regmap_fields_write(struct regmap_field *field,
unsigned int id, unsigned int val)
{
return regmap_fields_update_bits_base(field, id, ~0, val,
NULL, false, false);
}
static inline int regmap_fields_force_write(struct regmap_field *field,
unsigned int id, unsigned int val)
{
return regmap_fields_update_bits_base(field, id, ~0, val,
NULL, false, true);
}
static inline int
regmap_fields_update_bits(struct regmap_field *field, unsigned int id,
unsigned int mask, unsigned int val)
{
return regmap_fields_update_bits_base(field, id, mask, val,
NULL, false, false);
}
static inline int
regmap_fields_force_update_bits(struct regmap_field *field, unsigned int id,
unsigned int mask, unsigned int val)
{
return regmap_fields_update_bits_base(field, id, mask, val,
NULL, false, true);
}
/** /**
* struct regmap_irq_type - IRQ type definitions. * struct regmap_irq_type - IRQ type definitions.
* *
...@@ -1311,7 +1377,8 @@ struct regmap_irq_chip_data; ...@@ -1311,7 +1377,8 @@ struct regmap_irq_chip_data;
int regmap_add_irq_chip(struct regmap *map, int irq, int irq_flags, int regmap_add_irq_chip(struct regmap *map, int irq, int irq_flags,
int irq_base, const struct regmap_irq_chip *chip, int irq_base, const struct regmap_irq_chip *chip,
struct regmap_irq_chip_data **data); struct regmap_irq_chip_data **data);
int regmap_add_irq_chip_np(struct device_node *np, struct regmap *map, int irq, int regmap_add_irq_chip_fwnode(struct fwnode_handle *fwnode,
struct regmap *map, int irq,
int irq_flags, int irq_base, int irq_flags, int irq_base,
const struct regmap_irq_chip *chip, const struct regmap_irq_chip *chip,
struct regmap_irq_chip_data **data); struct regmap_irq_chip_data **data);
...@@ -1321,9 +1388,10 @@ int devm_regmap_add_irq_chip(struct device *dev, struct regmap *map, int irq, ...@@ -1321,9 +1388,10 @@ int devm_regmap_add_irq_chip(struct device *dev, struct regmap *map, int irq,
int irq_flags, int irq_base, int irq_flags, int irq_base,
const struct regmap_irq_chip *chip, const struct regmap_irq_chip *chip,
struct regmap_irq_chip_data **data); struct regmap_irq_chip_data **data);
int devm_regmap_add_irq_chip_np(struct device *dev, struct device_node *np, int devm_regmap_add_irq_chip_fwnode(struct device *dev,
struct regmap *map, int irq, int irq_flags, struct fwnode_handle *fwnode,
int irq_base, struct regmap *map, int irq,
int irq_flags, int irq_base,
const struct regmap_irq_chip *chip, const struct regmap_irq_chip *chip,
struct regmap_irq_chip_data **data); struct regmap_irq_chip_data **data);
void devm_regmap_del_irq_chip(struct device *dev, int irq, void devm_regmap_del_irq_chip(struct device *dev, int irq,
...@@ -1458,6 +1526,103 @@ static inline int regmap_fields_update_bits_base(struct regmap_field *field, ...@@ -1458,6 +1526,103 @@ static inline int regmap_fields_update_bits_base(struct regmap_field *field,
return -EINVAL; return -EINVAL;
} }
static inline int regmap_update_bits(struct regmap *map, unsigned int reg,
unsigned int mask, unsigned int val)
{
WARN_ONCE(1, "regmap API is disabled");
return -EINVAL;
}
static inline int regmap_update_bits_async(struct regmap *map, unsigned int reg,
unsigned int mask, unsigned int val)
{
WARN_ONCE(1, "regmap API is disabled");
return -EINVAL;
}
static inline int regmap_update_bits_check(struct regmap *map, unsigned int reg,
unsigned int mask, unsigned int val,
bool *change)
{
WARN_ONCE(1, "regmap API is disabled");
return -EINVAL;
}
static inline int
regmap_update_bits_check_async(struct regmap *map, unsigned int reg,
unsigned int mask, unsigned int val,
bool *change)
{
WARN_ONCE(1, "regmap API is disabled");
return -EINVAL;
}
static inline int regmap_write_bits(struct regmap *map, unsigned int reg,
unsigned int mask, unsigned int val)
{
WARN_ONCE(1, "regmap API is disabled");
return -EINVAL;
}
static inline int regmap_field_write(struct regmap_field *field,
unsigned int val)
{
WARN_ONCE(1, "regmap API is disabled");
return -EINVAL;
}
static inline int regmap_field_force_write(struct regmap_field *field,
unsigned int val)
{
WARN_ONCE(1, "regmap API is disabled");
return -EINVAL;
}
static inline int regmap_field_update_bits(struct regmap_field *field,
unsigned int mask, unsigned int val)
{
WARN_ONCE(1, "regmap API is disabled");
return -EINVAL;
}
static inline int
regmap_field_force_update_bits(struct regmap_field *field,
unsigned int mask, unsigned int val)
{
WARN_ONCE(1, "regmap API is disabled");
return -EINVAL;
}
static inline int regmap_fields_write(struct regmap_field *field,
unsigned int id, unsigned int val)
{
WARN_ONCE(1, "regmap API is disabled");
return -EINVAL;
}
static inline int regmap_fields_force_write(struct regmap_field *field,
unsigned int id, unsigned int val)
{
WARN_ONCE(1, "regmap API is disabled");
return -EINVAL;
}
static inline int
regmap_fields_update_bits(struct regmap_field *field, unsigned int id,
unsigned int mask, unsigned int val)
{
WARN_ONCE(1, "regmap API is disabled");
return -EINVAL;
}
static inline int
regmap_fields_force_update_bits(struct regmap_field *field, unsigned int id,
unsigned int mask, unsigned int val)
{
WARN_ONCE(1, "regmap API is disabled");
return -EINVAL;
}
static inline int regmap_get_val_bytes(struct regmap *map) static inline int regmap_get_val_bytes(struct regmap *map)
{ {
WARN_ONCE(1, "regmap API is disabled"); WARN_ONCE(1, "regmap API is disabled");
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment