samples: drivers: mbox_data: use DT

Instead of hardcoded stuff in C sources (node label and channel IDs).

Signed-off-by: Gerard Marull-Paretas <gerard@teslabs.com>
This commit is contained in:
Gerard Marull-Paretas 2024-02-23 11:33:50 +01:00 committed by Fabio Baltieri
parent ab8574a791
commit 529bf56aa3
19 changed files with 53 additions and 234 deletions

View file

@ -26,4 +26,10 @@
status = "okay";
};
};
mbox-consumer {
compatible = "vnd,mbox-consumer";
mboxes = <&mbox 3>, <&mbox 2>;
mbox-names = "tx", "rx";
};
};

View file

@ -1,3 +0,0 @@
CONFIG_MBOX_NXP_IMX_MU=y
CONFIG_INCLUDE_REMOTE_DIR=y
CONFIG_SECOND_CORE_MCUX=y

View file

@ -1,29 +0,0 @@
/*
* Copyright 2024 NXP
*
* SPDX-License-Identifier: Apache-2.0
*/
/ {
chosen {
/* Delete ipc chosen property where old IPM mailbox driver bellow is
* configured.
*/
/delete-property/ zephyr,ipc;
};
soc {
/* Delete IPM Driver node nxp,imx-mu */
/delete-node/ mailbox@40c48000;
/* Attach MBOX driver to MU Unit */
mbox:mbox@40c48000 {
compatible = "nxp,mbox-imx-mu";
reg = <0x40c48000 0x4000>;
interrupts = <118 0>;
rx-channels = <4>;
#mbox-cells = <1>;
status = "okay";
};
};
};

View file

@ -26,4 +26,10 @@
status = "okay";
};
};
mbox-consumer {
compatible = "vnd,mbox-consumer";
mboxes = <&mbox 3>, <&mbox 2>;
mbox-names = "tx", "rx";
};
};

View file

@ -26,4 +26,10 @@
status = "okay";
};
};
mbox-consumer {
compatible = "vnd,mbox-consumer";
mboxes = <&mbox 3>, <&mbox 2>;
mbox-names = "tx", "rx";
};
};

View file

@ -26,4 +26,10 @@
status = "okay";
};
};
mbox-consumer {
compatible = "vnd,mbox-consumer";
mboxes = <&mbox 3>, <&mbox 2>;
mbox-names = "tx", "rx";
};
};

View file

@ -1,3 +0,0 @@
CONFIG_MBOX_NXP_IMX_MU=y
CONFIG_SECOND_CORE_MCUX=y
CONFIG_INCLUDE_REMOTE_DIR=y

View file

@ -26,4 +26,10 @@
status = "okay";
};
};
mbox-consumer {
compatible = "vnd,mbox-consumer";
mboxes = <&mbox 2>, <&mbox 3>;
mbox-names = "tx", "rx";
};
};

View file

@ -1,4 +0,0 @@
CONFIG_MBOX_NXP_IMX_MU=y
CONFIG_BUILD_OUTPUT_INFO_HEADER=y
CONFIG_BUILD_OUTPUT_HEX=y
CONFIG_SECOND_CORE_MCUX=y

View file

@ -1,54 +0,0 @@
/*
* Copyright 2024 NXP
*
* SPDX-License-Identifier: Apache-2.0
*/
/ {
chosen {
zephyr,flash = &ocram;
zephyr,console = &lpuart2;
zephyr,shell-uart = &lpuart2;
/* Delete ipc chosen property where old IPM mailbox driver bellow is
* configured.
*/
/delete-property/ zephyr,ipc;
};
soc {
/delete-node/ gpt@400f0000;
/* Replace GPT2 with another GPT kernel timer */
gpt2_hw_timer:gpt@400f0000 {
compatible = "nxp,gpt-hw-timer";
reg = <0x400f0000 0x4000>;
interrupts = <120 0>;
status = "okay";
};
/* Delete IPM Driver node nxp,imx-mu */
/delete-node/ mailbox@40c4c000;
/* Attach MBOX driver to MU Unit */
mbox:mbox@40c4c000 {
compatible = "nxp,mbox-imx-mu";
reg = <0x40c4c000 0x4000>;
interrupts = <118 0>;
rx-channels = <4>;
#mbox-cells = <1>;
status = "okay";
};
};
};
/* Enable secondary LPUART */
&lpuart2 {
status = "okay";
current-speed = <115200>;
};
/* Disable primary GPT timer */
&gpt_hw_timer {
status = "disabled";
};

