Skip to content

drivers: Update Renesas RA drivers to support FSP version 6.0.0 #93137

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

Open
wants to merge 10 commits into
base: main
Choose a base branch
from
Open
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
30 changes: 27 additions & 3 deletions boards/arduino/portenta_c33/arduino_portenta_c33.dts
Original file line number Diff line number Diff line change
Expand Up @@ -95,15 +95,39 @@
};
};

&option_setting_s {
&option_setting_ofs0 {
status = "disabled";
};

&option_setting_sas {
&option_setting_dualsel {
status = "disabled";
};

&option_setting_ofs {
&option_setting_ofs1_sec {
status = "disabled";
};

&option_setting_banksel_sec {
status = "disabled";
};

&option_setting_bps_sec {
status = "disabled";
};

&option_setting_pbps_sec {
status = "disabled";
};

&option_setting_ofs1_sel {
status = "disabled";
};

&option_setting_banksel_sel {
status = "disabled";
};

&option_setting_bps_sel {
status = "disabled";
};

Expand Down
2 changes: 1 addition & 1 deletion drivers/can/can_renesas_ra.c
Original file line number Diff line number Diff line change
Expand Up @@ -1149,7 +1149,7 @@ DT_FOREACH_STATUS_OKAY(renesas_ra_canfd_global, CAN_RENESAS_RA_GLOBAL_DEFINE)
.tx_irq = DT_INST_IRQ_BY_NAME(index, tx, irq), \
.p_extend = &can_renesas_ra_data##index.fsp_canfd_extend, \
.p_bit_timing = &can_renesas_ra_data##index.bit_timing, \
.p_context = DEVICE_DT_INST_GET(index), \
.p_context = (void *)DEVICE_DT_INST_GET(index), \
.p_callback = can_renesas_ra_fsp_cb, \
}, \
.fsp_canfd_extend = \
Expand Down
2 changes: 1 addition & 1 deletion drivers/comparator/comparator_renesas_ra.c
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ static int acmphs_renesas_ra_init(const struct device *dev)
return ret;
}

data->fsp_config.p_context = dev;
data->fsp_config.p_context = (void *)dev;

fsp_err = R_ACMPHS_Open(&data->acmphs, &data->fsp_config);
if (FSP_SUCCESS != fsp_err) {
Expand Down
2 changes: 1 addition & 1 deletion drivers/display/display_renesas_ra.c
Original file line number Diff line number Diff line change
Expand Up @@ -491,7 +491,7 @@ static int display_init(const struct device *dev)
.contrast = {.enable = false}, \
.dithering_on = false}, \
.p_callback = renesas_ra_callback_adapter, \
.p_context = DEVICE_DT_INST_GET(id), \
.p_context = (void *)DEVICE_DT_INST_GET(id), \
.p_extend = (void *)(&display_extend_cfg##id), \
.line_detect_irq = DT_INST_IRQ_BY_NAME(id, line, irq), \
.line_detect_ipl = DT_INST_IRQ_BY_NAME(id, line, priority), \
Expand Down
24 changes: 13 additions & 11 deletions drivers/ethernet/eth_renesas_ra.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,15 @@ LOG_MODULE_REGISTER(LOG_MODULE_NAME);
#include "r_ether_phy.h"

/* Additional configurations to use with hal_renesas */
#define ETHER_DEFAULT NULL
#define ETHER_CHANNEL0 0
#define ETHER_BUF_SIZE 1536
#define ETHER_PADDING_OFFSET 1
#define ETHER_BROADCAST_FILTER 0
#define ETHER_TOTAL_BUF_NUM (CONFIG_ETH_RENESAS_TX_BUF_NUM + CONFIG_ETH_RENESAS_RX_BUF_NUM)
#define ETHER_EE_RECEIVE_EVENT_MASK (0x01070000)
#define ETHER_DEFAULT NULL
#define ETHER_CHANNEL0 0
#define ETHER_BUF_SIZE 1536
#define ETHER_PADDING_OFFSET 1
#define ETHER_BROADCAST_FILTER 0
#define ETHER_TOTAL_BUF_NUM (CONFIG_ETH_RENESAS_TX_BUF_NUM + CONFIG_ETH_RENESAS_RX_BUF_NUM)
#define ETHER_EE_RECEIVE_EVENT_MASK \
(ETHER_EESR_EVENT_MASK_RFOF | ETHER_EESR_EVENT_MASK_RDE | ETHER_EESR_EVENT_MASK_FR | \
ETHER_EESR_EVENT_MASK_RFCOF)

BUILD_ASSERT(DT_INST_ENUM_IDX(0, phy_connection_type) <= 1, "Invalid PHY connection setting");

Expand Down Expand Up @@ -79,8 +81,7 @@ LISTIFY(CONFIG_ETH_RENESAS_TX_BUF_NUM, DECLARE_ETHER_TX_BUFFER, (;));

uint8_t *pp_g_ether0_ether_buffers[ETHER_TOTAL_BUF_NUM] = {
LISTIFY(CONFIG_ETH_RENESAS_RX_BUF_NUM, DECLARE_ETHER_RX_BUFFER_PTR, (,)),
LISTIFY(CONFIG_ETH_RENESAS_TX_BUF_NUM, DECLARE_ETHER_TX_BUFFER_PTR, (,))
};
LISTIFY(CONFIG_ETH_RENESAS_TX_BUF_NUM, DECLARE_ETHER_TX_BUFFER_PTR, (,)) };

static __aligned(16) ether_instance_descriptor_t
g_ether0_tx_descriptors[CONFIG_ETH_RENESAS_TX_BUF_NUM];
Expand All @@ -90,6 +91,7 @@ static __aligned(16) ether_instance_descriptor_t
const ether_extended_cfg_t g_ether0_extended_cfg_t = {
.p_rx_descriptors = g_ether0_rx_descriptors,
.p_tx_descriptors = g_ether0_tx_descriptors,
.eesr_event_filter = ETHER_EE_RECEIVE_EVENT_MASK,
};

/* Dummy configuration for ether phy as hal layer require */
Expand Down Expand Up @@ -142,7 +144,7 @@ void renesas_ra_eth_callback(ether_callback_args_t *p_args)
struct device *dev = (struct device *)p_args->p_context;
struct renesas_ra_eth_context *ctx = dev->data;

if (p_args->status_eesr & ETHER_EE_RECEIVE_EVENT_MASK) {
if (p_args->event == ETHER_EVENT_RX_COMPLETE) {
k_sem_give(&ctx->rx_sem);
}
}
Expand Down Expand Up @@ -251,7 +253,7 @@ static void renesas_ra_eth_initialize(struct net_if *iface)
LOG_ERR("Failed to init ether - R_ETHER_Open fail");
}

