mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Tudor Ambarus <tudor.ambarus@linaro.org>
To: "Rafał Miłecki" <zajec5@gmail.com>,
	"Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
	"Rafael J. Wysocki" <rafael@kernel.org>,
	"Rob Herring" <robh+dt@kernel.org>,
	"Krzysztof Kozlowski" <krzysztof.kozlowski+dt@linaro.org>,
	"Brian Norris" <briannorris@chromium.org>,
	"Linux Kernel Mailing List" <linux-kernel@vger.kernel.org>,
	"devicetree@vger.kernel.org" <devicetree@vger.kernel.org>,
	"MTD Maling List" <linux-mtd@lists.infradead.org>
Subject: Re: Probing devices by their less-specific "compatible" bindings (here: brcmnand)
Date: Fri, 17 Mar 2023 14:19:15 +0000	[thread overview]
Message-ID: <33ad964e-edfd-a894-5399-1e870cb36112@linaro.org> (raw)
In-Reply-To: <399d2f43-5cad-6c51-fe3a-623950e2151a@gmail.com>



On 3/17/23 10:02, Rafał Miłecki wrote:
> Hi, I just spent few hours debugging hidden hw lockup and I need to
> consult driver core code behaviour.
> 
> I have a BCM4908 SoC based board with a NAND controller on it.
> 
> 
> ### Hardware binding
> 
> Hardware details:
> arch/arm64/boot/dts/broadcom/bcmbca/bcm4908.dtsi
> 
> Relevant part:
> nand-controller@1800 {
>     compatible = "brcm,nand-bcm63138", "brcm,brcmnand-v7.1",
> "brcm,brcmnand";
>     reg = <0x1800 0x600>, <0x2000 0x10>;
>     reg-names = "nand", "nand-int-base";
> }:
> 
> Above binding is based on the documentation:
> Documentation/devicetree/bindings/mtd/brcm,brcmnand.yaml
> 
> 
> ### Linux drivers
> 
> Linux has separated drivers for few Broadcom's NAND controller bindings:
> 
> 1. drivers/mtd/nand/raw/brcmnand/bcm63138_nand.c for:
> brcm,nand-bcm63138
> 
> 2. drivers/mtd/nand/raw/brcmnand/brcmnand.c for:
> brcm,brcmnand-v2.1
> brcm,brcmnand-v2.2
> brcm,brcmnand-v4.0
> brcm,brcmnand-v5.0
> brcm,brcmnand-v6.0
> brcm,brcmnand-v6.1
> brcm,brcmnand-v6.2
> brcm,brcmnand-v7.0
> brcm,brcmnand-v7.1
> brcm,brcmnand-v7.2
> brcm,brcmnand-v7.3
> 
> 3. drivers/mtd/nand/raw/brcmnand/brcmstb_nand.c for:
> brcm,brcmnand
> 
> 
> ### Problem
> 
> As first Linux probes my hardware using the "brcm,nand-bcm63138"
> compatibility string driver bcm63138_nand.c. That's good.
> 
> It that fails however (.probe() returns an error) then Linux core starts
> probing using drivers for less specific bindings.
> 
> In my case probing with the "brcm,brcmnand" string driver brcmstb_nand.c
> results in ignoring SoC specific bits and causes a hardware lockup. Hw
> isn't initialized properly and writel_relaxed(0x00000009, base + 0x04)
> just make it hang.
> 
> That obviously isn't an acceptable behavior for me. So I'm wondering
> what's going on wrong here.
> 
> Should Linux avoid probing with less-specific compatible strings?

No. It's quite common to have a list of compatibles. An use case is that
you have a new IP that works with an existing compatible, but this IP
also has new features that are not supported by the existing compatible
and by the hardware for which the existing compatible was created. So
people introduce a new compatible for the existing IP in order to
differentiate from the older versions. If the new compatible is not yet
defined in the driver, the second compatible from the list is used and
you get the IP working but with a reduced function set.

> Or should I not claim hw to be "brcm,brcmnand" compatible if it REQUIRES
> SoC-specific handling?

Correct.

Cheers,
ta

  reply	other threads:[~2023-03-17 14:19 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-17 10:02 Rafał Miłecki
2023-03-17 14:19 ` Tudor Ambarus [this message]
2023-03-17 14:34 ` Krzysztof Kozlowski
2023-03-17 21:54 ` Florian Fainelli
2023-03-18  0:24   ` William Zhang

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=33ad964e-edfd-a894-5399-1e870cb36112@linaro.org \
    --to=tudor.ambarus@linaro.org \
    --cc=briannorris@chromium.org \
    --cc=devicetree@vger.kernel.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=krzysztof.kozlowski+dt@linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mtd@lists.infradead.org \
    --cc=rafael@kernel.org \
    --cc=robh+dt@kernel.org \
    --cc=zajec5@gmail.com \
    /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

all inboxes | Powered by JetHome®