mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2024-12-28 11:18:45 +07:00
4ff028f6c1
The LPASS hardware allows configuring the MI2S SD lines to use when playing/recording audio. However, at the moment the lpass-cpu driver has SD0 hard-coded for mono/stereo (or additional fixed SD lines for more channels). For weird reasons there seems to be hardware that uses one of the other SD lines for mono/stereo. For example, some Samsung devices use an external Speaker amplifier connected to Quaternary MI2S. For some reason, the SD line for audio playback was connected to SD1 rather than SD0. (I have no idea why...) At the moment, the lpass-cpu driver cannot be configured to work for the Speaker on these devices. The q6afe driver already allows configuring the MI2S SD lines through the "qcom,sd-lines" device tree property, but this works only when routing audio through the ADSP. This commit adds a very similar configuration for the lpass-cpu driver. It is now possible to add additional subnodes to the lpass device in the device tree, to configure the SD lines for playback and/or capture. E.g. for the Samsung devices mentioned above: &lpass { dai@3 { reg = <MI2S_QUATERNARY>; qcom,playback-sd-lines = <1>; }; }; qcom,playback/capture-sd-lines takes a list of SD lines (0-3) in the same format as the q6afe driver. (The difference here is that q6afe has separate DAIs for playback/capture, while lpass-cpu has one for both...) For backwards compatibility with older device trees, the lpass-cpu driver defaults to LPAIF_I2SCTL_MODE_8CH if the subnode for a DAI is missing. This is equivalent to the previous behavior: Up to 8 channels can be configured, and SD0/QUAT01 will be chosen when setting up a stream with fewer channels. This allows the speaker to work on Samsung MSM8916 devices that use an external speaker amplifier. Signed-off-by: Stephan Gerhold <stephan@gerhold.net> Cc: Srinivas Kandagatla <srinivas.kandagatla@linaro.org> Link: https://lore.kernel.org/r/20200425184657.121991-2-stephan@gerhold.net Signed-off-by: Mark Brown <broonie@kernel.org>
102 lines
2.9 KiB
C
102 lines
2.9 KiB
C
/* SPDX-License-Identifier: GPL-2.0-only */
|
|
/*
|
|
* Copyright (c) 2010-2011,2013-2015 The Linux Foundation. All rights reserved.
|
|
*
|
|
* lpass.h - Definitions for the QTi LPASS
|
|
*/
|
|
|
|
#ifndef __LPASS_H__
|
|
#define __LPASS_H__
|
|
|
|
#include <linux/clk.h>
|
|
#include <linux/compiler.h>
|
|
#include <linux/platform_device.h>
|
|
#include <linux/regmap.h>
|
|
|
|
#define LPASS_AHBIX_CLOCK_FREQUENCY 131072000
|
|
#define LPASS_MAX_MI2S_PORTS (8)
|
|
#define LPASS_MAX_DMA_CHANNELS (8)
|
|
|
|
/* Both the CPU DAI and platform drivers will access this data */
|
|
struct lpass_data {
|
|
|
|
/* AHB-I/X bus clocks inside the low-power audio subsystem (LPASS) */
|
|
struct clk *ahbix_clk;
|
|
|
|
/* MI2S system clock */
|
|
struct clk *mi2s_osr_clk[LPASS_MAX_MI2S_PORTS];
|
|
|
|
/* MI2S bit clock (derived from system clock by a divider */
|
|
struct clk *mi2s_bit_clk[LPASS_MAX_MI2S_PORTS];
|
|
|
|
/* MI2S SD lines to use for playback/capture */
|
|
unsigned int mi2s_playback_sd_mode[LPASS_MAX_MI2S_PORTS];
|
|
unsigned int mi2s_capture_sd_mode[LPASS_MAX_MI2S_PORTS];
|
|
|
|
/* low-power audio interface (LPAIF) registers */
|
|
void __iomem *lpaif;
|
|
|
|
/* regmap backed by the low-power audio interface (LPAIF) registers */
|
|
struct regmap *lpaif_map;
|
|
|
|
/* interrupts from the low-power audio interface (LPAIF) */
|
|
int lpaif_irq;
|
|
|
|
/* SOC specific variations in the LPASS IP integration */
|
|
struct lpass_variant *variant;
|
|
|
|
/* bit map to keep track of static channel allocations */
|
|
unsigned long dma_ch_bit_map;
|
|
|
|
/* used it for handling interrupt per dma channel */
|
|
struct snd_pcm_substream *substream[LPASS_MAX_DMA_CHANNELS];
|
|
|
|
/* 8016 specific */
|
|
struct clk *pcnoc_mport_clk;
|
|
struct clk *pcnoc_sway_clk;
|
|
|
|
};
|
|
|
|
/* Vairant data per each SOC */
|
|
struct lpass_variant {
|
|
u32 i2sctrl_reg_base;
|
|
u32 i2sctrl_reg_stride;
|
|
u32 i2s_ports;
|
|
u32 irq_reg_base;
|
|
u32 irq_reg_stride;
|
|
u32 irq_ports;
|
|
u32 rdma_reg_base;
|
|
u32 rdma_reg_stride;
|
|
u32 rdma_channels;
|
|
u32 wrdma_reg_base;
|
|
u32 wrdma_reg_stride;
|
|
u32 wrdma_channels;
|
|
|
|
/**
|
|
* on SOCs like APQ8016 the channel control bits start
|
|
* at different offset to ipq806x
|
|
**/
|
|
u32 dmactl_audif_start;
|
|
u32 wrdma_channel_start;
|
|
/* SOC specific initialization like clocks */
|
|
int (*init)(struct platform_device *pdev);
|
|
int (*exit)(struct platform_device *pdev);
|
|
int (*alloc_dma_channel)(struct lpass_data *data, int direction);
|
|
int (*free_dma_channel)(struct lpass_data *data, int ch);
|
|
|
|
/* SOC specific dais */
|
|
struct snd_soc_dai_driver *dai_driver;
|
|
int num_dai;
|
|
const char * const *dai_osr_clk_names;
|
|
const char * const *dai_bit_clk_names;
|
|
};
|
|
|
|
/* register the platform driver from the CPU DAI driver */
|
|
int asoc_qcom_lpass_platform_register(struct platform_device *);
|
|
int asoc_qcom_lpass_cpu_platform_remove(struct platform_device *pdev);
|
|
int asoc_qcom_lpass_cpu_platform_probe(struct platform_device *pdev);
|
|
int asoc_qcom_lpass_cpu_dai_probe(struct snd_soc_dai *dai);
|
|
extern const struct snd_soc_dai_ops asoc_qcom_lpass_cpu_dai_ops;
|
|
|
|
#endif /* __LPASS_H__ */
|