Mark Brown | 93de912 | 2011-07-20 22:35:37 +0100 | [diff] [blame] | 1 | /* |
| 2 | * Register map access API internal header |
| 3 | * |
| 4 | * Copyright 2011 Wolfson Microelectronics plc |
| 5 | * |
| 6 | * Author: Mark Brown <broonie@opensource.wolfsonmicro.com> |
| 7 | * |
| 8 | * This program is free software; you can redistribute it and/or modify |
| 9 | * it under the terms of the GNU General Public License version 2 as |
| 10 | * published by the Free Software Foundation. |
| 11 | */ |
| 12 | |
| 13 | #ifndef _REGMAP_INTERNAL_H |
| 14 | #define _REGMAP_INTERNAL_H |
| 15 | |
| 16 | #include <linux/regmap.h> |
Mark Brown | 31244e3 | 2011-07-20 22:56:53 +0100 | [diff] [blame] | 17 | #include <linux/fs.h> |
Mark Brown | 93de912 | 2011-07-20 22:35:37 +0100 | [diff] [blame] | 18 | |
| 19 | struct regmap; |
| 20 | |
| 21 | struct regmap_format { |
| 22 | size_t buf_size; |
| 23 | size_t reg_bytes; |
| 24 | size_t val_bytes; |
| 25 | void (*format_write)(struct regmap *map, |
| 26 | unsigned int reg, unsigned int val); |
| 27 | void (*format_reg)(void *buf, unsigned int reg); |
| 28 | void (*format_val)(void *buf, unsigned int val); |
| 29 | unsigned int (*parse_val)(void *buf); |
| 30 | }; |
| 31 | |
| 32 | struct regmap { |
| 33 | struct mutex lock; |
| 34 | |
| 35 | struct device *dev; /* Device we do I/O on */ |
| 36 | void *work_buf; /* Scratch buffer used to format I/O */ |
| 37 | struct regmap_format format; /* Buffer format */ |
| 38 | const struct regmap_bus *bus; |
| 39 | |
Mark Brown | 31244e3 | 2011-07-20 22:56:53 +0100 | [diff] [blame] | 40 | #ifdef CONFIG_DEBUG_FS |
| 41 | struct dentry *debugfs; |
| 42 | #endif |
| 43 | |
Mark Brown | 93de912 | 2011-07-20 22:35:37 +0100 | [diff] [blame] | 44 | unsigned int max_register; |
| 45 | bool (*writeable_reg)(struct device *dev, unsigned int reg); |
| 46 | bool (*readable_reg)(struct device *dev, unsigned int reg); |
| 47 | bool (*volatile_reg)(struct device *dev, unsigned int reg); |
Mark Brown | 2efe164 | 2011-08-08 15:41:46 +0900 | [diff] [blame] | 48 | bool (*precious_reg)(struct device *dev, unsigned int reg); |
Lars-Peter Clausen | 6f30644 | 2011-09-05 20:46:32 +0200 | [diff] [blame^] | 49 | |
| 50 | u8 read_flag_mask; |
| 51 | u8 write_flag_mask; |
Mark Brown | 93de912 | 2011-07-20 22:35:37 +0100 | [diff] [blame] | 52 | }; |
| 53 | |
Mark Brown | 8de2f08 | 2011-08-10 17:14:41 +0900 | [diff] [blame] | 54 | bool regmap_writeable(struct regmap *map, unsigned int reg); |
| 55 | bool regmap_readable(struct regmap *map, unsigned int reg); |
| 56 | bool regmap_volatile(struct regmap *map, unsigned int reg); |
| 57 | bool regmap_precious(struct regmap *map, unsigned int reg); |
| 58 | |
Mark Brown | 31244e3 | 2011-07-20 22:56:53 +0100 | [diff] [blame] | 59 | #ifdef CONFIG_DEBUG_FS |
| 60 | extern void regmap_debugfs_initcall(void); |
| 61 | extern void regmap_debugfs_init(struct regmap *map); |
| 62 | extern void regmap_debugfs_exit(struct regmap *map); |
| 63 | #else |
| 64 | void regmap_debugfs_initcall(void) { } |
| 65 | void regmap_debugfs_init(struct regmap *map) { } |
| 66 | void regmap_debugfs_exit(struct regmap *map) { } |
| 67 | #endif |
| 68 | |
Mark Brown | 93de912 | 2011-07-20 22:35:37 +0100 | [diff] [blame] | 69 | #endif |