xref: /openbmc/linux/include/linux/mfd/abx500.h (revision ee0975c3)
1af873fceSThomas Gleixner /* SPDX-License-Identifier: GPL-2.0-only */
2812f9e9dSLinus Walleij /*
3812f9e9dSLinus Walleij  * Copyright (C) 2007-2009 ST-Ericsson AB
4fa661258SMattias Wallin  *
5fa661258SMattias Wallin  * ABX500 core access functions.
60fd0013cSMarcus Cooper  * The abx500 interface is used for the Analog Baseband chips.
7fa661258SMattias Wallin  *
8fa661258SMattias Wallin  * Author: Mattias Wallin <mattias.wallin@stericsson.com>
9fa661258SMattias Wallin  * Author: Mattias Nilsson <mattias.i.nilsson@stericsson.com>
10fa661258SMattias Wallin  * Author: Bengt Jonsson <bengt.g.jonsson@stericsson.com>
11fa661258SMattias Wallin  * Author: Rickard Andersson <rickard.andersson@stericsson.com>
12812f9e9dSLinus Walleij  */
13812f9e9dSLinus Walleij 
14812f9e9dSLinus Walleij #include <linux/regulator/machine.h>
15812f9e9dSLinus Walleij 
16313162d0SPaul Gortmaker struct device;
17313162d0SPaul Gortmaker 
18fa661258SMattias Wallin #ifndef MFD_ABX500_H
19fa661258SMattias Wallin #define MFD_ABX500_H
20812f9e9dSLinus Walleij 
21fa661258SMattias Wallin /**
22fa661258SMattias Wallin  * struct abx500_init_setting
23fa661258SMattias Wallin  * Initial value of the registers for driver to use during setup.
24fa661258SMattias Wallin  */
25fa661258SMattias Wallin struct abx500_init_settings {
26fa661258SMattias Wallin 	u8 bank;
27fa661258SMattias Wallin 	u8 reg;
28fa661258SMattias Wallin 	u8 setting;
29fa661258SMattias Wallin };
30fa661258SMattias Wallin 
31fa661258SMattias Wallin int abx500_set_register_interruptible(struct device *dev, u8 bank, u8 reg,
32fa661258SMattias Wallin 	u8 value);
33fa661258SMattias Wallin int abx500_get_register_interruptible(struct device *dev, u8 bank, u8 reg,
34fa661258SMattias Wallin 	u8 *value);
35fa661258SMattias Wallin int abx500_get_register_page_interruptible(struct device *dev, u8 bank,
36fa661258SMattias Wallin 	u8 first_reg, u8 *regvals, u8 numregs);
37fa661258SMattias Wallin int abx500_set_register_page_interruptible(struct device *dev, u8 bank,
38fa661258SMattias Wallin 	u8 first_reg, u8 *regvals, u8 numregs);
39fa661258SMattias Wallin /**
40fa661258SMattias Wallin  * abx500_mask_and_set_register_inerruptible() - Modifies selected bits of a
41fa661258SMattias Wallin  *	target register
42fa661258SMattias Wallin  *
43fa661258SMattias Wallin  * @dev: The AB sub device.
44fa661258SMattias Wallin  * @bank: The i2c bank number.
45fa661258SMattias Wallin  * @bitmask: The bit mask to use.
46fa661258SMattias Wallin  * @bitvalues: The new bit values.
47fa661258SMattias Wallin  *
48fa661258SMattias Wallin  * Updates the value of an AB register:
49fa661258SMattias Wallin  * value -> ((value & ~bitmask) | (bitvalues & bitmask))
50fa661258SMattias Wallin  */
51fa661258SMattias Wallin int abx500_mask_and_set_register_interruptible(struct device *dev, u8 bank,
52fa661258SMattias Wallin 	u8 reg, u8 bitmask, u8 bitvalues);
53fa661258SMattias Wallin int abx500_get_chip_id(struct device *dev);
54fa661258SMattias Wallin int abx500_event_registers_startup_state_get(struct device *dev, u8 *event);
55fa661258SMattias Wallin int abx500_startup_irq_enabled(struct device *dev, unsigned int irq);
56fa661258SMattias Wallin 
57fa661258SMattias Wallin struct abx500_ops {
58fa661258SMattias Wallin 	int (*get_chip_id) (struct device *);
59fa661258SMattias Wallin 	int (*get_register) (struct device *, u8, u8, u8 *);
60fa661258SMattias Wallin 	int (*set_register) (struct device *, u8, u8, u8);
61fa661258SMattias Wallin 	int (*get_register_page) (struct device *, u8, u8, u8 *, u8);
62fa661258SMattias Wallin 	int (*set_register_page) (struct device *, u8, u8, u8 *, u8);
63fa661258SMattias Wallin 	int (*mask_and_set_register) (struct device *, u8, u8, u8, u8);
64fa661258SMattias Wallin 	int (*event_registers_startup_state_get) (struct device *, u8 *);
65fa661258SMattias Wallin 	int (*startup_irq_enabled) (struct device *, unsigned int);
66e0f4fec0SMian Yousaf Kaukab 	void (*dump_all_banks) (struct device *);
67fa661258SMattias Wallin };
68fa661258SMattias Wallin 
69fa661258SMattias Wallin int abx500_register_ops(struct device *core_dev, struct abx500_ops *ops);
70c6252e9cSMark Brown void abx500_remove_ops(struct device *dev);
71812f9e9dSLinus Walleij #endif
72