xref: /OK3568_Linux_fs/kernel/include/linux/mfd/lochnagar.h (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun /* SPDX-License-Identifier: GPL-2.0 */
2*4882a593Smuzhiyun /*
3*4882a593Smuzhiyun  * Lochnagar internals
4*4882a593Smuzhiyun  *
5*4882a593Smuzhiyun  * Copyright (c) 2013-2018 Cirrus Logic, Inc. and
6*4882a593Smuzhiyun  *                         Cirrus Logic International Semiconductor Ltd.
7*4882a593Smuzhiyun  *
8*4882a593Smuzhiyun  * Author: Charles Keepax <ckeepax@opensource.cirrus.com>
9*4882a593Smuzhiyun  */
10*4882a593Smuzhiyun 
11*4882a593Smuzhiyun #include <linux/device.h>
12*4882a593Smuzhiyun #include <linux/mutex.h>
13*4882a593Smuzhiyun #include <linux/regmap.h>
14*4882a593Smuzhiyun 
15*4882a593Smuzhiyun #ifndef CIRRUS_LOCHNAGAR_H
16*4882a593Smuzhiyun #define CIRRUS_LOCHNAGAR_H
17*4882a593Smuzhiyun 
18*4882a593Smuzhiyun enum lochnagar_type {
19*4882a593Smuzhiyun 	LOCHNAGAR1,
20*4882a593Smuzhiyun 	LOCHNAGAR2,
21*4882a593Smuzhiyun };
22*4882a593Smuzhiyun 
23*4882a593Smuzhiyun /**
24*4882a593Smuzhiyun  * struct lochnagar - Core data for the Lochnagar audio board driver.
25*4882a593Smuzhiyun  *
26*4882a593Smuzhiyun  * @type: The type of Lochnagar device connected.
27*4882a593Smuzhiyun  * @dev: A pointer to the struct device for the main MFD.
28*4882a593Smuzhiyun  * @regmap: The devices main register map.
29*4882a593Smuzhiyun  * @analogue_config_lock: Lock used to protect updates in the analogue
30*4882a593Smuzhiyun  * configuration as these must not be changed whilst the hardware is processing
31*4882a593Smuzhiyun  * the last update.
32*4882a593Smuzhiyun  */
33*4882a593Smuzhiyun struct lochnagar {
34*4882a593Smuzhiyun 	enum lochnagar_type type;
35*4882a593Smuzhiyun 	struct device *dev;
36*4882a593Smuzhiyun 	struct regmap *regmap;
37*4882a593Smuzhiyun 
38*4882a593Smuzhiyun 	/* Lock to protect updates to the analogue configuration */
39*4882a593Smuzhiyun 	struct mutex analogue_config_lock;
40*4882a593Smuzhiyun };
41*4882a593Smuzhiyun 
42*4882a593Smuzhiyun /* Register Addresses */
43*4882a593Smuzhiyun #define LOCHNAGAR_SOFTWARE_RESET                             0x00
44*4882a593Smuzhiyun #define LOCHNAGAR_FIRMWARE_ID1                               0x01
45*4882a593Smuzhiyun #define LOCHNAGAR_FIRMWARE_ID2                               0x02
46*4882a593Smuzhiyun 
47*4882a593Smuzhiyun /* (0x0000)  Software Reset */
48*4882a593Smuzhiyun #define LOCHNAGAR_DEVICE_ID_MASK                           0xFFFC
49*4882a593Smuzhiyun #define LOCHNAGAR_DEVICE_ID_SHIFT                               2
50*4882a593Smuzhiyun #define LOCHNAGAR_REV_ID_MASK                              0x0003
51*4882a593Smuzhiyun #define LOCHNAGAR_REV_ID_SHIFT                                  0
52*4882a593Smuzhiyun 
53*4882a593Smuzhiyun int lochnagar_update_config(struct lochnagar *lochnagar);
54*4882a593Smuzhiyun 
55*4882a593Smuzhiyun #endif
56