Linux Serial subsystem development
 help / color / mirror / Atom feed
From: Hui Wang <hui.wang@canonical.com>
To: Hugo Villeneuve <hugo@hugovil.com>
Cc: linux-serial@vger.kernel.org, devicetree@vger.kernel.org,
	gregkh@linuxfoundation.org, jirislaby@kernel.org,
	hvilleneuve@dimonoff.com, robh@kernel.org, krzk+dt@kernel.org,
	conor+dt@kernel.org, andy@kernel.org,
	lech.perczak@camlingroup.com, Maarten.Brock@sttls.nl
Subject: Re: [PATCH v3 2/2] serial: sc16is7xx: hardware reset chip if reset-gpios is defined in DT
Date: Wed, 12 Jun 2024 22:46:12 +0800	[thread overview]
Message-ID: <2cbbb6cf-7dff-4b28-9b98-a795d92937ae@canonical.com> (raw)
In-Reply-To: <20240612095023.946d77e6c30f7ecc4cdad672@hugovil.com>


On 6/12/24 21:50, Hugo Villeneuve wrote:
> On Wed, 12 Jun 2024 21:14:54 +0800
> Hui Wang <hui.wang@canonical.com> wrote:
>
> Hi Hui,
>
>> Some boards connect a GPIO to the reset pin, and the reset pin needs
>> to be setup correctly before accessing the chip.
>>
>> Add a function to handle the chip reset. If the reset-gpios is defined
>> in the DT, do hardware reset through this GPIO, othwerwise do software
>> reset as before.
...
>> +		/* The minimum reset pulse width is 3 us. */
>> +		udelay(5);
>> +		gpiod_set_value_cansleep(reset_gpio, 0);
>> +		/* Deassert GPIO */
> Move this comment after its corresponding statement:
>      gpiod_set_value_cansleep(reset_gpio, 0); /* Deassert GPIO */
>
Got it.
>> +	} else {
>> +		/* Software reset */
>> +		regmap_write(regmap, SC16IS7XX_IOCONTROL_REG,
>> +			     SC16IS7XX_IOCONTROL_SRESET_BIT);
>> +	}
>> +
>> +	return 0;
>> +}
>> +
>>   int sc16is7xx_probe(struct device *dev, const struct sc16is7xx_devtype *devtype,
>>   		    struct regmap *regmaps[], int irq)
>>   {
>> @@ -1527,6 +1552,10 @@ int sc16is7xx_probe(struct device *dev, const struct sc16is7xx_devtype *devtype,
>>   	s->devtype = devtype;
>>   	dev_set_drvdata(dev, s);
>>   
>> +	ret = sc16is7xx_reset(dev, regmaps[0]);
>> +	if (ret)
>> +		goto out_clk;
>> +
> You could move this block where the original software reset was
> located, unless you have a good reason to move it here? This will make
> the review (diff) easier...

If I move it to the place where the original software reset was located, 
I can't use "goto out_clk" anymore, it not only needs to release clk but 
also needs to stop the kthread, so I have to add a new tag before the 
kthread_stop(s->kworker_task) and goto that tag.

Thanks.

>>   	kthread_init_worker(&s->kworker);
>>   	s->kworker_task = kthread_run(kthread_worker_fn, &s->kworker,
>>   				      "sc16is7xx");
>> @@ -1536,10 +1565,6 @@ int sc16is7xx_probe(struct device *dev, const struct sc16is7xx_devtype *devtype,
>>   	}
>>   	sched_set_fifo(s->kworker_task);
>>   
>> -	/* reset device, purging any pending irq / data */
>> -	regmap_write(regmaps[0], SC16IS7XX_IOCONTROL_REG,
>> -		     SC16IS7XX_IOCONTROL_SRESET_BIT);
>> -
>>   	/* Mark each port line and status as uninitialised. */
>>   	for (i = 0; i < devtype->nr_uart; ++i) {
>>   		s->p[i].port.line = SC16IS7XX_MAX_DEVS;
>> -- 
>> 2.34.1
>

  reply	other threads:[~2024-06-12 14:46 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-06-12 13:14 [PATCH v3 1/2] dt-bindings: serial: sc16is7xx: add reset-gpios Hui Wang
2024-06-12 13:14 ` [PATCH v3 2/2] serial: sc16is7xx: hardware reset chip if reset-gpios is defined in DT Hui Wang
2024-06-12 13:50   ` Hugo Villeneuve
2024-06-12 14:46     ` Hui Wang [this message]
2024-06-12 13:56   ` Lech Perczak
2024-06-12 14:50     ` Hui Wang
2024-06-13 20:45     ` Andy Shevchenko
2024-06-12 16:37 ` [PATCH v3 1/2] dt-bindings: serial: sc16is7xx: add reset-gpios Conor Dooley
2024-06-12 16:49   ` Hugo Villeneuve
2024-06-12 16:58     ` Conor Dooley

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=2cbbb6cf-7dff-4b28-9b98-a795d92937ae@canonical.com \
    --to=hui.wang@canonical.com \
    --cc=Maarten.Brock@sttls.nl \
    --cc=andy@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=hugo@hugovil.com \
    --cc=hvilleneuve@dimonoff.com \
    --cc=jirislaby@kernel.org \
    --cc=krzk+dt@kernel.org \
    --cc=lech.perczak@camlingroup.com \
    --cc=linux-serial@vger.kernel.org \
    --cc=robh@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox