hc
2023-12-08 01573e231f18eb2d99162747186f59511f56b64d
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
/* SPDX-License-Identifier: GPL-2.0+ */
 
#ifndef __AW_DEVICE_H__
#define __AW_DEVICE_H__
#include <linux/version.h>
#include <linux/kernel.h>
#include <sound/control.h>
#include <sound/soc.h>
#include "aw_acf_bin.h"
 
#define AW87XXX_PID_9B_PRODUCT_MAX    (1)
#define AW87XXX_PID_39_PRODUCT_MAX    (3)
#define AW87XXX_PID_59_3X9_PRODUCT_MAX    (2)
#define AW87XXX_PID_59_5X9_PRODUCT_MAX    (4)
#define AW87XXX_PID_5A_PRODUCT_MAX    (5)
#define AW87XXX_PID_76_PROFUCT_MAX    (3)
#define AW_PRODUCT_NAME_LEN        (8)
 
#define AW_GPIO_HIGHT_LEVEL        (1)
#define AW_GPIO_LOW_LEVEL        (0)
 
#define AW_I2C_RETRIES            (5)
#define AW_I2C_RETRY_DELAY        (2)
#define AW_I2C_READ_MSG_NUM        (2)
 
#define AW_READ_CHIPID_RETRIES        (5)
#define AW_READ_CHIPID_RETRY_DELAY    (2)
#define AW_DEV_REG_CHIPID        (0x00)
 
#define AW_DEV_REG_INVALID_MASK        (0xff)
 
#define AW_NO_RESET_GPIO        (-1)
 
#define AW_PID_9B_BIN_REG_CFG_COUNT    (10)
 
/********************************************
 *
 * aw87xxx devices attributes
 *
 *******************************************/
struct aw_device;
 
struct aw_device_ops {
   int (*pwr_on_func)(struct aw_device *aw_dev, struct aw_data_container *data);
   int (*pwr_off_func)(struct aw_device *aw_dev, struct aw_data_container *data);
};
 
enum aw_dev_chipid {
   AW_DEV_CHIPID_18 = 0x18,
   AW_DEV_CHIPID_39 = 0x39,
   AW_DEV_CHIPID_59 = 0x59,
   AW_DEV_CHIPID_69 = 0x69,
   AW_DEV_CHIPID_5A = 0x5A,
   AW_DEV_CHIPID_9A = 0x9A,
   AW_DEV_CHIPID_9B = 0x9B,
   AW_DEV_CHIPID_76 = 0x76,
};
 
enum aw_dev_hw_status {
   AW_DEV_HWEN_OFF = 0,
   AW_DEV_HWEN_ON,
   AW_DEV_HWEN_INVALID,
   AW_DEV_HWEN_STATUS_MAX,
};
 
enum aw_dev_soft_off_enable {
   AW_DEV_SOFT_OFF_DISENABLE = 0,
   AW_DEV_SOFT_OFF_ENABLE = 1,
};
 
enum aw_dev_soft_rst_enable {
   AW_DEV_SOFT_RST_DISENABLE = 0,
   AW_DEV_SOFT_RST_ENABLE = 1,
};
 
enum aw_reg_receiver_mode {
   AW_NOT_REC_MODE = 0,
   AW_IS_REC_MODE = 1,
};
 
struct aw_mute_desc {
   uint8_t addr;
   uint8_t enable;
   uint8_t disable;
   uint16_t mask;
};
 
struct aw_soft_rst_desc {
   int len;
   unsigned char *access;
};
 
struct aw_esd_check_desc {
   uint8_t first_update_reg_addr;
   uint8_t first_update_reg_val;
};
 
struct aw_rec_mode_desc {
   uint8_t addr;
   uint8_t enable;
   uint8_t disable;
   uint8_t mask;
};
 
struct aw_device {
   uint8_t i2c_addr;
   uint8_t chipid;
   uint8_t soft_rst_enable;
   uint8_t soft_off_enable;
   uint8_t is_rec_mode;
   int hwen_status;
   int i2c_bus;
   int rst_gpio;
   int rst_shared_gpio;
   int reg_max_addr;
   int product_cnt;
   const char **product_tab;
   const unsigned char *reg_access;
 
   struct device *dev;
   struct i2c_client *i2c;
   struct aw_mute_desc mute_desc;
   struct aw_soft_rst_desc soft_rst_desc;
   struct aw_esd_check_desc esd_desc;
   struct aw_rec_mode_desc rec_desc;
 
   struct aw_device_ops ops;
};
 
 
int aw_dev_i2c_write_byte(struct aw_device *aw_dev,
           uint8_t reg_addr, uint8_t reg_data);
int aw_dev_i2c_read_byte(struct aw_device *aw_dev,
           uint8_t reg_addr, uint8_t *reg_data);
int aw_dev_i2c_read_msg(struct aw_device *aw_dev,
   uint8_t reg_addr, uint8_t *data_buf, uint32_t data_len);
int aw_dev_i2c_write_bits(struct aw_device *aw_dev,
   uint8_t reg_addr, uint8_t mask, uint8_t reg_data);
void aw_dev_soft_reset(struct aw_device *aw_dev);
void aw_dev_hw_pwr_ctrl(struct aw_device *aw_dev, bool enable);
int aw_dev_default_profile_check(struct aw_device *aw_dev,
       int profile, struct aw_data_container *profile_data);
int aw_dev_default_pwr_on(struct aw_device *aw_dev,
           struct aw_data_container *profile_data);
int aw_dev_default_pwr_off(struct aw_device *aw_dev,
           struct aw_data_container *profile_data);
int aw_dev_esd_reg_status_check(struct aw_device *aw_dev);
int aw_dev_check_reg_is_rec_mode(struct aw_device *aw_dev);
int aw_dev_init(struct aw_device *aw_dev);
 
#endif