summaryrefslogtreecommitdiff
path: root/drivers/sound/maxim_codec.h
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2018-12-10 10:37:42 -0700
committerSimon Glass <sjg@chromium.org>2018-12-13 16:36:30 -0700
commit0ab6f0b358195b26096806f3002c8d153e5334dd (patch)
tree8e8793d4db2fb5ab7c352108a27e28ad3a88c5fc /drivers/sound/maxim_codec.h
parent482e585bdf4a9eb1374d525ec4e57c671038d239 (diff)
dm: sound: Move common code out of maxim98095
The register-access code is useful for any maxim codec. Move it out into its own file. Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'drivers/sound/maxim_codec.h')
-rw-r--r--drivers/sound/maxim_codec.h67
1 files changed, 67 insertions, 0 deletions
diff --git a/drivers/sound/maxim_codec.h b/drivers/sound/maxim_codec.h
new file mode 100644
index 0000000000..a3128e0bb7
--- /dev/null
+++ b/drivers/sound/maxim_codec.h
@@ -0,0 +1,67 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * maxim_codec.h -- MAXIM codec common interface file
+ *
+ * Copyright (C) 2013 Samsung Electronics
+ * D Krishna Mohan <krishna.md@samsung.com>
+ */
+
+#ifndef __MAXIM_COMMON_H__
+#define __MAXIM_COMMON_H__
+
+enum maxim_codec_type {
+ MAX98095,
+ MAX98090,
+};
+
+struct maxim_priv {
+ enum maxim_codec_type devtype;
+ unsigned int sysclk;
+ unsigned int rate;
+ unsigned int fmt;
+ struct udevice *dev;
+};
+
+#define MAXIM_AUDIO_I2C_BUS 7
+#define MAXIM_AUDIO_I2C_REG_98095 0x22
+
+#define MAXIM_AUDIO_I2C_REG MAXIM_AUDIO_I2C_REG_98095
+
+/*
+ * Writes value to a device register through i2c
+ *
+ * @param priv Private data for driver
+ * @param reg reg number to be write
+ * @param data data to be writen to the above registor
+ *
+ * @return int value 1 for change, 0 for no change or negative error code.
+ */
+int maxim_i2c_write(struct maxim_priv *priv, unsigned int reg,
+ unsigned char data);
+
+/*
+ * Read a value from a device register through i2c
+ *
+ * @param priv Private data for driver
+ * @param reg reg number to be read
+ * @param data address of read data to be stored
+ *
+ * @return int value 0 for success, -1 in case of error.
+ */
+unsigned int maxim_i2c_read(struct maxim_priv *priv, unsigned int reg,
+ unsigned char *data);
+
+/*
+ * update device register bits through i2c
+ *
+ * @param priv Private data for driver
+ * @param reg codec register
+ * @param mask register mask
+ * @param value new value
+ *
+ * @return int value 0 for success, non-zero error code.
+ */
+int maxim_bic_or(struct maxim_priv *priv, unsigned int reg, unsigned char mask,
+ unsigned char value);
+
+#endif /* __MAXIM_COMMON_H__ */