18093ac2bc969ff68aaf6025f4aee3bb70b889787Dmitry Shmidt#ifndef __LINUX_MFD_MSM_ADIE_CODEC_H
28093ac2bc969ff68aaf6025f4aee3bb70b889787Dmitry Shmidt#define __LINUX_MFD_MSM_ADIE_CODEC_H
38093ac2bc969ff68aaf6025f4aee3bb70b889787Dmitry Shmidt
48093ac2bc969ff68aaf6025f4aee3bb70b889787Dmitry Shmidt#include <linux/types.h>
58093ac2bc969ff68aaf6025f4aee3bb70b889787Dmitry Shmidt
68093ac2bc969ff68aaf6025f4aee3bb70b889787Dmitry Shmidt/* Value Represents a entry */
78093ac2bc969ff68aaf6025f4aee3bb70b889787Dmitry Shmidt#define ADIE_CODEC_ACTION_ENTRY       0x1
88093ac2bc969ff68aaf6025f4aee3bb70b889787Dmitry Shmidt/* Value representing a delay wait */
98093ac2bc969ff68aaf6025f4aee3bb70b889787Dmitry Shmidt#define ADIE_CODEC_ACTION_DELAY_WAIT      0x2
108093ac2bc969ff68aaf6025f4aee3bb70b889787Dmitry Shmidt/* Value representing a stage reached */
118093ac2bc969ff68aaf6025f4aee3bb70b889787Dmitry Shmidt#define ADIE_CODEC_ACTION_STAGE_REACHED   0x3
128093ac2bc969ff68aaf6025f4aee3bb70b889787Dmitry Shmidt
138093ac2bc969ff68aaf6025f4aee3bb70b889787Dmitry Shmidt/* This value is the state after the client sets the path */
148093ac2bc969ff68aaf6025f4aee3bb70b889787Dmitry Shmidt#define ADIE_CODEC_PATH_OFF                                        0x0050
158093ac2bc969ff68aaf6025f4aee3bb70b889787Dmitry Shmidt
168093ac2bc969ff68aaf6025f4aee3bb70b889787Dmitry Shmidt/* State to which client asks the drv to proceed to where it can
178093ac2bc969ff68aaf6025f4aee3bb70b889787Dmitry Shmidt * set up the clocks and 0-fill PCM buffers
188093ac2bc969ff68aaf6025f4aee3bb70b889787Dmitry Shmidt */
198093ac2bc969ff68aaf6025f4aee3bb70b889787Dmitry Shmidt#define ADIE_CODEC_DIGITAL_READY                                   0x0100
208093ac2bc969ff68aaf6025f4aee3bb70b889787Dmitry Shmidt
218093ac2bc969ff68aaf6025f4aee3bb70b889787Dmitry Shmidt/* State to which client asks the drv to proceed to where it can
228093ac2bc969ff68aaf6025f4aee3bb70b889787Dmitry Shmidt * start sending data after internal steady state delay
238093ac2bc969ff68aaf6025f4aee3bb70b889787Dmitry Shmidt */
248093ac2bc969ff68aaf6025f4aee3bb70b889787Dmitry Shmidt#define ADIE_CODEC_DIGITAL_ANALOG_READY                            0x1000
258093ac2bc969ff68aaf6025f4aee3bb70b889787Dmitry Shmidt
268093ac2bc969ff68aaf6025f4aee3bb70b889787Dmitry Shmidt
278093ac2bc969ff68aaf6025f4aee3bb70b889787Dmitry Shmidt/*  Client Asks adie to switch off the Analog portion of the
288093ac2bc969ff68aaf6025f4aee3bb70b889787Dmitry Shmidt *  the internal codec. After the use of this path
298093ac2bc969ff68aaf6025f4aee3bb70b889787Dmitry Shmidt */
308093ac2bc969ff68aaf6025f4aee3bb70b889787Dmitry Shmidt#define ADIE_CODEC_ANALOG_OFF                                      0x0750
318093ac2bc969ff68aaf6025f4aee3bb70b889787Dmitry Shmidt
328093ac2bc969ff68aaf6025f4aee3bb70b889787Dmitry Shmidt
338093ac2bc969ff68aaf6025f4aee3bb70b889787Dmitry Shmidt/* Client Asks adie to switch off the digital portion of the
348093ac2bc969ff68aaf6025f4aee3bb70b889787Dmitry Shmidt *  the internal codec. After switching off the analog portion.
358093ac2bc969ff68aaf6025f4aee3bb70b889787Dmitry Shmidt *
368093ac2bc969ff68aaf6025f4aee3bb70b889787Dmitry Shmidt *  0-fill PCM may or maynot be sent at this point
378093ac2bc969ff68aaf6025f4aee3bb70b889787Dmitry Shmidt *
388093ac2bc969ff68aaf6025f4aee3bb70b889787Dmitry Shmidt */
398093ac2bc969ff68aaf6025f4aee3bb70b889787Dmitry Shmidt#define ADIE_CODEC_DIGITAL_OFF                                     0x0600
408093ac2bc969ff68aaf6025f4aee3bb70b889787Dmitry Shmidt
418093ac2bc969ff68aaf6025f4aee3bb70b889787Dmitry Shmidt/* State to which client asks the drv to write the default values
428093ac2bc969ff68aaf6025f4aee3bb70b889787Dmitry Shmidt * to the registers */
438093ac2bc969ff68aaf6025f4aee3bb70b889787Dmitry Shmidt#define ADIE_CODEC_FLASH_IMAGE 					   0x0001
448093ac2bc969ff68aaf6025f4aee3bb70b889787Dmitry Shmidt
458093ac2bc969ff68aaf6025f4aee3bb70b889787Dmitry Shmidt/* Path type */
468093ac2bc969ff68aaf6025f4aee3bb70b889787Dmitry Shmidt#define ADIE_CODEC_RX 0
478093ac2bc969ff68aaf6025f4aee3bb70b889787Dmitry Shmidt#define ADIE_CODEC_TX 1
488093ac2bc969ff68aaf6025f4aee3bb70b889787Dmitry Shmidt#define ADIE_CODEC_LB 3
498093ac2bc969ff68aaf6025f4aee3bb70b889787Dmitry Shmidt#define ADIE_CODEC_MAX 4
508093ac2bc969ff68aaf6025f4aee3bb70b889787Dmitry Shmidt
518093ac2bc969ff68aaf6025f4aee3bb70b889787Dmitry Shmidt#define ADIE_CODEC_PACK_ENTRY(reg, mask, val) ((val)|(mask << 8)|(reg << 16))
528093ac2bc969ff68aaf6025f4aee3bb70b889787Dmitry Shmidt
538093ac2bc969ff68aaf6025f4aee3bb70b889787Dmitry Shmidt#define ADIE_CODEC_UNPACK_ENTRY(packed, reg, mask, val) \
548093ac2bc969ff68aaf6025f4aee3bb70b889787Dmitry Shmidt	do { \
558093ac2bc969ff68aaf6025f4aee3bb70b889787Dmitry Shmidt		((reg) = ((packed >> 16) & (0xff))); \
568093ac2bc969ff68aaf6025f4aee3bb70b889787Dmitry Shmidt		((mask) = ((packed >> 8) & (0xff))); \
578093ac2bc969ff68aaf6025f4aee3bb70b889787Dmitry Shmidt		((val) = ((packed) & (0xff))); \
588093ac2bc969ff68aaf6025f4aee3bb70b889787Dmitry Shmidt	} while (0);
598093ac2bc969ff68aaf6025f4aee3bb70b889787Dmitry Shmidt
608093ac2bc969ff68aaf6025f4aee3bb70b889787Dmitry Shmidtstruct adie_codec_action_unit {
618093ac2bc969ff68aaf6025f4aee3bb70b889787Dmitry Shmidt	u32 type;
628093ac2bc969ff68aaf6025f4aee3bb70b889787Dmitry Shmidt	u32 action;
638093ac2bc969ff68aaf6025f4aee3bb70b889787Dmitry Shmidt};
648093ac2bc969ff68aaf6025f4aee3bb70b889787Dmitry Shmidt
658093ac2bc969ff68aaf6025f4aee3bb70b889787Dmitry Shmidtstruct adie_codec_hwsetting_entry{
668093ac2bc969ff68aaf6025f4aee3bb70b889787Dmitry Shmidt	struct adie_codec_action_unit *actions;
678093ac2bc969ff68aaf6025f4aee3bb70b889787Dmitry Shmidt	u32 action_sz;
688093ac2bc969ff68aaf6025f4aee3bb70b889787Dmitry Shmidt	u32 freq_plan;
698093ac2bc969ff68aaf6025f4aee3bb70b889787Dmitry Shmidt	u32 osr;
708093ac2bc969ff68aaf6025f4aee3bb70b889787Dmitry Shmidt	/* u32  VolMask;
718093ac2bc969ff68aaf6025f4aee3bb70b889787Dmitry Shmidt	 * u32  SidetoneMask;
728093ac2bc969ff68aaf6025f4aee3bb70b889787Dmitry Shmidt	 */
738093ac2bc969ff68aaf6025f4aee3bb70b889787Dmitry Shmidt};
748093ac2bc969ff68aaf6025f4aee3bb70b889787Dmitry Shmidt
758093ac2bc969ff68aaf6025f4aee3bb70b889787Dmitry Shmidtstruct adie_codec_dev_profile {
768093ac2bc969ff68aaf6025f4aee3bb70b889787Dmitry Shmidt	u32 path_type; /* RX or TX */
778093ac2bc969ff68aaf6025f4aee3bb70b889787Dmitry Shmidt	u32 setting_sz;
788093ac2bc969ff68aaf6025f4aee3bb70b889787Dmitry Shmidt	struct adie_codec_hwsetting_entry *settings;
798093ac2bc969ff68aaf6025f4aee3bb70b889787Dmitry Shmidt};
808093ac2bc969ff68aaf6025f4aee3bb70b889787Dmitry Shmidt
818093ac2bc969ff68aaf6025f4aee3bb70b889787Dmitry Shmidtstruct adie_codec_register {
828093ac2bc969ff68aaf6025f4aee3bb70b889787Dmitry Shmidt	u8 reg;
838093ac2bc969ff68aaf6025f4aee3bb70b889787Dmitry Shmidt	u8 mask;
848093ac2bc969ff68aaf6025f4aee3bb70b889787Dmitry Shmidt	u8 val;
858093ac2bc969ff68aaf6025f4aee3bb70b889787Dmitry Shmidt};
868093ac2bc969ff68aaf6025f4aee3bb70b889787Dmitry Shmidt
878093ac2bc969ff68aaf6025f4aee3bb70b889787Dmitry Shmidtstruct adie_codec_register_image {
888093ac2bc969ff68aaf6025f4aee3bb70b889787Dmitry Shmidt	struct adie_codec_register *regs;
898093ac2bc969ff68aaf6025f4aee3bb70b889787Dmitry Shmidt	u32 img_sz;
908093ac2bc969ff68aaf6025f4aee3bb70b889787Dmitry Shmidt};
918093ac2bc969ff68aaf6025f4aee3bb70b889787Dmitry Shmidt
928093ac2bc969ff68aaf6025f4aee3bb70b889787Dmitry Shmidtstruct adie_codec_path;
938093ac2bc969ff68aaf6025f4aee3bb70b889787Dmitry Shmidt
948093ac2bc969ff68aaf6025f4aee3bb70b889787Dmitry Shmidtstruct adie_codec_anc_data {
958093ac2bc969ff68aaf6025f4aee3bb70b889787Dmitry Shmidt	u32 size;
968093ac2bc969ff68aaf6025f4aee3bb70b889787Dmitry Shmidt	u32 writes[];
978093ac2bc969ff68aaf6025f4aee3bb70b889787Dmitry Shmidt};
988093ac2bc969ff68aaf6025f4aee3bb70b889787Dmitry Shmidt
998093ac2bc969ff68aaf6025f4aee3bb70b889787Dmitry Shmidtstruct adie_codec_operations {
1008093ac2bc969ff68aaf6025f4aee3bb70b889787Dmitry Shmidt	int	 codec_id;
1018093ac2bc969ff68aaf6025f4aee3bb70b889787Dmitry Shmidt	int (*codec_open) (struct adie_codec_dev_profile *profile,
1028093ac2bc969ff68aaf6025f4aee3bb70b889787Dmitry Shmidt				struct adie_codec_path **path_pptr);
1038093ac2bc969ff68aaf6025f4aee3bb70b889787Dmitry Shmidt	int (*codec_close) (struct adie_codec_path *path_ptr);
1048093ac2bc969ff68aaf6025f4aee3bb70b889787Dmitry Shmidt	int (*codec_setpath) (struct adie_codec_path *path_ptr,
1058093ac2bc969ff68aaf6025f4aee3bb70b889787Dmitry Shmidt				u32 freq_plan, u32 osr);
1068093ac2bc969ff68aaf6025f4aee3bb70b889787Dmitry Shmidt	int (*codec_proceed_stage) (struct adie_codec_path *path_ptr,
1078093ac2bc969ff68aaf6025f4aee3bb70b889787Dmitry Shmidt					u32 state);
1088093ac2bc969ff68aaf6025f4aee3bb70b889787Dmitry Shmidt	u32 (*codec_freq_supported) (struct adie_codec_dev_profile *profile,
1098093ac2bc969ff68aaf6025f4aee3bb70b889787Dmitry Shmidt					u32 requested_freq);
1108093ac2bc969ff68aaf6025f4aee3bb70b889787Dmitry Shmidt	int (*codec_enable_sidetone) (struct adie_codec_path *rx_path_ptr,
1118093ac2bc969ff68aaf6025f4aee3bb70b889787Dmitry Shmidt					u32 enable);
1128093ac2bc969ff68aaf6025f4aee3bb70b889787Dmitry Shmidt	int (*codec_enable_anc) (struct adie_codec_path *rx_path_ptr,
1138093ac2bc969ff68aaf6025f4aee3bb70b889787Dmitry Shmidt		u32 enable, struct adie_codec_anc_data *calibration_writes);
1148093ac2bc969ff68aaf6025f4aee3bb70b889787Dmitry Shmidt	int (*codec_set_device_digital_volume) (
1158093ac2bc969ff68aaf6025f4aee3bb70b889787Dmitry Shmidt					struct adie_codec_path *path_ptr,
1168093ac2bc969ff68aaf6025f4aee3bb70b889787Dmitry Shmidt					u32 num_channels,
1178093ac2bc969ff68aaf6025f4aee3bb70b889787Dmitry Shmidt					u32 vol_percentage);
1188093ac2bc969ff68aaf6025f4aee3bb70b889787Dmitry Shmidt
1198093ac2bc969ff68aaf6025f4aee3bb70b889787Dmitry Shmidt	int (*codec_set_device_analog_volume) (struct adie_codec_path *path_ptr,
1208093ac2bc969ff68aaf6025f4aee3bb70b889787Dmitry Shmidt						u32 num_channels,
1218093ac2bc969ff68aaf6025f4aee3bb70b889787Dmitry Shmidt						u32 volume);
1228093ac2bc969ff68aaf6025f4aee3bb70b889787Dmitry Shmidt	int (*codec_set_master_mode) (struct adie_codec_path *path_ptr,
1238093ac2bc969ff68aaf6025f4aee3bb70b889787Dmitry Shmidt					u8 master);
1248093ac2bc969ff68aaf6025f4aee3bb70b889787Dmitry Shmidt};
1258093ac2bc969ff68aaf6025f4aee3bb70b889787Dmitry Shmidt
1268093ac2bc969ff68aaf6025f4aee3bb70b889787Dmitry Shmidtint adie_codec_register_codec_operations(
1278093ac2bc969ff68aaf6025f4aee3bb70b889787Dmitry Shmidt				const struct adie_codec_operations *codec_ops);
1288093ac2bc969ff68aaf6025f4aee3bb70b889787Dmitry Shmidtint adie_codec_open(struct adie_codec_dev_profile *profile,
1298093ac2bc969ff68aaf6025f4aee3bb70b889787Dmitry Shmidt	struct adie_codec_path **path_pptr);
1308093ac2bc969ff68aaf6025f4aee3bb70b889787Dmitry Shmidtint adie_codec_setpath(struct adie_codec_path *path_ptr,
1318093ac2bc969ff68aaf6025f4aee3bb70b889787Dmitry Shmidt	u32 freq_plan, u32 osr);
1328093ac2bc969ff68aaf6025f4aee3bb70b889787Dmitry Shmidtint adie_codec_proceed_stage(struct adie_codec_path *path_ptr, u32 state);
1338093ac2bc969ff68aaf6025f4aee3bb70b889787Dmitry Shmidtint adie_codec_close(struct adie_codec_path *path_ptr);
1348093ac2bc969ff68aaf6025f4aee3bb70b889787Dmitry Shmidtu32 adie_codec_freq_supported(struct adie_codec_dev_profile *profile,
1358093ac2bc969ff68aaf6025f4aee3bb70b889787Dmitry Shmidt							u32 requested_freq);
1368093ac2bc969ff68aaf6025f4aee3bb70b889787Dmitry Shmidtint adie_codec_enable_sidetone(struct adie_codec_path *rx_path_ptr, u32 enable);
1378093ac2bc969ff68aaf6025f4aee3bb70b889787Dmitry Shmidtint adie_codec_enable_anc(struct adie_codec_path *rx_path_ptr, u32 enable,
1388093ac2bc969ff68aaf6025f4aee3bb70b889787Dmitry Shmidt	struct adie_codec_anc_data *calibration_writes);
1398093ac2bc969ff68aaf6025f4aee3bb70b889787Dmitry Shmidtint adie_codec_set_device_digital_volume(struct adie_codec_path *path_ptr,
1408093ac2bc969ff68aaf6025f4aee3bb70b889787Dmitry Shmidt		u32 num_channels, u32 vol_percentage /* in percentage */);
1418093ac2bc969ff68aaf6025f4aee3bb70b889787Dmitry Shmidt
1428093ac2bc969ff68aaf6025f4aee3bb70b889787Dmitry Shmidtint adie_codec_set_device_analog_volume(struct adie_codec_path *path_ptr,
1438093ac2bc969ff68aaf6025f4aee3bb70b889787Dmitry Shmidt		u32 num_channels, u32 volume /* in percentage */);
1448093ac2bc969ff68aaf6025f4aee3bb70b889787Dmitry Shmidt
1458093ac2bc969ff68aaf6025f4aee3bb70b889787Dmitry Shmidtint adie_codec_set_master_mode(struct adie_codec_path *path_ptr, u8 master);
1468093ac2bc969ff68aaf6025f4aee3bb70b889787Dmitry Shmidt#endif
147