hc
2024-02-20 102a0743326a03cd1a1202ceda21e175b7d3575c
kernel/sound/soc/qcom/lpass-ipq806x.c
....@@ -1,14 +1,6 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * Copyright (c) 2010-2011,2013-2015 The Linux Foundation. All rights reserved.
3
- *
4
- * This program is free software; you can redistribute it and/or modify
5
- * it under the terms of the GNU General Public License version 2 and
6
- * only version 2 as published by the Free Software Foundation.
7
- *
8
- * This program is distributed in the hope that it will be useful,
9
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
10
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
- * GNU General Public License for more details.
124 *
135 * lpass-ipq806x.c -- ALSA SoC CPU DAI driver for QTi LPASS
146 * Splited out the IPQ8064 soc specific from lpass-cpu.c
....@@ -63,7 +55,48 @@
6355 .ops = &asoc_qcom_lpass_cpu_dai_ops,
6456 };
6557
66
-static int ipq806x_lpass_alloc_dma_channel(struct lpass_data *drvdata, int dir)
58
+static int ipq806x_lpass_init(struct platform_device *pdev)
59
+{
60
+ struct lpass_data *drvdata = platform_get_drvdata(pdev);
61
+ struct device *dev = &pdev->dev;
62
+ int ret;
63
+
64
+ drvdata->ahbix_clk = devm_clk_get(dev, "ahbix-clk");
65
+ if (IS_ERR(drvdata->ahbix_clk)) {
66
+ dev_err(dev, "error getting ahbix-clk: %ld\n",
67
+ PTR_ERR(drvdata->ahbix_clk));
68
+ ret = PTR_ERR(drvdata->ahbix_clk);
69
+ goto err_ahbix_clk;
70
+ }
71
+
72
+ ret = clk_set_rate(drvdata->ahbix_clk, LPASS_AHBIX_CLOCK_FREQUENCY);
73
+ if (ret) {
74
+ dev_err(dev, "error setting rate on ahbix_clk: %d\n", ret);
75
+ goto err_ahbix_clk;
76
+ }
77
+ dev_dbg(dev, "set ahbix_clk rate to %lu\n",
78
+ clk_get_rate(drvdata->ahbix_clk));
79
+
80
+ ret = clk_prepare_enable(drvdata->ahbix_clk);
81
+ if (ret) {
82
+ dev_err(dev, "error enabling ahbix_clk: %d\n", ret);
83
+ goto err_ahbix_clk;
84
+ }
85
+
86
+err_ahbix_clk:
87
+ return ret;
88
+}
89
+
90
+static int ipq806x_lpass_exit(struct platform_device *pdev)
91
+{
92
+ struct lpass_data *drvdata = platform_get_drvdata(pdev);
93
+
94
+ clk_disable_unprepare(drvdata->ahbix_clk);
95
+
96
+ return 0;
97
+}
98
+
99
+static int ipq806x_lpass_alloc_dma_channel(struct lpass_data *drvdata, int dir, unsigned int dai_id)
67100 {
68101 if (dir == SNDRV_PCM_STREAM_PLAYBACK)
69102 return IPQ806X_LPAIF_RDMA_CHAN_MI2S;
....@@ -71,7 +104,7 @@
71104 return -EINVAL;
72105 }
73106
74
-static int ipq806x_lpass_free_dma_channel(struct lpass_data *drvdata, int chan)
107
+static int ipq806x_lpass_free_dma_channel(struct lpass_data *drvdata, int chan, unsigned int dai_id)
75108 {
76109 return 0;
77110 }
....@@ -90,6 +123,30 @@
90123 .wrdma_reg_stride = 0x1000,
91124 .wrdma_channel_start = 5,
92125 .wrdma_channels = 4,
126
+ .loopback = REG_FIELD_ID(0x0010, 15, 15, 5, 0x4),
127
+ .spken = REG_FIELD_ID(0x0010, 14, 14, 5, 0x4),
128
+ .spkmode = REG_FIELD_ID(0x0010, 10, 13, 5, 0x4),
129
+ .spkmono = REG_FIELD_ID(0x0010, 9, 9, 5, 0x4),
130
+ .micen = REG_FIELD_ID(0x0010, 8, 8, 5, 0x4),
131
+ .micmode = REG_FIELD_ID(0x0010, 4, 7, 5, 0x4),
132
+ .micmono = REG_FIELD_ID(0x0010, 3, 3, 5, 0x4),
133
+ .wssrc = REG_FIELD_ID(0x0010, 2, 2, 5, 0x4),
134
+ .bitwidth = REG_FIELD_ID(0x0010, 0, 1, 5, 0x4),
135
+
136
+ .rdma_dyncclk = REG_FIELD_ID(0x6000, 12, 12, 4, 0x1000),
137
+ .rdma_bursten = REG_FIELD_ID(0x6000, 11, 11, 4, 0x1000),
138
+ .rdma_wpscnt = REG_FIELD_ID(0x6000, 8, 10, 4, 0x1000),
139
+ .rdma_intf = REG_FIELD_ID(0x6000, 4, 7, 4, 0x1000),
140
+ .rdma_fifowm = REG_FIELD_ID(0x6000, 1, 3, 4, 0x1000),
141
+ .rdma_enable = REG_FIELD_ID(0x6000, 0, 0, 4, 0x1000),
142
+
143
+ .wrdma_dyncclk = REG_FIELD_ID(0xB000, 12, 12, 4, 0x1000),
144
+ .wrdma_bursten = REG_FIELD_ID(0xB000, 11, 11, 4, 0x1000),
145
+ .wrdma_wpscnt = REG_FIELD_ID(0xB000, 8, 10, 4, 0x1000),
146
+ .wrdma_intf = REG_FIELD_ID(0xB000, 4, 7, 4, 0x1000),
147
+ .wrdma_fifowm = REG_FIELD_ID(0xB000, 1, 3, 4, 0x1000),
148
+ .wrdma_enable = REG_FIELD_ID(0xB000, 0, 0, 4, 0x1000),
149
+
93150 .dai_driver = &ipq806x_lpass_cpu_dai_driver,
94151 .num_dai = 1,
95152 .dai_osr_clk_names = (const char *[]) {
....@@ -98,6 +155,8 @@
98155 .dai_bit_clk_names = (const char *[]) {
99156 "mi2s-bit-clk",
100157 },
158
+ .init = ipq806x_lpass_init,
159
+ .exit = ipq806x_lpass_exit,
101160 .alloc_dma_channel = ipq806x_lpass_alloc_dma_channel,
102161 .free_dma_channel = ipq806x_lpass_free_dma_channel,
103162 };