Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp515806iob; Wed, 4 May 2022 01:48:32 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw5EpHLpikvfpXXQ2YSbVdMtImoxHLbMBUMzJc3Law7tB6fGPW5Yd6uqbeBlrr2EMfJ2p4p X-Received: by 2002:a17:902:f2ca:b0:15d:180d:704 with SMTP id h10-20020a170902f2ca00b0015d180d0704mr20169972plc.102.1651654112402; Wed, 04 May 2022 01:48:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1651654112; cv=none; d=google.com; s=arc-20160816; b=rtJWf8kB6AsYyiOFLLQ4223clV1JsgzQuMqy1ydaKOfy0fV9takxEHLQ+STEVlWdF/ HYclUyc0qkxRCQrz2KE9ruGssF5NlFNBxHlpu7mVPG6vmcHZA/wNDJBAhnmJgNLbBjI4 P38LhC95AbZhBLbjBWH4lqx0Drsx8Ansr7bm8TdOv9rNjh9ztW1O+306ORPpU3UN3gv+ SIl98wUJ6075h53CoojgyFg3y52kYuWUf3Zkan9pxB76dXWiaLKtTXpmlE331FLPYamU W8AFOMs/Ax+ePnhV4xWMyFqKtHYjdprMd18OrNwKQ5ehxFLmyTWfRrWN976JU3XB9DkS Q93Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=u1be6Hsy9QkoZoQsBwtNHnw+57iMhXxgiUyN9o/iLGk=; b=s3aW8H7hOpq8cBI9t3w1xPvHGlySWZr24bXS09rmZoVXQe+b8OEUqmHJmSoZHuCc5P umu9OkVlgQlgHAzkhs+G9SaBvTdNMHaIPImHJnY0j6RAudWXOyWb4lUVQ1rlS7FSxD8K Um9OkDQMV5MbsXEBAYPd7s+ECWwXHAUef6DT7ltyasZOLbzkn2z1GZLKUZThKcL5Cftq HOw4zsWo6p32olrpKXPToSP/rxhdUw9/Rf09LX0fQGBJb3tsMa9gIrqF7XLsHEvk4FOY Z4yNqvt1AAPw80SgacA0bpXvaaJDX9FO7tIBrDsnv2W2LtYKhCkmqzHhklYo+lij4OuL RIlg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bewilderbeest.net header.s=thorn header.b=hZUIcqjn; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=bewilderbeest.net Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id x62-20020a638641000000b003c157112368si15724929pgd.609.2022.05.04.01.48.16; Wed, 04 May 2022 01:48:32 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@bewilderbeest.net header.s=thorn header.b=hZUIcqjn; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=bewilderbeest.net Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345063AbiEDGyf (ORCPT + 99 others); Wed, 4 May 2022 02:54:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52734 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345049AbiEDGyd (ORCPT ); Wed, 4 May 2022 02:54:33 -0400 Received: from thorn.bewilderbeest.net (thorn.bewilderbeest.net [71.19.156.171]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4AD34205F9; Tue, 3 May 2022 23:50:58 -0700 (PDT) Received: from hatter.bewilderbeest.net (174-21-163-222.tukw.qwest.net [174.21.163.222]) (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 9CB18169; Tue, 3 May 2022 23:50:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bewilderbeest.net; s=thorn; t=1651647057; bh=u1be6Hsy9QkoZoQsBwtNHnw+57iMhXxgiUyN9o/iLGk=; h=From:To:Cc:Subject:Date:From; b=hZUIcqjnEATs2o08eIaqBvgjwRtC90gHuN6pS3KxQax0Udv7Reuh5Mf6lIirwPSoZ 6jtYdDcA0BoGGHgNa914YenMHmE8QgFFAVBBG/vEF4b9F+WJP177UBbq8VFThWoUvS QnXR9mMn/9fGYHALpPYdtBfPNEYgZngnmDHzX/1M= From: Zev Weiss To: Mark Brown , Liam Girdwood Cc: Zev Weiss , linux-kernel@vger.kernel.org, Greg Kroah-Hartman , Rob Herring , Krzysztof Kozlowski , devicetree@vger.kernel.org, openbmc@lists.ozlabs.org Subject: [PATCH 0/6] regulator: core: Add support for external outputs Date: Tue, 3 May 2022 23:50:35 -0700 Message-Id: <20220504065041.6718-1-zev@bewilderbeest.net> X-Mailer: git-send-email 2.36.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hello, This patch series is a new approach at implementing some functionality I previously attempted as a separate driver in drivers/misc [0], but I think (as suggested by Greg in that thread) ultimately makes more sense being built into the regulator subsystem. The hardware arrangement essentially amounts to a regulator whose output doesn't supply any devices within the system, but instead simply feeds a "dumb" external output -- picture a typical power distribution unit (PDU), but with DC outputs instead of AC. (The specific system I'm targeting at the moment is the Delta AHE-50DC Open19 power shelf [1], for which I'm working on a port of OpenBMC.) Supporting this doesn't require much in the way of new functionality, just some plumbing so that userspace (typically a human operator manually switching outlets on and off) can access the necessary bits of the regulator subsystem, and some DT bindings to describe this sort of setup. The DT bindings changes (patches 1 and 2) consist of a boolean regulator property to mark it as supplying an external output, and a reg-external-output binding to act as a downstream device representing that output. The redundancy between the two maybe isn't entirely ideal, but it was the cleanest approach I've been able to come up with so far in terms of working with the regulator subsystem; I'm certainly open to suggestions for better ways of going about this. Within the regulator core, patch 3 exposes the REGULATOR_ERROR_* flags (for regulators that define a get_error_flags() operation) to userspace as a set of read-only sysfs attributes, so that operators can diagnose the cause of faults that may occur, such as current or thermal limits being exceeded. Patch 4 adds support for the regulator-external-output property with a couple of small functional tweaks, making the 'state' sysfs attribute writable and skipping the auto-disabling in regulator_late_cleanup(). Patch 5 adds a special-purpose regulator_get_type (EXTERNAL_GET), and patch 6 adds a tiny driver acting as a placeholder for an external output, using EXTERNAL_GET. Review/feedback appreciated! Thanks, Zev [0] https://lore.kernel.org/openbmc/20220308011811.10353-1-zev@bewilderbeest.net/ [1] https://www.open19.org/marketplace/delta-16kw-power-shelf/ Zev Weiss (6): dt-bindings: regulator: Add regulator-external-output property dt-bindings: regulator: Add reg-external-output regulator: core: Add error flags to sysfs attributes regulator: core: Add external-output support regulator: core: Add external get type regulator: core: Add external-consumer driver .../ABI/testing/sysfs-class-regulator | 85 ++++++++++++ .../regulator/reg-external-output.yaml | 37 +++++ .../bindings/regulator/regulator.yaml | 6 + drivers/regulator/Kconfig | 9 ++ drivers/regulator/core.c | 130 ++++++++++++++++-- drivers/regulator/devres.c | 7 + drivers/regulator/internal.h | 3 + drivers/regulator/of_regulator.c | 2 + include/linux/regulator/machine.h | 1 + 9 files changed, 272 insertions(+), 8 deletions(-) create mode 100644 Documentation/devicetree/bindings/regulator/reg-external-output.yaml -- 2.36.0