diff --git a/Documentation/devicetree/bindings/sound/apple,mca.yaml b/Documentation/devicetree/bindings/sound/apple,mca.yaml index 2d6300c12831d..06094f3ac063b 100644 --- a/Documentation/devicetree/bindings/sound/apple,mca.yaml +++ b/Documentation/devicetree/bindings/sound/apple,mca.yaml @@ -110,6 +110,17 @@ properties: '#sound-dai-cells': const: 1 + apple,rx-bclk-inverted-clusters: + description: + Indices of clusters whose receive serializers sample on the opposite + bit clock edge to the one selected by the DAI format. The transmit + serializers keep the edge specified by the DAI format. + $ref: /schemas/types.yaml#/definitions/uint32-array + minItems: 1 + maxItems: 6 + items: + maximum: 5 + required: - compatible - reg diff --git a/arch/arm64/boot/dts/apple/t8122-j613.dts b/arch/arm64/boot/dts/apple/t8122-j613.dts index 1c503729a3101..d2326056944d9 100644 --- a/arch/arm64/boot/dts/apple/t8122-j613.dts +++ b/arch/arm64/boot/dts/apple/t8122-j613.dts @@ -390,6 +390,11 @@ }; }; +&mca { + /* Speaker-sense SDOUT is launched on the nominal RX sample edge. */ + apple,rx-bclk-inverted-clusters = <2>; +}; + / { sound { compatible = "apple,j613-macaudio", "apple,j413-macaudio", "apple,macaudio"; diff --git a/sound/soc/apple/mca.c b/sound/soc/apple/mca.c index 9dfb329f46201..74f6f61f7ee03 100644 --- a/sound/soc/apple/mca.c +++ b/sound/soc/apple/mca.c @@ -140,6 +140,7 @@ struct mca_cluster { struct dma_chan *dma_chans[SNDRV_PCM_STREAM_LAST + 1]; bool clk_provider; + bool rx_bclk_inverted; bool port_clk_started[SNDRV_PCM_STREAM_LAST + 1]; int port_clk_driver; /* The cluster driving this cluster's port */ @@ -594,6 +595,8 @@ static int mca_fe_set_fmt(struct snd_soc_dai *dai, unsigned int fmt) mca_modify(cl, CLUSTER_TX_OFF + REG_TX_SERDES_CONF, SERDES_CONF_BCLK_POL, serdes_conf); + if (cl->rx_bclk_inverted) + serdes_conf ^= SERDES_CONF_BCLK_POL; mca_modify(cl, CLUSTER_RX_OFF + REG_RX_SERDES_CONF, SERDES_CONF_BCLK_POL, serdes_conf); writel_relaxed(bitstart, @@ -1307,6 +1310,7 @@ static int apple_mca_probe(struct platform_device *pdev) struct snd_soc_dai_driver *dai_drivers; struct resource *res; void __iomem *base; + u32 rx_bclk_cluster; int nclusters; int ret, i; @@ -1328,6 +1332,14 @@ static int apple_mca_probe(struct platform_device *pdev) platform_set_drvdata(pdev, mca); clusters = mca->clusters; + of_property_for_each_u32(pdev->dev.of_node, "apple,rx-bclk-inverted-clusters", + rx_bclk_cluster) { + if (rx_bclk_cluster >= nclusters) + return dev_err_probe(&pdev->dev, -EINVAL, + "invalid RX BCLK cluster %u\n", rx_bclk_cluster); + clusters[rx_bclk_cluster].rx_bclk_inverted = true; + } + mca->switch_base = devm_platform_ioremap_resource(pdev, 1); if (IS_ERR(mca->switch_base))