drivers: memc: add update clock function

Add a function to update the flexspi bus clock. This is
needed when write operations are done to the hyperflash.

Signed-off-by: Jeppe Odgaard <jeppe.odgaard@prevas.dk>
This commit is contained in:
Jeppe Odgaard 2023-01-17 10:37:54 +01:00 committed by Carles Cufí
parent eed2de8c03
commit cd59e74412
2 changed files with 40 additions and 0 deletions

View file

@ -10,6 +10,7 @@
#include <zephyr/sys/util.h>
#include <zephyr/drivers/pinctrl.h>
#include <zephyr/pm/device.h>
#include <soc.h>
#include "memc_mcux_flexspi.h"
@ -77,6 +78,34 @@ int memc_flexspi_update_lut(const struct device *dev, uint32_t index,
return 0;
}
int memc_flexspi_update_clock(const struct device *dev,
flexspi_device_config_t *device_config,
flexspi_port_t port, enum memc_flexspi_clock_t clock)
{
#if CONFIG_SOC_SERIES_IMX_RT10XX
struct memc_flexspi_data *data = dev->data;
memc_flexspi_wait_bus_idle(dev);
FLEXSPI_Enable(data->base, false);
flexspi_clock_set_div(clock == MEMC_FLEXSPI_CLOCK_166M ? 0 : 3);
FLEXSPI_Enable(data->base, true);
memc_flexspi_reset(dev);
device_config->flexspiRootClk = flexspi_clock_get_freq();
FLEXSPI_UpdateDllValue(data->base, device_config, port);
memc_flexspi_reset(dev);
return 0;
#else
return -ENOTSUP;
#endif
}
int memc_flexspi_set_device_config(const struct device *dev,
const flexspi_device_config_t *device_config,
flexspi_port_t port)

View file

@ -8,6 +8,13 @@
#include <sys/types.h>
#include <fsl_flexspi.h>
enum memc_flexspi_clock_t {
/* Flexspi clock 332M, DDR mode, internal clock 166M. */
MEMC_FLEXSPI_CLOCK_166M,
/* Flexspi clock 83M, DDR mode, internal clock 42M. */
MEMC_FLEXSPI_CLOCK_42M,
};
void memc_flexspi_wait_bus_idle(const struct device *dev);
bool memc_flexspi_is_running_xip(const struct device *dev);
@ -15,6 +22,10 @@ bool memc_flexspi_is_running_xip(const struct device *dev);
int memc_flexspi_update_lut(const struct device *dev, uint32_t index,
const uint32_t *cmd, uint32_t count);
int memc_flexspi_update_clock(const struct device *dev,
flexspi_device_config_t *device_config,
flexspi_port_t port, enum memc_flexspi_clock_t clock);
int memc_flexspi_set_device_config(const struct device *dev,
const flexspi_device_config_t *device_config,
flexspi_port_t port);