Received: by 2002:ab2:6857:0:b0:1ef:ffd0:ce49 with SMTP id l23csp416911lqp; Thu, 21 Mar 2024 05:32:02 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWK1Wc1IjfPmkBfWm2bH/79LR7LUQYXH1XI/AGUqRx/vgfYw8nnbhyIIhJgkc/b5rG/tbvIuHEMgLzOFrCTBjLe9jpIhHt8klfktQj4Gw== X-Google-Smtp-Source: AGHT+IHxqdUvrxpPphv+SkYcr1bt8PXMNYnpeq7IAY8le6HRcTzsK3rE/f0z4t23MGye+UdDGrwU X-Received: by 2002:a17:90a:bb0c:b0:2a0:260:5a08 with SMTP id u12-20020a17090abb0c00b002a002605a08mr4396917pjr.31.1711024321839; Thu, 21 Mar 2024 05:32:01 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711024321; cv=pass; d=google.com; s=arc-20160816; b=PKyV8tYZ3BX/eZp3rAHNZDuZpoDH6TN1tdHp2Vva1bwOsUelEuMYmgsB5XdzhdFaIg +Z1ubA0SyL6DyrewCnLV1dHlRJ7OBDBpUF1LDeSr3e54a7F3jCMwIbWprkrXcY6ywtH2 TOvkaCC39/NACUGeqa7l3F0XuuHEldqWqF+bQKXqWVvXfBQZFRPb2tf/pJe6zB7CAt7T 5FJrA45I3801DfGkXTMi3IZfttzuPizuJT8X5xgIdAr2DCMHdFaz82hmhK5V9sa+V0FT rp/K+EsIYV7LbvTYxnTVtfTbe5zeTu5Wlntna08vXa5fmf+yUv94FeCmgxRpxW77+1U3 RMJg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=7eF1fjFD8b1hoXdzkySVAu3zItwsB5Bim4j2q9JOIDA=; fh=RaBP3jexsx7FfAAm5Vpbq6kQEAMS6befJZAby85iU+4=; b=KBQ/OCfb4NQrL1Mpvnobhl5Wd69lVuLeaNvqgquXdweePNXfKe1Ern79gHUgis3sz1 XNkpC8idTjzqHpezVpGq6b/LN2i/JpkK3LTyym9KnB7imp3L+90225jkmx+YWPCit2/l tLPwS1vLH7E7Jh57RsNBHd2gCimbWhT/LDokhVHcVu0jvxPqJ+nh4pO1PORvcwBonIoT IFqbTuidkteASo1L0zQv57UKbF8Ml/t4wDvadjqsWx6/kr5KKZB5Y3JnkAaX+UJ0dke+ hRRnB8C495nn+d+fcbTeN7IjEQ+pqP4UlPV/+hPswWkHV/hGW5WOd1jnjJ8eBRjttKjk px2Q==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@lunn.ch header.s=20171124 header.b=6Z0m1mDP; arc=pass (i=1 spf=pass spfdomain=lunn.ch dkim=pass dkdomain=lunn.ch dmarc=pass fromdomain=lunn.ch); spf=pass (google.com: domain of linux-kernel+bounces-110035-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-110035-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=lunn.ch Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id y12-20020a17090a154c00b0029b811fd314si3339718pja.174.2024.03.21.05.32.01 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Mar 2024 05:32:01 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-110035-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@lunn.ch header.s=20171124 header.b=6Z0m1mDP; arc=pass (i=1 spf=pass spfdomain=lunn.ch dkim=pass dkdomain=lunn.ch dmarc=pass fromdomain=lunn.ch); spf=pass (google.com: domain of linux-kernel+bounces-110035-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-110035-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=lunn.ch Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 833D5284C24 for ; Thu, 21 Mar 2024 12:32:01 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4DE1C7E560; Thu, 21 Mar 2024 12:31:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=lunn.ch header.i=@lunn.ch header.b="6Z0m1mDP" Received: from vps0.lunn.ch (vps0.lunn.ch [156.67.10.101]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9D6C37CF1E; Thu, 21 Mar 2024 12:31:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=156.67.10.101 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711024311; cv=none; b=Z4YN8PjtkaYpXSRf8SQyJOc/4S4XUzdRGBxedJdFJxx7uoolaOpg/vDYISdh5F7yoVA1KXdkxVeH0XZNwCKYX9TcWOhOHfWHeSJDhh06R1YultWjY5ChtTcTKHktejq4X5bCvCTN6ct4FBDJ8TWynb+DhR2QaBFI75pJgCT77/U= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711024311; c=relaxed/simple; bh=hhH6q7lgeaexqnAbcESxPxh8L7fYeDX7OFGYXof2HDg=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=ZvQYpXaJA/3+q41RD3yZNltsVZdkI2I+kYn2BxBDUxqAo6fV9F8IOYK+b2gE2y6Vc4jLblTF0J2Gn0W8EPL2K78bkdhfTXFon20Ii0rICv85TMnFzVghQtXxYZtVU637JHNhi66+8UQ2L/DV4AdBIz2YWrn/9HVk/0E3veBXWJQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=lunn.ch; spf=pass smtp.mailfrom=lunn.ch; dkim=pass (1024-bit key) header.d=lunn.ch header.i=@lunn.ch header.b=6Z0m1mDP; arc=none smtp.client-ip=156.67.10.101 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=lunn.ch Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=lunn.ch DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lunn.ch; s=20171124; h=In-Reply-To:Content-Disposition:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:From:Sender:Reply-To:Subject: Date:Message-ID:To:Cc:MIME-Version:Content-Type:Content-Transfer-Encoding: Content-ID:Content-Description:Content-Disposition:In-Reply-To:References; bh=7eF1fjFD8b1hoXdzkySVAu3zItwsB5Bim4j2q9JOIDA=; b=6Z0m1mDPyyueTqLxdWS6gUk+ES GTFeLVPKsY53YKsups+CmRMQakV68UDGufeLz0mUTEZe50FkEJN0bBfQFdnGqd79CeQ5qVeI4e2JA 5rTjemYUk8noCTKti5XyMyP3wqFbjolD/BeBExKlafFONOx9APw/WNQKzULor7NJvWpg=; Received: from andrew by vps0.lunn.ch with local (Exim 4.94.2) (envelope-from ) id 1rnHa1-00AsBh-67; Thu, 21 Mar 2024 13:31:33 +0100 Date: Thu, 21 Mar 2024 13:31:33 +0100 From: Andrew Lunn To: Vaishnav Achath Cc: Ayush Singh , Michael Walle , Krzysztof Kozlowski , open list , jkridner@beagleboard.org, robertcnelson@beagleboard.org, lorforlinux@beagleboard.org, Rob Herring , Krzysztof Kozlowski , Conor Dooley , Nishanth Menon , Vignesh Raghavendra , Tero Kristo , Derek Kiernan , Dragan Cvetic , Arnd Bergmann , Greg Kroah-Hartman , Mark Brown , Johan Hovold , Alex Elder , "open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS" , "moderated list:ARM/TEXAS INSTRUMENTS K3 ARCHITECTURE" , "open list:SPI SUBSYSTEM" , "moderated list:GREYBUS SUBSYSTEM" , Vaishnav M A Subject: Re: [PATCH v4 1/5] dt-bindings: misc: Add mikrobus-connector Message-ID: References: <5a9b1cd9-05ec-4606-92b6-eadbc7af6202@gmail.com> <81ec4156-8758-406e-876b-5acf13951d09@gmail.com> <2eec6437-dd11-408d-9bcb-92ba2bee4487@ti.com> <28c995cb-1660-435f-9ee4-1195439231f0@gmail.com> <9ea69bd3-977d-442e-aacc-3c819b1a5630@ti.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <9ea69bd3-977d-442e-aacc-3c819b1a5630@ti.com> On Thu, Mar 21, 2024 at 01:05:14PM +0530, Vaishnav Achath wrote: > Hi Andrew, > > On 21/03/24 00:14, Andrew Lunn wrote: > > On Wed, Mar 20, 2024 at 10:09:05PM +0530, Ayush Singh wrote: > > > On 3/20/24 01:02, Andrew Lunn wrote: > > > > > > > > Yes, after discussion with Vaishnav and trying to brainstorm some way to do > > > > > the same thing with dt overlays, it seems that trying to use dt overlays > > > > > will mean need to have completely separate implementation of mikroBUS for > > > > > local ports and mikroBUS over greybus. > > > > Could you explain why please? > > > > > > > > Are greybus I2C bus masters different from physical I2C bus masters? > > > > Are greybus SPI bus masters different from physical SPI bus masters? > > > > > > Well, they are virtual, so they are not declared in the device tree. I have > > > linked the greybus i2c implementation. It basically allocates an i2c_adpater > > > and then adds it using `i2c_add_adapter` method. This adapter can then be > > > passed to say mikroBUS driver where it can be used as a normal i2c_adapter, > > > and we can register the device to it. > > > > Being virtual does not really stop it being added to the DT. > > > > I'm making this all up, but i assume it will look something like this: > > > > greybus@42 { > > compatible = "acme,greybus"; > > reg = <0x42 0x100>; > > > > This would represent the greybus host controller. > > > > module@0 { > > reg = <0>; > > > > This would represent a module discovered on the bus. I assume there is > > some sort of addressing? The greybus core code dynamically creates the > > node in DT to describe the modules it has discovered. This is not too > > different to USB. You can already describe USB devices in DT, but the > > assumption is you know they exists, e.g. because they are hard wired, > > not hot-plugable. The USB core will associate the USB device with the > > node in DT. But actually creating a node in DT is not too big a jump. > > > > interface@0 { > > compatible = "greybus,i2c"; > > reg = <0>; > > } > > interface@1 { > > compatible = "greybus,spi"; > > reg = <1>; > > } > > interface@10 { > > compatible = "greybus,gpio"; > > reg = <10>; > > } > > > > It can then enumerate the interfaces on the module, and create the I2C > > node, SPI bus node, the gpio controller etc. Again, the greybus core > > can add nodes to DT to described the discovered hardware, and > > associate them to the linux devices which are created. > > > > This proposal looks great and would be the ideal solution, but we met with > few challenges when initially trying to implement something like this and > had to drop and take the route with minimal development effort to just > instantiate mikroBUS devices. > > From what we understand, you are recommending to change the manifest > description format used by greybus to device tree and also add of_bus > support for greybus - now this will not only solve instantiating mikrobus > devices on greybus but even complex devices on greybus making it a robust > solution and using standard tools and support DT offers. I would not discard the manifest. It exists, it appears to be used by a lot of devices. So use it. But consider it an 'intermediate representation'. Take it and transform it to DT. Looking at: https://libstock.mikroe.com/projects/view/5435/clickid there appears to be a name, and hardware revision in the manifest. Convert that to a string. Run a checksum over the rest of the manifest, and append that to the string. You can then look in /lib/firmware for a DT representation which matches. > However we have a few doubts: > * For USB or PCIe, to add OF device tree support the parent devices are > physically present, for example USB device is a child node of USB controller > (physically description available in a SoC DT) and USB interfaces are child > of USB devices, how would that hierarchy look for greybus devices? So DT support for USB, serial and PCIe devices already exists. When the core enumerates a PCIe or USB bus, it looks in the DT blob for the vendor:product ID, and associates any node it finds with the device. It is not used very often, but if you search the .dts files, you can find examples. > Would it be > USB/UART/transport controller -> AP Bridge host controller -> Module -> > interface -> bundle -> CPort ? That is for you to decide. I don't know the architecture well enough. It is rather old, but: https://lwn.net/Articles/715955/ There is a diagram of the sysfs tree, which looks pretty similar to what you say above. What is however missing from the diagram is the Linux devices themselves. Where do the I2C bus, the SPI bus, the GPIO controller etc appear in the tree? Maybe look at PCI and USB. Does the device tree representation include all the bridges and hubs etc. Or does it simply the representation? You need something to represent the controller. You need modules. Do you need the details of interface & bundle and cport? Could you represent them as an address tuple, and just have the devices under module? > When this mikrobus driver was initially implemented we could not think of > such an approach as the SVC and Control functionality were implemented in > userspace with gbridge ( https://github.com/anobli/gbridge ) with a netlink > interface to kernel greybus, but today there are references to do it > completely in kernel ( drivers/greybus/gb-beagleplay.c) and your proposal is > implementable. Does gb-beagleplay.c work together with the code in staging? It looks like the GPIO controller, I2C controller, SPI controller, etc are still in GregKH "Tree of crap". I don't think it is wise to build on top of something in staging. So you probably need to spend time to cleanup that code and moving it into the mainline proper. As you do that, you could add the code needed to dynamically add nodes to device tree. Andrew