From: Petre Rodan <petre.rodan@subdimension.ro>
To: Jonathan Cameron <Jonathan.Cameron@Huawei.com>
Cc: linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org,
Jonathan Cameron <jic23@kernel.org>,
Lars-Peter Clausen <lars@metafoo.de>
Subject: Re: [PATCH 6/6] iio: pressure: hsc030pa add sleep mode
Date: Sun, 14 Jan 2024 07:17:47 +0200 [thread overview]
Message-ID: <ZaNue0JgTw-WEhCw@sunspire> (raw)
In-Reply-To: <20240112171356.00003e88@Huawei.com>
[-- Attachment #1: Type: text/plain, Size: 3753 bytes --]
Hi Jonathan,
On Fri, Jan 12, 2024 at 05:13:56PM +0000, Jonathan Cameron wrote:
> On Wed, 10 Jan 2024 19:22:41 +0200
> Petre Rodan <petre.rodan@subdimension.ro> wrote:
>
> > Some custom chips from this series require a wakeup sequence before the
> > measurement cycle is started.
> >
[..]
> > + if (data->capabilities & HSC_CAP_SLEEP) {
> > + /*
> > + * Send the Full Measurement Request (FMR) command on the CS
> > + * line in order to wake up the sensor as per
> > + * "Sleep Mode for Use with Honeywell Digital Pressure Sensors"
> > + * technical note (consult the datasheet link in the header).
> > + *
> > + * These specifications require a dummy packet comprised only by
> > + * a single byte that contains the 7bit slave address and the
> > + * READ bit followed by a STOP.
> > + * Because the i2c API does not allow packets without a payload,
> > + * the driver sends two bytes in this implementation.
> > + */
> > + ret = i2c_master_recv(client, &buf, 1);
> > + if (ret < 0)
> > + return ret;
> > + }
> > +
[..]
> > diff --git a/drivers/iio/pressure/hsc030pa_spi.c b/drivers/iio/pressure/hsc030pa_spi.c
> > index 737197eddff0..1c139cdfe856 100644
> > --- a/drivers/iio/pressure/hsc030pa_spi.c
> > +++ b/drivers/iio/pressure/hsc030pa_spi.c
> > @@ -25,12 +25,40 @@ static int hsc_spi_recv(struct hsc_data *data)
> > struct spi_device *spi = to_spi_device(data->dev);
> > struct spi_transfer xfer = {
> > .tx_buf = NULL,
> > - .rx_buf = data->buffer,
> > - .len = HSC_REG_MEASUREMENT_RD_SIZE,
> > + .rx_buf = NULL,
> > + .len = 0,
> > };
> > + u16 orig_cs_setup_value;
> > + u8 orig_cs_setup_unit;
> > +
> > + if (data->capabilities & HSC_CAP_SLEEP) {
> > + /*
> > + * Send the Full Measurement Request (FMR) command on the CS
> > + * line in order to wake up the sensor as per
> > + * "Sleep Mode for Use with Honeywell Digital Pressure Sensors"
> > + * technical note (consult the datasheet link in the header).
> > + *
> > + * These specifications require the CS line to be held asserted
> > + * for at least 8µs without any payload being generated.
> > + */
> > + orig_cs_setup_value = spi->cs_setup.value;
> > + orig_cs_setup_unit = spi->cs_setup.unit;
> > + spi->cs_setup.value = 8;
> > + spi->cs_setup.unit = SPI_DELAY_UNIT_USECS;
> > + /*
> > + * Send a dummy 0-size packet so that CS gets toggled.
> > + * Trying to manually call spi->controller->set_cs() instead
> > + * does not work as expected during the second call.
> > + */
>
> Do you have a reference that says the CS must be toggled on 0 length transfer?
> If that's not specified in the SPI core somewhere then you will need to send
> something...
>
> > + spi_sync_transfer(spi, &xfer, 1);
> > + spi->cs_setup.value = orig_cs_setup_value;
> > + spi->cs_setup.unit = orig_cs_setup_unit;
> > + }
first of all thank you for the review.
I was afraid that this block will not be taken too well since I'm trying to
achieve something that the SPI subsystem was not designed for.
the code does exactly what the datasheet specs require on my SPI controller, but
indeed the API might change at some point making the code non-functional.
by 'sending something' you mean on the SPI bus or are you pushing me toward a
patch to SPI core?
unfortunately this chip feature is a special request only, there is no way for
me to test what happens if the wakeup sequence also contains a payload (in both
i2c and spi cases). the i2c wakeup code was inspired from the abp060mg driver,
but I can't reach its maintainer to ask for details. I also can't seem to reach
Honeywell. oh well.
best regards,
peter
--
petre rodan
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
next prev parent reply other threads:[~2024-01-14 5:17 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-01-10 17:22 [PATCH 0/6] iio: pressure: hsc030pa new features Petre Rodan
2024-01-10 17:22 ` [PATCH 1/6] dt-bindings: iio: pressure: honeywell,hsc030pa.yaml add spi props Petre Rodan
2024-01-10 20:43 ` Krzysztof Kozlowski
2024-01-10 17:22 ` [PATCH 2/6] dt-bindings: iio: pressure: honeywell,hsc030pa.yaml add sleep-mode Petre Rodan
2024-01-10 20:48 ` Krzysztof Kozlowski
2024-01-12 7:30 ` Petre Rodan
2024-01-16 17:30 ` Rob Herring
2024-01-17 16:50 ` Jonathan Cameron
2024-01-17 17:27 ` Rob Herring
2024-01-10 17:22 ` [PATCH 3/6] iio: pressure: hsc030pa cleanup Petre Rodan
2024-01-10 17:22 ` [PATCH 4/6] iio: pressure: hsc030pa add mandatory delay Petre Rodan
2024-01-10 17:22 ` [PATCH 5/6] iio: pressure: hsc030pa add triggered buffer Petre Rodan
2024-01-12 17:09 ` Jonathan Cameron
2024-01-10 17:22 ` [PATCH 6/6] iio: pressure: hsc030pa add sleep mode Petre Rodan
2024-01-12 17:13 ` Jonathan Cameron
2024-01-14 5:17 ` Petre Rodan [this message]
2024-01-14 15:27 ` Jonathan Cameron
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=ZaNue0JgTw-WEhCw@sunspire \
--to=petre.rodan@subdimension.ro \
--cc=Jonathan.Cameron@Huawei.com \
--cc=jic23@kernel.org \
--cc=lars@metafoo.de \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.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