1
0
Fork 0

MLK-15033-1: ASoC: codecs: Add support for AK4458 DAC

The AK4458 is a 32-bit 8ch Premium DAC, its datasheet is available here:
https://www.akm.com/akm/en/file/datasheet/AK4458VN.pdf

Signed-off-by: Mihai Serban <mihai.serban@nxp.com>
Signed-off-by: Shengjiu Wang <shengjiu.wang@nxp.com>
pull/10/head
Mihai Serban 2017-06-06 12:12:08 +03:00 committed by Jason Liu
parent 5602472fe2
commit bf518d0e30
7 changed files with 1340 additions and 0 deletions

View File

@ -0,0 +1,23 @@
AK4458 audio DAC
This device supports both I2C and SPI modes.
Required properties:
- compatible : "asahi-kasei,ak4458"
- reg : The I2C address of the device for I2C, the chip select number for SPI.
- asahi-kasei,pdn-gpios: A GPIO specifier for the GPIO controlling
the power down & reset pin.
- asahi-kasei,mute-gpios: A GPIO specifier for the GPIO controlling
the soft mute pin.
Example:
&i2c {
ak4458: ak4458@10 {
compatible = "asahi-kasei,ak4458";
reg = <0x10>;
asahi-kasei,pdn-gpios = <&gpio1 10 GPIO_ACTIVE_HIGH>
asahi-kasei,mute-gpios = <&gpio1 11 GPIO_ACTIVE_HIGH>
};
};

View File

@ -35,6 +35,9 @@ config SND_SOC_ALL_CODECS
select SND_SOC_ADAU7002
select SND_SOC_ADS117X
select SND_SOC_AK4104 if SPI_MASTER
select SND_SOC_AK4458
select SND_SOC_AK4458_I2C if I2C
select SND_SOC_AK4458_SPI if SPI_MASTER
select SND_SOC_AK4535 if I2C
select SND_SOC_AK4554
select SND_SOC_AK4613 if I2C
@ -371,6 +374,21 @@ config SND_SOC_AK4104
tristate "AKM AK4104 CODEC"
depends on SPI_MASTER
config SND_SOC_AK4458
tristate
config SND_SOC_AK4458_I2C
tristate "AKM AK4458 DAC I2c"
depends on I2C
select SND_SOC_AK4458
select REGMAP_I2C
config SND_SOC_AK4458_SPI
tristate "AKM AK4458 DAC SPI"
depends on SPI_MASTER
select SND_SOC_AK4458
select REGMAP_SPI
config SND_SOC_AK4535
tristate

View File

@ -27,6 +27,9 @@ snd-soc-adav801-objs := adav801.o
snd-soc-adav803-objs := adav803.o
snd-soc-ads117x-objs := ads117x.o
snd-soc-ak4104-objs := ak4104.o
snd-soc-ak4458-objs := ak4458.o
snd-soc-ak4458-i2c-objs := ak4458-i2c.o
snd-soc-ak4458-spi-objs := ak4458-spi.o
snd-soc-ak4535-objs := ak4535.o
snd-soc-ak4554-objs := ak4554.o
snd-soc-ak4613-objs := ak4613.o
@ -266,6 +269,9 @@ obj-$(CONFIG_SND_SOC_ADAV801) += snd-soc-adav801.o
obj-$(CONFIG_SND_SOC_ADAV803) += snd-soc-adav803.o
obj-$(CONFIG_SND_SOC_ADS117X) += snd-soc-ads117x.o
obj-$(CONFIG_SND_SOC_AK4104) += snd-soc-ak4104.o
obj-$(CONFIG_SND_SOC_AK4458) += snd-soc-ak4458.o
obj-$(CONFIG_SND_SOC_AK4458_I2C) += snd-soc-ak4458-i2c.o
obj-$(CONFIG_SND_SOC_AK4458_SPI) += snd-soc-ak4458-spi.o
obj-$(CONFIG_SND_SOC_AK4535) += snd-soc-ak4535.o
obj-$(CONFIG_SND_SOC_AK4554) += snd-soc-ak4554.o
obj-$(CONFIG_SND_SOC_AK4613) += snd-soc-ak4613.o

View File

