xref: /openbmc/linux/include/linux/mfd/lochnagar.h (revision 422dcafe)
1422dcafeSCharles Keepax /* SPDX-License-Identifier: GPL-2.0 */
2422dcafeSCharles Keepax /*
3422dcafeSCharles Keepax  * Lochnagar internals
4422dcafeSCharles Keepax  *
5422dcafeSCharles Keepax  * Copyright (c) 2013-2018 Cirrus Logic, Inc. and
6422dcafeSCharles Keepax  *                         Cirrus Logic International Semiconductor Ltd.
7422dcafeSCharles Keepax  *
8422dcafeSCharles Keepax  * Author: Charles Keepax <ckeepax@opensource.cirrus.com>
9422dcafeSCharles Keepax  */
10422dcafeSCharles Keepax 
11422dcafeSCharles Keepax #include <linux/device.h>
12422dcafeSCharles Keepax #include <linux/mutex.h>
13422dcafeSCharles Keepax #include <linux/regmap.h>
14422dcafeSCharles Keepax 
15422dcafeSCharles Keepax #ifndef CIRRUS_LOCHNAGAR_H
16422dcafeSCharles Keepax #define CIRRUS_LOCHNAGAR_H
17422dcafeSCharles Keepax 
18422dcafeSCharles Keepax enum lochnagar_type {
19422dcafeSCharles Keepax 	LOCHNAGAR1,
20422dcafeSCharles Keepax 	LOCHNAGAR2,
21422dcafeSCharles Keepax };
22422dcafeSCharles Keepax 
23422dcafeSCharles Keepax /**
24422dcafeSCharles Keepax  * struct lochnagar - Core data for the Lochnagar audio board driver.
25422dcafeSCharles Keepax  *
26422dcafeSCharles Keepax  * @type: The type of Lochnagar device connected.
27422dcafeSCharles Keepax  * @dev: A pointer to the struct device for the main MFD.
28422dcafeSCharles Keepax  * @regmap: The devices main register map.
29422dcafeSCharles Keepax  * @analogue_config_lock: Lock used to protect updates in the analogue
30422dcafeSCharles Keepax  * configuration as these must not be changed whilst the hardware is processing
31422dcafeSCharles Keepax  * the last update.
32422dcafeSCharles Keepax  */
33422dcafeSCharles Keepax struct lochnagar {
34422dcafeSCharles Keepax 	enum lochnagar_type type;
35422dcafeSCharles Keepax 	struct device *dev;
36422dcafeSCharles Keepax 	struct regmap *regmap;
37422dcafeSCharles Keepax 
38422dcafeSCharles Keepax 	/* Lock to protect updates to the analogue configuration */
39422dcafeSCharles Keepax 	struct mutex analogue_config_lock;
40422dcafeSCharles Keepax };
41422dcafeSCharles Keepax 
42422dcafeSCharles Keepax /* Register Addresses */
43422dcafeSCharles Keepax #define LOCHNAGAR_SOFTWARE_RESET                             0x00
44422dcafeSCharles Keepax #define LOCHNAGAR_FIRMWARE_ID1                               0x01
45422dcafeSCharles Keepax #define LOCHNAGAR_FIRMWARE_ID2                               0x02
46422dcafeSCharles Keepax 
47422dcafeSCharles Keepax /* (0x0000)  Software Reset */
48422dcafeSCharles Keepax #define LOCHNAGAR_DEVICE_ID_MASK                           0xFFFC
49422dcafeSCharles Keepax #define LOCHNAGAR_DEVICE_ID_SHIFT                               2
50422dcafeSCharles Keepax #define LOCHNAGAR_REV_ID_MASK                              0x0003
51422dcafeSCharles Keepax #define LOCHNAGAR_REV_ID_SHIFT                                  0
52422dcafeSCharles Keepax 
53422dcafeSCharles Keepax int lochnagar_update_config(struct lochnagar *lochnagar);
54422dcafeSCharles Keepax 
55422dcafeSCharles Keepax #endif
56