Unverified Commit 43a38a0f authored by Mark Brown's avatar Mark Brown
Browse files

ASoC: codecs: add support for ES8375

Merge series from Zhang Yi <zhangyi@everest-semi.com>:

The driver is for codec ES8375 of everest-semi.
parents fe644621 de2b3119
Loading
Loading
Loading
Loading
+71 −0
Original line number Diff line number Diff line
# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
%YAML 1.2
---
$id: http://devicetree.org/schemas/sound/everest,es8375.yaml#
$schema: http://devicetree.org/meta-schemas/core.yaml#

title: Everest ES8375 audio CODEC

maintainers:
  - Michael Zhang <zhangyi@everest-semi.com>

allOf:
  - $ref: dai-common.yaml#

properties:
  compatible:
    const: everest,es8375

  reg:
    maxItems: 1

  clocks:
    items:
      - description: clock for master clock (MCLK)

  clock-names:
    items:
      - const: mclk

  vdda-supply:
    description:
      Analogue power supply.

  vddd-supply:
    description:
      Interface power supply.

  everest,mclk-src:
    $ref: /schemas/types.yaml#/definitions/uint8
    description: |
      Represents the MCLK/SCLK pair pins used as the internal clock.
      0 represents selecting MCLK.
      1 represents selecting SCLK.
    enum: [0, 1]
    default: 0

  "#sound-dai-cells":
    const: 0

required:
  - compatible
  - reg
  - "#sound-dai-cells"
  - vdda-supply
  - vddd-supply

additionalProperties: false

examples:
  - |
    i2c {
      #address-cells = <1>;
      #size-cells = <0>;
      es8375: codec@18 {
        compatible = "everest,es8375";
        reg = <0x18>;
        vdda-supply = <&vdd3v3>;
        vddd-supply = <&vdd3v3>;
        #sound-dai-cells = <0>;
      };
    };
+5 −0
Original line number Diff line number Diff line
@@ -120,6 +120,7 @@ config SND_SOC_ALL_CODECS
	imply SND_SOC_ES8326
	imply SND_SOC_ES8328_SPI
	imply SND_SOC_ES8328_I2C
	imply SND_SOC_ES8375
	imply SND_SOC_ES8389
	imply SND_SOC_ES7134
	imply SND_SOC_ES7241
@@ -1211,6 +1212,10 @@ config SND_SOC_ES8328_SPI
	depends on SPI_MASTER
	select SND_SOC_ES8328

config SND_SOC_ES8375
	tristate "Everest Semi ES8375 CODEC"
	depends on I2C

config SND_SOC_ES8389
	tristate "Everest Semi ES8389 CODEC"
	depends on I2C
+2 −0
Original line number Diff line number Diff line
@@ -134,6 +134,7 @@ snd-soc-es8326-y := es8326.o
snd-soc-es8328-y := es8328.o
snd-soc-es8328-i2c-y := es8328-i2c.o
snd-soc-es8328-spi-y := es8328-spi.o
snd-soc-es8375-y := es8375.o
snd-soc-es8389-y := es8389.o
snd-soc-framer-y := framer-codec.o
snd-soc-gtm601-y := gtm601.o
@@ -556,6 +557,7 @@ obj-$(CONFIG_SND_SOC_ES8326) += snd-soc-es8326.o
obj-$(CONFIG_SND_SOC_ES8328)	+= snd-soc-es8328.o
obj-$(CONFIG_SND_SOC_ES8328_I2C)+= snd-soc-es8328-i2c.o
obj-$(CONFIG_SND_SOC_ES8328_SPI)+= snd-soc-es8328-spi.o
obj-$(CONFIG_SND_SOC_ES8375)    += snd-soc-es8375.o
obj-$(CONFIG_SND_SOC_ES8389)    += snd-soc-es8389.o
obj-$(CONFIG_SND_SOC_FRAMER)	+= snd-soc-framer.o
obj-$(CONFIG_SND_SOC_GTM601)    += snd-soc-gtm601.o
+793 −0

File added.

Preview size limit exceeded, changes collapsed.

+123 −0
Original line number Diff line number Diff line
/* SPDX-License-Identifier: GPL-2.0-only */
/*
* ES8375.h  --  ES8375 ALSA SoC Audio Codec
*
* Authors:
*
* Based on ES8375.h by Michael Zhang
*/
#ifndef _ES8375_H
#define _ES8375_H

