drivers: can: mcan: move message RAM configuration to front-end drivers
Some Bosch M_CAN IP core implementations use a fixed Message RAM configuration, other use a fixed memory area and relative addressing, others again have custom registers for configuring the Message RAM. Move the responsibility for configuring the various Bosch M_CAN Message RAM addresses to the front-end drivers. This removes some of the front-end specific code from the backend. Provide a helper function for configuring the most common variations. Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
This commit is contained in:
parent
65350b8362
commit
a781ccde0f
6 changed files with 123 additions and 72 deletions
|
@ -58,6 +58,9 @@ static int mcux_mcan_init(const struct device *dev)
|
|||
{
|
||||
const struct can_mcan_config *mcan_config = dev->config;
|
||||
const struct mcux_mcan_config *mcux_config = mcan_config->custom;
|
||||
struct can_mcan_data *mcan_data = dev->data;
|
||||
struct mcux_mcan_data *mcux_data = mcan_data->custom;
|
||||
const uintptr_t mrba = POINTER_TO_UINT(&mcux_data->msg_ram) & CAN_MCAN_MRBA_BA;
|
||||
int err;
|
||||
|
||||
if (!device_is_ready(mcux_config->clock_dev)) {
|
||||
|
@ -76,6 +79,16 @@ static int mcux_mcan_init(const struct device *dev)
|
|||
return -EINVAL;
|
||||
}
|
||||
|
||||
err = can_mcan_write_reg(dev, CAN_MCAN_MRBA, (uint32_t)mrba);
|
||||
if (err != 0) {
|
||||
return -EIO;
|
||||
}
|
||||
|
||||
err = can_mcan_configure_message_ram(dev, mrba);
|
||||
if (err != 0) {
|
||||
return -EIO;
|
||||
}
|
||||
|
||||
err = can_mcan_init(dev);
|
||||
if (err) {
|
||||
LOG_ERR("failed to initialize mcan (err %d)", err);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue