From: Greg Ungerer <gerg-Td1EMuHUCqxL1ZNQvxDV9g@public.gmane.org>
To: "Uwe Kleine-König"
<u.kleine-koenig-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
Cc: Oleksij Rempel <ore-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>,
Mark Brown <broonie-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>,
Fabio Estevam <festevam-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>,
Sascha Hauer <kernel-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>,
Vladimir Zapolskiy
<vladimir_zapolskiy-nmGgyN9QBj3QT0dZR+AlfA@public.gmane.org>,
"linux-spi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org"
<linux-spi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>
Subject: Re: [PATCHv3 1/2] spi: imx: fix use of native chip-selects with devicetree
Date: Thu, 10 Aug 2017 23:21:14 +1000 [thread overview]
Message-ID: <ac92f8ad-3ba6-a577-dc9c-9e8b6689afd4@linux-m68k.org> (raw)
In-Reply-To: <20170810124049.msmi2pfqmpoafsml-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
Hi Uwe,
On 10/08/17 22:40, Uwe Kleine-König wrote:
> Hello Greg,
>
> On Thu, Aug 10, 2017 at 10:24:09PM +1000, Greg Ungerer wrote:
>> On 10/08/17 21:49, Uwe Kleine-König wrote:
>>> On Thu, Aug 10, 2017 at 09:35:15PM +1000, Greg Ungerer wrote:
>>>> On 10/08/17 19:35, Vladimir Zapolskiy wrote:
>>>>> Errors in DTB (or platform data) may confuse a driver and lead to runtime
>>>>> misbehaviour. You describe an error in a board DTB, which is definitely
>>>>> better to handle in the SPI driver, but I don't think it is strictly
>>>>> mandatory to do it, because DTB errors are supposed to be fixed in DTB.
>>>>>
>>>>> May be one day a formal check of DTBs against Documentation/devicetree
>>>>> descriptions will be added and such DTB errors could be captured on DTB
>>>>> compilation stage.
>>>>
>>>> I completely agree with Vladmir here. Since "cs-gpios" defines the
>>>> number of chip selects, as per the code you point out, it is the range
>>>> limit. So if a DTB defines it wrongly then you can expect some things
>>>> not to work right. The spi code quite rightly relies on the DTB
>>>> definitions to be correct for proper operation.
>>>>
>>>>
>>>>>> And in this case:
>>>>>> cs-gpios = <&gpio1 0 0>, <&gpio1 1 0>, <&gpio1 2 0>, <&gpio1 3 0>, <0>;
>>>>>>
>>>>>> we should produce a 3 bit value b100 which will be shifted left and
>>>>>> "or"-ed with other ctrl bits.
>>>>
>>>> So the register settings will be wrong and the device will not work.
>>>> You can't really expect any other behavior from an incorrect DTB.
>>>
>>> I think nobody expects that a wrong dtb is good enough to make
>>> everything work. Maybe you can argue what should happen in a driver if
>>> it gets a wrong dtb. It can make the kernel oops, just silently not work
>>> or issue an error message; probably there are more options.
>>>
>>> The current state is that a broken dtb makes the spi-imx driver write to
>>> a unrelated register bit when asked to set a chip select signal. Oleksij
>>> tries to improve that and make the driver error out instead. It makes it
>>> easier for users to report problems or find the culprit themselves. I
>>> like that.
>>
>> But the check if the chip select is valid is based on information
>> that comes from the DTB. In the example of the wrong cs-gpios list
>> the DTB is saying it has more chip selects that the actual hardware
>> device does. How can you possibly protect against that?
>>
>> The current code seems to do its best to range check the chip select,
>> based on what the DTB says this hardware has.
>
> If I understood correctly the current state is the following:
>
> The spi-imx driver supports GPIOs as CS and a "native" mode where the
> hardware drives the CS line. If you write:
>
> cs-gpios = <&gpio2 0 0>, <0>, <&gpio1 17 0>
>
> That means: Use gpio2.0 as CS 0, native CS as CS 1 and gpio1.17 as CS 2.
That is correct, yes. But the current driver is buggy and does not
handle the "native" mode correctly - the intention of the patch
at the start of this thread is to fix this.
> So what the driver can check here: Does the dtb request a native CS at a
> position that is not supported by the hardware. Of course even if there
How does the driver know how many chip-selects are natively supported
by the hardware?
I am not familar with all iMX parts and their spi controllers, but
Oleksij suggested in an earlier email that some have 3 native chip
selects, some have 4, other variants may have some other number.
Regards
Greg
> are only 4 hardware CS the driver can still be used with 7 spi devices
> given that CS 4 .. 6 are using a GPIO as CS.
>
> Oleksij: please correct me if I'm wrong.
>
> Best regards
> Uwe
>
--
To unsubscribe from this list: send the line "unsubscribe linux-spi" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
next prev parent reply other threads:[~2017-08-10 13:21 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-07-11 4:22 [PATCHv3 0/2] spi: imx: native chip selects and devicetree Greg Ungerer
[not found] ` <1499746932-14850-1-git-send-email-gerg-Td1EMuHUCqxL1ZNQvxDV9g@public.gmane.org>
2017-07-11 4:22 ` [PATCHv3 1/2] spi: imx: fix use of native chip-selects with devicetree Greg Ungerer
[not found] ` <1499746932-14850-2-git-send-email-gerg-Td1EMuHUCqxL1ZNQvxDV9g@public.gmane.org>
2017-07-19 0:49 ` Vladimir Zapolskiy
[not found] ` <cfe8f524-ba18-60d2-2c1b-94903e5c4df5-ChpfBGZJDbMAvxtiuMwx3w@public.gmane.org>
2017-07-19 1:51 ` Greg Ungerer
2017-07-19 0:53 ` Fabio Estevam
[not found] ` <CAOMZO5Dq8mAULR+L6HJUMc6f=-d9QPZmn92+jzwKLuGYDA_AaA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2017-07-20 6:34 ` Oleksij Rempel
[not found] ` <20170720063449.qvi3s7faapcncoqm-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
2017-07-20 13:00 ` Greg Ungerer
[not found] ` <2892f819-f1a2-b68d-be01-e8ac7f4b4222-Td1EMuHUCqxL1ZNQvxDV9g@public.gmane.org>
2017-07-24 6:21 ` Oleksij Rempel
[not found] ` <20170724062147.o7tccwskxfuls3ej-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
2017-08-09 13:00 ` Greg Ungerer
[not found] ` <239ae959-ce96-711b-dbfb-4e892b7eab3b-Td1EMuHUCqxL1ZNQvxDV9g@public.gmane.org>
2017-08-10 6:09 ` Oleksij Rempel
[not found] ` <8ccba0c6-cd35-db2e-6a3f-32b79609271d-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
2017-08-10 9:35 ` Vladimir Zapolskiy
[not found] ` <b3e80e47-d1e5-41f9-a744-dc01e51d779e-nmGgyN9QBj3QT0dZR+AlfA@public.gmane.org>
2017-08-10 11:35 ` Greg Ungerer
[not found] ` <b0b60f4a-7ee9-c0e5-9eb0-ac6a29555e5c-Td1EMuHUCqxL1ZNQvxDV9g@public.gmane.org>
2017-08-10 11:47 ` Oleksij Rempel
2017-08-10 11:49 ` Uwe Kleine-König
[not found] ` <20170810114938.bsuztdxmngys2ekg-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
2017-08-10 12:24 ` Greg Ungerer
[not found] ` <6dea9014-6e45-199b-16de-418728757662-Td1EMuHUCqxL1ZNQvxDV9g@public.gmane.org>
2017-08-10 12:40 ` Uwe Kleine-König
[not found] ` <20170810124049.msmi2pfqmpoafsml-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
2017-08-10 13:21 ` Greg Ungerer [this message]
[not found] ` <ac92f8ad-3ba6-a577-dc9c-9e8b6689afd4-Td1EMuHUCqxL1ZNQvxDV9g@public.gmane.org>
2017-08-10 15:17 ` Uwe Kleine-König
2017-07-11 4:22 ` [PATCHv3 2/2] spi: imx: document use of native chip-selects in devicetree Greg Ungerer
[not found] ` <1499746932-14850-3-git-send-email-gerg-Td1EMuHUCqxL1ZNQvxDV9g@public.gmane.org>
2017-07-19 0:32 ` Vladimir Zapolskiy
2017-07-19 0:37 ` Fabio Estevam
[not found] ` <CAOMZO5A6CZAQUh3mBpH3AdEtcTH-=tdMdqL-SV+4=zcstVQEaQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2017-07-19 0:39 ` Vladimir Zapolskiy
[not found] ` <42e1aad1-ca53-ba70-2922-25e2b083d971-ChpfBGZJDbMAvxtiuMwx3w@public.gmane.org>
2017-07-19 0:42 ` Fabio Estevam
[not found] ` <CAOMZO5B55NzBpZscqQECt=2nUQatnU7s2Oc8YLkxFa-dbaB=bA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2017-07-19 1:07 ` Vladimir Zapolskiy
2017-07-19 1:05 ` Greg Ungerer
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=ac92f8ad-3ba6-a577-dc9c-9e8b6689afd4@linux-m68k.org \
--to=gerg-td1emuhucqxl1znqvxdv9g@public.gmane.org \
--cc=broonie-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org \
--cc=festevam-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
--cc=kernel-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org \
--cc=linux-spi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=ore-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org \
--cc=u.kleine-koenig-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org \
--cc=vladimir_zapolskiy-nmGgyN9QBj3QT0dZR+AlfA@public.gmane.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;
as well as URLs for NNTP newsgroup(s).