Skip to content

[DM/PIC] Support AMP mode #9762

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Dec 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions components/drivers/mailbox/mailbox-pic.c
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ static rt_err_t pic_mbox_request(struct rt_mbox_chan *chan)
struct pic_mbox *pic_mbox = raw_to_pic_mbox(chan->ctrl);

HWREG32(pic_mbox->regs + MAILBOX_IMASK) &= ~RT_BIT(index);
HWREG32(pic_mbox->regs + MAILBOX_ISTATE) = 0;

return RT_EOK;
}
Expand All @@ -89,6 +90,11 @@ static rt_err_t pic_mbox_send(struct rt_mbox_chan *chan, const void *data)
rt_thread_yield();
}

if (HWREG32(pic_mbox->peer_regs + MAILBOX_IMASK) & RT_BIT(index))
{
return -RT_ERROR;
}

level = rt_spin_lock_irqsave(&pic_mbox->lock);

HWREG32(pic_mbox->regs + MAILBOX_MSG(index)) = *(rt_uint32_t *)data;
Expand Down Expand Up @@ -187,6 +193,12 @@ static rt_err_t pic_mbox_probe(struct rt_platform_device *pdev)
}

pic_mbox->peer_regs = pic_mbox->regs + size / 2;

/* Init by the captain */
HWREG32(pic_mbox->regs + MAILBOX_IMASK) = 0xffffffff;
HWREG32(pic_mbox->regs + MAILBOX_ISTATE) = 0;
HWREG32(pic_mbox->peer_regs + MAILBOX_IMASK) = 0xffffffff;
HWREG32(pic_mbox->peer_regs + MAILBOX_ISTATE) = 0;
}
else
{
Expand Down
7 changes: 7 additions & 0 deletions components/drivers/pic/pic-gicv2.c
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,11 @@ static void gicv2_dist_init(struct gicv2 *gic)

LOG_D("Max irq = %d", gic->max_irq);

if (gic->skip_init)
{
return;
}

HWREG32(base + GIC_DIST_CTRL) = GICD_DISABLE;

/* Set all global (unused) interrupts to this CPU only. */
Expand Down Expand Up @@ -620,6 +625,8 @@ static rt_err_t gicv2_ofw_init(struct rt_ofw_node *np, const struct rt_ofw_node_
break;
}

gic->skip_init = rt_ofw_prop_read_bool(np, "skip-init");

gic_common_init_quirk_ofw(np, _gicv2_quirks, gic);
gicv2_init(gic);

Expand Down
2 changes: 2 additions & 0 deletions components/drivers/pic/pic-gicv2.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ struct gicv2
rt_size_t hyp_size;
void *vcpu_base;
rt_size_t vcpu_size;

rt_bool_t skip_init;
};

#endif /* __IRQ_GICV2_H__ */
7 changes: 7 additions & 0 deletions components/drivers/pic/pic-gicv3.c
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,11 @@ static void gicv3_dist_init(void)
LOG_D("%d SPIs implemented", _gic.line_nr - 32);
LOG_D("%d Extended SPIs implemented", _gic.espi_nr);

if (_gic.skip_init)
{
goto _get_max_irq;
}

/* Disable the distributor */
HWREG32(base + GICD_CTLR) = 0;
gicv3_dist_wait_for_rwp();
Expand Down Expand Up @@ -266,6 +271,7 @@ static void gicv3_dist_init(void)
HWREG64(base + GICD_IROUTERnE + i * 8) = affinity;
}

_get_max_irq:
if (GICD_TYPER_NUM_LPIS(_gic.gicd_typer) > 1)
{
/* Max LPI = 8192 + Math.pow(2, num_LPIs + 1) - 1 */
Expand Down Expand Up @@ -1063,6 +1069,7 @@ static rt_err_t gicv3_ofw_init(struct rt_ofw_node *np, const struct rt_ofw_node_
redist_stride = 0;
}
_gic.redist_stride = redist_stride;
_gic.skip_init = rt_ofw_prop_read_bool(np, "skip-init");

gic_common_init_quirk_ofw(np, _gicv3_quirks, &_gic.parent);
gicv3_init();
Expand Down
2 changes: 2 additions & 0 deletions components/drivers/pic/pic-gicv3.h
Original file line number Diff line number Diff line change
Expand Up @@ -385,6 +385,8 @@ struct gicv3
rt_uint64_t redist_flags;
rt_size_t redist_stride;
rt_size_t redist_regions_nr;

rt_bool_t skip_init;
};

#endif /* __PIC_GICV3_H__ */
Loading