@ -0,0 +1,69 @@
/*
* ak4458-i2c.c -- AK4458 DAC - I2C
*
* Copyright 2017 NXP
*
* Author: Mihai Serban <mihai.serban@nxp.com>
*
* This software is licensed under the terms of the GNU General Public
* License version 2, as published by the Free Software Foundation, and
* may be copied, distributed, and modified under those terms.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
#include <linux/init.h>
#include <linux/module.h>
#include <linux/i2c.h>
#include "ak4458.h"
static int ak4458_i2c_probe(struct i2c_client *i2c,
const struct i2c_device_id *id)
{
struct regmap *regmap;
regmap = devm_regmap_init_i2c(i2c, &ak4458_i2c_regmap_config);
if (IS_ERR(regmap))
return PTR_ERR(regmap);
return ak4458_probe(&i2c->dev, regmap);
}
static int ak4458_i2c_remove(struct i2c_client *i2c)
{
ak4458_remove(&i2c->dev);
return 0;
}
static const struct i2c_device_id ak4458_i2c_id[] = {
{ "ak4458", 0 },
{ }
};
MODULE_DEVICE_TABLE(i2c, ak4458_i2c_id);
static const struct of_device_id ak4458_of_match[] = {
{ .compatible = "asahi-kasei,ak4458", },
{ },
};
MODULE_DEVICE_TABLE(of, ak4458_of_match);
static struct i2c_driver ak4458_i2c_driver = {
.driver = {
.name = "ak4458",
.pm = &ak4458_pm,
.of_match_table = ak4458_of_match,
},
.probe = ak4458_i2c_probe,
.remove = ak4458_i2c_remove,
.id_table = ak4458_i2c_id
};
module_i2c_driver(ak4458_i2c_driver);
MODULE_DESCRIPTION("ASoC AK4458 driver - I2C");
MODULE_AUTHOR("Mihai Serban <mihai.serban@nxp.com>");
MODULE_LICENSE("GPL");

View File

@ -0,0 +1,61 @@
/*
* ak4458-spi.c -- AK4458 DAC - SPI
*
* Copyright 2017 NXP
*
* Author: Mihai Serban <mihai.serban@nxp.com>
*
* This software is licensed under the terms of the GNU General Public
* License version 2, as published by the Free Software Foundation, and
* may be copied, distributed, and modified under those terms.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
#include <linux/init.h>
#include <linux/module.h>
#include <linux/spi/spi.h>
#include "ak4458.h"
static int ak4458_spi_probe(struct spi_device *spi)
{
struct regmap *regmap;
regmap = devm_regmap_init_spi(spi, &ak4458_spi_regmap_config);
if (IS_ERR(regmap))
return PTR_ERR(regmap);
return ak4458_probe(&spi->dev, regmap);
}
static int ak4458_spi_remove(struct spi_device *spi)
{
ak4458_remove(&spi->dev);
return 0;
}
static const struct of_device_id ak4458_of_match[] = {
{ .compatible = "asahi-kasei,ak4458", },
{ },
};
MODULE_DEVICE_TABLE(of, ak4458_of_match);
static struct spi_driver ak4458_spi_driver = {
.driver = {
.name = "ak4458",
.pm = &ak4458_pm,
.of_match_table = ak4458_of_match,
},
.probe = ak4458_spi_probe,
.remove = ak4458_spi_remove
};
module_spi_driver(ak4458_spi_driver);
MODULE_DESCRIPTION("ASoC AK4458 driver - SPI");
MODULE_AUTHOR("Mihai Serban <mihai.serban@nxp.com>");
MODULE_LICENSE("GPL");

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,120 @@
/*
* ak4458.h -- audio driver for AK4458
*
* Copyright (C) 2016 Asahi Kasei Microdevices Corporation
* Author: Tsuyoshi Mutsuro
*
* This software is licensed under the terms of the GNU General Public
* License version 2, as published by the Free Software Foundation, and
* may be copied, distributed, and modified under those terms.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
#ifndef _AK4458_H
#define _AK4458_H
#include <linux/regmap.h>
/* Settings */
//#define AK4458_ACKS_USE_MANUAL_MODE
#define AK4458_00_CONTROL1 0x00
#define AK4458_01_CONTROL2 0x01
#define AK4458_02_CONTROL3 0x02
#define AK4458_03_LCHATT 0x03
#define AK4458_04_RCHATT 0x04
#define AK4458_05_CONTROL4 0x05
#define AK4458_06_DSD1 0x06
#define AK4458_07_CONTROL5 0x07
#define AK4458_08_SOUND_CONTROL 0x08
#define AK4458_09_DSD2 0x09
#define AK4458_0A_CONTROL6 0x0A
#define AK4458_0B_CONTROL7 0x0B
#define AK4458_0C_CONTROL8 0x0C
#define AK4458_0D_CONTROL9 0x0D
#define AK4458_0E_CONTROL10 0x0E
#define AK4458_0F_L2CHATT 0x0F
#define AK4458_10_R2CHATT 0x10
#define AK4458_11_L3CHATT 0x11
#define AK4458_12_R3CHATT 0x12
#define AK4458_13_L4CHATT 0x13
#define AK4458_14_R4CHATT 0x14
/* Bitfield Definitions */
/* AK4458_00_CONTROL1 (0x00) Fields */
//Addr Register Name D7 D6 D5 D4 D3 D2 D1 D0
//00H Control 1 ACKS 0 0 0 DIF2 DIF1 DIF0 RSTN
//MONO1 & SELLR1 bits
#define AK4458_DAC1_LR_MASK 0x0A
#define AK4458_DAC1_INV_MASK 0xC0
//MONO2 & SELLR2 bits
#define AK4458_DAC2_MASK1 0x20
#define AK4458_DAC2_MASK2 0x38
//MONO3 & SELLR3 bits
#define AK4458_DAC3_LR_MASK 0x44
#define AK4458_DAC3_INV_MASK 0x30
//MONO4 & SELLR4 bits
#define AK4458_DAC4_LR_MASK 0x88
#define AK4458_DAC4_INV_MASK 0xC0
//SDS2-0 bits
#define AK4458_SDS0__MASK 0x10
#define AK4458_SDS12_MASK 0x30
//Digital Filter (SD, SLOW, SSLOW)
#define AK4458_SD_MASK 0x20
#define AK4458_SLOW_MASK 0x01
#define AK4458_SSLOW_MASK 0x01
//DIF2 1 0
// x 1 0 MSB justified Figure 3 (default)
// x 1 1 I2S Compliment Figure 4
#define AK4458_DIF_MASK 0x06
#define AK4458_DIF_MSB_LOW_FS_MODE (2 << 1)
#define AK4458_DIF_I2S_LOW_FS_MODE (3 << 1)
// ACKS is Auto mode so disable the Manual feature
//#define AK4458_ACKS_USE_MANUAL_MODE
/* AK4458_00_CONTROL1 (0x00) D0 bit */
#define AK4458_RSTN_MASK 0x01
#define AK4458_RSTN (0x1 << 0)
#ifdef AK4458_ACKS_USE_MANUAL_MODE
/* AK4458_01_CONTROL2 (0x01) and AK4458_05_CONTROL4 (0x05) Fields */
#define AK4458_DFS01_MASK 0x18
#define AK4458_DFS2__MASK 0x02
#define AK4458_DFS01_48KHZ (0x0 << 3) // 30kHz to 54kHz
#define AK4458_DFS2__48KHZ (0x0 << 1) // 30kHz to 54kHz
#define AK4458_DFS01_96KHZ (0x1 << 3) // 54kHz to 108kHz
#define AK4458_DFS2__96KHZ (0x0 << 1) // 54kHz to 108kHz
#define AK4458_DFS01_192KHZ (0x2 << 3) // 120kHz to 216kHz
#define AK4458_DFS2__192KHZ (0x0 << 1) // 120kHz to 216kHz
#define AK4458_DFS01_384KHZ (0x0 << 3) // 384kHz
#define AK4458_DFS2__384KHZ (0x1 << 1) // 384kHz
#define AK4458_DFS01_768KHZ (0x1 << 3) // 768kHz
#define AK4458_DFS2__768KHZ (0x1 << 1) // 768kHz
#endif
extern const struct regmap_config ak4458_i2c_regmap_config;
extern const struct regmap_config ak4458_spi_regmap_config;
extern const struct dev_pm_ops ak4458_pm;
int ak4458_probe(struct device *dev, struct regmap *regmap);
void ak4458_remove(struct device *dev);
#endif