Skip to content

Commit 5303a16

Browse files
authored
Merge pull request #3655 from plbossart/merge/sound-upstream-20220517
Merge/sound upstream 20220517
2 parents ebc40b7 + 93f862b commit 5303a16

106 files changed

Lines changed: 1901 additions & 371 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

Documentation/devicetree/bindings/sound/fsl,micfil.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ microphone bitstream in a configurable output sampling rate.
66
Required properties:
77

88
- compatible : Compatible list, contains "fsl,imx8mm-micfil"
9+
or "fsl,imx8mp-micfil"
910

1011
- reg : Offset and length of the register set for the device.
1112

Documentation/devicetree/bindings/sound/realtek,rt1015p.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ properties:
2525
0 means shut down; 1 means power on.
2626
maxItems: 1
2727

28+
"#sound-dai-cells":
29+
const: 0
30+
2831
required:
2932
- compatible
3033

Documentation/devicetree/bindings/sound/rt5682.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ Optional properties:
4646

4747
- realtek,dmic-clk-driving-high : Set the high driving of the DMIC clock out.
4848

49+
- #sound-dai-cells: Should be set to '<0>'.
50+
4951
Pins on the device (for linking into audio routes) for RT5682:
5052

5153
* DMIC L1
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause
2+
3+
%YAML 1.2
4+
---
5+
$id: http://devicetree.org/schemas/sound/serial-midi.yaml#
6+
$schema: http://devicetree.org/meta-schemas/core.yaml#
7+
8+
title: Generic Serial MIDI Interface
9+
10+
maintainers:
11+
- Daniel Kaehn <kaehndan@gmail.com>
12+
13+
description:
14+
Generic MIDI interface using a serial device. This denotes that a serial device is
15+
dedicated to MIDI communication, either to an external MIDI device through a DIN5
16+
or other connector, or to a known hardwired MIDI controller. This device must be a
17+
child node of a serial node.
18+
19+
Can only be set to use standard baud rates corresponding to supported rates of the
20+
parent serial device. If the standard MIDI baud of 31.25 kBaud is needed
21+
(as would be the case if interfacing with arbitrary external MIDI devices),
22+
configure the clocks of the parent serial device so that a requested baud of 38.4 kBaud
23+
resuts in the standard MIDI baud rate, and set the 'current-speed' property to 38400 (default)
24+
25+
properties:
26+
compatible:
27+
const: serial-midi
28+
29+
current-speed:
30+
description: Baudrate to set the serial port to when this MIDI device is opened.
31+
default: 38400
32+
33+
required:
34+
- compatible
35+
36+
additionalProperties: false
37+
38+
examples:
39+
- |
40+
serial {
41+
midi {
42+
compatible = "serial-midi";
43+
};
44+
};
45+
- |
46+
serial {
47+
midi {
48+
compatible = "serial-midi";
49+
current-speed = <115200>;
50+
};
51+
};
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
2+
%YAML 1.2
3+
---
4+
$id: http://devicetree.org/schemas/sound/wlf,wm8940.yaml#
5+
$schema: http://devicetree.org/meta-schemas/core.yaml#
6+
7+
title: Wolfson WM8940 Codec Device Tree Bindings
8+
9+
maintainers:
10+
- patches@opensource.cirrus.com
11+
12+
properties:
13+
'#sound-dai-cells':
14+
const: 0
15+
16+
compatible:
17+
const: wlf,wm8940
18+
19+
reg:
20+
maxItems: 1
21+
22+
spi-max-frequency:
23+
maximum: 526000
24+
25+
required:
26+
- '#sound-dai-cells'
27+
- compatible
28+
- reg
29+
30+
additionalProperties: false
31+
32+
examples:
33+
- |
34+
spi {
35+
#address-cells = <1>;
36+
#size-cells = <0>;
37+
38+
codec@0 {
39+
#sound-dai-cells = <0>;
40+
compatible = "wlf,wm8940";
41+
reg = <0>;
42+
spi-max-frequency = <500000>;
43+
};
44+
};
45+
- |
46+
i2c {
47+
#address-cells = <1>;
48+
#size-cells = <0>;
49+
50+
codec@1a {
51+
#sound-dai-cells = <0>;
52+
compatible = "wlf,wm8940";
53+
reg = <0x1a>;
54+
};
55+
};
56+
57+
...

drivers/firmware/Kconfig

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,15 @@ config INTEL_STRATIX10_RSU
203203

204204
Say Y here if you want Intel RSU support.
205205

206+
config MTK_ADSP_IPC
207+
tristate "MTK ADSP IPC Protocol driver"
208+
depends on MTK_ADSP_MBOX
209+
help
210+
Say yes here to add support for the MediaTek ADSP IPC
211+
between host AP (Linux) and the firmware running on ADSP.
212+
ADSP exists on some mtk processors.
213+
Client might use shared memory to exchange information with ADSP.
214+
206215
config QCOM_SCM
207216
tristate
208217

