2 * Copyright (c) 2015 Google, Inc
3 * Written by Simon Glass <sjg@chromium.org>
5 * SPDX-License-Identifier: GPL-2.0+
12 * struct regmap_range - a register map range
14 * @start: Start address
15 * @size: Size in bytes
23 * struct regmap - a way of accessing hardware/bus registers
25 * @base: Base address of register map
26 * @range_count: Number of ranges available within the map
27 * @range: Pointer to the list of ranges, allocated if @range_count > 1
28 * @base_range: If @range_count is <= 1, @range points here
33 struct regmap_range *range, base_range;
37 * Interface to provide access to registers either through a direct memory
38 * bus or through a peripheral bus like I2C, SPI.
40 int regmap_write(struct regmap *map, uint offset, uint val);
41 int regmap_read(struct regmap *map, uint offset, uint *valp);
43 #define regmap_write32(map, ptr, member, val) \
44 regmap_write(map, (uint32_t *)(ptr)->member - (uint32_t *)(ptr), val)
46 #define regmap_read32(map, ptr, member, valp) \
47 regmap_read(map, (uint32_t *)(ptr)->member - (uint32_t *)(ptr), valp)
50 * regmap_init_mem() - Set up a new register map that uses memory access
52 * Use regmap_uninit() to free it.
54 * @dev: Device that uses this map
55 * @mapp: Returns allocated map
57 int regmap_init_mem(struct udevice *dev, struct regmap **mapp);
60 * regmap_init_mem_platdata() - Set up a new memory register map for of-platdata
62 * This creates a new regmap with a list of regions passed in, rather than
63 * using the device tree. It only supports 32-bit machines.
65 * Use regmap_uninit() to free it.
67 * @dev: Device that uses this map
68 * @reg: List of address, size pairs
69 * @count: Number of pairs (e.g. 1 if the regmap has a single entry)
70 * @mapp: Returns allocated map
72 int regmap_init_mem_platdata(struct udevice *dev, fdt_val_t *reg, int count,
73 struct regmap **mapp);
76 * regmap_get_range() - Obtain the base memory address of a regmap range
78 * @map: Regmap to query
79 * @range_num: Range to look up
81 void *regmap_get_range(struct regmap *map, unsigned int range_num);
84 * regmap_uninit() - free a previously inited regmap
86 int regmap_uninit(struct regmap *map);