Commit 371ca13c authored by Jeff Daly's avatar Jeff Daly Committed by Benjamin Cabé
Browse files

drivers: adc: microchip: Different channels per package type



LJ packages have 16 ADC channels vs 8 for SZ packages.  Enhance
devicetree to account for this as well as conditional defines/code.

Signed-off-by: default avatarJeff Daly <jeffd@silicom-usa.com>
parent 662d9c75
Loading
Loading
Loading
Loading
+5 −4
Original line number Diff line number Diff line
@@ -47,6 +47,7 @@ enum adc_pm_policy_state_flag {
	ADC_PM_POLICY_STATE_FLAG_COUNT,
};

#define XEC_ADC_CFG_CHANNELS DT_INST_PROP(0, channels)

struct adc_xec_regs {
	uint32_t control_reg;
@@ -54,8 +55,8 @@ struct adc_xec_regs {
	uint32_t status_reg;
	uint32_t single_reg;
	uint32_t repeat_reg;
	uint32_t channel_read_reg[8];
	uint32_t unused[18];
	uint32_t channel_read_reg[XEC_ADC_CFG_CHANNELS];
	uint32_t unused[10 + (MCHP_ADC_MAX_CHAN - XEC_ADC_CFG_CHANNELS)];
	uint32_t config_reg;
	uint32_t vref_channel_reg;
	uint32_t vref_control_reg;
@@ -139,7 +140,7 @@ static int adc_xec_channel_setup(const struct device *dev,
		return -EINVAL;
	}

	if (channel_cfg->channel_id >= MCHP_ADC_MAX_CHAN) {
	if (channel_cfg->channel_id >= XEC_ADC_CFG_CHANNELS) {
		return -EINVAL;
	}

@@ -205,7 +206,7 @@ static int adc_xec_start_read(const struct device *dev,
	struct adc_xec_data * const data = dev->data;
	uint32_t sar_ctrl;

	if (sequence->channels & ~BIT_MASK(MCHP_ADC_MAX_CHAN)) {
	if (sequence->channels & ~BIT_MASK(XEC_ADC_CFG_CHANNELS)) {
		LOG_ERR("Incorrect channels, bitmask 0x%x", sequence->channels);
		return -EINVAL;
	}
+1 −0
Original line number Diff line number Diff line
@@ -442,6 +442,7 @@
			status = "disabled";
			#io-channel-cells = <1>;
			clktime = <32>;
			channels = <8>;
		};
		kbd0: kbd@40009c00 {
			compatible = "microchip,xec-kbd";
+1 −0
Original line number Diff line number Diff line
@@ -650,6 +650,7 @@ adc0: adc@40007c00 {
	status = "disabled";
	#io-channel-cells = <1>;
	clktime = <32>;
	channels = <16>;
};
kbd0: kbd@40009c00 {
	compatible = "microchip,xec-kbd";
+4 −0
Original line number Diff line number Diff line
@@ -75,3 +75,7 @@
&systick {
	status = "disabled";
};

&adc0 {
	channels = <8>;
};
+5 −0
Original line number Diff line number Diff line
@@ -33,6 +33,11 @@ properties:
    required: true
    description: ADC clock high & low time count value <1:255>

  channels:
    type: int
    required: true
    description: Number of ADC channels supported by SoC

  pinctrl-0:
    required: true

Loading