Hi Prabhakar, Thanks for the review. > Subject: RE: [PATCH] iio: adc: rzg2l_adc: Add support for RZ/G2UL ADC > > Hi Biju, > > Thank you for the patch. > > > Subject: [PATCH] iio: adc: rzg2l_adc: Add support for RZ/G2UL ADC > > > > ADC found on RZ/G2UL SoC is almost identical to RZ/G2L SoC, but > > RZ/G2UL has 2 analog input channels compared to 8 channels on RZ/G2L. > > Therefore, added a new compatible to handle this difference. > > > > Signed-off-by: Biju Das <biju.das.jz@xxxxxxxxxxxxxx> > > --- > > drivers/iio/adc/rzg2l_adc.c | 18 +++++++++++++----- > > 1 file changed, 13 insertions(+), 5 deletions(-) > > > I wonder if this changes is really required. RZ/G2UL can still use the > "renesas,rzg2l-adc". As the driver populates the channels depending the > number of elements in the array passed in the DTS and not always 8 > channels. For example on Renesas SMARC EVK only four channels are > populated. > For me that restriction is coming from board design, as SoC is capable of handling 8 channels, But board design allows only 4. But on RZ/G2UL SoC, it is capable of handling only 2 channels. Other channels are invalid for RZ/G2UL SoC. That is the difference. > With this we don't have to differentiate RZ/G2UL SoC if just add two > channel entries in the SoC DTSI and the driver will just create two > channels. > > @Geert - your thoughts on this. > > Cheers, > Prabhakar > > > diff --git a/drivers/iio/adc/rzg2l_adc.c b/drivers/iio/adc/rzg2l_adc.c > > index 7585144b9715..703b08254c9f 100644 > > --- a/drivers/iio/adc/rzg2l_adc.c > > +++ b/drivers/iio/adc/rzg2l_adc.c > > @@ -16,6 +16,7 @@ > > #include <linux/io.h> > > #include <linux/mod_devicetable.h> > > #include <linux/module.h> > > +#include <linux/of_device.h> > > #include <linux/platform_device.h> > > #include <linux/pm_runtime.h> > > #include <linux/reset.h> > > @@ -61,6 +62,8 @@ > > #define RZG2L_ADC_CHN_MASK 0x7 > > #define RZG2L_ADC_TIMEOUT usecs_to_jiffies(1 * 4) > > > > +#define RZG2UL_ADC_MAX_CHANNELS 2 > > + > > struct rzg2l_adc_data { > > const struct iio_chan_spec *channels; > > u8 num_channels; > > @@ -76,6 +79,7 @@ struct rzg2l_adc { > > const struct rzg2l_adc_data *data; > > struct mutex lock; > > u16 last_val[RZG2L_ADC_MAX_CHANNELS]; > > + u8 max_channels; > > }; > > > > static const char * const rzg2l_adc_channel_name[] = { @@ -260,7 > > +264,9 @@ static int rzg2l_adc_read_label(struct iio_dev *iio_dev, > > const struct iio_chan_spec *chan, > > char *label) > > { > > - if (chan->channel >= RZG2L_ADC_MAX_CHANNELS) > > + struct rzg2l_adc *adc = iio_priv(iio_dev); > > + > > + if (chan->channel >= adc->max_channels) > > return -EINVAL; > > > > return sysfs_emit(label, "%s\n", rzg2l_adc_channel_name[chan- > > >channel]); > > @@ -290,7 +296,7 @@ static irqreturn_t rzg2l_adc_isr(int irq, void > > *dev_id) > > if (!intst) > > return IRQ_NONE; > > > > - for_each_set_bit(ch, &intst, RZG2L_ADC_MAX_CHANNELS) > > + for_each_set_bit(ch, &intst, adc->max_channels) > > adc->last_val[ch] = rzg2l_adc_readl(adc, RZG2L_ADCR(ch)) & > > RZG2L_ADCR_AD_MASK; > > > > /* clear the channel interrupt */ > > @@ -321,7 +327,7 @@ static int rzg2l_adc_parse_properties(struct > > platform_device *pdev, struct rzg2l > > return -ENODEV; > > } > > > > - if (num_channels > RZG2L_ADC_MAX_CHANNELS) { > > + if (num_channels > adc->max_channels) { > > dev_err(&pdev->dev, "num of channel children out of range\n"); > > return -EINVAL; > > } > > @@ -337,7 +343,7 @@ static int rzg2l_adc_parse_properties(struct > > platform_device *pdev, struct rzg2l > > if (ret) > > return ret; > > > > - if (channel >= RZG2L_ADC_MAX_CHANNELS) > > + if (channel >= adc->max_channels) > > return -EINVAL; > > > > chan_array[i].type = IIO_VOLTAGE; > > @@ -437,6 +443,7 @@ static int rzg2l_adc_probe(struct platform_device > > *pdev) > > > > adc = iio_priv(indio_dev); > > > > + adc->max_channels = (uintptr_t)of_device_get_match_data(dev); > > ret = rzg2l_adc_parse_properties(pdev, adc); > > if (ret) > > return ret; > > @@ -540,7 +547,8 @@ static int rzg2l_adc_probe(struct platform_device > > *pdev) } > > > > static const struct of_device_id rzg2l_adc_match[] = { > > - { .compatible = "renesas,rzg2l-adc",}, > > + { .compatible = "renesas,r9a07g043-adc", .data = (void > > *)RZG2UL_ADC_MAX_CHANNELS }, > > + { .compatible = "renesas,rzg2l-adc", .data = (void > > +*)RZG2L_ADC_MAX_CHANNELS }, > > { /* sentinel */ } > > }; > > MODULE_DEVICE_TABLE(of, rzg2l_adc_match); > > -- > > 2.25.1