mirror of
https://github.com/u-boot/u-boot.git
synced 2025-05-08 10:39:08 +00:00
adc: Add driver for STM32 ADC
This patch adds support for STMicroelectronics STM32 ADC (analog to digital converter). It's originally based on Linux kernel v4.18-rcs drivers/iio/adc/stm32-adc*. It's composed of: - core driver (UCLASS_SIMPLE_BUS) manages common resources (clk, regu). - child drivers (UCLASS_ADC) declare each ADC, channels and handle conversions. This driver currently supports STM32H7 and STM32MP1 ADC. Signed-off-by: Fabrice Gasnier <fabrice.gasnier@st.com> Reviewed-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
parent
fb4e674a4b
commit
a466ecec48
5 changed files with 534 additions and 0 deletions
51
drivers/adc/stm32-adc-core.h
Normal file
51
drivers/adc/stm32-adc-core.h
Normal file
|
@ -0,0 +1,51 @@
|
|||
/* SPDX-License-Identifier: GPL-2.0 */
|
||||
/*
|
||||
* Copyright (C) 2018, STMicroelectronics - All Rights Reserved
|
||||
* Author: Fabrice Gasnier <fabrice.gasnier@st.com>.
|
||||
*
|
||||
* Originally based on the Linux kernel v4.18 drivers/iio/adc/stm32-adc-core.h.
|
||||
*/
|
||||
|
||||
#ifndef __STM32_ADC_H
|
||||
#define __STM32_ADC_H
|
||||
|
||||
/*
|
||||
* STM32 - ADC global register map
|
||||
* ________________________________________________________
|
||||
* | Offset | Register |
|
||||
* --------------------------------------------------------
|
||||
* | 0x000 | Master ADC1 |
|
||||
* --------------------------------------------------------
|
||||
* | 0x100 | Slave ADC2 |
|
||||
* --------------------------------------------------------
|
||||
* | 0x200 | Slave ADC3 |
|
||||
* --------------------------------------------------------
|
||||
* | 0x300 | Master & Slave common regs |
|
||||
* --------------------------------------------------------
|
||||
*/
|
||||
#define STM32_ADC_MAX_ADCS 3
|
||||
#define STM32_ADCX_COMN_OFFSET 0x300
|
||||
|
||||
#include <common.h>
|
||||
#include <clk.h>
|
||||
#include <dm.h>
|
||||
|
||||
/**
|
||||
* struct stm32_adc_common - stm32 ADC driver common data (for all instances)
|
||||
* @base: control registers base cpu addr
|
||||
* @rate: clock rate used for analog circuitry
|
||||
* @aclk: clock for the analog circuitry
|
||||
* @bclk: bus clock common for all ADCs
|
||||
* @vref: regulator reference
|
||||
* @vref_uv: reference supply voltage (uV)
|
||||
*/
|
||||
struct stm32_adc_common {
|
||||
void __iomem *base;
|
||||
unsigned long rate;
|
||||
struct clk aclk;
|
||||
struct clk bclk;
|
||||
struct udevice *vref;
|
||||
int vref_uv;
|
||||
};
|
||||
|
||||
#endif
|
Loading…
Add table
Add a link
Reference in a new issue