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