View file

@ -40,6 +40,12 @@
status = "okay";
};
};
mbox-consumer {
compatible = "vnd,mbox-consumer";
mboxes = <&mbox 3>, <&mbox 2>;
mbox-names = "tx", "rx";
};
};
/* Enable secondary LPUART */

View file

@ -1,4 +0,0 @@
CONFIG_MBOX_NXP_IMX_MU=y
CONFIG_BUILD_OUTPUT_INFO_HEADER=y
CONFIG_BUILD_OUTPUT_HEX=y
CONFIG_SECOND_CORE_MCUX=y

View file

@ -1,54 +0,0 @@
/*
* Copyright 2024 NXP
*
* SPDX-License-Identifier: Apache-2.0
*/
/ {
chosen {
zephyr,flash = &ocram;
zephyr,console = &lpuart2;
zephyr,shell-uart = &lpuart2;
/* Delete ipc chosen property where old IPM mailbox driver bellow is
* configured.
*/
/delete-property/ zephyr,ipc;
};
soc {
/delete-node/ gpt@400f0000;
/* Replace GPT2 with another GPT kernel timer */
gpt2_hw_timer:gpt@400f0000 {
compatible = "nxp,gpt-hw-timer";
reg = <0x400f0000 0x4000>;
interrupts = <120 0>;
status = "okay";
};
/* Delete IPM Driver node nxp,imx-mu */
/delete-node/ mailbox@40c4c000;
/* Attach MBOX driver to MU Unit */
mbox:mbox@40c4c000 {
compatible = "nxp,mbox-imx-mu";
reg = <0x40c4c000 0x4000>;
interrupts = <118 0>;
rx-channels = <4>;
#mbox-cells = <1>;
status = "okay";
};
};
};
/* Enable secondary LPUART */
&lpuart2 {
status = "okay";
current-speed = <115200>;
};
/* Disable primary GPT timer */
&gpt_hw_timer {
status = "disabled";
};

View file

@ -40,6 +40,12 @@
status = "okay";
};
};
mbox-consumer {
compatible = "vnd,mbox-consumer";
mboxes = <&mbox 3>, <&mbox 2>;
mbox-names = "tx", "rx";
};
};
/* Enable secondary LPUART */

View file

@ -41,6 +41,11 @@
};
};
mbox-consumer {
compatible = "vnd,mbox-consumer";
mboxes = <&mbox 3>, <&mbox 2>;
mbox-names = "tx", "rx";
};
};
/* Enable secondary LPUART */

View file

@ -1,4 +0,0 @@
CONFIG_MBOX_NXP_IMX_MU=y
CONFIG_BUILD_OUTPUT_INFO_HEADER=y
CONFIG_BUILD_OUTPUT_HEX=y
CONFIG_SECOND_CORE_MCUX=y

View file

