@@ -151,8 +151,6 @@ static void config_can_##inst##_irq(void) \
151151 irq_enable(DT_INST_IRQ_BY_NAME(inst, line_1, irq)); \
152152}
153153
154- #ifdef CONFIG_CAN_FD_MODE
155-
156154#define CAN_STM32FD_CFG_INST (inst ) \
157155 PINCTRL_DT_INST_DEFINE(inst); \
158156 \
@@ -161,57 +159,18 @@ static void config_can_##inst##_irq(void) \
161159 .pcfg = PINCTRL_DT_INST_DEV_CONFIG_GET(inst), \
162160 }; \
163161 \
164- static const struct can_mcan_config can_mcan_cfg_##inst = { \
165- .can = (struct can_mcan_reg *) DT_INST_REG_ADDR_BY_NAME(inst, m_can), \
166- .bus_speed = DT_INST_PROP(inst, bus_speed), \
167- .sjw = DT_INST_PROP(inst, sjw), \
168- .sample_point = DT_INST_PROP_OR(inst, sample_point, 0), \
169- .prop_ts1 = DT_INST_PROP_OR(inst, prop_seg, 0) + \
170- DT_INST_PROP_OR(inst, phase_seg1, 0), \
171- .ts2 = DT_INST_PROP_OR(inst, phase_seg2, 0), \
172- .bus_speed_data = DT_INST_PROP(inst, bus_speed_data), \
173- .sjw_data = DT_INST_PROP(inst, sjw_data), \
174- .sample_point_data = DT_INST_PROP_OR(inst, sample_point_data, 0), \
175- .prop_ts1_data = DT_INST_PROP_OR(inst, prop_seg_data, 0) + \
176- DT_INST_PROP_OR(inst, phase_seg1_data, 0), \
177- .ts2_data = DT_INST_PROP_OR(inst, phase_seg2_data, 0), \
178- .tx_delay_comp_offset = DT_INST_PROP(inst, tx_delay_comp_offset), \
179- .phy = DEVICE_DT_GET_OR_NULL(DT_INST_PHANDLE(inst, phys)), \
180- .max_bitrate = DT_INST_CAN_TRANSCEIVER_MAX_BITRATE(inst, 5000000), \
181- .custom = &can_stm32fd_cfg_##inst, \
182- };
183- #else /* CONFIG_CAN_FD_MODE */
184- #define CAN_STM32FD_CFG_INST (inst ) \
185- PINCTRL_DT_INST_DEFINE(inst); \
186- \
187- static const struct can_stm32fd_config can_stm32fd_cfg_##inst = { \
188- .config_irq = config_can_##inst##_irq, \
189- .pcfg = PINCTRL_DT_INST_DEV_CONFIG_GET(inst), \
190- }; \
191- \
192- static const struct can_mcan_config can_mcan_cfg_##inst = { \
193- .can = (struct can_mcan_reg *) DT_INST_REG_ADDR_BY_NAME(inst, m_can), \
194- .bus_speed = DT_INST_PROP(inst, bus_speed), \
195- .sjw = DT_INST_PROP(inst, sjw), \
196- .sample_point = DT_INST_PROP_OR(inst, sample_point, 0), \
197- .prop_ts1 = DT_INST_PROP_OR(inst, prop_seg, 0) + \
198- DT_INST_PROP_OR(inst, phase_seg1, 0), \
199- .ts2 = DT_INST_PROP_OR(inst, phase_seg2, 0), \
200- .phy = DEVICE_DT_GET_OR_NULL(DT_INST_PHANDLE(inst, phys)), \
201- .max_bitrate = DT_INST_CAN_TRANSCEIVER_MAX_BITRATE(inst, 1000000), \
202- .custom = &can_stm32fd_cfg_##inst, \
203- };
204- #endif /* CONFIG_CAN_FD_MODE */
162+ static const struct can_mcan_config can_mcan_cfg_##inst = \
163+ CAN_MCAN_DT_CONFIG_INST_GET(inst, &can_stm32fd_cfg_##inst);
205164
206165#define CAN_STM32FD_DATA_INST (inst ) \
207- static struct can_mcan_data can_mcan_dev_data_ ##inst = { \
208- .msg_ram = ( struct can_mcan_msg_sram *) \
166+ static struct can_mcan_data can_mcan_data_ ##inst = \
167+ CAN_MCAN_DATA_INITIALIZER(( struct can_mcan_msg_sram *) \
209168 DT_INST_REG_ADDR_BY_NAME(inst, message_ram), \
210- } ;
169+ NULL) ;
211170
212171#define CAN_STM32FD_DEVICE_INST (inst ) \
213172 DEVICE_DT_INST_DEFINE(inst, &can_stm32fd_init, NULL, \
214- &can_mcan_dev_data_ ##inst, &can_mcan_cfg_##inst, \
173+ &can_mcan_data_ ##inst, &can_mcan_cfg_##inst, \
215174 POST_KERNEL, CONFIG_CAN_INIT_PRIORITY, \
216175 &can_stm32fd_driver_api);
217176
0 commit comments