u-boot-brain/include/regmap.h
Tom Rini 83d290c56f SPDX: Convert all of our single license tags to Linux Kernel style
When U-Boot started using SPDX tags we were among the early adopters and
there weren't a lot of other examples to borrow from.  So we picked the
area of the file that usually had a full license text and replaced it
with an appropriate SPDX-License-Identifier: entry.  Since then, the
Linux Kernel has adopted SPDX tags and they place it as the very first
line in a file (except where shebangs are used, then it's second line)
and with slightly different comment styles than us.

In part due to community overlap, in part due to better tag visibility
and in part for other minor reasons, switch over to that style.

This commit changes all instances where we have a single declared
license in the tag as both the before and after are identical in tag
contents.  There's also a few places where I found we did not have a tag
and have introduced one.

Signed-off-by: Tom Rini <trini@konsulko.com>
2018-05-07 09:34:12 -04:00

88 lines
2.3 KiB
C

/* SPDX-License-Identifier: GPL-2.0+ */
/*
* Copyright (c) 2015 Google, Inc
* Written by Simon Glass <sjg@chromium.org>
*/
#ifndef __REGMAP_H
#define __REGMAP_H
/**
* struct regmap_range - a register map range
*
* @start: Start address
* @size: Size in bytes
*/
struct regmap_range {
ulong start;
ulong size;
};
/**
* struct regmap - a way of accessing hardware/bus registers
*
* @base: Base address of register map
* @range_count: Number of ranges available within the map
* @range: Pointer to the list of ranges, allocated if @range_count > 1
* @base_range: If @range_count is <= 1, @range points here
*/
struct regmap {
phys_addr_t base;
int range_count;
struct regmap_range *range, base_range;
};
/*
* Interface to provide access to registers either through a direct memory
* bus or through a peripheral bus like I2C, SPI.
*/
int regmap_write(struct regmap *map, uint offset, uint val);
int regmap_read(struct regmap *map, uint offset, uint *valp);
#define regmap_write32(map, ptr, member, val) \
regmap_write(map, (uint32_t *)(ptr)->member - (uint32_t *)(ptr), val)
#define regmap_read32(map, ptr, member, valp) \
regmap_read(map, (uint32_t *)(ptr)->member - (uint32_t *)(ptr), valp)
/**
* regmap_init_mem() - Set up a new register map that uses memory access
*
* Use regmap_uninit() to free it.
*
* @dev: Device that uses this map
* @mapp: Returns allocated map
*/
int regmap_init_mem(struct udevice *dev, struct regmap **mapp);
/**
* regmap_init_mem_platdata() - Set up a new memory register map for of-platdata
*
* This creates a new regmap with a list of regions passed in, rather than
* using the device tree. It only supports 32-bit machines.
*
* Use regmap_uninit() to free it.
*
* @dev: Device that uses this map
* @reg: List of address, size pairs
* @count: Number of pairs (e.g. 1 if the regmap has a single entry)
* @mapp: Returns allocated map
*/
int regmap_init_mem_platdata(struct udevice *dev, fdt_val_t *reg, int count,
struct regmap **mapp);
/**
* regmap_get_range() - Obtain the base memory address of a regmap range
*
* @map: Regmap to query
* @range_num: Range to look up
*/
void *regmap_get_range(struct regmap *map, unsigned int range_num);
/**
* regmap_uninit() - free a previously inited regmap
*/
int regmap_uninit(struct regmap *map);
#endif