drivers: pwm: 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
09c054b13c
commit
0eead3aab6
3 changed files with 10 additions and 32 deletions
|
@ -27,7 +27,7 @@ LOG_MODULE_REGISTER(pwm_mcux_ftm);
|
||||||
|
|
||||||
struct mcux_ftm_config {
|
struct mcux_ftm_config {
|
||||||
FTM_Type *base;
|
FTM_Type *base;
|
||||||
char *clock_name;
|
const struct device *clock_dev;
|
||||||
clock_control_subsys_t clock_subsys;
|
clock_control_subsys_t clock_subsys;
|
||||||
ftm_clock_source_t ftm_clock_source;
|
ftm_clock_source_t ftm_clock_source;
|
||||||
ftm_clock_prescale_t prescale;
|
ftm_clock_prescale_t prescale;
|
||||||
|
@ -388,7 +388,6 @@ static int mcux_ftm_init(const struct device *dev)
|
||||||
const struct mcux_ftm_config *config = dev->config;
|
const struct mcux_ftm_config *config = dev->config;
|
||||||
struct mcux_ftm_data *data = dev->data;
|
struct mcux_ftm_data *data = dev->data;
|
||||||
ftm_chnl_pwm_config_param_t *channel = data->channel;
|
ftm_chnl_pwm_config_param_t *channel = data->channel;
|
||||||
const struct device *clock_dev;
|
|
||||||
ftm_config_t ftm_config;
|
ftm_config_t ftm_config;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
@ -397,13 +396,7 @@ static int mcux_ftm_init(const struct device *dev)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
clock_dev = device_get_binding(config->clock_name);
|
if (clock_control_get_rate(config->clock_dev, config->clock_subsys,
|
||||||
if (clock_dev == NULL) {
|
|
||||||
LOG_ERR("Could not get clock device");
|
|
||||||
return -EINVAL;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (clock_control_get_rate(clock_dev, config->clock_subsys,
|
|
||||||
&data->clock_freq)) {
|
&data->clock_freq)) {
|
||||||
LOG_ERR("Could not get clock frequency");
|
LOG_ERR("Could not get clock frequency");
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
@ -468,7 +461,7 @@ static void mcux_ftm_config_func_##n(const struct device *dev) \
|
||||||
#define FTM_DECLARE_CFG(n, CAPTURE_INIT) \
|
#define FTM_DECLARE_CFG(n, CAPTURE_INIT) \
|
||||||
static const struct mcux_ftm_config mcux_ftm_config_##n = { \
|
static const struct mcux_ftm_config mcux_ftm_config_##n = { \
|
||||||
.base = (FTM_Type *)DT_INST_REG_ADDR(n),\
|
.base = (FTM_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) \
|
.clock_subsys = (clock_control_subsys_t) \
|
||||||
DT_INST_CLOCKS_CELL(n, name), \
|
DT_INST_CLOCKS_CELL(n, name), \
|
||||||
.ftm_clock_source = kFTM_FixedClock, \
|
.ftm_clock_source = kFTM_FixedClock, \
|
||||||
|
|
|
@ -21,7 +21,7 @@ LOG_MODULE_REGISTER(pwm_mcux_pwt, CONFIG_PWM_LOG_LEVEL);
|
||||||
|
|
||||||
struct mcux_pwt_config {
|
struct mcux_pwt_config {
|
||||||
PWT_Type *base;
|
PWT_Type *base;
|
||||||
char *clock_name;
|
const struct device *clock_dev;
|
||||||
clock_control_subsys_t clock_subsys;
|
clock_control_subsys_t clock_subsys;
|
||||||
pwt_clock_source_t pwt_clock_source;
|
pwt_clock_source_t pwt_clock_source;
|
||||||
pwt_clock_prescale_t prescale;
|
pwt_clock_prescale_t prescale;
|
||||||
|
@ -279,15 +279,8 @@ static int mcux_pwt_init(const struct device *dev)
|
||||||
const struct mcux_pwt_config *config = dev->config;
|
const struct mcux_pwt_config *config = dev->config;
|
||||||
struct mcux_pwt_data *data = dev->data;
|
struct mcux_pwt_data *data = dev->data;
|
||||||
pwt_config_t *pwt_config = &data->pwt_config;
|
pwt_config_t *pwt_config = &data->pwt_config;
|
||||||
const struct device *clock_dev;
|
|
||||||
|
|
||||||
clock_dev = device_get_binding(config->clock_name);
|
if (clock_control_get_rate(config->clock_dev, config->clock_subsys,
|
||||||
if (clock_dev == NULL) {
|
|
||||||
LOG_ERR("could not get clock device");
|
|
||||||
return -EINVAL;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (clock_control_get_rate(clock_dev, config->clock_subsys,
|
|
||||||
&data->clock_freq)) {
|
&data->clock_freq)) {
|
||||||
LOG_ERR("could not get clock frequency");
|
LOG_ERR("could not get clock frequency");
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
@ -319,7 +312,7 @@ static const struct pwm_driver_api mcux_pwt_driver_api = {
|
||||||
\
|
\
|
||||||
static const struct mcux_pwt_config mcux_pwt_config_##n = { \
|
static const struct mcux_pwt_config mcux_pwt_config_##n = { \
|
||||||
.base = (PWT_Type *)DT_INST_REG_ADDR(n), \
|
.base = (PWT_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_subsys = \
|
||||||
(clock_control_subsys_t)DT_INST_CLOCKS_CELL(n, name), \
|
(clock_control_subsys_t)DT_INST_CLOCKS_CELL(n, name), \
|
||||||
.pwt_clock_source = kPWT_BusClock, \
|
.pwt_clock_source = kPWT_BusClock, \
|
||||||
|
|
|
@ -25,7 +25,7 @@ LOG_MODULE_REGISTER(pwm_mcux_tpm);
|
||||||
|
|
||||||
struct mcux_tpm_config {
|
struct mcux_tpm_config {
|
||||||
TPM_Type *base;
|
TPM_Type *base;
|
||||||
char *clock_name;
|
const struct device *clock_dev;
|
||||||
clock_control_subsys_t clock_subsys;
|
clock_control_subsys_t clock_subsys;
|
||||||
tpm_clock_source_t tpm_clock_source;
|
tpm_clock_source_t tpm_clock_source;
|
||||||
tpm_clock_prescale_t prescale;
|
tpm_clock_prescale_t prescale;
|
||||||
|
@ -132,7 +132,6 @@ static int mcux_tpm_init(const struct device *dev)
|
||||||
const struct mcux_tpm_config *config = dev->config;
|
const struct mcux_tpm_config *config = dev->config;
|
||||||
struct mcux_tpm_data *data = dev->data;
|
struct mcux_tpm_data *data = dev->data;
|
||||||
tpm_chnl_pwm_signal_param_t *channel = data->channel;
|
tpm_chnl_pwm_signal_param_t *channel = data->channel;
|
||||||
const struct device *clock_dev;
|
|
||||||
tpm_config_t tpm_config;
|
tpm_config_t tpm_config;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
@ -141,18 +140,12 @@ static int mcux_tpm_init(const struct device *dev)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
clock_dev = device_get_binding(config->clock_name);
|
if (clock_control_on(config->clock_dev, config->clock_subsys)) {
|
||||||
if (clock_dev == NULL) {
|
|
||||||
LOG_ERR("Could not get clock device");
|
|
||||||
return -EINVAL;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (clock_control_on(clock_dev, config->clock_subsys)) {
|
|
||||||
LOG_ERR("Could not turn on clock");
|
LOG_ERR("Could not turn on clock");
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (clock_control_get_rate(clock_dev, config->clock_subsys,
|
if (clock_control_get_rate(config->clock_dev, config->clock_subsys,
|
||||||
&data->clock_freq)) {
|
&data->clock_freq)) {
|
||||||
LOG_ERR("Could not get clock frequency");
|
LOG_ERR("Could not get clock frequency");
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
@ -183,8 +176,7 @@ static const struct pwm_driver_api mcux_tpm_driver_api = {
|
||||||
static const struct mcux_tpm_config mcux_tpm_config_##n = { \
|
static const struct mcux_tpm_config mcux_tpm_config_##n = { \
|
||||||
.base = (TPM_Type *) \
|
.base = (TPM_Type *) \
|
||||||
DT_INST_REG_ADDR(n), \
|
DT_INST_REG_ADDR(n), \
|
||||||
.clock_name = \
|
.clock_dev = DEVICE_DT_GET(DT_INST_CLOCKS_CTLR(n)), \
|
||||||
DT_INST_CLOCKS_LABEL(n), \
|
|
||||||
.clock_subsys = (clock_control_subsys_t) \
|
.clock_subsys = (clock_control_subsys_t) \
|
||||||
DT_INST_CLOCKS_CELL(n, name), \
|
DT_INST_CLOCKS_CELL(n, name), \
|
||||||
.tpm_clock_source = kTPM_SystemClock, \
|
.tpm_clock_source = kTPM_SystemClock, \
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue