1 // SPDX-License-Identifier: GPL-2.0-only
3 * Aspeed AST2400/2500/2600 ADC
5 * Copyright (C) 2017 Google, Inc.
6 * Copyright (C) 2021 Aspeed Technology Inc.
10 * clock period = period of PCLK * 2 * (ADC0C[31:17] + 1) * (ADC0C[9:0] + 1)
12 * clock period = period of PCLK * 2 * (ADC0C[15:0] + 1)
15 #include <linux/clk.h>
16 #include <linux/clk-provider.h>
17 #include <linux/err.h>
18 #include <linux/errno.h>
20 #include <linux/module.h>
21 #include <linux/of_platform.h>
22 #include <linux/platform_device.h>
23 #include <linux/regulator/consumer.h>
24 #include <linux/reset.h>
25 #include <linux/spinlock.h>
26 #include <linux/types.h>
27 #include <linux/bitfield.h>
28 #include <linux/regmap.h>
29 #include <linux/mfd/syscon.h>
31 #include <linux/iio/iio.h>
32 #include <linux/iio/driver.h>
33 #include <linux/iopoll.h>
35 #define ASPEED_RESOLUTION_BITS 10
36 #define ASPEED_CLOCKS_PER_SAMPLE 12
38 #define ASPEED_REG_ENGINE_CONTROL 0x00
39 #define ASPEED_REG_INTERRUPT_CONTROL 0x04
40 #define ASPEED_REG_VGA_DETECT_CONTROL 0x08
41 #define ASPEED_REG_CLOCK_CONTROL 0x0C
42 #define ASPEED_REG_COMPENSATION_TRIM 0xC4
44 * The register offset between 0xC8~0xCC can be read and won't affect the
45 * hardware logic in each version of ADC.
47 #define ASPEED_REG_MAX 0xD0
49 #define ASPEED_ADC_ENGINE_ENABLE BIT(0)
50 #define ASPEED_ADC_OP_MODE GENMASK(3, 1)
51 #define ASPEED_ADC_OP_MODE_PWR_DOWN 0
52 #define ASPEED_ADC_OP_MODE_STANDBY 1
53 #define ASPEED_ADC_OP_MODE_NORMAL 7
54 #define ASPEED_ADC_CTRL_COMPENSATION BIT(4)
55 #define ASPEED_ADC_AUTO_COMPENSATION BIT(5)
57 * Bit 6 determines not only the reference voltage range but also the dividing
58 * circuit for battery sensing.
60 #define ASPEED_ADC_REF_VOLTAGE GENMASK(7, 6)
61 #define ASPEED_ADC_REF_VOLTAGE_2500mV 0
62 #define ASPEED_ADC_REF_VOLTAGE_1200mV 1
63 #define ASPEED_ADC_REF_VOLTAGE_EXT_HIGH 2
64 #define ASPEED_ADC_REF_VOLTAGE_EXT_LOW 3
65 #define ASPEED_ADC_BAT_SENSING_DIV BIT(6)
66 #define ASPEED_ADC_BAT_SENSING_DIV_2_3 0
67 #define ASPEED_ADC_BAT_SENSING_DIV_1_3 1
68 #define ASPEED_ADC_CTRL_INIT_RDY BIT(8)
69 #define ASPEED_ADC_CH7_MODE BIT(12)
70 #define ASPEED_ADC_CH7_NORMAL 0
71 #define ASPEED_ADC_CH7_BAT 1
72 #define ASPEED_ADC_BAT_SENSING_ENABLE BIT(13)
73 #define ASPEED_ADC_CTRL_CHANNEL GENMASK(31, 16)
74 #define ASPEED_ADC_CTRL_CHANNEL_ENABLE(ch) FIELD_PREP(ASPEED_ADC_CTRL_CHANNEL, BIT(ch))
76 #define ASPEED_ADC_INIT_POLLING_TIME 500
77 #define ASPEED_ADC_INIT_TIMEOUT 500000
79 * When the sampling rate is too high, the ADC may not have enough charging
80 * time, resulting in a low voltage value. Thus, the default uses a slow
81 * sampling rate for most use cases.
83 #define ASPEED_ADC_DEF_SAMPLING_RATE 65000
85 struct aspeed_adc_trim_locate {
86 const unsigned int offset;
87 const unsigned int field;
90 struct aspeed_adc_model_data {
91 const char *model_name;
92 unsigned int min_sampling_rate; // Hz
93 unsigned int max_sampling_rate; // Hz
94 unsigned int vref_fixed_mv;
95 bool wait_init_sequence;
99 unsigned int num_channels;
100 const struct aspeed_adc_trim_locate *trim_locate;
108 struct aspeed_adc_data {
110 const struct aspeed_adc_model_data *model_data;
111 struct regulator *regulator;
114 struct clk_hw *fixed_div_clk;
115 struct clk_hw *clk_prescaler;
116 struct clk_hw *clk_scaler;
117 struct reset_control *rst;
119 u32 sample_period_ns;
121 bool battery_sensing;
122 struct adc_gain battery_mode_gain;
125 #define ASPEED_CHAN(_idx, _data_reg_addr) { \
126 .type = IIO_VOLTAGE, \
129 .address = (_data_reg_addr), \
130 .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), \
131 .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE) | \
132 BIT(IIO_CHAN_INFO_SAMP_FREQ) | \
133 BIT(IIO_CHAN_INFO_OFFSET), \
136 static const struct iio_chan_spec aspeed_adc_iio_channels[] = {
137 ASPEED_CHAN(0, 0x10),
138 ASPEED_CHAN(1, 0x12),
139 ASPEED_CHAN(2, 0x14),
140 ASPEED_CHAN(3, 0x16),
141 ASPEED_CHAN(4, 0x18),
142 ASPEED_CHAN(5, 0x1A),
143 ASPEED_CHAN(6, 0x1C),
144 ASPEED_CHAN(7, 0x1E),
145 ASPEED_CHAN(8, 0x20),
146 ASPEED_CHAN(9, 0x22),
147 ASPEED_CHAN(10, 0x24),
148 ASPEED_CHAN(11, 0x26),
149 ASPEED_CHAN(12, 0x28),
150 ASPEED_CHAN(13, 0x2A),
151 ASPEED_CHAN(14, 0x2C),
152 ASPEED_CHAN(15, 0x2E),
155 #define ASPEED_BAT_CHAN(_idx, _data_reg_addr) { \
156 .type = IIO_VOLTAGE, \
159 .address = (_data_reg_addr), \
160 .info_mask_separate = BIT(IIO_CHAN_INFO_RAW) | \
161 BIT(IIO_CHAN_INFO_OFFSET), \
162 .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE) | \
163 BIT(IIO_CHAN_INFO_SAMP_FREQ), \
165 static const struct iio_chan_spec aspeed_adc_iio_bat_channels[] = {
166 ASPEED_CHAN(0, 0x10),
167 ASPEED_CHAN(1, 0x12),
168 ASPEED_CHAN(2, 0x14),
169 ASPEED_CHAN(3, 0x16),
170 ASPEED_CHAN(4, 0x18),
171 ASPEED_CHAN(5, 0x1A),
172 ASPEED_CHAN(6, 0x1C),
173 ASPEED_BAT_CHAN(7, 0x1E),
176 static int aspeed_adc_set_trim_data(struct iio_dev *indio_dev)
178 struct device_node *syscon;
180 u32 scu_otp, trimming_val;
181 struct aspeed_adc_data *data = iio_priv(indio_dev);
183 syscon = of_find_node_by_name(NULL, "syscon");
184 if (syscon == NULL) {
185 dev_warn(data->dev, "Couldn't find syscon node\n");
188 scu = syscon_node_to_regmap(syscon);
190 dev_warn(data->dev, "Failed to get syscon regmap\n");
193 if (data->model_data->trim_locate) {
194 if (regmap_read(scu, data->model_data->trim_locate->offset,
197 "Failed to get adc trimming data\n");
202 (data->model_data->trim_locate->field)) >>
203 __ffs(data->model_data->trim_locate->field);
206 "trimming val = %d, offset = %08x, fields = %08x\n",
207 trimming_val, data->model_data->trim_locate->offset,
208 data->model_data->trim_locate->field);
209 writel(trimming_val, data->base + ASPEED_REG_COMPENSATION_TRIM);
214 static int aspeed_adc_compensation(struct iio_dev *indio_dev)
216 struct aspeed_adc_data *data = iio_priv(indio_dev);
217 u32 index, adc_raw = 0;
218 u32 adc_engine_control_reg_val;
220 adc_engine_control_reg_val =
221 readl(data->base + ASPEED_REG_ENGINE_CONTROL);
222 adc_engine_control_reg_val &= ~ASPEED_ADC_OP_MODE;
223 adc_engine_control_reg_val |=
224 (FIELD_PREP(ASPEED_ADC_OP_MODE, ASPEED_ADC_OP_MODE_NORMAL) |
225 ASPEED_ADC_ENGINE_ENABLE);
227 * Enable compensating sensing:
228 * After that, the input voltage of ADC will force to half of the reference
229 * voltage. So the expected reading raw data will become half of the max
230 * value. We can get compensating value = 0x200 - ADC read raw value.
231 * It is recommended to average at least 10 samples to get a final CV.
233 writel(adc_engine_control_reg_val | ASPEED_ADC_CTRL_COMPENSATION |
234 ASPEED_ADC_CTRL_CHANNEL_ENABLE(0),
235 data->base + ASPEED_REG_ENGINE_CONTROL);
237 * After enable compensating sensing mode need to wait some time for ADC stable
238 * Experiment result is 1ms.
242 for (index = 0; index < 16; index++) {
244 * Waiting for the sampling period ensures that the value acquired
245 * is fresh each time.
247 ndelay(data->sample_period_ns);
248 adc_raw += readw(data->base + aspeed_adc_iio_channels[0].address);
251 data->cv = BIT(ASPEED_RESOLUTION_BITS - 1) - adc_raw;
252 writel(adc_engine_control_reg_val,
253 data->base + ASPEED_REG_ENGINE_CONTROL);
254 dev_dbg(data->dev, "Compensating value = %d\n", data->cv);
259 static int aspeed_adc_set_sampling_rate(struct iio_dev *indio_dev, u32 rate)
261 struct aspeed_adc_data *data = iio_priv(indio_dev);
263 if (rate < data->model_data->min_sampling_rate ||
264 rate > data->model_data->max_sampling_rate)
266 /* Each sampling needs 12 clocks to convert.*/
267 clk_set_rate(data->clk_scaler->clk, rate * ASPEED_CLOCKS_PER_SAMPLE);
268 rate = clk_get_rate(data->clk_scaler->clk);
269 data->sample_period_ns = DIV_ROUND_UP_ULL(
270 (u64)NSEC_PER_SEC * ASPEED_CLOCKS_PER_SAMPLE, rate);
271 dev_dbg(data->dev, "Adc clock = %d sample period = %d ns", rate,
272 data->sample_period_ns);
277 static int aspeed_adc_read_raw(struct iio_dev *indio_dev,
278 struct iio_chan_spec const *chan,
279 int *val, int *val2, long mask)
281 struct aspeed_adc_data *data = iio_priv(indio_dev);
282 u32 adc_engine_control_reg_val;
285 case IIO_CHAN_INFO_RAW:
286 if (data->battery_sensing && chan->channel == 7) {
287 adc_engine_control_reg_val =
288 readl(data->base + ASPEED_REG_ENGINE_CONTROL);
289 writel(adc_engine_control_reg_val |
290 FIELD_PREP(ASPEED_ADC_CH7_MODE,
291 ASPEED_ADC_CH7_BAT) |
292 ASPEED_ADC_BAT_SENSING_ENABLE,
293 data->base + ASPEED_REG_ENGINE_CONTROL);
295 * After enable battery sensing mode need to wait some time for adc stable
296 * Experiment result is 1ms.
299 *val = readw(data->base + chan->address);
300 *val = (*val * data->battery_mode_gain.mult) /
301 data->battery_mode_gain.div;
302 /* Restore control register value */
303 writel(adc_engine_control_reg_val,
304 data->base + ASPEED_REG_ENGINE_CONTROL);
306 *val = readw(data->base + chan->address);
309 case IIO_CHAN_INFO_OFFSET:
310 if (data->battery_sensing && chan->channel == 7)
311 *val = (data->cv * data->battery_mode_gain.mult) /
312 data->battery_mode_gain.div;
317 case IIO_CHAN_INFO_SCALE:
318 *val = data->vref_mv;
319 *val2 = ASPEED_RESOLUTION_BITS;
320 return IIO_VAL_FRACTIONAL_LOG2;
322 case IIO_CHAN_INFO_SAMP_FREQ:
323 *val = clk_get_rate(data->clk_scaler->clk) /
324 ASPEED_CLOCKS_PER_SAMPLE;
332 static int aspeed_adc_write_raw(struct iio_dev *indio_dev,
333 struct iio_chan_spec const *chan,
334 int val, int val2, long mask)
337 case IIO_CHAN_INFO_SAMP_FREQ:
338 return aspeed_adc_set_sampling_rate(indio_dev, val);
340 case IIO_CHAN_INFO_SCALE:
341 case IIO_CHAN_INFO_RAW:
343 * Technically, these could be written but the only reasons
344 * for doing so seem better handled in userspace. EPERM is
345 * returned to signal this is a policy choice rather than a
346 * hardware limitation.
355 static int aspeed_adc_reg_access(struct iio_dev *indio_dev,
356 unsigned int reg, unsigned int writeval,
357 unsigned int *readval)
359 struct aspeed_adc_data *data = iio_priv(indio_dev);
361 if (!readval || reg % 4 || reg > ASPEED_REG_MAX)
364 *readval = readl(data->base + reg);
369 static const struct iio_info aspeed_adc_iio_info = {
370 .read_raw = aspeed_adc_read_raw,
371 .write_raw = aspeed_adc_write_raw,
372 .debugfs_reg_access = aspeed_adc_reg_access,
375 static void aspeed_adc_unregister_fixed_divider(void *data)
377 struct clk_hw *clk = data;
379 clk_hw_unregister_fixed_factor(clk);
382 static void aspeed_adc_reset_assert(void *data)
384 struct reset_control *rst = data;
386 reset_control_assert(rst);
389 static void aspeed_adc_clk_disable_unprepare(void *data)
391 struct clk *clk = data;
393 clk_disable_unprepare(clk);
396 static void aspeed_adc_power_down(void *data)
398 struct aspeed_adc_data *priv_data = data;
400 writel(FIELD_PREP(ASPEED_ADC_OP_MODE, ASPEED_ADC_OP_MODE_PWR_DOWN),
401 priv_data->base + ASPEED_REG_ENGINE_CONTROL);
404 static void aspeed_adc_reg_disable(void *data)
406 struct regulator *reg = data;
408 regulator_disable(reg);
411 static int aspeed_adc_vref_config(struct iio_dev *indio_dev)
413 struct aspeed_adc_data *data = iio_priv(indio_dev);
415 u32 adc_engine_control_reg_val;
417 if (data->model_data->vref_fixed_mv) {
418 data->vref_mv = data->model_data->vref_fixed_mv;
421 adc_engine_control_reg_val =
422 readl(data->base + ASPEED_REG_ENGINE_CONTROL);
423 data->regulator = devm_regulator_get_optional(data->dev, "vref");
424 if (!IS_ERR(data->regulator)) {
425 ret = regulator_enable(data->regulator);
428 ret = devm_add_action_or_reset(
429 data->dev, aspeed_adc_reg_disable, data->regulator);
432 data->vref_mv = regulator_get_voltage(data->regulator);
433 /* Conversion from uV to mV */
434 data->vref_mv /= 1000;
435 if ((data->vref_mv >= 1550) && (data->vref_mv <= 2700))
436 writel(adc_engine_control_reg_val |
438 ASPEED_ADC_REF_VOLTAGE,
439 ASPEED_ADC_REF_VOLTAGE_EXT_HIGH),
440 data->base + ASPEED_REG_ENGINE_CONTROL);
441 else if ((data->vref_mv >= 900) && (data->vref_mv <= 1650))
442 writel(adc_engine_control_reg_val |
444 ASPEED_ADC_REF_VOLTAGE,
445 ASPEED_ADC_REF_VOLTAGE_EXT_LOW),
446 data->base + ASPEED_REG_ENGINE_CONTROL);
448 dev_err(data->dev, "Regulator voltage %d not support",
453 if (PTR_ERR(data->regulator) != -ENODEV)
454 return PTR_ERR(data->regulator);
455 data->vref_mv = 2500000;
456 of_property_read_u32(data->dev->of_node,
457 "aspeed,int-vref-microvolt",
459 /* Conversion from uV to mV */
460 data->vref_mv /= 1000;
461 if (data->vref_mv == 2500)
462 writel(adc_engine_control_reg_val |
463 FIELD_PREP(ASPEED_ADC_REF_VOLTAGE,
464 ASPEED_ADC_REF_VOLTAGE_2500mV),
465 data->base + ASPEED_REG_ENGINE_CONTROL);
466 else if (data->vref_mv == 1200)
467 writel(adc_engine_control_reg_val |
468 FIELD_PREP(ASPEED_ADC_REF_VOLTAGE,
469 ASPEED_ADC_REF_VOLTAGE_1200mV),
470 data->base + ASPEED_REG_ENGINE_CONTROL);
472 dev_err(data->dev, "Voltage %d not support", data->vref_mv);
480 static int aspeed_adc_probe(struct platform_device *pdev)
482 struct iio_dev *indio_dev;
483 struct aspeed_adc_data *data;
485 u32 adc_engine_control_reg_val;
486 unsigned long scaler_flags = 0;
487 char clk_name[32], clk_parent_name[32];
489 indio_dev = devm_iio_device_alloc(&pdev->dev, sizeof(*data));
493 data = iio_priv(indio_dev);
494 data->dev = &pdev->dev;
495 data->model_data = of_device_get_match_data(&pdev->dev);
496 platform_set_drvdata(pdev, indio_dev);
498 data->base = devm_platform_ioremap_resource(pdev, 0);
499 if (IS_ERR(data->base))
500 return PTR_ERR(data->base);
502 /* Register ADC clock prescaler with source specified by device tree. */
503 spin_lock_init(&data->clk_lock);
504 snprintf(clk_parent_name, ARRAY_SIZE(clk_parent_name), "%s",
505 of_clk_get_parent_name(pdev->dev.of_node, 0));
506 snprintf(clk_name, ARRAY_SIZE(clk_name), "%s-fixed-div",
507 data->model_data->model_name);
508 data->fixed_div_clk = clk_hw_register_fixed_factor(
509 &pdev->dev, clk_name, clk_parent_name, 0, 1, 2);
510 if (IS_ERR(data->fixed_div_clk))
511 return PTR_ERR(data->fixed_div_clk);
513 ret = devm_add_action_or_reset(data->dev,
514 aspeed_adc_unregister_fixed_divider,
515 data->fixed_div_clk);
518 snprintf(clk_parent_name, ARRAY_SIZE(clk_parent_name), clk_name);
520 if (data->model_data->need_prescaler) {
521 snprintf(clk_name, ARRAY_SIZE(clk_name), "%s-prescaler",
522 data->model_data->model_name);
523 data->clk_prescaler = devm_clk_hw_register_divider(
524 &pdev->dev, clk_name, clk_parent_name, 0,
525 data->base + ASPEED_REG_CLOCK_CONTROL, 17, 15, 0,
527 if (IS_ERR(data->clk_prescaler))
528 return PTR_ERR(data->clk_prescaler);
529 snprintf(clk_parent_name, ARRAY_SIZE(clk_parent_name),
531 scaler_flags = CLK_SET_RATE_PARENT;
534 * Register ADC clock scaler downstream from the prescaler. Allow rate
535 * setting to adjust the prescaler as well.
537 snprintf(clk_name, ARRAY_SIZE(clk_name), "%s-scaler",
538 data->model_data->model_name);
539 data->clk_scaler = devm_clk_hw_register_divider(
540 &pdev->dev, clk_name, clk_parent_name, scaler_flags,
541 data->base + ASPEED_REG_CLOCK_CONTROL, 0,
542 data->model_data->scaler_bit_width,
543 data->model_data->need_prescaler ? CLK_DIVIDER_ONE_BASED : 0,
545 if (IS_ERR(data->clk_scaler))
546 return PTR_ERR(data->clk_scaler);
548 data->rst = devm_reset_control_get_shared(&pdev->dev, NULL);
549 if (IS_ERR(data->rst)) {
551 "invalid or missing reset controller device tree entry");
552 return PTR_ERR(data->rst);
554 reset_control_deassert(data->rst);
556 ret = devm_add_action_or_reset(data->dev, aspeed_adc_reset_assert,
561 ret = aspeed_adc_vref_config(indio_dev);
565 if (of_find_property(data->dev->of_node, "aspeed,trim-data-valid",
567 ret = aspeed_adc_set_trim_data(indio_dev);
572 if (of_find_property(data->dev->of_node, "aspeed,battery-sensing",
574 if (data->model_data->bat_sense_sup) {
575 data->battery_sensing = 1;
576 if (readl(data->base + ASPEED_REG_ENGINE_CONTROL) &
577 ASPEED_ADC_BAT_SENSING_DIV) {
578 data->battery_mode_gain.mult = 3;
579 data->battery_mode_gain.div = 1;
581 data->battery_mode_gain.mult = 3;
582 data->battery_mode_gain.div = 2;
586 "Failed to enable battery-sensing mode\n");
589 ret = clk_prepare_enable(data->clk_scaler->clk);
592 ret = devm_add_action_or_reset(data->dev,
593 aspeed_adc_clk_disable_unprepare,
594 data->clk_scaler->clk);
597 ret = aspeed_adc_set_sampling_rate(indio_dev,
598 ASPEED_ADC_DEF_SAMPLING_RATE);
602 adc_engine_control_reg_val =
603 readl(data->base + ASPEED_REG_ENGINE_CONTROL);
604 adc_engine_control_reg_val |=
605 FIELD_PREP(ASPEED_ADC_OP_MODE, ASPEED_ADC_OP_MODE_NORMAL) |
606 ASPEED_ADC_ENGINE_ENABLE;
607 /* Enable engine in normal mode. */
608 writel(adc_engine_control_reg_val,
609 data->base + ASPEED_REG_ENGINE_CONTROL);
611 ret = devm_add_action_or_reset(data->dev, aspeed_adc_power_down,
616 if (data->model_data->wait_init_sequence) {
617 /* Wait for initial sequence complete. */
618 ret = readl_poll_timeout(data->base + ASPEED_REG_ENGINE_CONTROL,
619 adc_engine_control_reg_val,
620 adc_engine_control_reg_val &
621 ASPEED_ADC_CTRL_INIT_RDY,
622 ASPEED_ADC_INIT_POLLING_TIME,
623 ASPEED_ADC_INIT_TIMEOUT);
628 aspeed_adc_compensation(indio_dev);
629 /* Start all channels in normal mode. */
630 adc_engine_control_reg_val =
631 readl(data->base + ASPEED_REG_ENGINE_CONTROL);
632 adc_engine_control_reg_val |= ASPEED_ADC_CTRL_CHANNEL;
633 writel(adc_engine_control_reg_val,
634 data->base + ASPEED_REG_ENGINE_CONTROL);
636 indio_dev->name = data->model_data->model_name;
637 indio_dev->info = &aspeed_adc_iio_info;
638 indio_dev->modes = INDIO_DIRECT_MODE;
639 indio_dev->channels = data->battery_sensing ?
640 aspeed_adc_iio_bat_channels :
641 aspeed_adc_iio_channels;
642 indio_dev->num_channels = data->model_data->num_channels;
644 ret = devm_iio_device_register(data->dev, indio_dev);
648 static const struct aspeed_adc_trim_locate ast2500_adc_trim = {
650 .field = GENMASK(31, 28),
653 static const struct aspeed_adc_trim_locate ast2600_adc0_trim = {
655 .field = GENMASK(3, 0),
658 static const struct aspeed_adc_trim_locate ast2600_adc1_trim = {
660 .field = GENMASK(7, 4),
663 static const struct aspeed_adc_model_data ast2400_model_data = {
664 .model_name = "ast2400-adc",
665 .vref_fixed_mv = 2500,
666 .min_sampling_rate = 10000,
667 .max_sampling_rate = 500000,
668 .need_prescaler = true,
669 .scaler_bit_width = 10,
673 static const struct aspeed_adc_model_data ast2500_model_data = {
674 .model_name = "ast2500-adc",
675 .vref_fixed_mv = 1800,
676 .min_sampling_rate = 1,
677 .max_sampling_rate = 1000000,
678 .wait_init_sequence = true,
679 .need_prescaler = true,
680 .scaler_bit_width = 10,
682 .trim_locate = &ast2500_adc_trim,
685 static const struct aspeed_adc_model_data ast2600_adc0_model_data = {
686 .model_name = "ast2600-adc0",
687 .min_sampling_rate = 10000,
688 .max_sampling_rate = 500000,
689 .wait_init_sequence = true,
690 .bat_sense_sup = true,
691 .scaler_bit_width = 16,
693 .trim_locate = &ast2600_adc0_trim,
696 static const struct aspeed_adc_model_data ast2600_adc1_model_data = {
697 .model_name = "ast2600-adc1",
698 .min_sampling_rate = 10000,
699 .max_sampling_rate = 500000,
700 .wait_init_sequence = true,
701 .bat_sense_sup = true,
702 .scaler_bit_width = 16,
704 .trim_locate = &ast2600_adc1_trim,
707 static const struct of_device_id aspeed_adc_matches[] = {
708 { .compatible = "aspeed,ast2400-adc", .data = &ast2400_model_data },
709 { .compatible = "aspeed,ast2500-adc", .data = &ast2500_model_data },
710 { .compatible = "aspeed,ast2600-adc0", .data = &ast2600_adc0_model_data },
711 { .compatible = "aspeed,ast2600-adc1", .data = &ast2600_adc1_model_data },
714 MODULE_DEVICE_TABLE(of, aspeed_adc_matches);
716 static struct platform_driver aspeed_adc_driver = {
717 .probe = aspeed_adc_probe,
719 .name = KBUILD_MODNAME,
720 .of_match_table = aspeed_adc_matches,
724 module_platform_driver(aspeed_adc_driver);
726 MODULE_AUTHOR("Rick Altherr <raltherr@google.com>");
727 MODULE_DESCRIPTION("Aspeed AST2400/2500/2600 ADC Driver");
728 MODULE_LICENSE("GPL");