err = R_ETHER_CallbackSet(&ctx->ctrl, renesas_ra_eth_callback, dev, NULL);
err = R_ETHER_CallbackSet(&ctx->ctrl, renesas_ra_eth_callback, (void *const)dev, NULL);

if (err != FSP_SUCCESS) {
LOG_ERR("Failed to init ether - R_ETHER_CallbackSet fail");
Expand Down
6 changes: 3 additions & 3 deletions drivers/flash/flash_renesas_ra_ospi_b.c
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ static int flash_renesas_ra_ospi_b_spi_mode_init(ospi_b_instance_ctrl_t *p_ctrl,
}

/* DDR sampling window extend */
R_XSPI->LIOCFGCS_b[p_ctrl->channel].DDRSMPEX = 1;
R_XSPI0->LIOCFGCS_b[p_ctrl->channel].DDRSMPEX = 1;

/* Switch OSPI module to 1S-1S-1S mode to configure flash device */
err = R_OSPI_B_SpiProtocolSet(p_ctrl, SPI_FLASH_PROTOCOL_EXTENDED_SPI);
Expand All @@ -172,9 +172,9 @@ static int flash_renesas_ra_ospi_b_spi_mode_init(ospi_b_instance_ctrl_t *p_ctrl,
}

/* Reset flash device by driving OM_RESET pin */
R_XSPI->LIOCTL_b.RSTCS0 = 0;
R_XSPI0->LIOCTL_b.RSTCS0 = 0;
k_sleep(K_USEC(500));
R_XSPI->LIOCTL_b.RSTCS0 = 1;
R_XSPI0->LIOCTL_b.RSTCS0 = 1;
k_sleep(K_NSEC(50));

/* Transfer write enable command */
Expand Down
2 changes: 1 addition & 1 deletion drivers/i2c/i2c_renesas_ra_iic.c
Original file line number Diff line number Diff line change
Expand Up @@ -540,7 +540,7 @@ static DEVICE_API(i2c, i2c_ra_iic_driver_api) = {
.tei_irq = DT_INST_IRQ_BY_NAME(index, tei, irq), \
.eri_irq = DT_INST_IRQ_BY_NAME(index, eri, irq), \
.p_callback = i2c_ra_iic_callback, \
.p_context = DEVICE_DT_GET(DT_DRV_INST(index)), \
.p_context = (void *)DEVICE_DT_GET(DT_DRV_INST(index)), \
}, \
}; \
\
Expand Down
2 changes: 1 addition & 1 deletion drivers/i2c/i2c_renesas_ra_sci_b.c
Original file line number Diff line number Diff line change
Expand Up @@ -710,7 +710,7 @@ static const struct i2c_driver_api renesas_ra_sci_b_i2c_driver_api = {
.txi_irq = DT_IRQ_BY_NAME(DT_INST_PARENT(index), txi, irq), \
.tei_irq = DT_IRQ_BY_NAME(DT_INST_PARENT(index), tei, irq), \
.p_callback = renesas_ra_sci_b_i2c_callback, \
.p_context = DEVICE_DT_GET(DT_DRV_INST(index)), \
.p_context = (void *)DEVICE_DT_GET(DT_DRV_INST(index)), \
}, \
.ext_cfg = \
{ \
Expand Down
2 changes: 1 addition & 1 deletion drivers/i2s/i2s_renesas_ra_ssie.c
Original file line number Diff line number Diff line change
Expand Up @@ -1155,7 +1155,7 @@ static DEVICE_API(i2s, i2s_renesas_ra_drv_api) = {
.word_length = I2S_WORD_LENGTH_16_BITS, \
.ws_continue = I2S_WS_CONTINUE_OFF, \
.p_callback = renesas_ra_ssie_callback, \
.p_context = DEVICE_DT_INST_GET(index), \
.p_context = (void *)DEVICE_DT_INST_GET(index), \
.p_extend = &ssi_extended_cfg_t_##index, \
.txi_irq = RA_SSIE_TX_IRQ_BY_NAME(index, irq), \
.rxi_irq = RA_SSIE_RX_IRQ_BY_NAME(index, irq), \
Expand Down
2 changes: 1 addition & 1 deletion drivers/i3c/i3c_renesas_ra.c
Original file line number Diff line number Diff line change
Expand Up @@ -1187,7 +1187,7 @@ static DEVICE_API(i3c, i3c_renesas_ra_api) = {
static i3c_cfg_t i3c##index##_cfg = { \
.channel = DT_INST_PROP(index, channel), \
.p_callback = &i3c_renesas_ra_hal_callback, \
.p_context = DEVICE_DT_INST_GET(index), \
.p_context = (void *)DEVICE_DT_INST_GET(index), \
.p_extend = &i3c##index##_cfg_extend, \
}; \
static i3c_device_cfg_t i3c##index##_master_cfg = {0}; \
Expand Down
19 changes: 16 additions & 3 deletions drivers/mdio/mdio_renesas_ra.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,12 @@ static int renesas_ra_mdio_read(const struct device *dev, uint8_t prtad, uint8_t
uint16_t *data)
{
struct renesas_ra_mdio_data *dev_data = dev->data;
ether_phy_extended_cfg_t *ext_cfg =
(ether_phy_extended_cfg_t *)dev_data->ether_phy_cfg.p_extend;
uint32_t read;
fsp_err_t err;

dev_data->ether_phy_ctrl.phy_lsi_address = prtad;
ext_cfg->p_phy_lsi_cfg_list[0]->address = prtad;

k_mutex_lock(&dev_data->rw_mutex, K_FOREVER);

Expand All @@ -59,9 +61,11 @@ static int renesas_ra_mdio_write(const struct device *dev, uint8_t prtad, uint8_
uint16_t data)
{
struct renesas_ra_mdio_data *dev_data = dev->data;
ether_phy_extended_cfg_t *ext_cfg =
(ether_phy_extended_cfg_t *)dev_data->ether_phy_cfg.p_extend;
fsp_err_t err;

dev_data->ether_phy_ctrl.phy_lsi_address = prtad;
ext_cfg->p_phy_lsi_cfg_list[0]->address = prtad;

k_mutex_lock(&dev_data->rw_mutex, K_FOREVER);

Expand Down Expand Up @@ -106,13 +110,22 @@ static DEVICE_API(mdio, renesas_ra_mdio_api) = {

#define RENSAS_RA_MDIO_INSTANCE_DEFINE(node) \
PINCTRL_DT_INST_DEFINE(node); \
static ether_phy_lsi_cfg_t renesas_ra_mdio##node##_lsi_cfg_list = { \
.type = ETHER_PHY_LSI_TYPE_CUSTOM, \
}; \
static ether_phy_extended_cfg_t renesas_ra_mdio##node##_extend = { \
.p_phy_lsi_cfg_list = \
{ \
&renesas_ra_mdio##node##_lsi_cfg_list, \
}, \
}; \
static struct renesas_ra_mdio_data renesas_ra_mdio##node##_data = { \
.ether_phy_cfg = { \
.channel = 0, \
.phy_reset_wait_time = 0x00020000, \
.mii_bit_access_wait_time = 8, \
.phy_lsi_type = ETHER_PHY_LSI_TYPE_CUSTOM, \
.flow_control = ETHER_PHY_FLOW_CONTROL_DISABLE, \
.p_extend = &renesas_ra_mdio##node##_extend, \
}}; \
static const struct renesas_ra_mdio_config renesas_ra_mdio##node##_cfg = { \
.pincfg = PINCTRL_DT_INST_DEV_CONFIG_GET(node)}; \
Expand Down
Loading
Loading