@ -1,55 +0,0 @@
/*
* Copyright 2024 NXP
*
* SPDX-License-Identifier: Apache-2.0
*/
/ {
chosen {
zephyr,flash = &ocram;
zephyr,console = &lpuart2;
zephyr,shell-uart = &lpuart2;
/* Delete ipc chosen property where old IPM mailbox driver bellow is
* configured.
*/
/delete-property/ zephyr,ipc;
};
soc {
/delete-node/ gpt@400f0000;
/* Replace GPT2 with another GPT kernel timer */
gpt2_hw_timer:gpt@400f0000 {
compatible = "nxp,gpt-hw-timer";
reg = <0x400f0000 0x4000>;
interrupts = <120 0>;
status = "okay";
};
/* Delete IPM Driver node nxp,imx-mu */
/delete-node/ mailbox@40c4c000;
/* Attach MBOX driver to MU Unit */
mbox:mbox@40c4c000 {
compatible = "nxp,mbox-imx-mu";
reg = <0x40c4c000 0x4000>;
interrupts = <118 0>;
rx-channels = <4>;
#mbox-cells = <1>;
status = "okay";
};
};
};
/* Enable secondary LPUART */
&lpuart2 {
status = "okay";
current-speed = <115200>;
};
/* Disable primary GPT timer */
&gpt_hw_timer {
status = "disabled";
};

View file

@ -15,9 +15,6 @@ static K_SEM_DEFINE(g_mbox_data_rx_sem, 0, 1);
static uint32_t g_mbox_received_data;
static uint32_t g_mbox_received_channel;
#define TX_ID (2)
#define RX_ID (3)
static void callback(const struct device *dev, uint32_t channel, void *user_data,
struct mbox_msg *data)
{
@ -29,20 +26,14 @@ static void callback(const struct device *dev, uint32_t channel, void *user_data
int main(void)
{
struct mbox_channel tx_channel;
struct mbox_channel rx_channel;
const struct device *dev;
const struct mbox_channel tx_channel = MBOX_DT_CHANNEL_GET(DT_PATH(mbox_consumer), tx);
const struct mbox_channel rx_channel = MBOX_DT_CHANNEL_GET(DT_PATH(mbox_consumer), rx);
struct mbox_msg msg = {0};
uint32_t message = 0;
printk("mbox_data Server demo started\n");
dev = DEVICE_DT_GET(DT_NODELABEL(mbox));
mbox_init_channel(&tx_channel, dev, TX_ID);
mbox_init_channel(&rx_channel, dev, RX_ID);
const int max_transfer_size_bytes = mbox_mtu_get(dev);
const int max_transfer_size_bytes = mbox_mtu_get(tx_channel.dev);
/* Sample currently supports only transfer size up to 4 bytes */
if ((max_transfer_size_bytes <= 0) || (max_transfer_size_bytes > 4)) {
printk("mbox_mtu_get() error\n");

View file

@ -15,9 +15,6 @@ static K_SEM_DEFINE(g_mbox_data_rx_sem, 0, 1);
static uint32_t g_mbox_received_data;
static uint32_t g_mbox_received_channel;
#define TX_ID (3)
#define RX_ID (2)
static void callback(const struct device *dev, uint32_t channel, void *user_data,
struct mbox_msg *data)
{
@ -29,20 +26,14 @@ static void callback(const struct device *dev, uint32_t channel, void *user_data
int main(void)
{
struct mbox_channel tx_channel;
struct mbox_channel rx_channel;
const struct device *dev;
const struct mbox_channel tx_channel = MBOX_DT_CHANNEL_GET(DT_PATH(mbox_consumer), tx);
const struct mbox_channel rx_channel = MBOX_DT_CHANNEL_GET(DT_PATH(mbox_consumer), rx);
struct mbox_msg msg = {0};
uint32_t message = 0;
printk("mbox_data Client demo started\n");
dev = DEVICE_DT_GET(DT_NODELABEL(mbox));
mbox_init_channel(&tx_channel, dev, TX_ID);
mbox_init_channel(&rx_channel, dev, RX_ID);
const int max_transfer_size_bytes = mbox_mtu_get(dev);
const int max_transfer_size_bytes = mbox_mtu_get(tx_channel.dev);
/* Sample currently supports only transfer size up to 4 bytes */
if ((max_transfer_size_bytes < 0) || (max_transfer_size_bytes > 4)) {
printk("mbox_mtu_get() error\n");