Skip to content

Commit

Permalink
drivers: dac: add checks for internal channel config
Browse files Browse the repository at this point in the history
Return -ENOTSUP if these flags are specified but not supported.

Signed-off-by: Corey Wharton <xodus7@cwharton.com>
  • Loading branch information
xodus7 authored and nashif committed Sep 17, 2024
1 parent 2b9ed72 commit d80174f
Show file tree
Hide file tree
Showing 17 changed files with 84 additions and 3 deletions.
5 changes: 5 additions & 0 deletions drivers/dac/dac_ad559x.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,11 @@ static int dac_ad559x_channel_setup(const struct device *dev,
return -EINVAL;
}

if (channel_cfg->internal) {
LOG_ERR("Internal channels not supported");
return -ENOTSUP;
}

data->dac_conf |= BIT(channel_cfg->channel_id);

return mfd_ad559x_write_reg(config->mfd_dev, AD559X_REG_LDAC_EN, data->dac_conf);
Expand Down
5 changes: 5 additions & 0 deletions drivers/dac/dac_ad569x.c
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,11 @@ static int ad569x_channel_setup(const struct device *dev, const struct dac_chann
return -EINVAL;
}

if (channel_cfg->internal) {
LOG_ERR("Internal channels not supported");
return -ENOTSUP;
}

return 0;
}

Expand Down
5 changes: 5 additions & 0 deletions drivers/dac/dac_ad56xx.c
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,11 @@ static int ad56xx_channel_setup(const struct device *dev, const struct dac_chann
return -EINVAL;
}

if (channel_cfg->internal) {
LOG_ERR("Internal channels not supported");
return -ENOTSUP;
}

return 0;
}

Expand Down
5 changes: 5 additions & 0 deletions drivers/dac/dac_dacx0501.c
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,11 @@ static int dacx0501_channel_setup(const struct device *dev,
return -ENOTSUP;
}

if (channel_cfg->internal) {
LOG_ERR("Internal channels not supported");
return -ENOTSUP;
}

return 0;
}

Expand Down
5 changes: 5 additions & 0 deletions drivers/dac/dac_dacx0508.c
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,11 @@ static int dacx0508_channel_setup(const struct device *dev,
return -ENOTSUP;
}

if (channel_cfg->internal) {
LOG_ERR("Internal channels not supported");
return -ENOTSUP;
}

data->configured |= BIT(channel_cfg->channel_id);

return 0;
Expand Down
5 changes: 5 additions & 0 deletions drivers/dac/dac_dacx3608.c
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,11 @@ static int dacx3608_channel_setup(const struct device *dev,
return -ENOTSUP;
}

if (channel_cfg->internal) {
LOG_ERR("Internal channels not supported");
return -ENOTSUP;
}

if (data->configured & BIT(channel_cfg->channel_id)) {
LOG_DBG("Channel %d already configured", channel_cfg->channel_id);
return 0;
Expand Down
5 changes: 5 additions & 0 deletions drivers/dac/dac_esp32.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,11 @@ static int dac_esp32_channel_setup(const struct device *dev,
return -EINVAL;
}

if (channel_cfg->internal) {
LOG_ERR("Internal channels not supported");
return -ENOTSUP;
}

dac_output_enable(channel_cfg->channel_id);

return 0;
Expand Down
5 changes: 5 additions & 0 deletions drivers/dac/dac_gd32.c
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,11 @@ static int dac_gd32_channel_setup(const struct device *dev,
return -ENOTSUP;
}

if (channel_cfg->internal) {
LOG_ERR("Internal channels not supported");
return -ENOTSUP;
}

data->resolutions[dacx] = channel_cfg->resolution;

dac_gd32_disable(dacx);
Expand Down
5 changes: 5 additions & 0 deletions drivers/dac/dac_ltc166x.c
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,11 @@ static int ltc166x_channel_setup(const struct device *dev,
return -ENOTSUP;
}

if (channel_cfg->internal) {
LOG_ERR("Internal channels not supported");
return -ENOTSUP;
}

return 0;
}

Expand Down
4 changes: 4 additions & 0 deletions drivers/dac/dac_mcp4725.c
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,10 @@ static int mcp4725_channel_setup(const struct device *dev,
return -ENOTSUP;
}