drivers/firmware/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ obj-$(CONFIG_INTEL_STRATIX10_RSU) += stratix10-rsu.o
1515
obj-$(CONFIG_ISCSI_IBFT_FIND) += iscsi_ibft_find.o
1616
obj-$(CONFIG_ISCSI_IBFT) += iscsi_ibft.o
1717
obj-$(CONFIG_FIRMWARE_MEMMAP) += memmap.o
18+
obj-$(CONFIG_MTK_ADSP_IPC) += mtk-adsp-ipc.o
1819
obj-$(CONFIG_RASPBERRYPI_FIRMWARE) += raspberrypi.o
1920
obj-$(CONFIG_FW_CFG_SYSFS) += qemu_fw_cfg.o
2021
obj-$(CONFIG_QCOM_SCM) += qcom-scm.o

drivers/firmware/mtk-adsp-ipc.c

Lines changed: 157 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,157 @@
1+
// SPDX-License-Identifier: GPL-2.0
2+
/*
3+
* Copyright (c) 2022 MediaTek Corporation. All rights reserved.
4+
* Author: Allen-KH Cheng <allen-kh.cheng@mediatek.com>
5+
*/
6+
7+
#include <linux/firmware/mediatek/mtk-adsp-ipc.h>
8+
#include <linux/kernel.h>
9+
#include <linux/mailbox_client.h>
10+
#include <linux/module.h>
11+
#include <linux/of_platform.h>
12+
#include <linux/platform_device.h>
13+
#include <linux/slab.h>
14+
15+
/*
16+
* mtk_adsp_ipc_send - send ipc cmd to MTK ADSP
17+
*
18+
* @ipc: ADSP IPC handle
19+
* @idx: index of the mailbox channel
20+
* @msg: IPC cmd (reply or request)
21+
*
22+
* Returns zero for success from mbox_send_message
23+
* negative value for error
24+
*/
25+
int mtk_adsp_ipc_send(struct mtk_adsp_ipc *ipc, unsigned int idx, uint32_t msg)
26+
{
27+
struct mtk_adsp_chan *adsp_chan;
28+
int ret;
29+
30+
if (idx >= MTK_ADSP_MBOX_NUM)
31+
return -EINVAL;
32+
33+
adsp_chan = &ipc->chans[idx];
34+
ret = mbox_send_message(adsp_chan->ch, &msg);
35+
if (ret < 0)
36+
return ret;
37+
38+
return 0;
39+
}
40+
EXPORT_SYMBOL_GPL(mtk_adsp_ipc_send);
41+
42+
/*
43+
* mtk_adsp_ipc_recv - recv callback used by MTK ADSP mailbox
44+
*
45+
* @c: mbox client
46+
* @msg: message received
47+
*
48+
* Users of ADSP IPC will need to privde handle_reply and handle_request
49+
* callbacks.
50+
*/
51+
static void mtk_adsp_ipc_recv(struct mbox_client *c, void *msg)
52+
{
53+
struct mtk_adsp_chan *chan = container_of(c, struct mtk_adsp_chan, cl);
54+
struct device *dev = c->dev;
55+
56+
switch (chan->idx) {
57+
case MTK_ADSP_MBOX_REPLY:
58+
chan->ipc->ops->handle_reply(chan->ipc);
59+
break;
60+
case MTK_ADSP_MBOX_REQUEST:
61+
chan->ipc->ops->handle_request(chan->ipc);
62+
break;
63+
default:
64+
dev_err(dev, "wrong mbox chan %d\n", chan->idx);
65+
break;
66+
}
67+
}
68+
69+
static int mtk_adsp_ipc_probe(struct platform_device *pdev)
70+
{
71+
struct device *dev = &pdev->dev;
72+
struct mtk_adsp_ipc *adsp_ipc;
73+
struct mtk_adsp_chan *adsp_chan;
74+
struct mbox_client *cl;
75+
char *chan_name;
76+
int ret;
77+
int i, j;
78+
79+
device_set_of_node_from_dev(&pdev->dev, pdev->dev.parent);
80+
81+
adsp_ipc = devm_kzalloc(dev, sizeof(*adsp_ipc), GFP_KERNEL);
82+
if (!adsp_ipc)
83+
return -ENOMEM;
84+
85+
for (i = 0; i < MTK_ADSP_MBOX_NUM; i++) {
86+
chan_name = kasprintf(GFP_KERNEL, "mbox%d", i);
87+
if (!chan_name) {
88+
ret = -ENOMEM;
89+
goto out;
90+
}
91+
92+
adsp_chan = &adsp_ipc->chans[i];
93+
cl = &adsp_chan->cl;
94+
cl->dev = dev->parent;
95+
cl->tx_block = false;
96+
cl->knows_txdone = false;
97+
cl->tx_prepare = NULL;
98+
cl->rx_callback = mtk_adsp_ipc_recv;
99+
100+
adsp_chan->ipc = adsp_ipc;
101+
adsp_chan->idx = i;
102+
adsp_chan->ch = mbox_request_channel_byname(cl, chan_name);
103+
if (IS_ERR(adsp_chan->ch)) {
104+
ret = PTR_ERR(adsp_chan->ch);
105+
if (ret != -EPROBE_DEFER)
106+
dev_err(dev, "Failed to request mbox chan %d ret %d\n",
107+
i, ret);
108+
goto out_free;
109+
}
110+
111+
dev_dbg(dev, "request mbox chan %s\n", chan_name);
112+
kfree(chan_name);
113+
}
114+
115+
adsp_ipc->dev = dev;
116+
dev_set_drvdata(dev, adsp_ipc);
117+
dev_dbg(dev, "MTK ADSP IPC initialized\n");
118+
119+
return 0;
120+
121+
out_free:
122+
kfree(chan_name);
123+
out:
124+
for (j = 0; j < i; j++) {
125+
adsp_chan = &adsp_ipc->chans[j];
126+
mbox_free_channel(adsp_chan->ch);
127+
}
128+
129+
return ret;
130+
}
131+
132+
static int mtk_adsp_ipc_remove(struct platform_device *pdev)
133+
{
134+
struct mtk_adsp_ipc *adsp_ipc = dev_get_drvdata(&pdev->dev);
135+
struct mtk_adsp_chan *adsp_chan;
136+
int i;
137+
138+
for (i = 0; i < MTK_ADSP_MBOX_NUM; i++) {
139+
adsp_chan = &adsp_ipc->chans[i];
140+
mbox_free_channel(adsp_chan->ch);
141+
}
142+
143+
return 0;
144+
}
145+
146+
static struct platform_driver mtk_adsp_ipc_driver = {
147+
.driver = {
148+
.name = "mtk-adsp-ipc",
149+
},
150+
.probe = mtk_adsp_ipc_probe,
151+
.remove = mtk_adsp_ipc_remove,
152+
};
153+
builtin_platform_driver(mtk_adsp_ipc_driver);
154+
155+
MODULE_AUTHOR("Allen-KH Cheng <allen-kh.cheng@mediatek.com>");
156+
MODULE_DESCRIPTION("MTK ADSP IPC Driver");
157+
MODULE_LICENSE("GPL");
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
/* SPDX-License-Identifier: GPL-2.0 */
2+
/*
3+
* Copyright (c) 2022 MediaTek Inc.
4+
*/
5+
6+
#ifndef MTK_ADSP_IPC_H
7+
#define MTK_ADSP_IPC_H
8+
9+
#include <linux/device.h>
10+
#include <linux/types.h>
11+
#include <linux/mailbox_controller.h>
12+
#include <linux/mailbox_client.h>
13+
14+
#define MTK_ADSP_IPC_REQ 0
15+
#define MTK_ADSP_IPC_RSP 1
16+
#define MTK_ADSP_IPC_OP_REQ 0x1
17+
#define MTK_ADSP_IPC_OP_RSP 0x2
18+
19+
enum {
20+
MTK_ADSP_MBOX_REPLY,
21+
MTK_ADSP_MBOX_REQUEST,
22+
MTK_ADSP_MBOX_NUM,
23+
};
24+
25+
struct mtk_adsp_ipc;
26+
27+
struct mtk_adsp_ipc_ops {
28+
void (*handle_reply)(struct mtk_adsp_ipc *ipc);
29+
void (*handle_request)(struct mtk_adsp_ipc *ipc);
30+
};
31+
32+
struct mtk_adsp_chan {
33+
struct mtk_adsp_ipc *ipc;
34+
struct mbox_client cl;
35+
struct mbox_chan *ch;
36+
char *name;
37+
int idx;
38+
};
39+
40+
struct mtk_adsp_ipc {
41+
struct mtk_adsp_chan chans[MTK_ADSP_MBOX_NUM];
42+
struct device *dev;
43+
struct mtk_adsp_ipc_ops *ops;
44+
void *private_data;
45+
};
46+
47+
static inline void mtk_adsp_ipc_set_data(struct mtk_adsp_ipc *ipc, void *data)
48+
{
49+
if (!ipc)
50+
return;
51+
52+
ipc->private_data = data;
53+
}
54+
55+
static inline void *mtk_adsp_ipc_get_data(struct mtk_adsp_ipc *ipc)
56+
{
57+
if (!ipc)
58+
return NULL;
59+
60+
return ipc->private_data;
61+
}
62+
63+
int mtk_adsp_ipc_send(struct mtk_adsp_ipc *ipc, unsigned int idx, uint32_t op);
64+
65+
#endif /* MTK_ADSP_IPC_H */

0 commit comments

Comments
 (0)