|
17 | 17 | #include <zephyr/pm/device_runtime.h>
|
18 | 18 | #include <zephyr/sys/byteorder.h>
|
19 | 19 | #include <zephyr/sys/util.h>
|
| 20 | +#include <zephyr/drivers/mspi/mspi_dw.h> |
20 | 21 |
|
21 | 22 | #include "mspi_dw.h"
|
22 | 23 |
|
@@ -48,6 +49,7 @@ struct mspi_dw_data {
|
48 | 49 | uint32_t ctrlr0;
|
49 | 50 | uint32_t spi_ctrlr0;
|
50 | 51 | uint32_t baudr;
|
| 52 | + uint32_t rx_sample_dly; |
51 | 53 |
|
52 | 54 | #if defined(CONFIG_MSPI_XIP)
|
53 | 55 | uint32_t xip_freq;
|
@@ -113,6 +115,7 @@ DEFINE_MM_REG_WR(imr, 0x2c)
|
113 | 115 | DEFINE_MM_REG_RD(isr, 0x30)
|
114 | 116 | DEFINE_MM_REG_RD(risr, 0x34)
|
115 | 117 | DEFINE_MM_REG_RD_WR(dr, 0x60)
|
| 118 | +DEFINE_MM_REG_WR(rx_sample_dly, 0xf0) |
116 | 119 | DEFINE_MM_REG_WR(spi_ctrlr0, 0xf4)
|
117 | 120 |
|
118 | 121 | #if defined(CONFIG_MSPI_XIP)
|
@@ -936,6 +939,7 @@ static int start_next_packet(const struct device *dev, k_timeout_t timeout)
|
936 | 939 | : 0);
|
937 | 940 | write_spi_ctrlr0(dev, dev_data->spi_ctrlr0);
|
938 | 941 | write_baudr(dev, dev_data->baudr);
|
| 942 | + write_rx_sample_dly(dev, dev_data->rx_sample_dly); |
939 | 943 | write_ser(dev, BIT(dev_data->dev_id->dev_idx));
|
940 | 944 |
|
941 | 945 | if (xip_enabled) {
|
@@ -1262,6 +1266,20 @@ static int _api_xip_config(const struct device *dev,
|
1262 | 1266 | return 0;
|
1263 | 1267 | }
|
1264 | 1268 |
|
| 1269 | +static int api_timing_config(const struct device *dev, |
| 1270 | + const struct mspi_dev_id *dev_id, |
| 1271 | + const uint32_t param_mask, void *cfg) |
| 1272 | +{ |
| 1273 | + struct mspi_dw_data *dev_data = dev->data; |
| 1274 | + struct mspi_dw_timing_cfg *config = cfg; |
| 1275 | + |
| 1276 | + if (param_mask & MSPI_DW_RX_TIMING_CFG) { |
| 1277 | + dev_data->rx_sample_dly = config->rx_sample_dly; |
| 1278 | + return 0; |
| 1279 | + } |
| 1280 | + return -ENOTSUP; |
| 1281 | +} |
| 1282 | + |
1265 | 1283 | static int api_xip_config(const struct device *dev,
|
1266 | 1284 | const struct mspi_dev_id *dev_id,
|
1267 | 1285 | const struct mspi_xip_cfg *cfg)
|
@@ -1407,6 +1425,7 @@ static DEVICE_API(mspi, drv_api) = {
|
1407 | 1425 | .dev_config = api_dev_config,
|
1408 | 1426 | .get_channel_status = api_get_channel_status,
|
1409 | 1427 | .transceive = api_transceive,
|
| 1428 | + .timing_config = api_timing_config, |
1410 | 1429 | #if defined(CONFIG_MSPI_XIP)
|
1411 | 1430 | .xip_config = api_xip_config,
|
1412 | 1431 | #endif
|
|
0 commit comments