From patchwork Sun Mar 17 19:37:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ayush Singh X-Patchwork-Id: 13594828 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id A809BC54E60 for ; Sun, 17 Mar 2024 19:38:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=W9kltcFJlOvl5Eiz1zCEL33OwRjygg9ksP7fTVIIcB8=; b=n8zNX5d7uMDst/ AY62ydYJ0wQBtwoCa7KAn+VJWH7zyWH0TZDZNFzPdhFulX7gjp2I7FmOFTJkc/oP5RxTUfX5y2DcG HWwgxK42nHn6fqrhFkUteV6ErQubawKZ7Zwk5Rjt8DaPlmYiw4+itKY2z+5UszenT2ov0BPoEHOqE wg+JV2e0tySm6Isdl7F+V26Aw7kUk/0tR/j9Hq5xSyJTBbcgCAhP+mAo3JLGc09jzsJ8D32K+/7LH 6M3NrXkbhJcPJJ0WmwG2YSTJAnGr+N/zVBgyltdxjMVu6GplD7s7khQV9IT1/mgqIiQ03VFN+bJXt sVoJpIn/nagO0xn69yag==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rlwL3-00000006E8q-34G8; Sun, 17 Mar 2024 19:38:34 +0000 Received: from mail-pf1-x42e.google.com ([2607:f8b0:4864:20::42e]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rlwKy-00000006E5W-0iGo for linux-arm-kernel@lists.infradead.org; Sun, 17 Mar 2024 19:38:30 +0000 Received: by mail-pf1-x42e.google.com with SMTP id d2e1a72fcca58-6e7224cb3f2so219469b3a.1 for ; Sun, 17 Mar 2024 12:38:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1710704307; x=1711309107; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=vO9G69iyqVQbbyIAUNqe8gLJ4ujwClNwkyBvzcpz7K4=; b=dA2Q0zNXz1867vcyBHLMpo4dgnHEY3NniJh4ilL04FLW+DGxwTfIxFQ9Mhx1S0DP+8 GrIjkYIuIeWXU2+Eh8EDFUhiKOfbCh5t2TAOU61rrAZ7h6VGu+wfBrb1BE7/0zPptaOr bcADD68LteDeUUImUsNYZtg3VwBTjmxh7dggLdn8vvjfjZ40qkyMjoKlCCG3w3bk9tQg mj1UPzv+nodr18lR9GpT0ttkxN+vbZEa5tCC+RGQL611wy1EmxsHcZv5dtMYpyN++Ui1 S4AqwXaYODWFvjzULfJ4Tb7FUG5itUC/IhHpGvSEcJAZJQAPKm7ad+au2BdceWPi4A42 KihA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710704307; x=1711309107; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=vO9G69iyqVQbbyIAUNqe8gLJ4ujwClNwkyBvzcpz7K4=; b=Fd99q62J67dd6JSrxqxK/j9TGQXkDHu8w2QXUyNdeCe0K2aOm6Y/tVHfrQ0DRdLA5p Y+Q8JLfqgkQ7kLqRNUSn5Aer6sgxsFQXAK1L6sI0VIrEdvsEY04o3MwS5BtEuG990lgX J1qNxZAn3zTORnekhBi8Y2PUYDqvThvXF/uoXIqnKVTZh9XtXNt381E8KIsVWaQXOwIQ mLYhRl70iKvzqQRDmJ7UF0gASc8UKYHAuG/BdqrTGs0H/BN5drpCYIihgLasxsB7DIlb 2KPne1v/XcEzymQDTzPsywSg8t35TsLWE/b8zw78e3FGadmFvUBBiJPs2UFVLxRp/VxZ dJJQ== X-Forwarded-Encrypted: i=1; AJvYcCU2JYOeBh7JVQf2ftnCeeHmbmmryp/BXgKr7jrpnoNwydK21SmRXOoXCCvGYbTzbmS40VHrheZd2iFtiTRA3Eq508O0ZmIPHMC63DmV0iCkFkKBAiY= X-Gm-Message-State: AOJu0YyP9POAPnFy8t8hQI64qOqgorFouYSkCtRnOyamU1LEpWDt+6Zm 5UZX72Pp+9Gj251NEMLi5HvP4YiI1iDWwoUSZaBlvzAm86opVeE9 X-Google-Smtp-Source: AGHT+IHb5ZQG5AZs1yNwiaA+uHOH5JqdctbG/pUZFDyCNz6pl0xo2W10sE+uFQzu766SlSdKr8rJ2g== X-Received: by 2002:a17:90a:de93:b0:29d:fb99:7dcc with SMTP id n19-20020a17090ade9300b0029dfb997dccmr9795831pjv.18.1710704306906; Sun, 17 Mar 2024 12:38:26 -0700 (PDT) Received: from toolbox.iitism.net ([103.15.228.94]) by smtp.gmail.com with ESMTPSA id st6-20020a17090b1fc600b0029bbdc920besm6125995pjb.44.2024.03.17.12.38.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Mar 2024 12:38:26 -0700 (PDT) From: Ayush Singh To: linux-kernel@vger.kernel.org (open list) Cc: Ayush Singh , 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 , Vaishnav M A , Mark Brown , Johan Hovold , Alex Elder , devicetree@vger.kernel.org (open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS), linux-arm-kernel@lists.infradead.org (moderated list:ARM/TEXAS INSTRUMENTS K3 ARCHITECTURE), linux-spi@vger.kernel.org (open list:SPI SUBSYSTEM), greybus-dev@lists.linaro.org (moderated list:GREYBUS SUBSYSTEM), Vaishnav M A Subject: [PATCH v4 3/5] greybus: Add mikroBUS manifest types Date: Mon, 18 Mar 2024 01:07:11 +0530 Message-ID: <20240317193714.403132-4-ayushdevel1325@gmail.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240317193714.403132-1-ayushdevel1325@gmail.com> References: <20240317193714.403132-1-ayushdevel1325@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240317_123828_373580_83AABE76 X-CRM114-Status: GOOD ( 21.66 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DONOTMERGE mikroBUS addon boards allow using same mikroBUS connector for a wide range of peripherals. It is also possible for the addon board not to use all the pins in mikroBUS socket (marked by NC or Not Connected). This would require the need to create an almost new overlays for each permutation of the hardware. To overcome this, a manifest format based on Greybus manifest specification was created which allows describing mikroBUS addon boards. The reason for choosing greybus manifest for the identifier is that so far we discussed only about physical mikroBUS ports on the board, but we can also have mikroBUS ports on a remote microcontroller appearing on host over greybus and there a device tree overlay solution does not work as the standard identifier mechanism. The patch introduces 3 new greybus descriptor types: 1. mikrobus-descriptor: Is a fixed-length descriptor (12 bytes), and the manifest shall have precisely one mikroBUS descriptor. Each byte describes a configuration of the corresponding pin on the mikroBUS addon board in a clockwise direction starting from the PWM pin omitting power (VCC and ground) pins as same as the default state of the pin. There are mikroBUS addon boards that use some dedicated SPI, UART, PWM, and I2C pins as GPIO pins, so it is necessary to redefine the default pin configuration of that pins on the host system. Also, sometimes it is required the pull-up on the host pin for correct functionality 2. property-descriptor: Are used to pass named properties or named GPIOs to the host. The host system uses this information to properly configure specific board drivers by passing the properties and GPIO name. There can be multiple instances of property descriptors per add-on board manifest. 3. device-descriptor: Describes a device on the mikroBUS port. The device descriptor is a fixed-length descriptor, and there can be multiple instances of device descriptors in an add-on board manifest in cases where the add-on board presents more than one device to the host. New mikroBUS addon boards also sometimes contain a 1-wire EEPROM with the mikroBUS manifest, thus enabling plug and play support. I have also created PR to add mikrobus descriptors in Greybus spec and I think the old PR on manifesto by Vaishnav should also work. However, both of these repositories seem to be inactive. I am guessing the greybus mailing list can provide more information on how I should go about these. Here is a sample mikroBUS manifest: ``` ;; ; PRESSURE CLICK ; https://www.mikroe.com/pressure-click ; CONFIG_IIO_ST_PRESS ; ; Copyright 2020 BeagleBoard.org Foundation ; Copyright 2020 Texas Instruments ; [manifest-header] version-major = 0 version-minor = 1 [interface-descriptor] vendor-string-id = 1 product-string-id = 2 [string-descriptor 1] string = MIKROE [string-descriptor 2] string = Pressure [mikrobus-descriptor] pwm-state = 4 int-state = 1 rx-state = 7 tx-state = 7 scl-state = 6 sda-state = 6 mosi-state = 5 miso-state = 5 sck-state = 5 cs-state = 5 rst-state = 2 an-state = 1 [device-descriptor 1] driver-string-id = 3 protocol = 0x3 reg = 0x5d [string-descriptor 3] string = lps331ap ``` Link: https://www.mikroe.com/clickid ClickID Link: https://docs.beagleboard.org/latest/projects/beagleconnect/index.html beagleconnect Link: https://github.com/projectara/greybus-spec Greybus Spec Link: https://github.com/projectara/greybus-spec/pull/4 Greybus Spec PR Link: https://github.com/projectara/manifesto/pull/2 manifesto PR Co-developed-by: Vaishnav M A Signed-off-by: Vaishnav M A Signed-off-by: Ayush Singh --- include/linux/greybus/greybus_manifest.h | 49 ++++++++++++++++++++++++ 1 file changed, 49 insertions(+) diff --git a/include/linux/greybus/greybus_manifest.h b/include/linux/greybus/greybus_manifest.h index bef9eb2093e9..83241e19d9b3 100644 --- a/include/linux/greybus/greybus_manifest.h +++ b/include/linux/greybus/greybus_manifest.h @@ -23,6 +23,9 @@ enum greybus_descriptor_type { GREYBUS_TYPE_STRING = 0x02, GREYBUS_TYPE_BUNDLE = 0x03, GREYBUS_TYPE_CPORT = 0x04, + GREYBUS_TYPE_MIKROBUS = 0x05, + GREYBUS_TYPE_PROPERTY = 0x06, + GREYBUS_TYPE_DEVICE = 0x07, }; enum greybus_protocol { @@ -151,6 +154,49 @@ struct greybus_descriptor_cport { __u8 protocol_id; /* enum greybus_protocol */ } __packed; +/* + * A mikrobus descriptor is used to describe the details + * about the bus ocnfiguration for the add-on board + * connected to the mikrobus port. + */ +struct greybus_descriptor_mikrobus { + __u8 pin_state[12]; +} __packed; + +/* + * A property descriptor is used to pass named properties + * to device drivers through the unified device properties + * interface under linux/property.h + */ +struct greybus_descriptor_property { + __u8 length; + __u8 id; + __u8 propname_stringid; + __u8 type; + __u8 value[]; +} __packed; + +/* + * A device descriptor is used to describe the + * details required by a add-on board device + * driver. + */ +struct greybus_descriptor_device { + __u8 id; + __u8 driver_stringid; + __u8 protocol; + __u8 reg; + __le32 max_speed_hz; + __u8 irq; + __u8 irq_type; + __u8 mode; + __u8 prop_link; + __u8 gpio_link; + __u8 reg_link; + __u8 clock_link; + __u8 pad[1]; +} __packed; + struct greybus_descriptor_header { __le16 size; __u8 type; /* enum greybus_descriptor_type */ @@ -164,6 +210,9 @@ struct greybus_descriptor { struct greybus_descriptor_interface interface; struct greybus_descriptor_bundle bundle; struct greybus_descriptor_cport cport; + struct greybus_descriptor_mikrobus mikrobus; + struct greybus_descriptor_property property; + struct greybus_descriptor_device device; }; } __packed;