drivers: spi: NXP: Convert clock control to use DEVICE_DT_GET
Replace device_get_binding with DEVICE_DT_GET for getting access to the clock controller device. Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
This commit is contained in:
parent
2dd696f544
commit
7ee312ec57
3 changed files with 9 additions and 27 deletions
|
@ -20,7 +20,7 @@ LOG_MODULE_REGISTER(spi_mcux_dspi);
|
|||
|
||||
struct spi_mcux_config {
|
||||
SPI_Type *base;
|
||||
char *clock_name;
|
||||
const struct device *clock_dev;
|
||||
clock_control_subsys_t clock_subsys;
|
||||
void (*irq_config_func)(const struct device *dev);
|
||||
uint32_t pcs_sck_delay;
|
||||
|
@ -131,7 +131,6 @@ static int spi_mcux_configure(const struct device *dev,
|
|||
struct spi_mcux_data *data = dev->data;
|
||||
SPI_Type *base = config->base;
|
||||
dspi_master_config_t master_config;
|
||||
const struct device *clock_dev;
|
||||
uint32_t clock_freq;
|
||||
uint32_t word_size;
|
||||
|
||||
|
@ -180,12 +179,7 @@ static int spi_mcux_configure(const struct device *dev,
|
|||
ctar_config->lastSckToPcsDelayInNanoSec = config->sck_pcs_delay;
|
||||
ctar_config->betweenTransferDelayInNanoSec = config->transfer_delay;
|
||||
|
||||
clock_dev = device_get_binding(config->clock_name);
|
||||
if (clock_dev == NULL) {
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (clock_control_get_rate(clock_dev, config->clock_subsys,
|
||||
if (clock_control_get_rate(config->clock_dev, config->clock_subsys,
|
||||
&clock_freq)) {
|
||||
return -EINVAL;
|
||||
}
|
||||
|
@ -292,7 +286,7 @@ static const struct spi_driver_api spi_mcux_driver_api = {
|
|||
static void spi_mcux_config_func_##id(const struct device *dev); \
|
||||
static const struct spi_mcux_config spi_mcux_config_##id = { \
|
||||
.base = (SPI_Type *)DT_INST_REG_ADDR(id), \
|
||||
.clock_name = DT_INST_CLOCKS_LABEL(id), \
|
||||
.clock_dev = DEVICE_DT_GET(DT_INST_CLOCKS_CTLR(id)), \
|
||||
.clock_subsys = \
|
||||
(clock_control_subsys_t)DT_INST_CLOCKS_CELL(id, name), \
|
||||
.irq_config_func = spi_mcux_config_func_##id, \
|
||||
|
|
|
@ -25,7 +25,7 @@ LOG_MODULE_REGISTER(spi_mcux_flexcomm, CONFIG_SPI_LOG_LEVEL);
|
|||
|
||||
struct spi_mcux_config {
|
||||
SPI_Type *base;
|
||||
char *clock_name;
|
||||
const struct device *clock_dev;
|
||||
clock_control_subsys_t clock_subsys;
|
||||
void (*irq_config_func)(const struct device *dev);
|
||||
};
|
||||
|
@ -48,7 +48,6 @@ struct stream {
|
|||
|
||||
struct spi_mcux_data {
|
||||
const struct device *dev;
|
||||
const struct device *dev_clock;
|
||||
spi_master_handle_t handle;
|
||||
struct spi_context ctx;
|
||||
size_t transfer_len;
|
||||
|
@ -176,7 +175,7 @@ static int spi_mcux_configure(const struct device *dev,
|
|||
SPI_MasterGetDefaultConfig(&master_config);
|
||||
|
||||
/* Get the clock frequency */
|
||||
if (clock_control_get_rate(data->dev_clock,
|
||||
if (clock_control_get_rate(config->clock_dev,
|
||||
config->clock_subsys, &clock_freq)) {
|
||||
return -EINVAL;
|
||||
}
|
||||
|
@ -684,11 +683,6 @@ static int spi_mcux_init(const struct device *dev)
|
|||
const struct spi_mcux_config *config = dev->config;
|
||||
struct spi_mcux_data *data = dev->data;
|
||||
|
||||
data->dev_clock = device_get_binding(config->clock_name);
|
||||
if (data->dev_clock == NULL) {
|
||||
return -ENODEV;
|
||||
}
|
||||
|
||||
config->irq_config_func(dev);
|
||||
|
||||
data->dev = dev;
|
||||
|
@ -773,7 +767,7 @@ static void spi_mcux_config_func_##id(const struct device *dev) \
|
|||
static const struct spi_mcux_config spi_mcux_config_##id = { \
|
||||
.base = \
|
||||
(SPI_Type *)DT_INST_REG_ADDR(id), \
|
||||
.clock_name = DT_INST_CLOCKS_LABEL(id), \
|
||||
.clock_dev = DEVICE_DT_GET(DT_INST_CLOCKS_CTLR(id)), \
|
||||
.clock_subsys = \
|
||||
(clock_control_subsys_t)DT_INST_CLOCKS_CELL(id, name),\
|
||||
SPI_MCUX_FLEXCOMM_IRQ_HANDLER_FUNC(id) \
|
||||
|
|
|
@ -22,7 +22,7 @@ LOG_MODULE_REGISTER(spi_mcux_lpspi);
|
|||
|
||||
struct spi_mcux_config {
|
||||
LPSPI_Type *base;
|
||||
char *clock_name;
|
||||
const struct device *clock_dev;
|
||||
clock_control_subsys_t clock_subsys;
|
||||
void (*irq_config_func)(const struct device *dev);
|
||||
uint32_t pcs_sck_delay;
|
||||
|
@ -131,7 +131,6 @@ static int spi_mcux_configure(const struct device *dev,
|
|||
struct spi_mcux_data *data = dev->data;
|
||||
LPSPI_Type *base = config->base;
|
||||
lpspi_master_config_t master_config;
|
||||
const struct device *clock_dev;
|
||||
uint32_t clock_freq;
|
||||
uint32_t word_size;
|
||||
|
||||
|
@ -179,12 +178,7 @@ static int spi_mcux_configure(const struct device *dev,
|
|||
master_config.lastSckToPcsDelayInNanoSec = config->sck_pcs_delay;
|
||||
master_config.betweenTransferDelayInNanoSec = config->transfer_delay;
|
||||
|
||||
clock_dev = device_get_binding(config->clock_name);
|
||||
if (clock_dev == NULL) {
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (clock_control_get_rate(clock_dev, config->clock_subsys,
|
||||
if (clock_control_get_rate(config->clock_dev, config->clock_subsys,
|
||||
&clock_freq)) {
|
||||
return -EINVAL;
|
||||
}
|
||||
|
@ -289,7 +283,7 @@ static const struct spi_driver_api spi_mcux_driver_api = {
|
|||
\
|
||||
static const struct spi_mcux_config spi_mcux_config_##n = { \
|
||||
.base = (LPSPI_Type *) DT_INST_REG_ADDR(n), \
|
||||
.clock_name = DT_INST_CLOCKS_LABEL(n), \
|
||||
.clock_dev = DEVICE_DT_GET(DT_INST_CLOCKS_CTLR(n)), \
|
||||
.clock_subsys = \
|
||||
(clock_control_subsys_t)DT_INST_CLOCKS_CELL(n, name), \
|
||||
.irq_config_func = spi_mcux_config_func_##n, \
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue