diff options
Diffstat (limited to 'drivers/aiodev/stm32-adc.c')
-rw-r--r-- | drivers/aiodev/stm32-adc.c | 39 |
1 files changed, 28 insertions, 11 deletions
diff --git a/drivers/aiodev/stm32-adc.c b/drivers/aiodev/stm32-adc.c index c99b995eaf..a1998da62c 100644 --- a/drivers/aiodev/stm32-adc.c +++ b/drivers/aiodev/stm32-adc.c @@ -1,4 +1,4 @@ -// SPDX-License-Identifier: GPL-2.0 +// SPDX-License-Identifier: GPL-2.0-only /* * Copyright (C) 2018, STMicroelectronics - All Rights Reserved * Author: Fabrice Gasnier <fabrice.gasnier@st.com> @@ -91,7 +91,7 @@ static void stm32_adc_stop(struct stm32_adc *adc) static int stm32_adc_start_channel(struct stm32_adc *adc, int channel) { - struct device_d *dev = adc->aiodev.hwdev; + struct device *dev = adc->aiodev.hwdev; struct stm32_adc_common *common = adc->common; int ret; u32 val; @@ -153,7 +153,7 @@ static int stm32_adc_start_channel(struct stm32_adc *adc, int channel) static int stm32_adc_channel_data(struct stm32_adc *adc, int channel, int *data) { - struct device_d *dev = &adc->aiodev.dev; + struct device *dev = &adc->aiodev.dev; int ret; u32 val; @@ -211,7 +211,7 @@ static void stm32_adc_smpr_init(struct stm32_adc *adc, int channel, u32 smp_ns) adc->smpr_val[r] = (adc->smpr_val[r] & ~mask) | (smp << shift); } -static int stm32_adc_chan_of_init(struct device_d *dev, struct stm32_adc *adc) +static int stm32_adc_chan_of_init(struct device *dev, struct stm32_adc *adc) { unsigned int i; int num_channels = 0, num_times = 0; @@ -219,7 +219,7 @@ static int stm32_adc_chan_of_init(struct device_d *dev, struct stm32_adc *adc) int ret; /* Retrieve single ended channels listed in device tree */ - of_get_property(dev->device_node, "st,adc-channels", &num_channels); + of_get_property(dev->of_node, "st,adc-channels", &num_channels); num_channels /= sizeof(__be32); if (num_channels > adc->cfg->max_channels) { @@ -228,7 +228,7 @@ static int stm32_adc_chan_of_init(struct device_d *dev, struct stm32_adc *adc) } /* Optional sample time is provided either for each, or all channels */ - of_get_property(dev->device_node, "st,min-sample-time-nsecs", &num_times); + of_get_property(dev->of_node, "st,min-sample-time-nsecs", &num_times); num_times /= sizeof(__be32); if (num_times > 1 && num_times != num_channels) { dev_err(dev, "Invalid st,min-sample-time-nsecs\n"); @@ -252,7 +252,8 @@ static int stm32_adc_chan_of_init(struct device_d *dev, struct stm32_adc *adc) for (i = 0; i < num_channels; i++) { u32 chan; - ret = of_property_read_u32_index(dev->device_node, "st,adc-channels", i, &chan); + ret = of_property_read_u32_index(dev->of_node, + "st,adc-channels", i, &chan); if (ret) return ret; @@ -273,7 +274,8 @@ static int stm32_adc_chan_of_init(struct device_d *dev, struct stm32_adc *adc) * get either no value, 1 shared value for all indexes, or one * value per channel. */ - of_property_read_u32_index(dev->device_node, "st,min-sample-time-nsecs", + of_property_read_u32_index(dev->of_node, + "st,min-sample-time-nsecs", i, &smp); /* Prepare sampling time settings */ stm32_adc_smpr_init(adc, chan, smp); @@ -288,14 +290,14 @@ static int stm32_adc_chan_of_init(struct device_d *dev, struct stm32_adc *adc) return ret; } -static int stm32_adc_probe(struct device_d *dev) +static int stm32_adc_probe(struct device *dev) { struct stm32_adc_common *common = dev->parent->priv; struct stm32_adc *adc; u32 offset; int ret; - ret = of_property_read_u32(dev->device_node, "reg", &offset); + ret = of_property_read_u32(dev->of_node, "reg", &offset); if (ret) { dev_err(dev, "Can't read reg property\n"); return ret; @@ -360,13 +362,28 @@ static const struct stm32_adc_cfg stm32mp1_adc_cfg = { .has_vregready = true, }; +/* STM32MP13 programmable sampling time (ADC clock cycles, rounded down) */ +static const unsigned int stm32mp13_adc_smp_cycles[STM32_ADC_MAX_SMP + 1] = { + 2, 6, 12, 24, 47, 92, 247, 640, +}; + +static const struct stm32_adc_cfg stm32mp13_adc_cfg = { + .num_bits = 16, + .max_channels = 19, + .smp_bits = stm32h7_smp_bits, + .smp_cycles = stm32mp13_adc_smp_cycles, + .has_vregready = false, +}; + static const struct of_device_id stm32_adc_match[] = { { .compatible = "st,stm32h7-adc", .data = &stm32h7_adc_cfg }, { .compatible = "st,stm32mp1-adc", .data = &stm32mp1_adc_cfg }, + { .compatible = "st,stm32mp13-adc", .data = &stm32mp13_adc_cfg }, {} }; +MODULE_DEVICE_TABLE(of, stm32_adc_match); -static struct driver_d stm32_adc_driver = { +static struct driver stm32_adc_driver = { .name = "stm32-adc", .probe = stm32_adc_probe, .of_compatible = DRV_OF_COMPAT(stm32_adc_match), |