<div dir="ltr">Great!<div><br></div><div>Thanks a lot Jonathan</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, 6 Feb 2020 at 13:40, Jonathan Cameron <<a href="mailto:jic23@kernel.org">jic23@kernel.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">On Mon, 3 Feb 2020 17:09:17 +0200<br>
Tomer Maimon <<a href="mailto:tmaimon77@gmail.com" target="_blank">tmaimon77@gmail.com</a>> wrote:<br>
<br>
> Modify NPCM ADC reset support from<br>
> direct register access to reset controller support.<br>
> <br>
> please make sure to modify NPCM adc device tree<br>
> parameters as described at nuvoton,npcm-adc.txt<br>
> document for using this change.<br>
> <br>
> Signed-off-by: Tomer Maimon <<a href="mailto:tmaimon77@gmail.com" target="_blank">tmaimon77@gmail.com</a>><br>
<br>
Applied. I added a note for anyone browsing the tree in future<br>
to say that we know this is a breaking change, but in this case<br>
close ecosystem etc so it's fine..<br>
<br>
I don't want others to point at your patch when I tell them no<br>
for similar changes in more generic parts!<br>
<br>
Thanks,<br>
<br>
Jonathan<br>
<br>
> ---<br>
> drivers/iio/adc/npcm_adc.c | 30 +++++++++---------------------<br>
> 1 file changed, 9 insertions(+), 21 deletions(-)<br>
> <br>
> diff --git a/drivers/iio/adc/npcm_adc.c b/drivers/iio/adc/npcm_adc.c<br>
> index a6170a37ebe8..83bad2d5575d 100644<br>
> --- a/drivers/iio/adc/npcm_adc.c<br>
> +++ b/drivers/iio/adc/npcm_adc.c<br>
> @@ -14,6 +14,7 @@<br>
> #include <linux/regulator/consumer.h><br>
> #include <linux/spinlock.h><br>
> #include <linux/uaccess.h><br>
> +#include <linux/reset.h><br>
> <br>
> struct npcm_adc {<br>
> bool int_status;<br>
> @@ -23,13 +24,9 @@ struct npcm_adc {<br>
> struct clk *adc_clk;<br>
> wait_queue_head_t wq;<br>
> struct regulator *vref;<br>
> - struct regmap *rst_regmap;<br>
> + struct reset_control *reset;<br>
> };<br>
> <br>
> -/* NPCM7xx reset module */<br>
> -#define NPCM7XX_IPSRST1_OFFSET 0x020<br>
> -#define NPCM7XX_IPSRST1_ADC_RST BIT(27)<br>
> -<br>
> /* ADC registers */<br>
> #define NPCM_ADCCON 0x00<br>
> #define NPCM_ADCDATA 0x04<br>
> @@ -106,13 +103,11 @@ static int npcm_adc_read(struct npcm_adc *info, int *val, u8 channel)<br>
> msecs_to_jiffies(10));<br>
> if (ret == 0) {<br>
> regtemp = ioread32(info->regs + NPCM_ADCCON);<br>
> - if ((regtemp & NPCM_ADCCON_ADC_CONV) && info->rst_regmap) {<br>
> + if (regtemp & NPCM_ADCCON_ADC_CONV) {<br>
> /* if conversion failed - reset ADC module */<br>
> - regmap_write(info->rst_regmap, NPCM7XX_IPSRST1_OFFSET,<br>
> - NPCM7XX_IPSRST1_ADC_RST);<br>
> + reset_control_assert(info->reset);<br>
> msleep(100);<br>
> - regmap_write(info->rst_regmap, NPCM7XX_IPSRST1_OFFSET,<br>
> - 0x0);<br>
> + reset_control_deassert(info->reset);<br>
> msleep(100);<br>
> <br>
> /* Enable ADC and start conversion module */<br>
> @@ -186,7 +181,6 @@ static int npcm_adc_probe(struct platform_device *pdev)<br>
> struct npcm_adc *info;<br>
> struct iio_dev *indio_dev;<br>
> struct device *dev = &pdev->dev;<br>
> - struct device_node *np = pdev->dev.of_node;<br>
> <br>
> indio_dev = devm_iio_device_alloc(&pdev->dev, sizeof(*info));<br>
> if (!indio_dev)<br>
> @@ -199,6 +193,10 @@ static int npcm_adc_probe(struct platform_device *pdev)<br>
> if (IS_ERR(info->regs))<br>
> return PTR_ERR(info->regs);<br>
> <br>
> + info->reset = devm_reset_control_get(&pdev->dev, NULL);<br>
> + if (IS_ERR(info->reset))<br>
> + return PTR_ERR(info->reset);<br>
> +<br>
> info->adc_clk = devm_clk_get(&pdev->dev, NULL);<br>
> if (IS_ERR(info->adc_clk)) {<br>
> dev_warn(&pdev->dev, "ADC clock failed: can't read clk\n");<br>
> @@ -211,16 +209,6 @@ static int npcm_adc_probe(struct platform_device *pdev)<br>
> div = div >> NPCM_ADCCON_DIV_SHIFT;<br>
> info->adc_sample_hz = clk_get_rate(info->adc_clk) / ((div + 1) * 2);<br>
> <br>
> - if (of_device_is_compatible(np, "nuvoton,npcm750-adc")) {<br>
> - info->rst_regmap = syscon_regmap_lookup_by_compatible<br>
> - ("nuvoton,npcm750-rst");<br>
> - if (IS_ERR(info->rst_regmap)) {<br>
> - dev_err(&pdev->dev, "Failed to find nuvoton,npcm750-rst\n");<br>
> - ret = PTR_ERR(info->rst_regmap);<br>
> - goto err_disable_clk;<br>
> - }<br>
> - }<br>
> -<br>
> irq = platform_get_irq(pdev, 0);<br>
> if (irq <= 0) {<br>
> ret = -EINVAL;<br>
<br>
</blockquote></div>