Received: by 2002:a05:6358:489b:b0:bb:da1:e618 with SMTP id x27csp1355260rwn; Thu, 15 Sep 2022 14:36:43 -0700 (PDT) X-Google-Smtp-Source: AMsMyM53+38aZQ96wfkdQnPG5/A0PKGiAM/lDpmQb5/2ZI9XW6v1MPst8lX1Tt8mIAzNsK1h8iPn X-Received: by 2002:a17:906:8a75:b0:77b:d534:a289 with SMTP id hy21-20020a1709068a7500b0077bd534a289mr1282207ejc.118.1663277802864; Thu, 15 Sep 2022 14:36:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663277802; cv=none; d=google.com; s=arc-20160816; b=ldu/A/KJ/eBxqAjh0W+9VsCFBHeh4fvSMI4+ANOFt1c4OJGK/9Lmq2xUn8SdRp+vRt kUKUqZ+o8P3yR8E0e6a0NkTT5leqkmjsUxU9tHatyIe4om0VO+kK/a5RKduihd+TLRSd 8DYhVFCIwz7dAsorkpcfIb07DIqGsAP53bUy92PJR7kTsMeGp0wDTEjJkp7MIPyB+NG/ 50KpKaeM3VWDvOuRpJfKYVbQV105l0me5dMvlRWldbJrF+Myp4FZu3FBxXsETf4Ivfpm AEm9+PDHaE61t4XzMU52yjH5d/mZfmDrK/KUXzH5kDRHMo2tA9fvntpwyFClery8AOB2 8PUw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=9IZny1pHSrMOkFJZahxCMvVJPfrOtiyEunVo6uVbKv0=; b=nY1pCLV25udbJCW4mONxatbwG9K333+yiGIDBmkcIBOhnVj8ej/6aH4qDIcvvr6TkL fCx0li0lzMRevPl0e2do+duRqsLWlRENAKovwZQq3Q1bxWtON2gjSyJj/+aoRdKl/C5N fzE/vSKQNqpa1Pp+uJ5mybmH2rWR4pBcKdXjiEebXFE5Z9V4QX9EHmkuBteSI9eBJL69 NpTbU1W9If5R7Ok9oPd9P2Lq7STTPprC4VdzbokFRFw4PYifoTguSDREbdymOmcYji+c Cn7E8QBCIc7WEafQnttHbP6rMbG1/2ZPbWlWqRWJGnJup5IdRRsyz9xdi60n5msdxP+d 3mgQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=NWLeHKx+; 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=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id x22-20020a170906711600b00780429cae96si3009218ejj.412.2022.09.15.14.36.17; Thu, 15 Sep 2022 14:36:42 -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=@kernel.org header.s=k20201202 header.b=NWLeHKx+; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229577AbiIOVZy (ORCPT + 99 others); Thu, 15 Sep 2022 17:25:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50404 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229548AbiIOVZw (ORCPT ); Thu, 15 Sep 2022 17:25:52 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4A8007F262; Thu, 15 Sep 2022 14:25:51 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 0112DB8226F; Thu, 15 Sep 2022 21:25:49 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E4C0EC433C1; Thu, 15 Sep 2022 21:25:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1663277148; bh=H2ls57PFfBqVntzlewdbjz+tZyYLdyUvuWWhbZDYtOo=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=NWLeHKx+ZR674A4He77HHQapvQQd1EWssJGSFx+ANscW+bvIqbyClN1PzpL9GNXn8 WoMsz6Qg7SNQLKKzd9zBE7Za+cDL/yfzN7zJORJTeF+boYajcanat7ty3syOFcqHwj FcCrZi5I10HixJVRP5MVm19EPbIKFjuowLzakB+O/U0wBlchc58Gd7oUbCuxcadaD/ hVUAzwgcwgUVWEWm/UCALSKvZc9KNBvmsxT8R+3alY6G4pk+XOtBNO1wHvk5RUN+ro 1xCy2fzdLAUP3iNMgHiGCplB9f6Ii/qMYTuA3IfCYGdOTsay2gGVYnpCG2f4UQp0fb umd2XqfIX01UA== Date: Thu, 15 Sep 2022 16:25:45 -0500 From: Bjorn Andersson To: Sebastian Reichel Cc: Bjorn Andersson , Rob Herring , Krzysztof Kozlowski , linux-pm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, Lee Jones , dri-devel@lists.freedesktop.org Subject: Re: [PATCH 2/2] power: supply: Add Lenovo Yoga C630 EC driver Message-ID: <20220915212545.q6vxcnrffwr3buq2@builder.lan> References: <20220810030500.2793882-1-bjorn.andersson@linaro.org> <20220810030500.2793882-3-bjorn.andersson@linaro.org> <20220913104545.2u6mcyy3bg4dp6ly@mercury.elektranox.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220913104545.2u6mcyy3bg4dp6ly@mercury.elektranox.org> X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS 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 On Tue, Sep 13, 2022 at 12:45:45PM +0200, Sebastian Reichel wrote: > Hi, > > [+Cc Lee Jones, DRI devel] > > On Tue, Aug 09, 2022 at 10:05:00PM -0500, Bjorn Andersson wrote: > > The Qualcomm Snapdragon-based Lenovo Yoga C630 has some sort of EC > > providing AC-adapter and battery status, as well as USB Type-C altmode > > notifications for Displayport operation. > > > > The Yoga C630 ships with Windows, where these operations primarily are > > implemented in ACPI, but due to various issues with the hardware > > representation therein it's not possible to run Linux on this > > information. As such this is a best-effort re-implementation of these > > operations, based on the register map expressed in ACPI and a fair > > amount of trial and error. > > > > Signed-off-by: Bjorn Andersson > > --- > > [...] > > + val = yoga_c630_ec_read8(ec, LENOVO_EC_BAT_ATTRIBUTES); > > + if (val < 0) > > + goto out_unlock; > > + ec->unit_ma = val & LENOVO_EC_BAT_ATTR_UNIT_IS_MA; > > + if (!ec->unit_ma) > > + ec->scale = 1000; > > + else > > + ec->scale = 1; > > Since I'm not sure how much of information was gained by reverse > engineering: Is this really milliamps vs microamps and not milliamps > vs milliwatt? SBS batteries usually report either mA or mW. > Unfortunately I don't know the answer to this. > > [...] > > + case POWER_SUPPLY_PROP_SERIAL_NUMBER: > > + val->strval = "05072018"; > > + break; > > why is this hardcoded? :) > I don't know, but as Daniel suggests, it would make sense to just drop it. > > [...] > > + device_for_each_child_node(dev, fwnode) { > > + ret = fwnode_property_read_u32(fwnode, "reg", &port); > > + if (ret < 0) > > + continue; > > + > > + /* Got multiple ports, but altmode is only possible on port 1 */ > > + if (port != 1) > > + continue; > > + > > + ec->bridge.funcs = &yoga_c630_ec_bridge_funcs; > > + ec->bridge.of_node = to_of_node(fwnode); > > + ec->bridge.ops = DRM_BRIDGE_OP_HPD; > > + ec->bridge.type = DRM_MODE_CONNECTOR_USB; > > + > > + ret = devm_drm_bridge_add(dev, &ec->bridge); > > + if (ret) { > > + dev_err(dev, "failed to register drm bridge\n"); > > + fwnode_handle_put(fwnode); > > + return ret; > > + } > > I wonder if DRM people want to see this in drivers/gpu/drm/bridge. > Maybe it's better to make this a MFD driver? > I did consider it, but it adds a whole bunch of boiler plate code without a lot of benefit. There are a few other cases where I think it would make sense to have drm bridges outside of drivers/gpu/drm, such as drivers/usb/typec/altmodes/ and drivers/platform/chrome/... > > [...] > > -- Sebastian Thanks, Bjorn