Skip to content

Commit c22f93f

Browse files
dianacretucrazoes
authored andcommitted
hw: mu: Add mu-write implementation
Add implementation for MU write in order to communicate with the host. We add and store reference to both side A and side B's MUs in the adsp structure because write to control register of side B has to make and reflect some changes in status register of side A. Signed-off-by: Diana Cretu <dianacretu2806@gmail.com> Signed-off-by: Shreeya Patel <shreeya.patel23498@gmail.com>
1 parent d1234bc commit c22f93f

3 files changed

Lines changed: 74 additions & 5 deletions

File tree

hw/adsp/dsp/imx8-mu.c

Lines changed: 63 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,12 +51,69 @@ static void mu_write(void *opaque, hwaddr addr,
5151
struct adsp_io_info *info = opaque;
5252
struct adsp_dev *adsp = info->adsp;
5353
struct adsp_reg_space *space = info->space;
54+
struct qemu_io_msg_irq irq;
55+
uint64_t xsr;
5456

5557
log_write(adsp->log, space, addr, val, size,
5658
info->region[addr >> 2]);
5759

58-
/* set value via SHM */
60+
/* Interrupt arrived, check src */
5961
info->region[addr >> 2] = val;
62+
63+
switch (addr) {
64+
case IMX_MU_xCR:
65+
66+
/* send IRQ to parent */
67+
irq.hdr.type = QEMU_IO_TYPE_IRQ;
68+
irq.hdr.msg = QEMU_IO_MSG_IRQ;
69+
irq.hdr.size = sizeof(irq);
70+
irq.irq = 0;
71+
72+
/* send a new message to host */
73+
if (val & IMX_MU_xCR_GIRn(1)) {
74+
/* activate pending bit on MU Side A */
75+
xsr = adsp->mu_a->region[IMX_MU_xSR >> 2] & ~0;
76+
xsr |= IMX_MU_xSR_GIPn(1);
77+
adsp->mu_a->region[IMX_MU_xSR >> 2] = xsr;
78+
qemu_io_send_msg(&irq.hdr);
79+
}
80+
81+
/* send reply to host */
82+
if (val & IMX_MU_xCR_GIRn(0)) {
83+
/* TODO: currently activates pending bit on MU Side B */
84+
xsr = adsp->mu_a->region[IMX_MU_xSR >> 2] & ~0;
85+
xsr |= IMX_MU_xSR_GIPn(0);
86+
adsp->mu_a->region[IMX_MU_xSR >> 2] = xsr;
87+
qemu_io_send_msg(&irq.hdr);
88+
}
89+
90+
break;
91+
case IMX_MU_xSR:
92+
break;
93+
default:
94+
break;
95+
}
96+
}
97+
98+
void adsp_imx8_irq_msg(struct adsp_dev *adsp, struct qemu_io_msg *msg)
99+
{
100+
struct adsp_io_info *info = adsp->mu_b;
101+
uint64_t xcr, xsr;
102+
103+
xcr = info->region[IMX_MU_xCR >> 2];
104+
105+
/* reply arrived from host */
106+
if (xcr & IMX_MU_xCR_GIRn(1)) {
107+
/* set pending bit for reply on DSP */
108+
xsr = info->region[IMX_MU_xSR >> 2] & ~0;
109+
xsr |= IMX_MU_xSR_GIPn(1);
110+
info->region[IMX_MU_xSR >> 2] = xsr;
111+
} else {
112+
/* new message arrived from host, so activate pending bit */
113+
xsr = info->region[IMX_MU_xSR >> 2] & ~0;
114+
xsr |= IMX_MU_xSR_GIPn(0);
115+
info->region[IMX_MU_xSR >> 2] = xsr;
116+
}
60117
}
61118

62119
const MemoryRegionOps imx8_mu_ops = {
@@ -69,4 +126,9 @@ void adsp_imx8_mu_init(struct adsp_dev *adsp, MemoryRegion *parent,
69126
struct adsp_io_info *info)
70127
{
71128
mu_reset(info);
129+
if (!strcmp(info->space->name, "mu_13a")) {
130+
adsp->mu_a = info;
131+
} else {
132+
adsp->mu_b = info;
133+
}
72134
}

hw/adsp/dsp/imx8.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ static int bridge_cb(void *data, struct qemu_io_msg *msg)
5656
case QEMU_IO_TYPE_REG:
5757
break;
5858
case QEMU_IO_TYPE_IRQ:
59+
adsp_imx8_irq_msg(adsp, msg);
5960
break;
6061
case QEMU_IO_TYPE_PM:
6162
adsp_pm_msg(adsp, msg);
@@ -251,7 +252,12 @@ static struct adsp_reg_space imx8_io[] = {
251252
.reg = adsp_imx8_mbox_map, .init = &adsp_mbox_init, .ops = &mbox_io_ops,
252253
.desc = {.base = ADSP_IMX8_DSP_MAILBOX_BASE,
253254
.size = ADSP_IMX8_DSP_MAILBOX_SIZE},},
254-
{ .name = "mu", .reg_count = ARRAY_SIZE(adsp_imx8_mu_map),
255+
{ .name = "mu_13a", .reg_count = ARRAY_SIZE(adsp_imx8_mu_map),
256+
.reg = adsp_imx8_mu_map, .init = &adsp_imx8_mu_init,
257+
.ops = &imx8_mu_ops,
258+
.desc = {.base = ADSP_IMX8_DSP_MU_BASE,
259+
.size = ADSP_IMX8_DSP_MU_SIZE},},
260+
{ .name = "mu_13b", .reg_count = ARRAY_SIZE(adsp_imx8_mu_map),
255261
.reg = adsp_imx8_mu_map, .init = &adsp_imx8_mu_init,
256262
.ops = &imx8_mu_ops,
257263
.desc = {.base = ADSP_IMX8_DSP_MU_BASE,

include/hw/audio/adsp-dev.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,10 @@ struct adsp_dev_ops {
4242
};
4343

4444
struct adsp_dev {
45-
46-
struct adsp_io_info *shim;
47-
int shm_idx;
45+
struct adsp_io_info *mu_a;
46+
struct adsp_io_info *mu_b;
47+
struct adsp_io_info *shim;
48+
int shm_idx;
4849

4950
/* runtime CPU */
5051
struct adsp_xtensa *xtensa[ADSP_MAX_CORES];

0 commit comments

Comments
 (0)