From patchwork Tue Dec 21 18:28:23 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jarrett Schultz X-Patchwork-Id: 527467 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 17724C433F5 for ; Tue, 21 Dec 2021 18:28:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241324AbhLUS2f (ORCPT ); Tue, 21 Dec 2021 13:28:35 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46396 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241319AbhLUS2e (ORCPT ); Tue, 21 Dec 2021 13:28:34 -0500 Received: from mail-pg1-x52c.google.com (mail-pg1-x52c.google.com [IPv6:2607:f8b0:4864:20::52c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 52D4BC061574; Tue, 21 Dec 2021 10:28:34 -0800 (PST) Received: by mail-pg1-x52c.google.com with SMTP id l10so13071039pgm.7; Tue, 21 Dec 2021 10:28:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=yMrw3jeTSxVnle4QnJMuBd8eLQyA7pAe3fJ1YXj/9cg=; b=eoDLrOGDDv2cRrhd/6ICsAfg8y8SChg/RxFgTFfkTCFC0noHfCh8z/vWwc7ZKoBL8k H4NKTxQB2Yeugg0zmYvxqhM8qq8xjCiK/AOh7jcMU+UTCkLnrN7sfHu25vNGble392Pa EHeXhLrtgCH4t+CVu1SmwjfodU0i3RHWktNPLq9vJTYvqobjv+WdgTZTjoTQILs2yFAv /+ldmUjXiSXF7Da8Zk8O6TQpDMHBYedLF++Ua7dKlpPXhEaB35xHpxiYndA4roQN38dA WjrfEsJmRw6HIvofnnRfR/1ffMntVwPx2q/uRzoUB7tUzIHcRu3VFuywm/rxSImcZjqc nwYQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=yMrw3jeTSxVnle4QnJMuBd8eLQyA7pAe3fJ1YXj/9cg=; b=jwsSrJI2/pwhRPZiRiov0ZA4tWIZPxYGk36Ax3Rw/KVmhacLWK+znHahw5t/oC/RSC 6yrClAveTgQg02PrwmWAgfhrr91AK5PUYRr0oxsP1DUhVnEodbcNRfi91UmbBY8c/dVb 8CN5/mjf0TBEIF99SQ+mW5wKoS2JHqYk8SGGpk+wvjBkWpDxogNDsKm3gKbfL57gYdR8 pk8FzoOMjqlL7r/X0BESg9qdPdgGXABdpnGjaH23VwERaXeyc1GOeJWypQAb3+LBsXPJ mW3bKEIqkbLKAqm2EcIi4E5ueEiw7LHjBfG5J8X2GmFRWFTwcnFgsz9j78o8xqfB0SSP iEZw== X-Gm-Message-State: AOAM531JCKIdSqrp/o72WqoEMOr30XzmRGmA7GjUFVB52W2+Q4kJ3aRl OQw5eGixM3W9biWvZ49uECsgKJR9yew= X-Google-Smtp-Source: ABdhPJxFDqs7WjFVyVvPTGEK9gNICOmPTXrB/mtFyZef4phn5nLsAfQDod3zRWyJ3Ma0yi2NhDPxaA== X-Received: by 2002:a63:6707:: with SMTP id b7mr4064794pgc.588.1640111313936; Tue, 21 Dec 2021 10:28:33 -0800 (PST) Received: from jaschultz-Thelio-Major.corp.microsoft.com ([2001:4898:80e8:36:b871:81c1:f2ef:8174]) by smtp.gmail.com with ESMTPSA id s19sm23436133pfu.137.2021.12.21.10.28.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Dec 2021 10:28:33 -0800 (PST) From: Jarrett Schultz X-Google-Original-From: Jarrett Schultz To: Rob Herring , Andy Gross , bjorn.andersson@linaro.org, Hans de Goede , Mark Gross , Maximilian Luz Cc: Felipe Balbi , linux-arm-msm@vger.kernel.org, platform-driver-x86@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, Jarrett Schultz Subject: [PATCH RESEND v4 1/4] dt-bindings: platform: microsoft: Document surface xbl Date: Tue, 21 Dec 2021 10:28:23 -0800 Message-Id: <20211221182826.2141789-2-jaschultzMS@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211221182826.2141789-1-jaschultzMS@gmail.com> References: <20211221182826.2141789-1-jaschultzMS@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org From: Jarrett Schultz Introduce yaml for surface xbl driver. Signed-off-by: Jarrett Schultz --- Changes in v4: - Addressed small formatting changes - Removed unnecessary lines --- Changes in v3: - Updated description to only pertain to the hardware - Updated the required field to properly reflect the binding - Removed the first example - Fixed the size of the reg field in the second example --- Changes in v2: - Removed json-schema dependence - Elaborated on description of driver - Updated example --- .../platform/microsoft/surface-xbl.yaml | 64 +++++++++++++++++++ MAINTAINERS | 7 ++ 2 files changed, 71 insertions(+) create mode 100644 Documentation/devicetree/bindings/platform/microsoft/surface-xbl.yaml diff --git a/Documentation/devicetree/bindings/platform/microsoft/surface-xbl.yaml b/Documentation/devicetree/bindings/platform/microsoft/surface-xbl.yaml new file mode 100644 index 000000000000..df5a87a016f4 --- /dev/null +++ b/Documentation/devicetree/bindings/platform/microsoft/surface-xbl.yaml @@ -0,0 +1,64 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/platform/microsoft/surface-xbl.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Surface Extensible Bootloader for Microsoft Surface Duo + +maintainers: + - Jarrett Schultz + +description: | + Defined to expose information that is used during production when + device is in manufacturing mode. Some of the information included + in this imem section is - + * board_id + * battery_present + * hw_init_retries + * is_customer_mode + * is_act_mode + * pmic_reset_reason + * touch_fw_version + * ocp_error_location + See sysfs documentation for more information. + +properties: + compatible: + const: simple-mfd + + reg: + maxItems: 1 + +additionalProperties: false + +required: + - compatible + - reg + - ranges + - address-cells + - size-cells + +examples: + - | + / { + compatible = "foo"; + model = "foo"; + #address-cells = <2>; + #size-cells = <2>; + + imem@146bf000 { + compatible = "simple-mfd"; + reg = <0x0 0x146bf000 0x0 0x1000>; + ranges = <0x0 0x0 0x146bf000 0x1000>; + #address-cells = <1>; + #size-cells = <1>; + status = "okay"; + + xbl@a94 { + compatible = "microsoft,sm8150-surface-duo-xbl"; + reg = <0xa94 0x100>; + status = "okay"; + }; + }; + }; diff --git a/MAINTAINERS b/MAINTAINERS index 13f9a84a617e..5d0ca2a98b57 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -12649,6 +12649,13 @@ F: Documentation/driver-api/surface_aggregator/clients/dtx.rst F: drivers/platform/surface/surface_dtx.c F: include/uapi/linux/surface_aggregator/dtx.h +MICROSOFT SURFACE DUO XBL DRIVER +M: Jarrett Schultz +L: linux-arm-msm@vger.kernel.org +L: platform-driver-x86@vger.kernel.org +S: Supported +F: Documentation/devicetree/bindings/platform/microsoft/surface-xbl.yaml + MICROSOFT SURFACE GPE LID SUPPORT DRIVER M: Maximilian Luz L: platform-driver-x86@vger.kernel.org From patchwork Tue Dec 21 18:28:24 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jarrett Schultz X-Patchwork-Id: 526641 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5D35CC4167D for ; Tue, 21 Dec 2021 18:28:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241336AbhLUS2g (ORCPT ); Tue, 21 Dec 2021 13:28:36 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46402 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237034AbhLUS2f (ORCPT ); Tue, 21 Dec 2021 13:28:35 -0500 Received: from mail-pg1-x530.google.com (mail-pg1-x530.google.com [IPv6:2607:f8b0:4864:20::530]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 79FE3C061574; Tue, 21 Dec 2021 10:28:35 -0800 (PST) Received: by mail-pg1-x530.google.com with SMTP id m15so13047018pgu.11; Tue, 21 Dec 2021 10:28:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=vhp/aClFSu6zCTiB0ewICEwB0s2D+8VsIVOQhvNHlRA=; b=buxnMh7slYzf6kZv3RqdyzOf4WI5fW6CVPZx1ihZG3Wa7U+jnHPVx0xVFmezL3GZIz 8ljzABhuU2fAnEQezDsjvhagDkGakCQn6Jdv4GaurZJEgWXQcrv4rwETXme8DZNgaK6y bBn/X7DgbzOJn8OGg361xTzBmxI+QjrH9IEHBZxTqiGCh+NgqFxcW1Bvn5pOKxIYDYax /WdHssYM7eboaUix0i6vwojD6ODMo75VO4adYW4hmA65zOOXf715EMkhnMolOI0u9HOD J4UO/aD0VRoMBiDi1lgFgxCiFaTEtUVV3eMEehtaBeJj7hLYMXzaAo8MAL6XSCzXxZ+m Lc4w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=vhp/aClFSu6zCTiB0ewICEwB0s2D+8VsIVOQhvNHlRA=; b=MBUnwP3pdkqphScDUP78T+z7x6npMipk1kK2SyAUpqJiWid2QHKTlWyJa4F5+dqLcg yB7weubIGnTg1vcHVUpsNlCxhH4hZZh7DxLXu1UpAFRijjmYE3/N/CFFshkVlR+vs18n QgA/uWhYW3aHpPP4/thejk9+4Ji1KhUBJMFe4YVT+Mg8RmRMJBQsicIytsfVdOIJCPZ0 pDPjRNXX2X4FpWhhWZZwjtau39bh2z4hiS/L/VUk65jnEuTmR2flKk8ONn0WSbssG3JM 4ShYDWnJaRYIPm1vDT6uQ/yf3scgATpkBtLr1a9KMw5AxaBmOpaWhqfAwdN/93s117xR ZrFA== X-Gm-Message-State: AOAM530IdoDoDWSyGAbR9AcyZH+t1qEkXPfJlvCJi0qklhe/8v8DDStE dryGR1tdYmz8cb/7X8j+nOw/QacOrAo= X-Google-Smtp-Source: ABdhPJya7iVWjOPayDAcPWcIzuvqzcth9yIH2ZYJdL5bjS45JYLGEU04qr7N3tHSdLutK3yOvBtisA== X-Received: by 2002:a63:8648:: with SMTP id x69mr4003818pgd.9.1640111314819; Tue, 21 Dec 2021 10:28:34 -0800 (PST) Received: from jaschultz-Thelio-Major.corp.microsoft.com ([2001:4898:80e8:36:b871:81c1:f2ef:8174]) by smtp.gmail.com with ESMTPSA id s19sm23436133pfu.137.2021.12.21.10.28.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Dec 2021 10:28:34 -0800 (PST) From: Jarrett Schultz X-Google-Original-From: Jarrett Schultz To: Rob Herring , Andy Gross , bjorn.andersson@linaro.org, Hans de Goede , Mark Gross , Maximilian Luz Cc: Felipe Balbi , linux-arm-msm@vger.kernel.org, platform-driver-x86@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, Jarrett Schultz Subject: [PATCH RESEND v4 2/4] platform: surface: Add surface xbl Date: Tue, 21 Dec 2021 10:28:24 -0800 Message-Id: <20211221182826.2141789-3-jaschultzMS@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211221182826.2141789-1-jaschultzMS@gmail.com> References: <20211221182826.2141789-1-jaschultzMS@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org From: Jarrett Schultz Introduce support for the Extensible Boot Loader driver found on the Surface Duo. Makes device information available to users via sysfs. Signed-off-by: Jarrett Schultz --- Changes in v4: - N/A --- Changes in v3: - Updated several descriptions in the yaml to be more descriptive - Renamed files to use an underscore instead of a dash --- Changes in v2: - Added types.h inclusion and removed unused inclusions - Minor updates to code and acronym style - Remove __packed attribute on driver struct - Use .dev_groups for sysfs - Added more in-depth description of driver in Kconfig - Changed target KernelVersion in sysfs documentation --- .../ABI/testing/sysfs-platform-surface-xbl | 79 ++++++++ MAINTAINERS | 2 + drivers/platform/surface/Kconfig | 12 ++ drivers/platform/surface/Makefile | 1 + drivers/platform/surface/surface_xbl.c | 186 ++++++++++++++++++ 5 files changed, 280 insertions(+) create mode 100644 Documentation/ABI/testing/sysfs-platform-surface-xbl create mode 100644 drivers/platform/surface/surface_xbl.c diff --git a/Documentation/ABI/testing/sysfs-platform-surface-xbl b/Documentation/ABI/testing/sysfs-platform-surface-xbl new file mode 100644 index 000000000000..505a662d8511 --- /dev/null +++ b/Documentation/ABI/testing/sysfs-platform-surface-xbl @@ -0,0 +1,79 @@ +What: /sys/devices/platform/146bfa94.xbl/battery_present +Date: October 2021 +KernelVersion: 5.16 +Contact: jaschultz@microsoft.com +Description: + Read only. It returns whether the battery is present. Valid + values are: + 0 - battery absent + 1 - battery present + +What: /sys/devices/platform/146bfa94.xbl/board_id +Date: October 2021 +KernelVersion: 5.16 +Contact: jaschultz@microsoft.com +Description: + Read only. It returns a Microsoft specific board id. + +What: /sys/devices/platform/146bfa94.xbl/hw_init_retries +Date: October 2021 +KernelVersion: 5.16 +Contact: jaschultz@microsoft.com +Description: + Read only. It returns a Microsoft specific value related to the + retries attempted to properly initialize the battery charging + subsystem. + +What: /sys/devices/platform/146bfa94.xbl/is_act_mode +Date: October 2021 +KernelVersion: 5.16 +Contact: jaschultz@microsoft.com +Description: + Read only. It returns whether ACT mode is enabled. Valid values + are: + 0 - ACT disabled + 1 - ACT enabled + + ACT mode is used to run checks and put the device to shipmode + at factory. + +What: /sys/devices/platform/146bfa94.xbl/is_customer_mode +Date: October 2021 +KernelVersion: 5.16 +Contact: jaschultz@microsoft.com +Description: + + mode. Valid values are: + 0 - Not in manufacturing mode + 1 - In manufacturing mode + +What: /sys/devices/platform/146bfa94.xbl/ocp_error_location +Date: October 2021 +KernelVersion: 5.16 +Contact: jaschultz@microsoft.com +Description: + Read only. It returns 0 or the id of the power rail which has the + OCP error. Valid values are: + Bit(s) Meaning + 15 More than one OCP error occurred + 14-12 PMIC + 11-7 SMPS + 6-2 LDO + 1-0 BOB + +What: /sys/devices/platform/146bfa94.xbl/pmic_reset_reason +Date: October 2021 +KernelVersion: 5.16 +Contact: jaschultz@microsoft.com +Description: + Read only. It returns the reason for the reset. Valid values + are: + 0 - no reason lol + 9 - Battery driver triggered + +What: /sys/devices/platform/146bfa94.xbl/touch_fw_version +Date: October 2021 +KernelVersion: 5.16 +Contact: jaschultz@microsoft.com +Description: + Read only. It returns the version of the firmware. diff --git a/MAINTAINERS b/MAINTAINERS index 5d0ca2a98b57..e65eddf5d25d 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -12654,7 +12654,9 @@ M: Jarrett Schultz L: linux-arm-msm@vger.kernel.org L: platform-driver-x86@vger.kernel.org S: Supported +F: Documentation/ABI/testing/sysfs-platform-surface-xbl F: Documentation/devicetree/bindings/platform/microsoft/surface-xbl.yaml +F: drivers/platform/surface/surface-xbl.c MICROSOFT SURFACE GPE LID SUPPORT DRIVER M: Maximilian Luz diff --git a/drivers/platform/surface/Kconfig b/drivers/platform/surface/Kconfig index 5f0578e25f71..96d6030d8d49 100644 --- a/drivers/platform/surface/Kconfig +++ b/drivers/platform/surface/Kconfig @@ -185,6 +185,18 @@ config SURFACE_PRO3_BUTTON help This driver handles the power/home/volume buttons on the Microsoft Surface Pro 3/4 tablet. +config SURFACE_XBL + tristate "Surface XBL Driver" + depends on ARM64 || COMPILE_TEST + depends on OF + help + If you say 'Y' to this option, support will be included for the + Surface Extensible Boot Loader (XBL) Driver. This driver exposes + information about the device through sysfs. + + This driver can also be built as a module. If so, the module + will be called surface-xbl. + source "drivers/platform/surface/aggregator/Kconfig" endif # SURFACE_PLATFORMS diff --git a/drivers/platform/surface/Makefile b/drivers/platform/surface/Makefile index 32889482de55..eef05d247f75 100644 --- a/drivers/platform/surface/Makefile +++ b/drivers/platform/surface/Makefile @@ -16,3 +16,4 @@ obj-$(CONFIG_SURFACE_GPE) += surface_gpe.o obj-$(CONFIG_SURFACE_HOTPLUG) += surface_hotplug.o obj-$(CONFIG_SURFACE_PLATFORM_PROFILE) += surface_platform_profile.o obj-$(CONFIG_SURFACE_PRO3_BUTTON) += surfacepro3_button.o +obj-$(CONFIG_SURFACE_XBL) += surface_xbl.o diff --git a/drivers/platform/surface/surface_xbl.c b/drivers/platform/surface/surface_xbl.c new file mode 100644 index 000000000000..e6272b704526 --- /dev/null +++ b/drivers/platform/surface/surface_xbl.c @@ -0,0 +1,186 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * Surface eXtensible Boot Loader (XBL) + * + * Copyright (C) 2021 Microsoft Corporation + * Author: Jarrett Schultz + */ + +#include +#include +#include +#include +#include + +#define SURFACE_XBL_MAX_VERSION_LEN 16 +#define SURFACE_XBL_BOARD_ID 0 +#define SURFACE_XBL_BATTERY_PRESENT 1 +#define SURFACE_XBL_HW_INIT_RETRIES 2 +#define SURFACE_XBL_IS_CUSTOMER_MODE 3 +#define SURFACE_XBL_IS_ACT_MODE 4 +#define SURFACE_XBL_PMIC_RESET_REASON 5 +#define SURFACE_XBL_TOUCH_FW_VERSION 6 +#define SURFACE_XBL_OCP_ERROR_LOCATION \ + (SURFACE_XBL_TOUCH_FW_VERSION + \ + SURFACE_XBL_MAX_VERSION_LEN) + +struct surface_xbl { + struct device *dev; + + u8 board_id; + u8 battery_present; + u8 hw_init_retries; + u8 is_customer_mode; + u8 is_act_mode; + u8 pmic_reset_reason; + char touch_fw_version[SURFACE_XBL_MAX_VERSION_LEN]; + u16 ocp_error_location; +}; + +static ssize_t +board_id_show(struct device *dev, struct device_attribute *attr, char *buf) +{ + struct surface_xbl *sxbl = dev_get_drvdata(dev); + + return sysfs_emit(buf, "%d\n", sxbl->board_id); +} +static DEVICE_ATTR_RO(board_id); + +static ssize_t +battery_present_show(struct device *dev, struct device_attribute *attr, char *buf) +{ + struct surface_xbl *sxbl = dev_get_drvdata(dev); + + return sysfs_emit(buf, "%d\n", sxbl->battery_present); +} +static DEVICE_ATTR_RO(battery_present); + +static ssize_t +hw_init_retries_show(struct device *dev, struct device_attribute *attr, char *buf) +{ + struct surface_xbl *sxbl = dev_get_drvdata(dev); + + return sysfs_emit(buf, "%d\n", sxbl->hw_init_retries); +} +static DEVICE_ATTR_RO(hw_init_retries); + +static ssize_t +is_customer_mode_show(struct device *dev, struct device_attribute *attr, char *buf) +{ + struct surface_xbl *sxbl = dev_get_drvdata(dev); + + return sysfs_emit(buf, "%d\n", sxbl->is_customer_mode); +} +static DEVICE_ATTR_RO(is_customer_mode); + +static ssize_t +is_act_mode_show(struct device *dev, struct device_attribute *attr, char *buf) +{ + struct surface_xbl *sxbl = dev_get_drvdata(dev); + + return sysfs_emit(buf, "%d\n", sxbl->is_act_mode); +} +static DEVICE_ATTR_RO(is_act_mode); + +static ssize_t +pmic_reset_reason_show(struct device *dev, struct device_attribute *attr, char *buf) +{ + struct surface_xbl *sxbl = dev_get_drvdata(dev); + + return sysfs_emit(buf, "%d\n", sxbl->pmic_reset_reason); +} +static DEVICE_ATTR_RO(pmic_reset_reason); + +static ssize_t +touch_fw_version_show(struct device *dev, struct device_attribute *attr, char *buf) +{ + struct surface_xbl *sxbl = dev_get_drvdata(dev); + + return sysfs_emit(buf, "0x%s\n", sxbl->touch_fw_version); +} +static DEVICE_ATTR_RO(touch_fw_version); + +static ssize_t +ocp_error_location_show(struct device *dev, struct device_attribute *attr, char *buf) +{ + struct surface_xbl *sxbl = dev_get_drvdata(dev); + + return sysfs_emit(buf, "%d\n", sxbl->ocp_error_location); +} +static DEVICE_ATTR_RO(ocp_error_location); + +static struct attribute *xbl_attrs[] = { + &dev_attr_board_id.attr, + &dev_attr_battery_present.attr, + &dev_attr_hw_init_retries.attr, + &dev_attr_is_customer_mode.attr, + &dev_attr_is_act_mode.attr, + &dev_attr_pmic_reset_reason.attr, + &dev_attr_touch_fw_version.attr, + &dev_attr_ocp_error_location.attr, + NULL +}; + +static const struct attribute_group xbl_attr_group = { + .attrs = xbl_attrs, +}; + +const struct attribute_group *xbl_sysfs_groups[] = { + &xbl_attr_group, + NULL +}; + +static int surface_xbl_probe(struct platform_device *pdev) +{ + struct surface_xbl *sxbl; + void __iomem *regs; + int i; + + sxbl = devm_kzalloc(&pdev->dev, sizeof(*sxbl), GFP_KERNEL); + if (!sxbl) + return -ENOMEM; + + sxbl->dev = &pdev->dev; + + regs = devm_platform_ioremap_resource(pdev, 0); + if (IS_ERR(regs)) + return PTR_ERR(regs); + + platform_set_drvdata(pdev, sxbl); + + sxbl->board_id = readb(regs + SURFACE_XBL_BOARD_ID); + sxbl->battery_present = readb(regs + SURFACE_XBL_BATTERY_PRESENT); + sxbl->hw_init_retries = readb(regs + SURFACE_XBL_HW_INIT_RETRIES); + sxbl->is_customer_mode = readb(regs + SURFACE_XBL_IS_CUSTOMER_MODE); + sxbl->is_act_mode = readb(regs + SURFACE_XBL_IS_ACT_MODE); + sxbl->pmic_reset_reason = readb(regs + SURFACE_XBL_PMIC_RESET_REASON); + + for (i = 0; i < SURFACE_XBL_MAX_VERSION_LEN; i++) + sxbl->touch_fw_version[i] = readb(regs + SURFACE_XBL_TOUCH_FW_VERSION + i); + + sxbl->ocp_error_location = readb(regs + SURFACE_XBL_OCP_ERROR_LOCATION); + + return 0; +} + +static const struct of_device_id surface_xbl_of_match[] = { + { + .compatible = "microsoft,sm8150-surface-duo-xbl" + }, + { } +}; +MODULE_DEVICE_TABLE(of, surface_xbl_of_match); + +static struct platform_driver surface_xbl_driver = { + .driver = { + .name = "surface-xbl", + .of_match_table = surface_xbl_of_match, + .dev_groups = xbl_sysfs_groups + }, + .probe = surface_xbl_probe, +}; +module_platform_driver(surface_xbl_driver); + +MODULE_AUTHOR("Jarrett Schultz "); +MODULE_DESCRIPTION("Surface Extensible Bootloader"); +MODULE_LICENSE("GPL"); From patchwork Tue Dec 21 18:28:25 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jarrett Schultz X-Patchwork-Id: 526640 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E2367C433F5 for ; Tue, 21 Dec 2021 18:28:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241340AbhLUS2h (ORCPT ); Tue, 21 Dec 2021 13:28:37 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46412 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241337AbhLUS2g (ORCPT ); Tue, 21 Dec 2021 13:28:36 -0500 Received: from mail-pf1-x42b.google.com (mail-pf1-x42b.google.com [IPv6:2607:f8b0:4864:20::42b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 285F6C061574; Tue, 21 Dec 2021 10:28:36 -0800 (PST) Received: by mail-pf1-x42b.google.com with SMTP id c2so70111pfc.1; Tue, 21 Dec 2021 10:28:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=xQC5STMzw4TlY0FvT781KJXZa9jGBgzdgcysSv7pHIg=; b=PHNILbg5zu9B+nrTaUJ4u8DISDwxjdcnL7Ck1t1Gv7LEy7+aljPgbA9IiwzLXd1DGD jIQQzMI7jAv+/onFxB8Zn9d55AlkXp08hOX5cFHGf/o8GI3LDsuA8QRQK7ggBg3ttqzk w1h5JuRNDMRboIqkH77cfA9lrZHUMmWJm++uA6jAOqOLQowp9z2jbSj0Cb6kgEMoLPpN NZ3wev5sT5MI1FT5nAXBvOxcct0ewGZ7GoLjP7koDUH3CgE1rsGGtKC3/dP/2cAxbPK9 VRuEe3TaDupTN52IPCw5W8FCRz78Ma6clGUWnKXBWPPk+y23DeSfkPxYEmygWL4pe7Lf 56lg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=xQC5STMzw4TlY0FvT781KJXZa9jGBgzdgcysSv7pHIg=; b=5SE7eAOMMdZMfq+tkBhFGfwMpf06P4KKzI6LWxtLFbJtAe8n7gFiDfRDGz3kobVcup D5eYwSRQ+AwC9zqmjtzEyZxVqH4JPclxckcek8W4gZxi15VxBf51YzsDpxQM9lSu3fKG jlqSlGNAy/P+0eDbGGjq5W9A3S8blpJtLihkt9DfoKfnwgmbIhScGusqU7qRVF7w6bO/ ywEPOlxTbYW4evW637LaKeLJhPhBlbMNd/edYbrejynoYMSL/P4K9yk7rk28RPTtPJJR PYG38srxDbRPJfRcv1nLHaXZD+Kt83HWtYY4A0xWsbG5Lgw0yaKj6JOqccc4dPMb70H4 rjIA== X-Gm-Message-State: AOAM530o7J3ic4ZXJ0HOSIfmtufNGrC8TrdkkdoxxWqKqTxHfDLfUGqu Gx8eyMkm+q3Q5pmAgh0qLQ8= X-Google-Smtp-Source: ABdhPJy/vd0oGUe2uvFOW0EEA5ajTWnrgWWATbExu3LpqAzlhmtUTukt2LyeGVnz9Nv4ogEtyv+fxg== X-Received: by 2002:a63:e50:: with SMTP id 16mr4030925pgo.619.1640111315659; Tue, 21 Dec 2021 10:28:35 -0800 (PST) Received: from jaschultz-Thelio-Major.corp.microsoft.com ([2001:4898:80e8:36:b871:81c1:f2ef:8174]) by smtp.gmail.com with ESMTPSA id s19sm23436133pfu.137.2021.12.21.10.28.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Dec 2021 10:28:35 -0800 (PST) From: Jarrett Schultz X-Google-Original-From: Jarrett Schultz To: Rob Herring , Andy Gross , bjorn.andersson@linaro.org, Hans de Goede , Mark Gross , Maximilian Luz Cc: Felipe Balbi , linux-arm-msm@vger.kernel.org, platform-driver-x86@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, Jarrett Schultz Subject: [PATCH RESEND v4 3/4] arm64: dts: qcom: sm8150: Add imem section Date: Tue, 21 Dec 2021 10:28:25 -0800 Message-Id: <20211221182826.2141789-4-jaschultzMS@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211221182826.2141789-1-jaschultzMS@gmail.com> References: <20211221182826.2141789-1-jaschultzMS@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org From: Jarrett Schultz Introduce the imem section in preparation for the surface xbl driver. Signed-off-by: Jarrett Schultz Reviewed-by: Bjorn Andersson --- Changes in v4: - N/A --- Changes in v3: - N/A --- Changes in v2: - Created to properly reference the xbl section inside of imem --- arch/arm64/boot/dts/qcom/sm8150.dtsi | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/arch/arm64/boot/dts/qcom/sm8150.dtsi b/arch/arm64/boot/dts/qcom/sm8150.dtsi index 81b4ff2cc4cd..bcfcb7306cdc 100644 --- a/arch/arm64/boot/dts/qcom/sm8150.dtsi +++ b/arch/arm64/boot/dts/qcom/sm8150.dtsi @@ -1175,6 +1175,14 @@ gpi_dma1: dma-controller@a00000 { status = "disabled"; }; + imem: imem@146bf000 { + compatible = "simple-mfd"; + reg = <0x0 0x146bf000 0x0 0x1000>; + ranges = <0x0 0x0 0x146bf000 0x1000>; + #address-cells = <1>; + #size-cells = <1>; + }; + qupv3_id_1: geniqup@ac0000 { compatible = "qcom,geni-se-qup"; reg = <0x0 0x00ac0000 0x0 0x6000>; From patchwork Tue Dec 21 18:28:26 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jarrett Schultz X-Patchwork-Id: 527466 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id BA274C43219 for ; Tue, 21 Dec 2021 18:28:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241349AbhLUS2i (ORCPT ); Tue, 21 Dec 2021 13:28:38 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46416 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241311AbhLUS2h (ORCPT ); Tue, 21 Dec 2021 13:28:37 -0500 Received: from mail-pf1-x429.google.com (mail-pf1-x429.google.com [IPv6:2607:f8b0:4864:20::429]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 09211C061574; Tue, 21 Dec 2021 10:28:37 -0800 (PST) Received: by mail-pf1-x429.google.com with SMTP id v13so60536pfi.3; Tue, 21 Dec 2021 10:28:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=AtngP8d0g0fi2Zi2weqgSY60agKP0OsKMyjizujaa74=; b=Q3r4GoA8o/zYVcwujoPbTOpghL3YfVRSaA/MrB3KGhWFEfWhne3McSgxheE8s+9WaU V4odamfn+MNJnQEeVYfp71N396wLLT6MwbIQM3RYHFs5S8TJfGmYRv77AOpd6DXcEtM6 RUdnQDdkWpua9keDDXaXNMdcQxHBXeauZY46sgdjH5+pKKJZ3D+pN+jzkSthkQKsakhc b8fERRuktBX4hW4X0CMsuXAEvwZOEY+ErzdE+rCpSgI8H9DCwQp0UYNhNrPIyzZ1cm8j f6Ar3itIz9w9LghDA7QXEMwbx2VdX2HqRHiAmdLPV2RwyWrP/tw6kBS484W69BHXtWfl ooHg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=AtngP8d0g0fi2Zi2weqgSY60agKP0OsKMyjizujaa74=; b=NeRPhxjF+ClPfKYGsSHMcz7hl6oy5xes6SDPf1wBIco2KfEP6eQj6RxMk8w4wb3kDx gLYIKmuvd6grokYON3wtoIPcvev9nkUZ28LHUZqCnZijSoKWps8zTzVSb5adDiJGF/b2 SwhxMbA2f97VKG4B6DG2ih90ZWQtDfw06JWOSRfS+/OASrYQSPRpPAxeEu1+gVE09lm0 LW/5njufK/8i1m5JSZM9uwLqm636MHB18tUo1vYzcv6Uzf008v+fPjy7S2bY0ZHaOX9j XKDluGpkfPkNFexSFSdaEyZXNZ+6ovBzBwfh5fmEopw/ZXqFevWSYKKHxeRTQYf+wVvL PT6Q== X-Gm-Message-State: AOAM532h41akmEs0mgq1n2dOW0gAIhr3asvzCSgaXh/3V4MzXkfkOyDN kZ0iitDXcjqT1fd+pfQRcr4= X-Google-Smtp-Source: ABdhPJwxhTCNg3D2B6n/fOoZWVyeb1dwKHhW1JJA4lk5TEYiBhog0aJCNVOscXnjhKP2x3CnGjhysA== X-Received: by 2002:a63:9143:: with SMTP id l64mr1793570pge.495.1640111316637; Tue, 21 Dec 2021 10:28:36 -0800 (PST) Received: from jaschultz-Thelio-Major.corp.microsoft.com ([2001:4898:80e8:36:b871:81c1:f2ef:8174]) by smtp.gmail.com with ESMTPSA id s19sm23436133pfu.137.2021.12.21.10.28.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Dec 2021 10:28:36 -0800 (PST) From: Jarrett Schultz X-Google-Original-From: Jarrett Schultz To: Rob Herring , Andy Gross , bjorn.andersson@linaro.org, Hans de Goede , Mark Gross , Maximilian Luz Cc: Felipe Balbi , linux-arm-msm@vger.kernel.org, platform-driver-x86@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, Jarrett Schultz Subject: [PATCH RESEND v4 4/4] arm64: dts: qcom: surface-duo: Add surface xbl Date: Tue, 21 Dec 2021 10:28:26 -0800 Message-Id: <20211221182826.2141789-5-jaschultzMS@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211221182826.2141789-1-jaschultzMS@gmail.com> References: <20211221182826.2141789-1-jaschultzMS@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org From: Jarrett Schultz Introduce device tree source for the surface xbl driver. Signed-off-by: Jarrett Schultz --- Changes in v4: - N/A --- Changes in v3: - N/A --- Changes in v2: - Updated to reference an offset inside of imem --- .../boot/dts/qcom/sm8150-microsoft-surface-duo.dts | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/arch/arm64/boot/dts/qcom/sm8150-microsoft-surface-duo.dts b/arch/arm64/boot/dts/qcom/sm8150-microsoft-surface-duo.dts index 5901c28e6696..abb7964daac4 100644 --- a/arch/arm64/boot/dts/qcom/sm8150-microsoft-surface-duo.dts +++ b/arch/arm64/boot/dts/qcom/sm8150-microsoft-surface-duo.dts @@ -430,6 +430,16 @@ &i2c19 { /* MAX34417 @ 0x1e */ }; +&imem { + status = "okay"; + + xbl@a94 { + compatible = "microsoft,sm8150-surface-duo-xbl"; + reg = <0xa94 0x100>; + status = "okay"; + }; +}; + &pon { pwrkey { status = "okay";