mirror of
https://github.com/torvalds/linux.git
synced 2026-05-28 09:04:39 +02:00
ASoC: add CS42L84 codec driver
Merge series from James Calligeros <jcalligeros99@gmail.com>: This patch set adds a driver for the Cirrus Logic CS42L84 codec. This chip is (so far) found only on Apple Silicon Macs. In keeping with proud Apple tradition, the CS42L84 is essentially just a CS42L42 with a different regmap and no publicly available datasheet. It may also be missing its parent's S/PDIF capabilities as none of Apple's devices support S/PDIF out, however this cannot be positively confirmed. This driver has lived in the downstream Asahi tree for quite a while now, and gained some refinements along the way. I have squashed most of these into the initial driver commit as they were small changes like tweaking msleep()s or filling out TLVs, but left seperate a larger change to tip/ring sense IRQ handling as it differs significantly from what is found in the CS42L42 driver.
This commit is contained in:
commit
a2f4b8c860
56
Documentation/devicetree/bindings/sound/cirrus,cs42l84.yaml
Normal file
56
Documentation/devicetree/bindings/sound/cirrus,cs42l84.yaml
Normal file
|
|
@ -0,0 +1,56 @@
|
|||
# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
|
||||
%YAML 1.2
|
||||
---
|
||||
$id: http://devicetree.org/schemas/sound/cirrus,cs42l84.yaml#
|
||||
$schema: http://devicetree.org/meta-schemas/core.yaml#
|
||||
|
||||
title: Cirrus Logic CS42L84 audio CODEC
|
||||
|
||||
maintainers:
|
||||
- Martin Povišer <povik+lin@cutebit.org>
|
||||
|
||||
description: |
|
||||
The CS42L84 is a headphone jack codec made by Cirrus Logic and embedded
|
||||
in personal computers sold by Apple. It was first seen in 2021 Macbook
|
||||
Pro models. It has stereo DAC for playback, mono ADC for capture, and
|
||||
is somewhat similar to CS42L42 but with a different regmap.
|
||||
|
||||
properties:
|
||||
compatible:
|
||||
enum:
|
||||
- cirrus,cs42l84
|
||||
|
||||
reg:
|
||||
maxItems: 1
|
||||
|
||||
reset-gpios:
|
||||
maxItems: 1
|
||||
|
||||
interrupts:
|
||||
maxItems: 1
|
||||
|
||||
'#sound-dai-cells':
|
||||
const: 0
|
||||
|
||||
required:
|
||||
- compatible
|
||||
- reg
|
||||
|
||||
additionalProperties: false
|
||||
|
||||
examples:
|
||||
- |
|
||||
#include <dt-bindings/gpio/gpio.h>
|
||||
#include <dt-bindings/interrupt-controller/irq.h>
|
||||
i2c {
|
||||
#address-cells = <1>;
|
||||
#size-cells = <0>;
|
||||
|
||||
jack_codec: codec@4b {
|
||||
compatible = "cirrus,cs42l84";
|
||||
reg = <0x4b>;
|
||||
reset-gpios = <&pinctrl_nub 4 GPIO_ACTIVE_LOW>;
|
||||
interrupts-extended = <&pinctrl_ap 180 IRQ_TYPE_LEVEL_LOW>;
|
||||
#sound-dai-cells = <0>;
|
||||
};
|
||||
};
|
||||
|
|
@ -2132,9 +2132,11 @@ L: asahi@lists.linux.dev
|
|||
L: linux-sound@vger.kernel.org
|
||||
S: Maintained
|
||||
F: Documentation/devicetree/bindings/sound/adi,ssm3515.yaml
|
||||
F: Documentation/devicetree/bindings/sound/cirrus,cs42l84.yaml
|
||||
F: Documentation/devicetree/bindings/sound/apple,*
|
||||
F: sound/soc/apple/*
|
||||
F: sound/soc/codecs/cs42l83-i2c.c
|
||||
F: sound/soc/codecs/cs42l84.*
|
||||
F: sound/soc/codecs/ssm3515.c
|
||||
|
||||
ARM/APPLE MACHINE SUPPORT
|
||||
|
|
|
|||
|
|
@ -85,6 +85,7 @@ config SND_SOC_ALL_CODECS
|
|||
imply SND_SOC_CS42L52
|
||||
imply SND_SOC_CS42L56
|
||||
imply SND_SOC_CS42L73
|
||||
imply SND_SOC_CS42L84
|
||||
imply SND_SOC_CS4234
|
||||
imply SND_SOC_CS4265
|
||||
imply SND_SOC_CS4270
|
||||
|
|
@ -929,6 +930,12 @@ config SND_SOC_CS42L83
|
|||
select REGMAP_I2C
|
||||
select SND_SOC_CS42L42_CORE
|
||||
|
||||
config SND_SOC_CS42L84
|
||||
tristate "Cirrus Logic CS42L84 CODEC"
|
||||
depends on I2C
|
||||
select REGMAP
|
||||
select REGMAP_I2C
|
||||
|
||||
config SND_SOC_CS4234
|
||||
tristate "Cirrus Logic CS4234 CODEC"
|
||||
depends on I2C
|
||||
|
|
|
|||
|
|
@ -91,6 +91,7 @@ snd-soc-cs42l52-y := cs42l52.o
|
|||
snd-soc-cs42l56-y := cs42l56.o
|
||||
snd-soc-cs42l73-y := cs42l73.o
|
||||
snd-soc-cs42l83-i2c-y := cs42l83-i2c.o
|
||||
snd-soc-cs42l84-objs := cs42l84.o
|
||||
snd-soc-cs4234-y := cs4234.o
|
||||
snd-soc-cs4265-y := cs4265.o
|
||||
snd-soc-cs4270-y := cs4270.o
|
||||
|
|
@ -505,6 +506,7 @@ obj-$(CONFIG_SND_SOC_CS42L52) += snd-soc-cs42l52.o
|
|||
obj-$(CONFIG_SND_SOC_CS42L56) += snd-soc-cs42l56.o
|
||||
obj-$(CONFIG_SND_SOC_CS42L73) += snd-soc-cs42l73.o
|
||||
obj-$(CONFIG_SND_SOC_CS42L83) += snd-soc-cs42l83-i2c.o
|
||||
obj-$(CONFIG_SND_SOC_CS42L84) += snd-soc-cs42l84.o
|
||||
obj-$(CONFIG_SND_SOC_CS4234) += snd-soc-cs4234.o
|
||||
obj-$(CONFIG_SND_SOC_CS4265) += snd-soc-cs4265.o
|
||||
obj-$(CONFIG_SND_SOC_CS4270) += snd-soc-cs4270.o
|
||||
|
|
|
|||
1112
sound/soc/codecs/cs42l84.c
Normal file
1112
sound/soc/codecs/cs42l84.c
Normal file
File diff suppressed because it is too large
Load Diff
210
sound/soc/codecs/cs42l84.h
Normal file
210
sound/soc/codecs/cs42l84.h
Normal file
|
|
@ -0,0 +1,210 @@
|
|||
/* SPDX-License-Identifier: GPL-2.0-only */
|
||||
/*
|
||||
* Copyright (C) The Asahi Linux Contributors
|
||||
*
|
||||
* Based on sound/soc/codecs/cs42l42.h
|
||||
*
|
||||
* Copyright 2016 Cirrus Logic, Inc.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef __CS42L84_H__
|
||||
#define __CS42L84_H__
|
||||
|
||||
#include <linux/bits.h>
|
||||
|
||||
#define CS42L84_CHIP_ID 0x42a84
|
||||
|
||||
#define CS42L84_DEVID 0x0000
|
||||
#define CS42L84_REVID 0x73fe
|
||||
#define CS42L84_FRZ_CTL 0x0006
|
||||
#define CS42L84_FRZ_CTL_ENGAGE BIT(0)
|
||||
|
||||
#define CS42L84_TSRS_PLUG_INT_STATUS 0x0400
|
||||
#define CS42L84_TSRS_PLUG_INT_MASK 0x0418
|
||||
#define CS42L84_RS_PLUG_SHIFT 0
|
||||
#define CS42L84_RS_PLUG BIT(0)
|
||||
#define CS42L84_RS_UNPLUG BIT(1)
|
||||
#define CS42L84_TS_PLUG_SHIFT 2
|
||||
#define CS42L84_TS_PLUG BIT(2)
|
||||
#define CS42L84_TS_UNPLUG BIT(3)
|
||||
#define CS42L84_TSRS_PLUG_VAL_MASK GENMASK(3, 0)
|
||||
#define CS42L84_PLL_LOCK_STATUS 0x040e // probably bit 0x10
|
||||
#define CS42L84_PLL_LOCK_STATUS_LOCKED BIT(4)
|
||||
#define CS42L84_PLL_LOCK_STATUS_ERROR BIT(5)
|
||||
|
||||
#define CS42L84_PLUG 3
|
||||
#define CS42L84_UNPLUG 0
|
||||
#define CS42L84_TRANS 1
|
||||
|
||||
#define CS42L84_CCM_CTL1 0x0600
|
||||
#define CS42L84_CCM_CTL1_MCLK_SRC GENMASK(1, 0)
|
||||
#define CS42L84_CCM_CTL1_MCLK_SRC_RCO 0
|
||||
#define CS42L84_CCM_CTL1_MCLK_SRC_MCLK 1
|
||||
#define CS42L84_CCM_CTL1_MCLK_SRC_BCLK 2
|
||||
#define CS42L84_CCM_CTL1_MCLK_SRC_PLL 3
|
||||
#define CS42L84_CCM_CTL1_MCLK_FREQ GENMASK(3, 2)
|
||||
#define CS42L84_CCM_CTL1_MCLK_F_12MHZ 0b00
|
||||
#define CS42L84_CCM_CTL1_MCLK_F_24MHZ 0b01
|
||||
#define CS42L84_CCM_CTL1_MCLK_F_12_288KHZ 0b10
|
||||
#define CS42L84_CCM_CTL1_MCLK_F_24_576KHZ 0b11
|
||||
#define CS42L84_CCM_CTL1_RCO \
|
||||
(FIELD_PREP(CS42L84_CCM_CTL1_MCLK_SRC, CS42L84_CCM_CTL1_MCLK_SRC_RCO) \
|
||||
| FIELD_PREP(CS42L84_CCM_CTL1_MCLK_FREQ, CS42L84_CCM_CTL1_MCLK_F_12MHZ))
|
||||
|
||||
#define CS42L84_CCM_SAMP_RATE 0x0601
|
||||
#define CS42L84_CCM_SAMP_RATE_RATE_48KHZ 4
|
||||
#define CS42L84_CCM_SAMP_RATE_RATE_96KHZ 5
|
||||
#define CS42L84_CCM_SAMP_RATE_RATE_192KHZ 6
|
||||
#define CS42L84_CCM_SAMP_RATE_RATE_44K1HZ 12
|
||||
#define CS42L84_CCM_SAMP_RATE_RATE_88K2HZ 13
|
||||
#define CS42L84_CCM_SAMP_RATE_RATE_176K4HZ 14
|
||||
#define CS42L84_CCM_CTL3 0x0602
|
||||
#define CS42L84_CCM_CTL3_REFCLK_DIV GENMASK(2, 1)
|
||||
#define CS42L84_CCM_CTL4 0x0603
|
||||
#define CS42L84_CCM_CTL4_REFCLK_EN BIT(0)
|
||||
|
||||
#define CS42L84_CCM_ASP_CLK_CTRL 0x0608
|
||||
|
||||
#define CS42L84_PLL_CTL1 0x0800
|
||||
#define CS42L84_PLL_CTL1_EN BIT(0)
|
||||
#define CS42L84_PLL_CTL1_MODE GENMASK(2, 1)
|
||||
#define CS42L84_PLL_DIV_FRAC0 0x0804
|
||||
#define CS42L84_PLL_DIV_FRAC1 0x0805
|
||||
#define CS42L84_PLL_DIV_FRAC2 0x0806
|
||||
#define CS42L84_PLL_DIV_INT 0x0807
|
||||
#define CS42L84_PLL_DIVOUT 0x0808
|
||||
|
||||
#define CS42L84_RING_SENSE_CTL 0x1282
|
||||
#define CS42L84_RING_SENSE_CTL_INV BIT(7)
|
||||
#define CS42L84_RING_SENSE_CTL_UNK1 BIT(6)
|
||||
#define CS42L84_RING_SENSE_CTL_FALLTIME GENMASK(5, 3)
|
||||
#define CS42L84_RING_SENSE_CTL_RISETIME GENMASK(2, 0)
|
||||
#define CS42L84_TIP_SENSE_CTL 0x1283
|
||||
#define CS42L84_TIP_SENSE_CTL_INV BIT(7)
|
||||
#define CS42L84_TIP_SENSE_CTL_FALLTIME GENMASK(5, 3)
|
||||
#define CS42L84_TIP_SENSE_CTL_RISETIME GENMASK(2, 0)
|
||||
|
||||
#define CS42L84_TSRS_PLUG_STATUS 0x1288
|
||||
|
||||
#define CS42L84_TIP_SENSE_CTL2 0x1473
|
||||
#define CS42L84_TIP_SENSE_CTL2_MODE GENMASK(7, 6)
|
||||
#define CS42L84_TIP_SENSE_CTL2_MODE_DISABLED 0b00
|
||||
#define CS42L84_TIP_SENSE_CTL2_MODE_DIG_INPUT 0b01
|
||||
#define CS42L84_TIP_SENSE_CTL2_MODE_SHORT_DET 0b11
|
||||
#define CS42L84_TIP_SENSE_CTL2_INV BIT(5)
|
||||
|
||||
#define CS42L84_MISC_DET_CTL 0x1474
|
||||
#define CS42L84_MISC_DET_CTL_DETECT_MODE GENMASK(4, 3)
|
||||
#define CS42L84_MISC_DET_CTL_HSBIAS_CTL GENMASK(2, 1)
|
||||
#define CS42L84_MISC_DET_CTL_PDN_MIC_LVL_DET BIT(0)
|
||||
|
||||
#define CS42L84_MIC_DET_CTL1 0x1475
|
||||
#define CS42L84_MIC_DET_CTL1_HS_DET_LEVEL GENMASK(5, 0)
|
||||
|
||||
#define CS42L84_MIC_DET_CTL4 0x1477
|
||||
#define CS42L84_MIC_DET_CTL4_LATCH_TO_VP BIT(1)
|
||||
|
||||
#define CS42L84_HS_DET_STATUS2 0x147d
|
||||
|
||||
#define CS42L84_MSM_BLOCK_EN1 0x1800
|
||||
#define CS42L84_MSM_BLOCK_EN2 0x1801
|
||||
#define CS42L84_MSM_BLOCK_EN2_ASP_SHIFT 6
|
||||
#define CS42L84_MSM_BLOCK_EN2_BUS_SHIFT 5
|
||||
#define CS42L84_MSM_BLOCK_EN2_DAC_SHIFT 4
|
||||
#define CS42L84_MSM_BLOCK_EN2_ADC_SHIFT 3
|
||||
#define CS42L84_MSM_BLOCK_EN3 0x1802
|
||||
#define CS42L84_MSM_BLOCK_EN3_TR_SENSE BIT(3)
|
||||
|
||||
#define CS42L84_HS_DET_CTL2 0x1811
|
||||
#define CS42L84_HS_DET_CTL2_CTL GENMASK(7, 6)
|
||||
#define CS42L84_HS_DET_CTL2_SET GENMASK(5, 4)
|
||||
#define CS42L84_HS_DET_CTL2_REF BIT(3)
|
||||
#define CS42L84_HS_DET_CTL2_AUTO_TIME GENMASK(1, 0)
|
||||
|
||||
#define CS42L84_HS_SWITCH_CTL 0x1812
|
||||
#define CS42L84_HS_SWITCH_CTL_REF_HS3 BIT(7)
|
||||
#define CS42L84_HS_SWITCH_CTL_REF_HS4 BIT(6)
|
||||
#define CS42L84_HS_SWITCH_CTL_HSB_FILT_HS3 BIT(5)
|
||||
#define CS42L84_HS_SWITCH_CTL_HSB_FILT_HS4 BIT(4)
|
||||
#define CS42L84_HS_SWITCH_CTL_HSB_HS3 BIT(3)
|
||||
#define CS42L84_HS_SWITCH_CTL_HSB_HS4 BIT(2)
|
||||
#define CS42L84_HS_SWITCH_CTL_GNDHS_HS3 BIT(1)
|
||||
#define CS42L84_HS_SWITCH_CTL_GNDHS_HS4 BIT(0)
|
||||
|
||||
#define CS42L84_HS_CLAMP_DISABLE 0x1813
|
||||
|
||||
#define CS42L84_ADC_CTL1 0x2000
|
||||
#define CS42L84_ADC_CTL1_PREAMP_GAIN_SHIFT 6
|
||||
#define CS42L84_ADC_CTL1_PGA_GAIN_SHIFT 0
|
||||
#define CS42L84_ADC_CTL4 0x2003
|
||||
#define CS42L84_ADC_CTL4_WNF_CF_SHIFT 4
|
||||
#define CS42L84_ADC_CTL4_WNF_EN_SHIFT 3
|
||||
#define CS42L84_ADC_CTL4_HPF_CF_SHIFT 1
|
||||
#define CS42L84_ADC_CTL4_HPF_EN_SHIFT 0
|
||||
|
||||
#define CS42L84_DAC_CTL1 0x3000
|
||||
#define CS42L84_DAC_CTL1_UNMUTE BIT(0)
|
||||
//#define CS42L84_DAC_CTL1_DACB_INV_SHIFT 1
|
||||
//#define CS42L84_DAC_CTL1_DACA_INV_SHIFT 0
|
||||
#define CS42L84_DAC_CTL2 0x3001
|
||||
|
||||
#define CS42L84_DAC_CHA_VOL_LSB 0x3004
|
||||
#define CS42L84_DAC_CHA_VOL_MSB 0x3005
|
||||
#define CS42L84_DAC_CHB_VOL_LSB 0x3006
|
||||
#define CS42L84_DAC_CHB_VOL_MSB 0x3007
|
||||
#define CS42L84_HP_VOL_CTL 0x3020
|
||||
#define CS42L84_HP_VOL_CTL_ZERO_CROSS BIT(1)
|
||||
#define CS42L84_HP_VOL_CTL_SOFT BIT(0)
|
||||
|
||||
#define CS42L84_SRC_ASP_RX_CH1 0b1101
|
||||
#define CS42L84_SRC_ASP_RX_CH2 0b1110
|
||||
|
||||
#define CS42L84_BUS_ASP_TX_SRC 0x4000
|
||||
#define CS42L84_BUS_ASP_TX_SRC_CH1_SHIFT 0
|
||||
#define CS42L84_BUS_DAC_SRC 0x4001
|
||||
#define CS42L84_BUS_DAC_SRC_DACA_SHIFT 0
|
||||
#define CS42L84_BUS_DAC_SRC_DACB_SHIFT 4
|
||||
|
||||
#define CS42L84_ASP_CTL 0x5000
|
||||
#define CS42L84_ASP_CTL_BCLK_EN_SHIFT 1
|
||||
#define CS42L84_ASP_CTL_TDM_MODE BIT(2)
|
||||
#define CS42L84_ASP_FSYNC_CTL2 0x5010
|
||||
#define CS42L84_ASP_FSYNC_CTL2_BCLK_PERIOD_LO GENMASK(7, 1)
|
||||
#define CS42L84_ASP_FSYNC_CTL3 0x5011
|
||||
#define CS42L84_ASP_FSYNC_CTL3_BCLK_PERIOD_HI GENMASK(4, 0)
|
||||
#define CS42L84_ASP_DATA_CTL 0x5018
|
||||
|
||||
#define CS42L84_ASP_RX_EN 0x5020
|
||||
#define CS42L84_ASP_RX_EN_CH1_SHIFT 0
|
||||
#define CS42L84_ASP_RX_EN_CH2_SHIFT 1
|
||||
#define CS42L84_ASP_TX_EN 0x5024
|
||||
#define CS42L84_ASP_TX_EN_CH1_SHIFT 0
|
||||
|
||||
#define CS42L84_ASP_RX_CH1_CTL1 0x5028
|
||||
#define CS42L84_ASP_RX_CH1_CTL2 0x5029
|
||||
#define CS42L84_ASP_RX_CH1_WIDTH 0x502a
|
||||
#define CS42L84_ASP_RX_CH2_CTL1 0x502c
|
||||
#define CS42L84_ASP_RX_CH2_CTL2 0x502d
|
||||
#define CS42L84_ASP_RX_CH2_WIDTH 0x502e
|
||||
|
||||
#define CS42L84_ASP_RX_CHx_CTL1_EDGE BIT(0)
|
||||
#define CS42L84_ASP_RX_CHx_CTL1_SLOT_START_LSB GENMASK(7, 1)
|
||||
#define CS42L84_ASP_RX_CHx_CTL2_SLOT_START_MSB GENMASK(2, 0)
|
||||
|
||||
#define CS42L84_ASP_TX_CH1_CTL1 0x5068
|
||||
#define CS42L84_ASP_TX_CH1_CTL2 0x5069
|
||||
#define CS42L84_ASP_TX_CH1_WIDTH 0x506a
|
||||
#define CS42L84_ASP_TX_CH2_CTL1 0x506c
|
||||
#define CS42L84_ASP_TX_CH2_CTL2 0x506d
|
||||
#define CS42L84_ASP_TX_CH2_WIDTH 0x506e
|
||||
|
||||
#define CS42L84_DEBOUNCE_TIME_125MS 0b001
|
||||
#define CS42L84_DEBOUNCE_TIME_500MS 0b011
|
||||
|
||||
#define CS42L84_BOOT_TIME_US 3000
|
||||
#define CS42L84_CLOCK_SWITCH_DELAY_US 150
|
||||
#define CS42L84_PLL_LOCK_POLL_US 250
|
||||
#define CS42L84_PLL_LOCK_TIMEOUT_US 1250
|
||||
|
||||
#endif /* __CS42L84_H__ */
|
||||
Loading…
Reference in New Issue
Block a user