Simon Glass | 0ab6f0b | 2018-12-10 10:37:42 -0700 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
| 2 | /* |
| 3 | * maxim_codec.h -- MAXIM codec common interface file |
| 4 | * |
| 5 | * Copyright (C) 2013 Samsung Electronics |
| 6 | * D Krishna Mohan <krishna.md@samsung.com> |
| 7 | */ |
| 8 | |
| 9 | #ifndef __MAXIM_COMMON_H__ |
| 10 | #define __MAXIM_COMMON_H__ |
| 11 | |
| 12 | enum maxim_codec_type { |
| 13 | MAX98095, |
| 14 | MAX98090, |
| 15 | }; |
| 16 | |
| 17 | struct maxim_priv { |
| 18 | enum maxim_codec_type devtype; |
| 19 | unsigned int sysclk; |
| 20 | unsigned int rate; |
| 21 | unsigned int fmt; |
| 22 | struct udevice *dev; |
| 23 | }; |
| 24 | |
| 25 | #define MAXIM_AUDIO_I2C_BUS 7 |
| 26 | #define MAXIM_AUDIO_I2C_REG_98095 0x22 |
| 27 | |
| 28 | #define MAXIM_AUDIO_I2C_REG MAXIM_AUDIO_I2C_REG_98095 |
| 29 | |
| 30 | /* |
| 31 | * Writes value to a device register through i2c |
| 32 | * |
| 33 | * @param priv Private data for driver |
| 34 | * @param reg reg number to be write |
| 35 | * @param data data to be writen to the above registor |
| 36 | * |
Heinrich Schuchardt | 185f812 | 2022-01-19 18:05:50 +0100 | [diff] [blame] | 37 | * Return: int value 1 for change, 0 for no change or negative error code. |
Simon Glass | 0ab6f0b | 2018-12-10 10:37:42 -0700 | [diff] [blame] | 38 | */ |
| 39 | int maxim_i2c_write(struct maxim_priv *priv, unsigned int reg, |
| 40 | unsigned char data); |
| 41 | |
| 42 | /* |
| 43 | * Read a value from a device register through i2c |
| 44 | * |
| 45 | * @param priv Private data for driver |
| 46 | * @param reg reg number to be read |
| 47 | * @param data address of read data to be stored |
| 48 | * |
Heinrich Schuchardt | 185f812 | 2022-01-19 18:05:50 +0100 | [diff] [blame] | 49 | * Return: int value 0 for success, -1 in case of error. |
Simon Glass | 0ab6f0b | 2018-12-10 10:37:42 -0700 | [diff] [blame] | 50 | */ |
| 51 | unsigned int maxim_i2c_read(struct maxim_priv *priv, unsigned int reg, |
| 52 | unsigned char *data); |
| 53 | |
| 54 | /* |
| 55 | * update device register bits through i2c |
| 56 | * |
| 57 | * @param priv Private data for driver |
| 58 | * @param reg codec register |
| 59 | * @param mask register mask |
| 60 | * @param value new value |
| 61 | * |
Heinrich Schuchardt | 185f812 | 2022-01-19 18:05:50 +0100 | [diff] [blame] | 62 | * Return: int value 0 for success, non-zero error code. |
Simon Glass | 0ab6f0b | 2018-12-10 10:37:42 -0700 | [diff] [blame] | 63 | */ |
| 64 | int maxim_bic_or(struct maxim_priv *priv, unsigned int reg, unsigned char mask, |
| 65 | unsigned char value); |
| 66 | |
| 67 | #endif /* __MAXIM_COMMON_H__ */ |