Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.5 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 117BFC433C1 for ; Tue, 30 Mar 2021 08:18:14 +0000 (UTC) Received: from lists.ozlabs.org (lists.ozlabs.org [112.213.38.117]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 485296196C for ; Tue, 30 Mar 2021 08:18:13 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 485296196C Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=bewilderbeest.net Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=openbmc-bounces+openbmc=archiver.kernel.org@lists.ozlabs.org Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4F8j4g59hyz2yjc for ; Tue, 30 Mar 2021 19:18:11 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=bewilderbeest.net header.i=@bewilderbeest.net header.a=rsa-sha256 header.s=thorn header.b=BvQQY0nh; dkim-atps=neutral Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=bewilderbeest.net (client-ip=71.19.156.171; helo=thorn.bewilderbeest.net; envelope-from=zev@bewilderbeest.net; receiver=) Authentication-Results: lists.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=bewilderbeest.net header.i=@bewilderbeest.net header.a=rsa-sha256 header.s=thorn header.b=BvQQY0nh; dkim-atps=neutral Received: from thorn.bewilderbeest.net (thorn.bewilderbeest.net [71.19.156.171]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4F8j4C5jbbz2yRW for ; Tue, 30 Mar 2021 19:17:46 +1100 (AEDT) Received: from hatter.bewilderbeest.net (unknown [IPv6:2600:6c44:7f:ba20::7c6]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: zev) by thorn.bewilderbeest.net (Postfix) with ESMTPSA id 7C61B167; Tue, 30 Mar 2021 01:17:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bewilderbeest.net; s=thorn; t=1617092264; bh=VvcznrS1rjWpiKZiP+i/h/lLrJJWsyYrC/wQiX5Rzo4=; h=Date:From:To:Cc:Subject:From; b=BvQQY0nhA/SRfdxkuOha5Hqtzy/xI4EkYwYD4wGb6h1Mnr36FErF3EKR87j1QcKEE OfjIjzj2mchfpXLz3sFDwclz/oC+MrmjuSG2o+lST0qzZNW514NiyHEKO27ZUjDkEP KC2XR1G41bxVQLgDZW+0MzAhJN2yShvPd2ig/Re0= Date: Tue, 30 Mar 2021 03:17:41 -0500 From: Zev Weiss To: Guenter Roeck , Jean Delvare , linux-hwmon@vger.kernel.org Subject: Enabling pmbus power control Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline X-BeenThere: openbmc@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development list for OpenBMC List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Andrew Jeffery , openbmc@lists.ozlabs.org, Mark Brown , Liam Girdwood , linux-kernel@vger.kernel.org Errors-To: openbmc-bounces+openbmc=archiver.kernel.org@lists.ozlabs.org Sender: "openbmc" Hello, I'm working on a board that has a handful of LM25066 PMICs controlling the power supply to various devices, and I'd like to have both the existing hwmon sensor functionality as well as userspace power on/off control, which does not currently seem to be available (other than via 'i2cset -f', which I'd of course prefer to avoid). I've drafted up a couple possible versions of this, and was hoping to get some opinions on the appropriate overall approach. One option is to add a read-write sysfs attribute to the existing hwmon directory (current incarnation of the patch: https://thorn.bewilderbeest.net/~zev/patches/pmbus-statectl.patch). This bears a vague resemblance to a patch that was rejected a couple years ago (https://lore.kernel.org/linux-hwmon/20190417161817.GA13109@roeck-us.net/), but is different enough that I wonder if it might potentially be tolerable? (It exposes significantly less, for one thing.) The other approach involves layering a regulator device over the pmbus device as is done in the LTC2978 driver, and then putting a reg-userspace-consumer on top of that (current patch: https://thorn.bewilderbeest.net/~zev/patches/pmbus-ureg.patch). My first attempt at this ran into problems with all the reg-userspace-consumer instances getting attached to the first regulator device, I think due to all of the regulators ending up under the same name in the global namespace of regulator_map_list. I worked around that by adding an ID counter to produce a unique name for each, though that changes device names in userspace-visible ways that I'm not sure would be considered OK for backwards compatibility. (I'm not familiar enough with the regulator code to know if there's a better way of fixing that problem.) The #if-ing to keep it behind a Kconfig option is also kind of ugly as it stands. The first version seems simpler to me (and avoids the rather more cumbersome sysfs paths the second one produces, for what that's worth). I think the second is (at least structurally) perhaps more aligned with what Guenter was saying in the previous discussion linked above, though. Does anyone have any advice on the best way to proceed with this? If the reg-userspace-consumer approach is the preferred route, suggestions on a better fix for the name collision problem would be welcome. Thanks, Zev