// Registors
#define ES8375_RESET1              0x00
#define ES8375_MCLK_SEL            0x01
#define ES8375_CLK_MGR2            0x02
#define ES8375_CLK_MGR3            0x03
#define ES8375_CLK_MGR4            0x04
#define ES8375_CLK_MGR5            0x05
#define ES8375_CLK_MGR6            0x06
#define ES8375_CLK_MGR7            0x07
#define ES8375_CLK_MGR8            0x08
#define ES8375_CLK_MGR9            0x09
#define ES8375_CLK_MGR10           0x0A
#define ES8375_CLK_MGR11           0x0B
#define ES8375_CLK_MGR12           0x0C
#define ES8375_DIV_SPKCLK          0x0E
#define ES8375_CSM1                0x0F
#define ES8375_CSM2                0x10
#define ES8375_VMID_CHARGE2        0x11
#define ES8375_VMID_CHARGE3        0x12
#define ES8375_SDP                 0x15
#define ES8375_SDP2                0x16
#define ES8375_ADC1                0x17
#define ES8375_ADC2                0x18
#define ES8375_ADC_OSR_GAIN        0x19
#define ES8375_ADC_VOLUME          0x1A
#define ES8375_ADC_AUTOMUTE        0x1B
#define ES8375_ADC_AUTOMUTE_ATTN   0x1C
#define ES8375_HPF1                0x1D
#define ES8375_DAC1                0x1F
#define ES8375_DAC2                0x20
#define ES8375_DAC_VOLUME          0x21
#define ES8375_DAC_VPPSCALE        0x22
#define ES8375_DAC_AUTOMUTE1       0x23
#define ES8375_DAC_AUTOMUTE        0x24
#define ES8375_DAC_CAL             0x25
#define ES8375_DAC_OTP             0x27
#define ES8375_ANALOG_SPK1         0x28
#define ES8375_ANALOG_SPK2         0x29
#define ES8375_VMID_SEL            0x2D
#define ES8375_ANALOG1             0x2E
#define ES8375_ANALOG2             0x32
#define ES8375_ANALOG3             0x37
#define ES8375_ADC2DAC_CLKTRI      0xF8
#define ES8375_SYS_CTRL2           0xF9
#define ES8375_FLAGS2              0xFB
#define ES8375_SPK_OFFSET          0xFC
#define ES8375_CHIP_ID1            0xFD
#define ES8375_CHIP_ID0            0xFE
#define ES8375_CHIP_VERSION        0xFF

// Bit Shifts
#define ADC_OSR_GAIN_SHIFT_0        0
#define ADC_RAMPRATE_SHIFT_0        0
#define ADC_VOLUME_SHIFT_0          0
#define ADC_AUTOMUTE_NG_SHIFT_0     0
#define ADC_AUTOMUTE_ATTN_SHIFT_0   0
#define DAC_RAMPRATE_SHIFT_0        0
#define DAC_VOLUME_SHIFT_0          0
#define DAC_VPPSCALE_SHIFT_0        0
#define DAC_AUTOMUTE_NG_SHIFT_0     0
#define DAC_AUTOMUTE_ATTN_SHIFT_0   0
#define DMIC_GAIN_SHIFT_2           2
#define ADC_AUTOMUTE_WS_SHIFT_3     3
#define DMIC_POL_SHIFT_4            4
#define DAC_RAMCLR_SHIFT_4          4
#define ES8375_EN_MODL_SHIFT_4      4
#define ADC_RAMCLR_SHIFT_5          5
#define ADC_HPF_SHIFT_5             5
#define DAC_INV_SHIFT_5             5
#define DAC_AUTOMUTE_WS_SHIFT_5     5
#define ES8375_EN_PGAL_SHIFT_5      5
#define ES8375_ADC_P2S_MUTE_SHIFT_5 5
#define ADC_INV_SHIFT_6             6
#define DAC_DEMMUTE_SHIFT_6         6
#define ES8375_DAC_S2P_MUTE_SHIFT_6 6
#define ADC_SRC_SHIFT_7             7
#define ADC_AUTOMUTE_SHIFT_7        7
#define DAC_DSMMUTE_SHIFT_7         7
#define DAC_AUTOMUTE_EN_SHIFT_7     7

// Function values
#define ES8375_ADC_OSR_GAIN_MAX         0x3F
#define ES8375_DMIC_GAIN_MAX            0x04
#define ES8375_ADC_AUTOMUTE_ATTN_MAX    0x1F
#define ES8375_AUTOMUTE_NG_MAX          0x07
#define ES8375_ADC_VOLUME_MAX           0xFF
#define ES8375_DAC_VOLUME_MAX           0xFF
#define ES8375_DAC_VPPSCALE_MAX         0x3F
#define ES8375_DAC_AUTOMUTE_ATTN_MAX    0x17
#define ES8375_REG_MAX                  0xFF

enum ES8375_supplies {
	ES8375_SUPPLY_VD = 0,
	ES8375_SUPPLY_VA,
};

// Properties
#define ES8375_3V3  1
#define ES8375_1V8  0

#define ES8375_MCLK_PIN	0
#define ES8375_BCLK_PIN 1
#define ES8375_MCLK_SOURCE	ES8375_MCLK_PIN

#define DMIC_POSITIVE_EDGE  0
#define DMIC_NEGATIVE_EDGE  1
#define DMIC_POL  DMIC_POSITIVE_EDGE

#define PA_SHUTDOWN     0
#define PA_ENABLE       1

#endif