1 /* SPDX-License-Identifier: GPL-2.0+ */
3 * Copyright (c) 2015 Google, Inc
4 * Written by Simon Glass <sjg@chromium.org>
11 * struct regmap_range - a register map range
13 * @start: Start address
14 * @size: Size in bytes
22 * struct regmap - a way of accessing hardware/bus registers
24 * @range_count: Number of ranges available within the map
25 * @ranges: Array of ranges
29 struct regmap_range ranges[0];
33 * Interface to provide access to registers either through a direct memory
34 * bus or through a peripheral bus like I2C, SPI.
36 int regmap_write(struct regmap *map, uint offset, uint val);
37 int regmap_read(struct regmap *map, uint offset, uint *valp);
39 #define regmap_write32(map, ptr, member, val) \
40 regmap_write(map, (uint32_t *)(ptr)->member - (uint32_t *)(ptr), val)
42 #define regmap_read32(map, ptr, member, valp) \
43 regmap_read(map, (uint32_t *)(ptr)->member - (uint32_t *)(ptr), valp)
46 * regmap_update_bits() - Perform a read/modify/write using a mask
48 * @map: The map returned by regmap_init_mem*()
49 * @offset: Offset of the memory
50 * @mask: Mask to apply to the read value
51 * @val: Value to apply to the value to write
53 int regmap_update_bits(struct regmap *map, uint offset, uint mask, uint val);
56 * regmap_init_mem() - Set up a new register map that uses memory access
58 * Use regmap_uninit() to free it.
60 * @node: Device node that uses this map
61 * @mapp: Returns allocated map
63 int regmap_init_mem(ofnode node, struct regmap **mapp);
66 * regmap_init_mem_platdata() - Set up a new memory register map for of-platdata
68 * This creates a new regmap with a list of regions passed in, rather than
69 * using the device tree. It only supports 32-bit machines.
71 * Use regmap_uninit() to free it.
73 * @dev: Device that uses this map
74 * @reg: List of address, size pairs
75 * @count: Number of pairs (e.g. 1 if the regmap has a single entry)
76 * @mapp: Returns allocated map
78 int regmap_init_mem_platdata(struct udevice *dev, fdt_val_t *reg, int count,
79 struct regmap **mapp);
82 * regmap_get_range() - Obtain the base memory address of a regmap range
84 * @map: Regmap to query
85 * @range_num: Range to look up
87 void *regmap_get_range(struct regmap *map, unsigned int range_num);
90 * regmap_uninit() - free a previously inited regmap
92 int regmap_uninit(struct regmap *map);