adc: updates to MEC172x adc to support pinctrl
Changes to adc module to support pinctrl. Signed-off-by: Jay Vasanth <jay.vasanth@microchip.com>
This commit is contained in:
parent
535c20e490
commit
9138d81365
2 changed files with 19 additions and 1 deletions
|
@ -12,6 +12,7 @@ LOG_MODULE_REGISTER(adc_mchp_xec);
|
|||
|
||||
#include <drivers/adc.h>
|
||||
#include <drivers/interrupt_controller/intc_mchp_xec_ecia.h>
|
||||
#include <drivers/pinctrl.h>
|
||||
#include <soc.h>
|
||||
#include <errno.h>
|
||||
|
||||
|
@ -37,6 +38,7 @@ struct adc_xec_config {
|
|||
uint8_t girq_repeat_pos;
|
||||
uint8_t pcr_regidx;
|
||||
uint8_t pcr_bitpos;
|
||||
const struct pinctrl_dev_config *pcfg;
|
||||
};
|
||||
|
||||
struct adc_xec_data {
|
||||
|
@ -304,6 +306,13 @@ static int adc_xec_init(const struct device *dev)
|
|||
const struct adc_xec_config *const cfg = ADC_XEC_CONFIG(dev);
|
||||
struct adc_xec_regs *adc_regs = ADC_XEC_REG_BASE(dev);
|
||||
struct adc_xec_data *data = ADC_XEC_DATA(dev);
|
||||
int ret;
|
||||
|
||||
ret = pinctrl_apply_state(cfg->pcfg, PINCTRL_STATE_DEFAULT);
|
||||
if (ret != 0) {
|
||||
LOG_ERR("XEC ADC V2 pinctrl setup failed (%d)", ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
adc_regs->control_reg = XEC_ADC_CTRL_ACTIVATE
|
||||
| XEC_ADC_CTRL_POWER_SAVER_DIS
|
||||
|
@ -326,6 +335,8 @@ static int adc_xec_init(const struct device *dev)
|
|||
return 0;
|
||||
}
|
||||
|
||||
PINCTRL_DT_INST_DEFINE(0);
|
||||
|
||||
static struct adc_xec_config adc_xec_dev_cfg_0 = {
|
||||
.base_addr = (uintptr_t)(DT_INST_REG_ADDR(0)),
|
||||
.girq_single = (uint8_t)(DT_INST_PROP_BY_IDX(0, girqs, 0)),
|
||||
|
@ -334,6 +345,7 @@ static struct adc_xec_config adc_xec_dev_cfg_0 = {
|
|||
.girq_repeat_pos = (uint8_t)(DT_INST_PROP_BY_IDX(0, girqs, 3)),
|
||||
.pcr_regidx = (uint8_t)(DT_INST_PROP_BY_IDX(0, pcrs, 0)),
|
||||
.pcr_bitpos = (uint8_t)(DT_INST_PROP_BY_IDX(0, pcrs, 1)),
|
||||
.pcfg = PINCTRL_DT_INST_DEV_CONFIG_GET(0),
|
||||
};
|
||||
|
||||
static struct adc_xec_data adc_xec_dev_data_0 = {
|
||||
|
|
|
@ -6,7 +6,7 @@ description: Microchip XEC ADC
|
|||
|
||||
compatible: "microchip,xec-adc-v2"
|
||||
|
||||
include: adc-controller.yaml
|
||||
include: [adc-controller.yaml, pinctrl-device.yaml]
|
||||
|
||||
properties:
|
||||
reg:
|
||||
|
@ -28,6 +28,12 @@ properties:
|
|||
required: true
|
||||
description: ADC PCR register index and bit position
|
||||
|
||||
pinctrl-0:
|
||||
required: true
|
||||
|
||||
pinctrl-names:
|
||||
required: true
|
||||
|
||||
"#girq-cells":
|
||||
type: int
|
||||
const: 2
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue