Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp2337127pxb; Thu, 11 Feb 2021 09:47:50 -0800 (PST) X-Google-Smtp-Source: ABdhPJxiQPX08Mzzuzxv+4Ewf3Ygb/aE+HqnkKjqGPLEz61uu9G3iPJVuhAvoj27UxCXUseTJL9B X-Received: by 2002:a05:6402:424a:: with SMTP id g10mr9328304edb.236.1613065670165; Thu, 11 Feb 2021 09:47:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1613065670; cv=none; d=google.com; s=arc-20160816; b=a1s22GZB7qCndIALlfyXBdX0y8+kUZwmVd8V6Oe4iO/KCsJe+y9COrkSJa84dSTWw3 GUf0iixKZ9EsBNGBYyue2BHKQwC/pEq3A2+ohDX5+EkAYOQyA86xcqGKqGOVE0YJBmxX CLy6k+IGkuuVw59bqWOTABXkj1bINcm0ZGxbgzHrOghVuQY8Zscg53iwC0YWHSsvw5Ot kG5Iqj7Frs9t9s2/9NndRnTP1xBBWsbgt/76nDOZCdyQpA4WDWUzQD98Sur72K7AR+na nTd/UMtv136Bd00inUF95HAVtYAmu7owFCnfhAn7yc27lQOsw4obOwXOkX1IqUFswZaa 0xRw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject; bh=G0kRREPJLiUooHv8qY7roTWDAvhWKZWReyq/wCuDvcM=; b=brmYnnUg2/Rj0LVrPQVCfRT71D/iqIZcq6gov/4Ec07hRGm8vus9dlCfXtZTRmjH+Y 7KsBAIZlEZ+2VNq8cLgXLANGNG9v+Muvx/JoJ/np6nVIyvmBkyZ+BaMu614ndCwdSEwF 70lY03Vxn6660yP1hwGx7rwusMpswkyamAu+frV00NvsFAx1l0/g1cXXS/xJMcVrDc2a fsA85I3xGH0A62RnqolrAGXRAqAWmnbmmLiEhITwttgcrAiUl/7tNNPtoSvfVbW5vmWu XOVQ+kzprWEqJWWsksfV0BB4Rz7ysP6Yl7UNOqq+lBaeTlIHSLeDq2aYOL8ouWUhvSzv m2bg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id cx13si3966780edb.500.2021.02.11.09.47.26; Thu, 11 Feb 2021 09:47:50 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232515AbhBKRp2 (ORCPT + 99 others); Thu, 11 Feb 2021 12:45:28 -0500 Received: from mout.kundenserver.de ([212.227.126.130]:57915 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231138AbhBKRDw (ORCPT ); Thu, 11 Feb 2021 12:03:52 -0500 Received: from [192.168.1.155] ([95.114.27.115]) by mrelayeu.kundenserver.de (mreue009 [212.227.15.167]) with ESMTPSA (Nemesis) id 1Mf0Je-1lqkp01DlC-00gYWj; Thu, 11 Feb 2021 18:01:12 +0100 Subject: Re: RFC: oftree based setup of composite board devices To: Andy Shevchenko Cc: "Enrico Weigelt, metux IT consult" , Linux Kernel Mailing List , "Rafael J. Wysocki" , Linus Walleij , Bartosz Golaszewski , Rob Herring , Frank Rowand , Pantelis Antoniou , "open list:GPIO SUBSYSTEM" , devicetree References: <20210208222203.22335-1-info@metux.net> <1b92deea-cf6d-7eca-197f-b12456279890@metux.net> From: "Enrico Weigelt, metux IT consult" Message-ID: Date: Thu, 11 Feb 2021 18:01:11 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.7.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: tl Content-Transfer-Encoding: 8bit X-Provags-ID: V03:K1:mSMdZII7B/L5K2vNbMMBbOi186sVVNTPZWRXD+rGUPifstgIhqX mbp4DOAf3sOPrv/sAJ+eEjU2gs3+wy+1oM23u5HiuahwM5L2TaMX234+swtoM1JUa987js1 JIY4Kb2XhC0cs9ey6NtNHG+Wl+AbAAVOSupkPNFz2Sbf/FHB3a0RsqHtfWQfQBxIWJJ+CLY rrX8IrRMnqWoUh9LSPxDw== X-Spam-Flag: NO X-UI-Out-Filterresults: notjunk:1;V03:K0:H6wFMNih/84=:LmtpXXihpqFcKAZQwFPgib B2iC6LP7KojdCbUy/la9cRTd/OUQ71mR+mCswI3BIir6CvQ4ANG23f2KRxU6koVRXa2ZsBGQA 0dvKvoN5M0BvCcQXdoW3GNv1+j6RYspIvfLRrfWRCoA/jVC5TcjB5z4txlFQwCi2cw1DPdqmg 4ODIwj//TJvRxKJjYgQ3rSpJSr7N/ZpvSUJdOEfEcj6ToguijOV5AL9aT/qkPhz4QplR6Rh3h 0EcTx8/9W9XTHvLMhkbEekOkCsWjzO0tGxgDx8XtghWtwlCtYheLvrzSifapjF/bwekpiBD7O a3VEKtdR9QOC9RQQ3hmELy7vnwBVh6/DvWVF4u6PzaTf9ZCibgRwQ5ESEK88GNE5L7IwaFJBp pPToAmyn7DcT36CYkUe9HKDutMqAVpWYYnO8swuh9T1xmt+NhVN4UWHBabhkU Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 11.02.21 12:41, Andy Shevchenko wrote: Hi, > On Thu, Feb 11, 2021 at 1:15 PM Enrico Weigelt, metux IT consult > wrote: >> On 10.02.21 11:30, Andy Shevchenko wrote: > >>>> Use cases are boards with non-oftree firmware (ACPI, etc) where certain >>>> platform devices can't be directly enumerated via firmware. Traditionally >>>> we had to write board specific drivers that check for board identification >>>> (DMI strings, etc), then initialize the actual devices and their links >>>> (eg. gpio<->leds/buttons, ...). Often this can be expressed just by DT. >>> >>> In ACPI we support DT compatible strings, and we support overlays for >>> a long time. Would it work for you? >> >> please tell me more, how ACPI and DT can already work together ? > > It's all in documentation. > > https://www.kernel.org/doc/html/latest/firmware-guide/acpi/enumeration.html#device-tree-namespace-link-device-id Thanks, but I'm still unsure how this helps me. I'm not intending to touch any firmware (and expect people in the field flashing new fw). I have to live with what we find in the field (otherwise I'd just write omplete DTs for the corresponding boards and throw out ACPI :p) > https://www.kernel.org/doc/html/latest/admin-guide/acpi/ssdt-overlays.html Are you suggesting I should load SSDT overlays at runtime (from userland ?) instead of using DT ? > Please, please, read documentation beforehand! I actually did read that documentation, but unfortunately it doesn't tell me how to use additional DTs on ACPI systems. >> You already know my apu board driver - that's my first example usecase. > > Sorry, but I forgot about it. Can you summarize what is your use case > that really needs so intrusive and hard work? The current APU2/3/4 driver is pretty much fine (except that possibly some more bios-version specific quirks might be needed). It basically just instantiates a bunch of other devices (gpio, led, input, ...) and connects them. All of that (except for the DMI match table) already can be easily expressed in DT, so this calls for a generalization. At that point I tried to achieve the following goals: * a generic mechanism for detecting boards (and later pci cards, usb dongles, etc) and probing the devices from the corresponding DT * have everything that makes up an individual board in one DT(S) * ability to blacklist (kick out) specific devices already probed via ACPI, so they don't conflict. (*1) >> * match rules shall be inside the DTS >> * future match rules shall also check for bios versions etc >> * adding new boards shall be possible by just adding another DTS to >> the tree (not a whole module) >> * supporting several board variants (w/ small differences) by one DTS >> * sometimes existing devices (eg. enumerated by acpi) need to be kicked >> out (buggy firmware, ...) >> * can't rely on any special userland tweaks > > Show an example why either of the above is needed in your case and > tell what is the exact issue. In the specific APU case (note that my proposal is a generic mechanism for a whole class of similar usecases), *some* bios versions already enumerate *some* gpios, later versions already enumerate some LEDs but different naming than the driver's, etc., etc. (at time of writing the driver, apu bios didn't support any of that). For preventing conflicts and consistency between all bios versions, it's IMHO better to just remove the conflicting devices if they're enumerated by bios. > Yes, that driver represents hardware. MFD already has some support for > composite devices. We have the auxiliary bus for some other > interesting cases, etc. Depending on the hardware in question you have > to choose a proper bus and locking (access synchronisation) schema. Yes, but similar to the apu case, I'd like to be able describe those devices just by a DT (instead of lots of C code). >> Those things could be expressed via DTS, so we don't need to write >> individual drivers anymore. > > It seems you are trying to create something like "universal quirk". > Brave idea, but from my experience a fiasco is what will be out of it. > The hardware has a lot of different issues and levels of issues and it > is close to impossible to describe everything possible and predict the > future... Good luck! Dont worry, I don't try create some one-fits-all-solution. It's just for a specific class of use cases, where we need additional devices that can't be (reliably) enumerated via firmware or buses. >> * need to split the information into several places (instead of having >> all in one DTS) >> * need to have one separate module board, or merge the dmi tables. > > Have no idea what you are talking about here, sorry. Well, for now I have the matching criteria (DMI strings) within the DT - don't need any additional code per board. For using the existing mechanisms, I would need to move that out into a separate .c file, something I'd like to avoid. >> My goal is having everything that describes a board into one DTS >> (source) file. > > I'm confused, you are talking about non-DT platforms in the > cover-letter and now you are talking about DTS. AFAIK DTS allows you > to put everything in one source. Nope, I'm using DT *in addition* to firmware data (ACPI), for things that arent't properly described by firmware. The idea goes like this: * walk through all available board descriptions (builtin dtbs) * check whether board matches critiera given in the DT * if match: * kick out blacklisted devices * populate devices from the DT The idea is just not having to write lots of C code for cases like the apu boards anymore, but reuse existing DT infrastructure for that and also heavily reduce code size this way (for apu case, the dtb is around 2kb, while the existing driver is around 17kb) --mtx -- --- Hinweis: unverschlüsselte E-Mails können leicht abgehört und manipuliert werden ! Für eine vertrauliche Kommunikation senden Sie bitte ihren GPG/PGP-Schlüssel zu. --- Enrico Weigelt, metux IT consult Free software and Linux embedded engineering info@metux.net -- +49-151-27565287