Commit 41e0207f authored by Mark Brown's avatar Mark Brown

ASoC: codecs: Add Awinic AW88395 audio amplifier

Merge series from wangweidong.a@awinic.com:

The Awinic AW88395 is an I2S/TDM input, high efficiency
digital Smart K audio amplifier with an integrated 10.25V
smart boost converter.

Add a DT schema for describing Awinic AW88395 audio amplifiers. They are
controlled using I2C
parents 381ee169 f88b6c0c
# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
%YAML 1.2
---
$id: http://devicetree.org/schemas/sound/awinic,aw88395.yaml#
$schema: http://devicetree.org/meta-schemas/core.yaml#
title: Awinic AW88395 Smart Audio Amplifier
maintainers:
- Weidong Wang <wangweidong.a@awinic.com>
description:
The Awinic AW88395 is an I2S/TDM input, high efficiency
digital Smart K audio amplifier with an integrated 10.25V
smart boost convert.
allOf:
- $ref: dai-common.yaml#
properties:
compatible:
const: awinic,aw88395
reg:
maxItems: 1
'#sound-dai-cells':
const: 0
reset-gpios:
maxItems: 1
required:
- compatible
- reg
- '#sound-dai-cells'
- reset-gpios
unevaluatedProperties: false
examples:
- |
#include <dt-bindings/gpio/gpio.h>
i2c {
#address-cells = <1>;
#size-cells = <0>;
audio-codec@34 {
compatible = "awinic,aw88395";
reg = <0x34>;
#sound-dai-cells = <0>;
reset-gpios = <&gpio 10 GPIO_ACTIVE_LOW>;
};
};
......@@ -54,6 +54,7 @@ config SND_SOC_ALL_CODECS
imply SND_SOC_ALC5623
imply SND_SOC_ALC5632
imply SND_SOC_AW8738
imply SND_SOC_AW88395
imply SND_SOC_BT_SCO
imply SND_SOC_BD28623
imply SND_SOC_CQ0093VC
......@@ -601,6 +602,22 @@ config SND_SOC_AW8738
SND_SOC_SIMPLE_AMPLIFIER, but additionally allows setting the
operation mode using the Awinic-specific one-wire pulse control.
config SND_SOC_AW88395_LIB
tristate
config SND_SOC_AW88395
tristate "Soc Audio for awinic aw88395"
depends on I2C
select CRC8
select CRC32
select REGMAP_I2C
select SND_SOC_AW88395_LIB
help
this option enables support for aw88395 Smart PA.
The Awinic AW88395 is an I2S/TDM input, high efficiency
digital Smart K audio amplifier with an integrated 10V
smart boost convert.
config SND_SOC_BD28623
tristate "ROHM BD28623 CODEC"
help
......
......@@ -46,6 +46,9 @@ snd-soc-ak5386-objs := ak5386.o
snd-soc-ak5558-objs := ak5558.o
snd-soc-arizona-objs := arizona.o arizona-jack.o
snd-soc-aw8738-objs := aw8738.o
snd-soc-aw88395-lib-objs := aw88395/aw88395_lib.o
snd-soc-aw88395-objs := aw88395/aw88395.o \
aw88395/aw88395_device.o
snd-soc-bd28623-objs := bd28623.o
snd-soc-bt-sco-objs := bt-sco.o
snd-soc-cpcap-objs := cpcap.o
......@@ -409,6 +412,8 @@ obj-$(CONFIG_SND_SOC_ALC5623) += snd-soc-alc5623.o
obj-$(CONFIG_SND_SOC_ALC5632) += snd-soc-alc5632.o
obj-$(CONFIG_SND_SOC_ARIZONA) += snd-soc-arizona.o
obj-$(CONFIG_SND_SOC_AW8738) += snd-soc-aw8738.o
obj-$(CONFIG_SND_SOC_AW88395_LIB) += snd-soc-aw88395-lib.o
obj-$(CONFIG_SND_SOC_AW88395) +=snd-soc-aw88395.o
obj-$(CONFIG_SND_SOC_BD28623) += snd-soc-bd28623.o
obj-$(CONFIG_SND_SOC_BT_SCO) += snd-soc-bt-sco.o
obj-$(CONFIG_SND_SOC_CQ0093VC) += snd-soc-cq93vc.o
......
This diff is collapsed.
// SPDX-License-Identifier: GPL-2.0-only
//
// aw88395.h -- ALSA SoC AW88395 codec support
//
// Copyright (c) 2022-2023 AWINIC Technology CO., LTD
//
// Author: Bruce zhao <zhaolei@awinic.com>
//
#ifndef __AW88395_H__
#define __AW88395_H__
#define AW88395_CHIP_ID_REG (0x00)
#define AW88395_START_RETRIES (5)
#define AW88395_START_WORK_DELAY_MS (0)
#define AW88395_DSP_16_DATA_MASK (0x0000ffff)
#define AW88395_I2C_NAME "aw88395_smartpa"
#define AW88395_RATES (SNDRV_PCM_RATE_8000_48000 | \
SNDRV_PCM_RATE_96000)
#define AW88395_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | \
SNDRV_PCM_FMTBIT_S24_LE | \
SNDRV_PCM_FMTBIT_S32_LE)
#define FADE_TIME_MAX 100000
#define FADE_TIME_MIN 0
#define AW88395_PROFILE_EXT(xname, profile_info, profile_get, profile_set) \
{ \
.iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
.name = xname, \
.info = profile_info, \
.get = profile_get, \
.put = profile_set, \
}
enum {
AW88395_SYNC_START = 0,
AW88395_ASYNC_START,
};
enum {
AW88395_STREAM_CLOSE = 0,
AW88395_STREAM_OPEN,
};
struct aw88395 {
struct aw_device *aw_pa;
struct mutex lock;
struct gpio_desc *reset_gpio;
struct delayed_work start_work;
struct regmap *regmap;
struct aw_container *aw_cfg;
};
#endif
// SPDX-License-Identifier: GPL-2.0-only
//
// aw883_data_type.h -- The data type of the AW88395 chip
//
// Copyright (c) 2022-2023 AWINIC Technology CO., LTD
//
// Author: Bruce zhao <zhaolei@awinic.com>
//
#ifndef __AW88395_DATA_TYPE_H__
#define __AW88395_DATA_TYPE_H__
#define PROJECT_NAME_MAX (24)
#define CUSTOMER_NAME_MAX (16)
#define CFG_VERSION_MAX (4)
#define DEV_NAME_MAX (16)
#define PROFILE_STR_MAX (32)
#define ACF_FILE_ID (0xa15f908)
enum aw_cfg_hdr_version {
AW88395_CFG_HDR_VER = 0x00000001,
AW88395_CFG_HDR_VER_V1 = 0x01000000,
};
enum aw_cfg_dde_type {
AW88395_DEV_NONE_TYPE_ID = 0xFFFFFFFF,
AW88395_DEV_TYPE_ID = 0x00000000,
AW88395_SKT_TYPE_ID = 0x00000001,
AW88395_DEV_DEFAULT_TYPE_ID = 0x00000002,
};
enum aw_sec_type {
ACF_SEC_TYPE_REG = 0,
ACF_SEC_TYPE_DSP,
ACF_SEC_TYPE_DSP_CFG,
ACF_SEC_TYPE_DSP_FW,
ACF_SEC_TYPE_HDR_REG,
ACF_SEC_TYPE_HDR_DSP_CFG,
ACF_SEC_TYPE_HDR_DSP_FW,
ACF_SEC_TYPE_MULTIPLE_BIN,
ACF_SEC_TYPE_SKT_PROJECT,
ACF_SEC_TYPE_DSP_PROJECT,
ACF_SEC_TYPE_MONITOR,
ACF_SEC_TYPE_MAX,
};
enum profile_data_type {
AW88395_DATA_TYPE_REG = 0,
AW88395_DATA_TYPE_DSP_CFG,
AW88395_DATA_TYPE_DSP_FW,
AW88395_DATA_TYPE_MAX,
};
enum aw_prof_type {
AW88395_PROFILE_MUSIC = 0,
AW88395_PROFILE_VOICE,
AW88395_PROFILE_VOIP,
AW88395_PROFILE_RINGTONE,
AW88395_PROFILE_RINGTONE_HS,
AW88395_PROFILE_LOWPOWER,
AW88395_PROFILE_BYPASS,
AW88395_PROFILE_MMI,
AW88395_PROFILE_FM,
AW88395_PROFILE_NOTIFICATION,
AW88395_PROFILE_RECEIVER,
AW88395_PROFILE_MAX,
};
enum aw_profile_status {
AW88395_PROFILE_WAIT = 0,
AW88395_PROFILE_OK,
};
struct aw_cfg_hdr {
u32 id;
char project[PROJECT_NAME_MAX];
char custom[CUSTOMER_NAME_MAX];
char version[CFG_VERSION_MAX];
u32 author_id;
u32 ddt_size;
u32 ddt_num;
u32 hdr_offset;
u32 hdr_version;
u32 reserved[3];
};
struct aw_cfg_dde {
u32 type;
char dev_name[DEV_NAME_MAX];
u16 dev_index;
u16 dev_bus;
u16 dev_addr;
u16 dev_profile;
u32 data_type;
u32 data_size;
u32 data_offset;
u32 data_crc;
u32 reserved[5];
};
struct aw_cfg_dde_v1 {
u32 type;
char dev_name[DEV_NAME_MAX];
u16 dev_index;
u16 dev_bus;
u16 dev_addr;
u16 dev_profile;
u32 data_type;
u32 data_size;
u32 data_offset;
u32 data_crc;
char dev_profile_str[PROFILE_STR_MAX];
u32 chip_id;
u32 reserved[4];
};
struct aw_sec_data_desc {
u32 len;
u8 *data;
};
struct aw_prof_desc {
u32 id;
u32 prof_st;
char *prf_str;
u32 fw_ver;
struct aw_sec_data_desc sec_desc[AW88395_DATA_TYPE_MAX];
};
struct aw_all_prof_info {
struct aw_prof_desc prof_desc[AW88395_PROFILE_MAX];
};
struct aw_prof_info {
int count;
int prof_type;
char **prof_name_list;
struct aw_prof_desc *prof_desc;
};
#endif
This diff is collapsed.
// SPDX-License-Identifier: GPL-2.0-only
//
// aw88395_device.h -- AW88395 function for ALSA Audio Driver
//
// Copyright (c) 2022-2023 AWINIC Technology CO., LTD
//
// Author: Bruce zhao <zhaolei@awinic.com>
//
#ifndef __AW88395_DEVICE_FILE_H__
#define __AW88395_DEVICE_FILE_H__
#include "aw88395.h"
#include "aw88395_data_type.h"
#include "aw88395_lib.h"
#define AW88395_DEV_DEFAULT_CH (0)
#define AW88395_DEV_DSP_CHECK_MAX (5)
#define AW88395_DSP_I2C_WRITES
#define AW88395_MAX_RAM_WRITE_BYTE_SIZE (128)
#define AW88395_DSP_ODD_NUM_BIT_TEST (0x5555)
#define AW88395_DSP_EVEN_NUM_BIT_TEST (0xAAAA)
#define AW88395_DSP_ST_CHECK_MAX (2)
#define AW88395_FADE_IN_OUT_DEFAULT (0)
#define AW88395_CALI_RE_MAX (15000)
#define AW88395_CALI_RE_MIN (4000)
#define AW88395_CALI_DELAY_CACL(value) ((value * 32) / 48)
#define AW88395_DSP_RE_TO_SHOW_RE(re, shift) (((re) * (1000)) >> (shift))
#define AW88395_SHOW_RE_TO_DSP_RE(re, shift) (((re) << shift) / (1000))
#define AW88395_ACF_FILE "aw88395_acf.bin"
#define AW88395_DEV_SYSST_CHECK_MAX (10)
enum {
AW88395_DEV_VDSEL_DAC = 0,
AW88395_DEV_VDSEL_VSENSE = 1,
};
enum {
AW88395_DSP_CRC_NA = 0,
AW88395_DSP_CRC_OK = 1,
};
enum {
AW88395_DSP_FW_UPDATE_OFF = 0,
AW88395_DSP_FW_UPDATE_ON = 1,
};
enum {
AW88395_FORCE_UPDATE_OFF = 0,
AW88395_FORCE_UPDATE_ON = 1,
};
enum {
AW88395_1000_US = 1000,
AW88395_2000_US = 2000,
AW88395_3000_US = 3000,
AW88395_4000_US = 4000,
AW88395_5000_US = 5000,
AW88395_10000_US = 10000,
AW88395_100000_US = 100000,
};
enum {
AW88395_DEV_TYPE_OK = 0,
AW88395_DEV_TYPE_NONE = 1,
};
enum AW88395_DEV_STATUS {
AW88395_DEV_PW_OFF = 0,
AW88395_DEV_PW_ON,
};
enum AW88395_DEV_FW_STATUS {
AW88395_DEV_FW_FAILED = 0,
AW88395_DEV_FW_OK,
};
enum AW88395_DEV_MEMCLK {
AW88395_DEV_MEMCLK_OSC = 0,
AW88395_DEV_MEMCLK_PLL = 1,
};
enum AW88395_DEV_DSP_CFG {
AW88395_DEV_DSP_WORK = 0,
AW88395_DEV_DSP_BYPASS = 1,
};
enum {
AW88395_DSP_16_DATA = 0,
AW88395_DSP_32_DATA = 1,
};
enum {
AW88395_NOT_RCV_MODE = 0,
AW88395_RCV_MODE = 1,
};
struct aw_profctrl_desc {
unsigned int cur_mode;
};
struct aw_volume_desc {
unsigned int init_volume;
unsigned int mute_volume;
unsigned int ctl_volume;
unsigned int max_volume;
};
struct aw_dsp_mem_desc {
unsigned int dsp_madd_reg;
unsigned int dsp_mdat_reg;
unsigned int dsp_fw_base_addr;
unsigned int dsp_cfg_base_addr;
};
struct aw_vmax_desc {
unsigned int init_vmax;
};
struct aw_cali_delay_desc {
unsigned int delay;
};
struct aw_cali_desc {
u32 cali_re;
u32 ra;
};
struct aw_container {
int len;
u8 data[];
};
struct aw_device {
int status;
struct mutex dsp_lock;
unsigned char prof_cur;
unsigned char prof_index;
unsigned char dsp_crc_st;
u16 chip_id;
unsigned int channel;
unsigned int fade_step;
struct i2c_client *i2c;
struct device *dev;
struct regmap *regmap;
char *acf;
u32 fade_en;
unsigned char dsp_cfg;
u32 dsp_fw_len;
u32 dsp_cfg_len;
u8 platform;
u8 fw_status;
unsigned int fade_in_time;
unsigned int fade_out_time;
struct aw_prof_info prof_info;
struct aw_sec_data_desc crc_dsp_cfg;
struct aw_profctrl_desc profctrl_desc;
struct aw_volume_desc volume_desc;
struct aw_dsp_mem_desc dsp_mem_desc;
struct aw_vmax_desc vmax_desc;
struct aw_cali_delay_desc cali_delay_desc;
struct aw_cali_desc cali_desc;
};
int aw88395_init(struct aw_device **aw_dev, struct i2c_client *i2c, struct regmap *regmap);
int aw88395_dev_init(struct aw_device *aw_dev, struct aw_container *aw_cfg);
int aw88395_dev_start(struct aw_device *aw_dev);
int aw88395_dev_stop(struct aw_device *aw_dev);
int aw88395_dev_fw_update(struct aw_device *aw_dev, bool up_dsp_fw_en, bool force_up_en);
void aw88395_dev_set_volume(struct aw_device *aw_dev, unsigned short set_vol);
int aw88395_dev_get_prof_data(struct aw_device *aw_dev, int index,
struct aw_prof_desc **prof_desc);
char *aw88395_dev_get_prof_name(struct aw_device *aw_dev, int index);
int aw88395_dev_set_profile_index(struct aw_device *aw_dev, int index);
int aw88395_dev_get_profile_index(struct aw_device *aw_dev);
int aw88395_dev_get_profile_count(struct aw_device *aw_dev);
int aw88395_dev_load_acf_check(struct aw_device *aw_dev, struct aw_container *aw_cfg);
int aw88395_dev_cfg_load(struct aw_device *aw_dev, struct aw_container *aw_cfg);
void aw88395_dev_mute(struct aw_device *aw_dev, bool is_mute);
#endif
This diff is collapsed.
// SPDX-License-Identifier: GPL-2.0-only
//
// aw88395_lib.h -- ACF bin parsing and check library file for aw88395
//
// Copyright (c) 2022-2023 AWINIC Technology CO., LTD
//
// Author: Bruce zhao <zhaolei@awinic.com>
//
#ifndef __AW88395_LIB_H__
#define __AW88395_LIB_H__
#define CHECK_REGISTER_NUM_OFFSET (4)
#define VALID_DATA_LEN (4)
#define VALID_DATA_ADDR (4)
#define PARSE_DSP_REG_NUM (4)
#define REG_DATA_BYTP_LEN (8)
#define CHECK_DSP_REG_NUM (12)
#define DSP_VALID_DATA_LEN (12)
#define DSP_VALID_DATA_ADDR (12)
#define PARSE_SOC_APP_NUM (8)
#define CHECK_SOC_APP_NUM (12)
#define APP_DOWNLOAD_ADDR (4)
#define APP_VALID_DATA_LEN (12)
#define APP_VALID_DATA_ADDR (12)
#define BIN_NUM_MAX (100)
#define HEADER_LEN (60)
#define BIN_DATA_TYPE_OFFSET (8)
#define DATA_LEN (44)
#define VALID_DATA_ADDR_OFFSET (60)
#define START_ADDR_OFFSET (64)
#define AW88395_FW_CHECK_PART (10)
#define HDADER_LEN (60)
#define HEADER_VERSION_OFFSET (4)
enum bin_header_version_enum {
HEADER_VERSION_V1 = 0x01000000,
};
enum data_type_enum {
DATA_TYPE_REGISTER = 0x00000000,
DATA_TYPE_DSP_REG = 0x00000010,
DATA_TYPE_DSP_CFG = 0x00000011,
DATA_TYPE_SOC_REG = 0x00000020,
DATA_TYPE_SOC_APP = 0x00000021,
DATA_TYPE_DSP_FW = 0x00000022,
DATA_TYPE_MULTI_BINS = 0x00002000,
};
enum data_version_enum {
DATA_VERSION_V1 = 0x00000001,
DATA_VERSION_MAX,
};
struct bin_header_info {
unsigned int check_sum;
unsigned int header_ver;
unsigned int bin_data_type;
unsigned int bin_data_ver;
unsigned int bin_data_len;
unsigned int ui_ver;
unsigned char chip_type[8];
unsigned int reg_byte_len;
unsigned int data_byte_len;
unsigned int device_addr;
unsigned int valid_data_len;
unsigned int valid_data_addr;
unsigned int reg_num;
unsigned int reg_data_byte_len;
unsigned int download_addr;
unsigned int app_version;
unsigned int header_len;
};
struct bin_container {
unsigned int len;
unsigned char data[];
};
struct aw_bin {
unsigned char *p_addr;
unsigned int all_bin_parse_num;
unsigned int multi_bin_parse_num;
unsigned int single_bin_parse_num;
struct bin_header_info header_info[BIN_NUM_MAX];
struct bin_container info;
};
#endif
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment