2019-05-29 22:17:58 +08:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0-only */
|
2015-03-04 08:21:53 +08:00
|
|
|
/*
|
2020-10-08 13:17:01 +08:00
|
|
|
* Copyright (c) 2010-2011,2013-2015,2020 The Linux Foundation. All rights reserved.
|
2015-03-04 08:21:53 +08:00
|
|
|
*
|
|
|
|
* 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>
|
2021-01-20 01:15:27 +08:00
|
|
|
#include <dt-bindings/sound/qcom,lpass.h>
|
2020-10-08 13:17:01 +08:00
|
|
|
#include "lpass-hdmi.h"
|
2015-03-04 08:21:53 +08:00
|
|
|
|
|
|
|
#define LPASS_AHBIX_CLOCK_FREQUENCY 131072000
|
2015-05-22 05:52:49 +08:00
|
|
|
#define LPASS_MAX_MI2S_PORTS (8)
|
2015-05-22 05:53:14 +08:00
|
|
|
#define LPASS_MAX_DMA_CHANNELS (8)
|
2020-10-08 13:17:01 +08:00
|
|
|
#define LPASS_MAX_HDMI_DMA_CHANNELS (4)
|
|
|
|
|
|
|
|
#define QCOM_REGMAP_FIELD_ALLOC(d, m, f, mf) \
|
|
|
|
do { \
|
|
|
|
mf = devm_regmap_field_alloc(d, m, f); \
|
|
|
|
if (IS_ERR(mf)) \
|
|
|
|
return -EINVAL; \
|
|
|
|
} while (0)
|
2015-03-04 08:21:53 +08:00
|
|
|
|
2020-08-14 18:53:01 +08:00
|
|
|
struct lpaif_i2sctl {
|
|
|
|
struct regmap_field *loopback;
|
|
|
|
struct regmap_field *spken;
|
|
|
|
struct regmap_field *spkmode;
|
|
|
|
struct regmap_field *spkmono;
|
|
|
|
struct regmap_field *micen;
|
|
|
|
struct regmap_field *micmode;
|
|
|
|
struct regmap_field *micmono;
|
|
|
|
struct regmap_field *wssrc;
|
|
|
|
struct regmap_field *bitwidth;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
struct lpaif_dmactl {
|
2020-10-08 13:17:00 +08:00
|
|
|
struct regmap_field *intf;
|
2020-08-14 18:53:01 +08:00
|
|
|
struct regmap_field *bursten;
|
|
|
|
struct regmap_field *wpscnt;
|
|
|
|
struct regmap_field *fifowm;
|
|
|
|
struct regmap_field *enable;
|
|
|
|
struct regmap_field *dyncclk;
|
2020-10-08 13:17:01 +08:00
|
|
|
struct regmap_field *burst8;
|
|
|
|
struct regmap_field *burst16;
|
|
|
|
struct regmap_field *dynburst;
|
2020-08-14 18:53:01 +08:00
|
|
|
};
|
|
|
|
|
2015-03-04 08:21:53 +08:00
|
|
|
/* 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 */
|
2015-05-22 05:52:49 +08:00
|
|
|
struct clk *mi2s_osr_clk[LPASS_MAX_MI2S_PORTS];
|
2015-03-04 08:21:53 +08:00
|
|
|
|
|
|
|
/* MI2S bit clock (derived from system clock by a divider */
|
2015-05-22 05:52:49 +08:00
|
|
|
struct clk *mi2s_bit_clk[LPASS_MAX_MI2S_PORTS];
|
2015-03-04 08:21:53 +08:00
|
|
|
|
ASoC: qcom: lpass-cpu: Make I2S SD lines configurable
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>
2020-04-26 02:46:57 +08:00
|
|
|
/* 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];
|
2021-06-04 23:45:45 +08:00
|
|
|
|
|
|
|
/* The state of MI2S prepare dai_ops was called */
|
|
|
|
bool mi2s_was_prepared[LPASS_MAX_MI2S_PORTS];
|
|
|
|
|
2020-10-08 13:17:01 +08:00
|
|
|
int hdmi_port_enable;
|
ASoC: qcom: lpass-cpu: Make I2S SD lines configurable
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>
2020-04-26 02:46:57 +08:00
|
|
|
|
2015-03-04 08:21:53 +08:00
|
|
|
/* low-power audio interface (LPAIF) registers */
|
|
|
|
void __iomem *lpaif;
|
2020-10-08 13:17:01 +08:00
|
|
|
void __iomem *hdmiif;
|
2015-03-04 08:21:53 +08:00
|
|
|
|
|
|
|
/* regmap backed by the low-power audio interface (LPAIF) registers */
|
|
|
|
struct regmap *lpaif_map;
|
2020-10-08 13:17:01 +08:00
|
|
|
struct regmap *hdmiif_map;
|
2015-03-04 08:21:53 +08:00
|
|
|
|
|
|
|
/* interrupts from the low-power audio interface (LPAIF) */
|
|
|
|
int lpaif_irq;
|
2020-10-08 13:17:01 +08:00
|
|
|
int hdmiif_irq;
|
2015-05-16 20:32:17 +08:00
|
|
|
/* SOC specific variations in the LPASS IP integration */
|
|
|
|
struct lpass_variant *variant;
|
2015-05-22 05:53:14 +08:00
|
|
|
|
2015-05-22 05:53:21 +08:00
|
|
|
/* bit map to keep track of static channel allocations */
|
2016-02-11 20:17:51 +08:00
|
|
|
unsigned long dma_ch_bit_map;
|
2020-10-08 13:17:01 +08:00
|
|
|
unsigned long hdmi_dma_ch_bit_map;
|
2015-05-22 05:53:21 +08:00
|
|
|
|
2015-05-22 05:53:14 +08:00
|
|
|
/* used it for handling interrupt per dma channel */
|
|
|
|
struct snd_pcm_substream *substream[LPASS_MAX_DMA_CHANNELS];
|
2020-10-08 13:17:01 +08:00
|
|
|
struct snd_pcm_substream *hdmi_substream[LPASS_MAX_HDMI_DMA_CHANNELS];
|
2015-05-22 23:53:52 +08:00
|
|
|
|
2020-08-14 18:52:57 +08:00
|
|
|
/* SOC specific clock list */
|
|
|
|
struct clk_bulk_data *clks;
|
|
|
|
int num_clks;
|
2016-08-01 14:10:54 +08:00
|
|
|
|
2020-08-14 18:53:01 +08:00
|
|
|
/* Regmap fields of I2SCTL & DMACTL registers bitfields */
|
|
|
|
struct lpaif_i2sctl *i2sctl;
|
|
|
|
struct lpaif_dmactl *rd_dmactl;
|
|
|
|
struct lpaif_dmactl *wr_dmactl;
|
2020-10-08 13:17:01 +08:00
|
|
|
struct lpaif_dmactl *hdmi_rd_dmactl;
|
|
|
|
/* Regmap fields of HDMI_CTRL registers*/
|
|
|
|
struct regmap_field *hdmitx_legacy_en;
|
|
|
|
struct regmap_field *hdmitx_parity_calc_en;
|
|
|
|
struct regmap_field *hdmitx_ch_msb[LPASS_MAX_HDMI_DMA_CHANNELS];
|
|
|
|
struct regmap_field *hdmitx_ch_lsb[LPASS_MAX_HDMI_DMA_CHANNELS];
|
|
|
|
struct lpass_hdmi_tx_ctl *tx_ctl;
|
|
|
|
struct lpass_vbit_ctrl *vbit_ctl;
|
|
|
|
struct lpass_hdmitx_dmactl *hdmi_tx_dmactl[LPASS_MAX_HDMI_DMA_CHANNELS];
|
|
|
|
struct lpass_dp_metadata_ctl *meta_ctl;
|
|
|
|
struct lpass_sstream_ctl *sstream_ctl;
|
2015-05-16 20:32:17 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
/* Vairant data per each SOC */
|
|
|
|
struct lpass_variant {
|
|
|
|
u32 irq_reg_base;
|
|
|
|
u32 irq_reg_stride;
|
|
|
|
u32 irq_ports;
|
|
|
|
u32 rdma_reg_base;
|
|
|
|
u32 rdma_reg_stride;
|
|
|
|
u32 rdma_channels;
|
2020-10-08 13:17:01 +08:00
|
|
|
u32 hdmi_rdma_reg_base;
|
|
|
|
u32 hdmi_rdma_reg_stride;
|
|
|
|
u32 hdmi_rdma_channels;
|
2016-02-11 20:17:23 +08:00
|
|
|
u32 wrdma_reg_base;
|
|
|
|
u32 wrdma_reg_stride;
|
|
|
|
u32 wrdma_channels;
|
2020-10-08 13:17:01 +08:00
|
|
|
u32 i2sctrl_reg_base;
|
|
|
|
u32 i2sctrl_reg_stride;
|
|
|
|
u32 i2s_ports;
|
2015-05-16 20:32:17 +08:00
|
|
|
|
2020-08-14 18:53:01 +08:00
|
|
|
/* I2SCTL Register fields */
|
|
|
|
struct reg_field loopback;
|
|
|
|
struct reg_field spken;
|
|
|
|
struct reg_field spkmode;
|
|
|
|
struct reg_field spkmono;
|
|
|
|
struct reg_field micen;
|
|
|
|
struct reg_field micmode;
|
|
|
|
struct reg_field micmono;
|
|
|
|
struct reg_field wssrc;
|
|
|
|
struct reg_field bitwidth;
|
|
|
|
|
2020-10-08 13:17:01 +08:00
|
|
|
u32 hdmi_irq_reg_base;
|
|
|
|
u32 hdmi_irq_reg_stride;
|
|
|
|
u32 hdmi_irq_ports;
|
|
|
|
|
|
|
|
/* HDMI specific controls */
|
|
|
|
u32 hdmi_tx_ctl_addr;
|
|
|
|
u32 hdmi_legacy_addr;
|
|
|
|
u32 hdmi_vbit_addr;
|
|
|
|
u32 hdmi_ch_lsb_addr;
|
|
|
|
u32 hdmi_ch_msb_addr;
|
|
|
|
u32 ch_stride;
|
|
|
|
u32 hdmi_parity_addr;
|
|
|
|
u32 hdmi_dmactl_addr;
|
|
|
|
u32 hdmi_dma_stride;
|
|
|
|
u32 hdmi_DP_addr;
|
|
|
|
u32 hdmi_sstream_addr;
|
|
|
|
|
|
|
|
/* HDMI SSTREAM CTRL fields */
|
|
|
|
struct reg_field sstream_en;
|
|
|
|
struct reg_field dma_sel;
|
|
|
|
struct reg_field auto_bbit_en;
|
|
|
|
struct reg_field layout;
|
|
|
|
struct reg_field layout_sp;
|
|
|
|
struct reg_field set_sp_on_en;
|
|
|
|
struct reg_field dp_audio;
|
|
|
|
struct reg_field dp_staffing_en;
|
|
|
|
struct reg_field dp_sp_b_hw_en;
|
|
|
|
|
|
|
|
/* HDMI DP METADATA CTL fields */
|
|
|
|
struct reg_field mute;
|
|
|
|
struct reg_field as_sdp_cc;
|
|
|
|
struct reg_field as_sdp_ct;
|
|
|
|
struct reg_field aif_db4;
|
|
|
|
struct reg_field frequency;
|
|
|
|
struct reg_field mst_index;
|
|
|
|
struct reg_field dptx_index;
|
|
|
|
|
|
|
|
/* HDMI TX CTRL fields */
|
|
|
|
struct reg_field soft_reset;
|
|
|
|
struct reg_field force_reset;
|
|
|
|
|
|
|
|
/* HDMI TX DMA CTRL */
|
|
|
|
struct reg_field use_hw_chs;
|
|
|
|
struct reg_field use_hw_usr;
|
|
|
|
struct reg_field hw_chs_sel;
|
|
|
|
struct reg_field hw_usr_sel;
|
|
|
|
|
|
|
|
/* HDMI VBIT CTRL */
|
|
|
|
struct reg_field replace_vbit;
|
|
|
|
struct reg_field vbit_stream;
|
|
|
|
|
|
|
|
/* HDMI TX LEGACY */
|
|
|
|
struct reg_field legacy_en;
|
|
|
|
|
|
|
|
/* HDMI TX PARITY */
|
|
|
|
struct reg_field calc_en;
|
|
|
|
|
|
|
|
/* HDMI CH LSB */
|
|
|
|
struct reg_field lsb_bits;
|
|
|
|
|
|
|
|
/* HDMI CH MSB */
|
|
|
|
struct reg_field msb_bits;
|
|
|
|
|
|
|
|
struct reg_field hdmi_rdma_bursten;
|
|
|
|
struct reg_field hdmi_rdma_wpscnt;
|
|
|
|
struct reg_field hdmi_rdma_fifowm;
|
|
|
|
struct reg_field hdmi_rdma_enable;
|
|
|
|
struct reg_field hdmi_rdma_dyncclk;
|
|
|
|
struct reg_field hdmi_rdma_burst8;
|
|
|
|
struct reg_field hdmi_rdma_burst16;
|
|
|
|
struct reg_field hdmi_rdma_dynburst;
|
|
|
|
|
2020-08-14 18:53:01 +08:00
|
|
|
/* RD_DMA Register fields */
|
2020-10-08 13:17:00 +08:00
|
|
|
struct reg_field rdma_intf;
|
2020-08-14 18:53:01 +08:00
|
|
|
struct reg_field rdma_bursten;
|
|
|
|
struct reg_field rdma_wpscnt;
|
|
|
|
struct reg_field rdma_fifowm;
|
|
|
|
struct reg_field rdma_enable;
|
|
|
|
struct reg_field rdma_dyncclk;
|
|
|
|
|
|
|
|
/* WR_DMA Register fields */
|
2020-10-08 13:17:00 +08:00
|
|
|
struct reg_field wrdma_intf;
|
2020-08-14 18:53:01 +08:00
|
|
|
struct reg_field wrdma_bursten;
|
|
|
|
struct reg_field wrdma_wpscnt;
|
|
|
|
struct reg_field wrdma_fifowm;
|
|
|
|
struct reg_field wrdma_enable;
|
|
|
|
struct reg_field wrdma_dyncclk;
|
|
|
|
|
2015-05-22 05:53:05 +08:00
|
|
|
/**
|
|
|
|
* on SOCs like APQ8016 the channel control bits start
|
|
|
|
* at different offset to ipq806x
|
|
|
|
**/
|
2016-02-11 20:17:30 +08:00
|
|
|
u32 dmactl_audif_start;
|
2016-02-11 20:17:23 +08:00
|
|
|
u32 wrdma_channel_start;
|
2017-02-28 06:29:20 +08:00
|
|
|
/* SOC specific initialization like clocks */
|
2015-05-16 20:32:17 +08:00
|
|
|
int (*init)(struct platform_device *pdev);
|
|
|
|
int (*exit)(struct platform_device *pdev);
|
2020-10-08 13:17:01 +08:00
|
|
|
int (*alloc_dma_channel)(struct lpass_data *data, int direction, unsigned int dai_id);
|
|
|
|
int (*free_dma_channel)(struct lpass_data *data, int ch, unsigned int dai_id);
|
2015-05-16 20:32:17 +08:00
|
|
|
|
|
|
|
/* SOC specific dais */
|
|
|
|
struct snd_soc_dai_driver *dai_driver;
|
|
|
|
int num_dai;
|
2017-04-05 16:34:10 +08:00
|
|
|
const char * const *dai_osr_clk_names;
|
|
|
|
const char * const *dai_bit_clk_names;
|
2020-08-14 18:52:57 +08:00
|
|
|
|
|
|
|
/* SOC specific clocks configuration */
|
|
|
|
const char **clk_name;
|
|
|
|
int num_clks;
|
2015-03-04 08:21:53 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
/* register the platform driver from the CPU DAI driver */
|
|
|
|
int asoc_qcom_lpass_platform_register(struct platform_device *);
|
2015-05-16 20:32:17 +08:00
|
|
|
int asoc_qcom_lpass_cpu_platform_remove(struct platform_device *pdev);
|
2020-11-14 02:38:22 +08:00
|
|
|
void asoc_qcom_lpass_cpu_platform_shutdown(struct platform_device *pdev);
|
2015-05-16 20:32:17 +08:00
|
|
|
int asoc_qcom_lpass_cpu_platform_probe(struct platform_device *pdev);
|
|
|
|
int asoc_qcom_lpass_cpu_dai_probe(struct snd_soc_dai *dai);
|
2015-08-28 10:53:31 +08:00
|
|
|
extern const struct snd_soc_dai_ops asoc_qcom_lpass_cpu_dai_ops;
|
2015-03-04 08:21:53 +08:00
|
|
|
|
|
|
|
#endif /* __LPASS_H__ */
|