if (channel_cfg->internal) {
return -ENOTSUP;
}

return 0;
}

Expand Down
4 changes: 4 additions & 0 deletions drivers/dac/dac_mcp4728.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ static int mcp4728_channel_setup(const struct device *dev,
return -ENOTSUP;
}

if (channel_cfg->internal) {
return -ENOTSUP;
}

return 0;
}

Expand Down
5 changes: 5 additions & 0 deletions drivers/dac/dac_mcux_dac.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@ static int mcux_dac_channel_setup(const struct device *dev,
return -ENOTSUP;
}

if (channel_cfg->internal) {
LOG_ERR("Internal channels not supported");
return -ENOTSUP;
}

DAC_GetDefaultConfig(&dac_config);
dac_config.enableLowPowerMode = config->low_power;
dac_config.referenceVoltageSource = config->reference;
Expand Down
5 changes: 5 additions & 0 deletions drivers/dac/dac_mcux_dac32.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,11 @@ static int mcux_dac32_channel_setup(const struct device *dev,
return -ENOTSUP;
}

if (channel_cfg->internal) {
LOG_ERR("Internal channels not supported");
return -ENOTSUP;
}

DAC32_GetDefaultConfig(&dac32_config);
dac32_config.enableLowPowerMode = config->low_power;
dac32_config.referenceVoltageSource = config->reference;
Expand Down
11 changes: 8 additions & 3 deletions drivers/dac/dac_mcux_gau.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,20 +38,25 @@ static int nxp_gau_dac_channel_setup(const struct device *dev,
{
const struct nxp_gau_dac_config *config = dev->config;
dac_channel_config_t dac_channel_config = {0};
bool use_internal = true;

if (channel_cfg->resolution != 10) {
LOG_ERR("DAC only support 10 bit resolution");
return -EINVAL;
}

if (channel_cfg->buffered) {
if (channel_cfg->internal && channel_cfg->buffered) {
LOG_ERR("DAC output can not be buffered and internal");
return -EINVAL;
} else if (channel_cfg->buffered) {
/* External and internal output are mutually exclusive */
LOG_WRN("Note: buffering DAC output to pad disconnects internal output");
use_internal = false;
}

dac_channel_config.waveType = kDAC_WaveNormal;
dac_channel_config.outMode = channel_cfg->buffered ?
kDAC_ChannelOutputPAD : kDAC_ChannelOutputInternal;
dac_channel_config.outMode =
use_internal ? kDAC_ChannelOutputInternal : kDAC_ChannelOutputPAD;
dac_channel_config.timingMode = kDAC_NonTimingCorrelated;
dac_channel_config.enableTrigger = false;
dac_channel_config.enableDMA = false;
Expand Down
5 changes: 5 additions & 0 deletions drivers/dac/dac_mcux_lpdac.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@ static int mcux_lpdac_channel_setup(const struct device *dev,
return -ENOTSUP;
}

if (channel_cfg->internal) {
LOG_ERR("Internal channels not supported");
return -ENOTSUP;
}

DAC_GetDefaultConfig(&dac_config);
dac_config.referenceVoltageSource = config->ref_voltage;
#if defined(FSL_FEATURE_LPDAC_HAS_GCR_BUF_SPD_CTRL) && FSL_FEATURE_LPDAC_HAS_GCR_BUF_SPD_CTRL
Expand Down
4 changes: 4 additions & 0 deletions drivers/dac/dac_sam.c
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,10 @@ static int dac_sam_channel_setup(const struct device *dev,
return -ENOTSUP;
}

if (channel_cfg->internal) {
return -ENOTSUP;
}

/* Enable Channel */
dac->DACC_CHER = DACC_CHER_CH0 << channel_cfg->channel_id;

Expand Down
4 changes: 4 additions & 0 deletions drivers/dac/dac_sam0.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,10 @@ static int dac_sam0_channel_setup(const struct device *dev,
return -ENOTSUP;
}

if (channel_cfg->internal) {
return -ENOSYS;
}

return 0;
}

Expand Down

0 comments on commit d80174f

Please sign in to comment.