From patchwork Tue Jan 3 15:04:18 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bhupesh Sharma X-Patchwork-Id: 38488 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp4667767wrt; Tue, 3 Jan 2023 07:09:09 -0800 (PST) X-Google-Smtp-Source: AMrXdXuObeWoMLNe4zl6LjkKHPKRplVYnN9Xkhwu/yXSRBjJO2Uif06TFDtF7JB8n4uzzOWJTdar X-Received: by 2002:a17:902:ee55:b0:192:dbc3:6b79 with SMTP id 21-20020a170902ee5500b00192dbc36b79mr3043153plo.12.1672758549446; Tue, 03 Jan 2023 07:09:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672758549; cv=none; d=google.com; s=arc-20160816; b=vJo0bup+CdKE/a+6SnpAJ4l4FmQCRQIaz2SDawNgSyweHFk0QntlWkV8MC0L6o71tP wiDeet64QvlUYAF+zGA+uKjog4crQ5nogmFdx4f+IgjypNrt3XH/hwgv9CnZtGFy2tUj WQUrwr0CGyZO84jKbyX+4V1AGLgYkVxM1r3Ez/WWgeDsXAuQIqu9eBxvm5+KKy3tLzkC e7eRuzEa5aegrQBCY5MmQz5akctIQfPV/6iwPC0TmjCVWmYXKS9WkCmi4SzqzpWDzPvg tXIOdFIXRg829KKIaLL6id1kOkwhqMFznojYBLbVp096MVEsUOoIbKRuiGzS/U0XYxPW QQUg== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=03EcVfcgn594UPANtn877VRHUEcrNy316gwc2wdWerc=; b=cuhpPl1y/QN0Al9vF5afQfVgsmqps5cFQhSMu8DNStZLthpbaJ1Qr2pRbXPzHUeuG3 bd6rXto/rsVDhKg+1c/y8ehCpU38cjNXRPLZlnI81Xp7DBqgoUJ+Ncdmmt1IrHS2dPDd ehJlE+c+SxjyVXtFMOALSRf+YlkZT7dp6sf2biPn7v/B8hlquVV+ZVcg9BXp814WBGOk IiMSd884VDBbeyCwp8KjFMukzGuE5tNXavKL/w7Gj0oQSuFxRbRyEgA52D/U+4+4Yul3 bO1bmIbFDruwFwy3Apc1og5rPm4ngpAry4MY4YzRkS+3zssS9UGLE8ZF30rxueHWhDDl fUpw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=tAwja7qo; 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=linaro.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id s15-20020a170902ea0f00b00190fb8f9e0bsi9630398plg.490.2023.01.03.07.08.56; Tue, 03 Jan 2023 07:09:09 -0800 (PST) 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=@linaro.org header.s=google header.b=tAwja7qo; 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=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237903AbjACPFC (ORCPT + 99 others); Tue, 3 Jan 2023 10:05:02 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40122 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237628AbjACPEq (ORCPT ); Tue, 3 Jan 2023 10:04:46 -0500 Received: from mail-pl1-x633.google.com (mail-pl1-x633.google.com [IPv6:2607:f8b0:4864:20::633]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 481DB11A11 for ; Tue, 3 Jan 2023 07:04:45 -0800 (PST) Received: by mail-pl1-x633.google.com with SMTP id b2so32830830pld.7 for ; Tue, 03 Jan 2023 07:04:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; 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=03EcVfcgn594UPANtn877VRHUEcrNy316gwc2wdWerc=; b=tAwja7qo6FA2QF9L8ZZa7e1lkzKJIkHyamwXHR8tc68vLGODBiKjEwpCCvC3tVNHto GJ25c8hpVSOWLPbOOef61/cw7aE7hz4j2AS/p07Xr9ZabWXVpPx6SMVrZm7VIqp4AnR1 ZR+oSg5R22/Q7d1APEIpAhzuwtEFPtFGajKBXLK4BJGmVDSTprTOk8rh+LigIGcwhnHp GJSUHSv0l4LndZ1lXBm1zGKaEcCxOp9n3JC3tBiEWGt3BdyTl1wQekbWmH3CGnIBbFQg 66lXT7/e7JpToyvPe/SqolNVQ5+Z9jdllB+XTXg5KVxqkXLYjIeMIGf+ii9e54kqDwgT O6Kg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=03EcVfcgn594UPANtn877VRHUEcrNy316gwc2wdWerc=; b=o2AdxeiSTCQwmjWinzrcmm5WqxgL5Ltjo33PqE4mbEsmgDqHwGotRpFwbPvjgk+4mS G2D9es0293l7HFKRsQHMU+Pc1sGSApHXKV75LY4Xk/z+vKhcfcftAq9chlvt0gMa/sM4 U+pavaMlO4QdM6vbDvJ9qDLaZ7y2/FhIGoZENkZU39elVDkdTYZWADWXW8njfy8D16a0 6v2il+QonVR47JB6zAsHSsqGi0PMSiyzML/CeMlT6x8v7UPkGTLGz3GQbI8LLbxiZhPh 6hhV8h/qiVFgqoD7LLMFAOxrpNNB/MP16zgFop5y1kZl5kO7Glpn3WVpAD6CXAq07g6d /f5w== X-Gm-Message-State: AFqh2krfzBHR8qDs/d2UWIQcuJ5eN9aU/tmqpYhU8K4WmHCCMTiV1y+x XOePAwWrpKNHLofezDd689JwGA== X-Received: by 2002:a17:90b:485:b0:20d:bd5e:d54a with SMTP id bh5-20020a17090b048500b0020dbd5ed54amr46844701pjb.21.1672758284721; Tue, 03 Jan 2023 07:04:44 -0800 (PST) Received: from localhost.localdomain ([2401:4900:1c5e:e3b5:c341:16de:ce17:b857]) by smtp.gmail.com with ESMTPSA id 8-20020a17090a0f0800b0021952b5e9bcsm20952300pjy.53.2023.01.03.07.04.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Jan 2023 07:04:44 -0800 (PST) From: Bhupesh Sharma To: linux-arm-msm@vger.kernel.org, linux-usb@vger.kernel.org, devicetree@vger.kernel.org Cc: quic_schowdhu@quicinc.com, agross@kernel.org, andersson@kernel.org, konrad.dybcio@linaro.org, gregkh@linuxfoundation.org, linux-kernel@vger.kernel.org, bhupesh.linux@gmail.com, bhupesh.sharma@linaro.org, robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org Subject: [PATCH v2 1/2] dt-bindings: soc: qcom: eud: Add SM6115 / SM4250 binding Date: Tue, 3 Jan 2023 20:34:18 +0530 Message-Id: <20230103150419.3923421-2-bhupesh.sharma@linaro.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20230103150419.3923421-1-bhupesh.sharma@linaro.org> References: <20230103150419.3923421-1-bhupesh.sharma@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS autolearn=unavailable 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1754014468630866116?= X-GMAIL-MSGID: =?utf-8?q?1754014468630866116?= Add dt-bindings for EUD found on Qualcomm SM6115 / SM4250 SoC. On this SoC (and derivatives) the enable bit inside 'tcsr_check_reg' needs to be set first to 'enable' the eud module. So, update the dt-bindings to accommodate the third register property required by the driver on these SoCs. Cc: Souradeep Chowdhury Signed-off-by: Bhupesh Sharma --- .../devicetree/bindings/soc/qcom/qcom,eud.yaml | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/Documentation/devicetree/bindings/soc/qcom/qcom,eud.yaml b/Documentation/devicetree/bindings/soc/qcom/qcom,eud.yaml index c98aab209bc5d..1dffe14868735 100644 --- a/Documentation/devicetree/bindings/soc/qcom/qcom,eud.yaml +++ b/Documentation/devicetree/bindings/soc/qcom/qcom,eud.yaml @@ -18,12 +18,22 @@ properties: items: - enum: - qcom,sc7280-eud + - qcom,sm6115-eud - const: qcom,eud reg: + minItems: 2 items: - description: EUD Base Register Region - description: EUD Mode Manager Register + - description: TCSR Check Register + + reg-names: + minItems: 2 + items: + - const: eud-base + - const: eud-mode-mgr + - const: tcsr-check-base interrupts: description: EUD interrupt From patchwork Tue Jan 3 15:04:19 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bhupesh Sharma X-Patchwork-Id: 38489 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp4668445wrt; Tue, 3 Jan 2023 07:10:21 -0800 (PST) X-Google-Smtp-Source: AMrXdXuCSGfjd8N85BpfJuKF7qaxpFE2QVp+McTnDzu2X0AgpTsSiwYzeHN13WnKrAk677Esq39o X-Received: by 2002:a05:6a20:43ab:b0:a3:8512:54f7 with SMTP id i43-20020a056a2043ab00b000a3851254f7mr61870827pzl.29.1672758621458; Tue, 03 Jan 2023 07:10:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672758621; cv=none; d=google.com; s=arc-20160816; b=OjOkOm2yBEMXoOBoO0e0LS4x4jlZSZXWRQ/170EWgaHHDttR6V7MuNSf4ANXYrtH/j tkmQQ06ouyst/dCNr4Ya8hUtE7Ph5kpyAOs0fyFVAQw1jxHyBIQ1aMdbQVQTLiYA8CvZ mubKNy9W/D36Boq7O+UmS8iGwhKEN2U/ZwiGLj8RID4t2vh7mY4VbJ12ygAYUn0K3FmQ bmBiBl7bRkR7Ds2fzG+7gSg2NuSSkPD0eXZUfF7aCEsv6E49sEttVV0HqXXb5YSv7nmE 26YWxe6wIoNS4p69CQ4qCQyyzgtaHNO1cnfM01FDyW/pgbobE3rMDG0scrdzCKDHS7Tn Qikg== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=N13vpL6q9P0WudTM1gFfahAVjoJ4UnTdBTjpXvHDPN4=; b=k/sBWEUHVuklehPhswG6P6jniRR54+fdxFhPlvxi4jjsMTlOOcKw3LOMnzX47VOkx4 A+Q6TZSUlRVZBJg+HaRKofGBXS54dwFkO2dVbxhdkhzPm49ShstLzeCb30PCZEssA9Y2 07vJhQ/voHUlrcibKZ+jYTyopMA3p831P8PWQh/ADdw/VtVN2YdQ6+0f5f2y25TTPoxt wOfFlolRmge7F10bKLt4HdZptS5zH0gSq9cKu+gwc139wAqqr3ylx7J6TKECxYjLmU+g LLMuXkfksa0WsbxMMtqd1NJYq+68kfWkcveCgR+wDtjkUkbYFsZHU6xV9AEEoEx94p/u zFyg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=fAhuk6kM; 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=linaro.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id x185-20020a6386c2000000b00478e26efc95si20070301pgd.34.2023.01.03.07.10.08; Tue, 03 Jan 2023 07:10:21 -0800 (PST) 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=@linaro.org header.s=google header.b=fAhuk6kM; 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=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237907AbjACPFH (ORCPT + 99 others); Tue, 3 Jan 2023 10:05:07 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40232 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237944AbjACPEv (ORCPT ); Tue, 3 Jan 2023 10:04:51 -0500 Received: from mail-pl1-x62b.google.com (mail-pl1-x62b.google.com [IPv6:2607:f8b0:4864:20::62b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 51F2E11A0C for ; Tue, 3 Jan 2023 07:04:50 -0800 (PST) Received: by mail-pl1-x62b.google.com with SMTP id y19so13806048plb.2 for ; Tue, 03 Jan 2023 07:04:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; 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=N13vpL6q9P0WudTM1gFfahAVjoJ4UnTdBTjpXvHDPN4=; b=fAhuk6kMp791OWqVdI0FD/kqqSvppMpzbLNlO8XgrHygfFi+VOJiX6JfcTBC4UZ9dG kPCbEGi9xotF2PfePRt9GR7ZsNe43J0DY6xqF2dzRgmBcNqbX/dsH3bj1iN8VbBLXy69 nE0WwAn/6EC0ht2IPyIE+L+JG+KYmyhqcDAdiW773VASGgZAVEw8mIECSZm7/DY9lby1 Y4f1Ao0hfkuMOGK+YSGKvn+aNqoKQoQ1bv+SvAWrW+On4kH5MSTbbWhRGDc/RVs3eMqm EVxBaTsX0n+YptQmI7YtFUH4dOK8EN1O/kxzz8bLw40cdNAYI+Pd6hQ7SEnRAzQnFkZA tffw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=N13vpL6q9P0WudTM1gFfahAVjoJ4UnTdBTjpXvHDPN4=; b=duGGmO8vbQYTZSVqEYb/OamYCk3l8qBneqJNxnUNOuB2T4W9f3p5XB7Hg+CxKr7/QM XAzJa5lOX12Vsvuympb+Qo3/BjpzEUSWuWpkLDDmfLuaM1AHNUauEqCYsS7NnNvRP31c qYcX5sjvkO689SD7vNJkhR6/4SSd9UWP9UF+BBj/nU54MGzcPrah8HZyu5BemZqKTgpE EV5LFE5q3e++Xk6JQLJNk5XPV3cEadM3N3q5sHTS5clCUWS6IvayCUE4BA24xBOsIv7N cYWGWjLHnQzyX4DyAIli1ElmH6ITwPyi5AXZe90d2WNEXGh3bIx6zS8LiDrim/JszLOC lCbA== X-Gm-Message-State: AFqh2kq43iZgmQMTuqpvhKFWuQFRJ1XDAZMc9GEyG1kSxOs95SZz67SH Ev0w5nvi4G+QsxXjji/9Z/xtpw== X-Received: by 2002:a17:90a:8a08:b0:223:3642:f74f with SMTP id w8-20020a17090a8a0800b002233642f74fmr53242910pjn.0.1672758289750; Tue, 03 Jan 2023 07:04:49 -0800 (PST) Received: from localhost.localdomain ([2401:4900:1c5e:e3b5:c341:16de:ce17:b857]) by smtp.gmail.com with ESMTPSA id 8-20020a17090a0f0800b0021952b5e9bcsm20952300pjy.53.2023.01.03.07.04.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Jan 2023 07:04:49 -0800 (PST) From: Bhupesh Sharma To: linux-arm-msm@vger.kernel.org, linux-usb@vger.kernel.org, devicetree@vger.kernel.org Cc: quic_schowdhu@quicinc.com, agross@kernel.org, andersson@kernel.org, konrad.dybcio@linaro.org, gregkh@linuxfoundation.org, linux-kernel@vger.kernel.org, bhupesh.linux@gmail.com, bhupesh.sharma@linaro.org, robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org Subject: [PATCH v2 2/2] usb: misc: eud: Add driver support for SM6115 / SM4250 Date: Tue, 3 Jan 2023 20:34:19 +0530 Message-Id: <20230103150419.3923421-3-bhupesh.sharma@linaro.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20230103150419.3923421-1-bhupesh.sharma@linaro.org> References: <20230103150419.3923421-1-bhupesh.sharma@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS autolearn=unavailable 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1754014544300182812?= X-GMAIL-MSGID: =?utf-8?q?1754014544300182812?= Add SM6115 / SM4250 SoC EUD support in qcom_eud driver. On some SoCs (like the SM6115 / SM4250 SoC), the mode manager needs to be accessed only via the secure world (through 'scm' calls). Also, the enable bit inside 'tcsr_check_reg' needs to be set first to set the eud in 'enable' mode on these SoCs. Cc: Souradeep Chowdhury Signed-off-by: Bhupesh Sharma --- drivers/usb/misc/Kconfig | 1 + drivers/usb/misc/qcom_eud.c | 49 ++++++++++++++++++++++++++++++++++--- 2 files changed, 47 insertions(+), 3 deletions(-) diff --git a/drivers/usb/misc/Kconfig b/drivers/usb/misc/Kconfig index a5f7652db7da1..ed4ae32ff1577 100644 --- a/drivers/usb/misc/Kconfig +++ b/drivers/usb/misc/Kconfig @@ -140,6 +140,7 @@ config USB_APPLEDISPLAY config USB_QCOM_EUD tristate "QCOM Embedded USB Debugger(EUD) Driver" depends on ARCH_QCOM || COMPILE_TEST + select QCOM_SCM select USB_ROLE_SWITCH help This module enables support for Qualcomm Technologies, Inc. diff --git a/drivers/usb/misc/qcom_eud.c b/drivers/usb/misc/qcom_eud.c index b7f13df007646..a96ca28a4899b 100644 --- a/drivers/usb/misc/qcom_eud.c +++ b/drivers/usb/misc/qcom_eud.c @@ -11,7 +11,9 @@ #include #include #include +#include #include +#include #include #include #include @@ -30,15 +32,24 @@ #define EUD_INT_SAFE_MODE BIT(4) #define EUD_INT_ALL (EUD_INT_VBUS | EUD_INT_SAFE_MODE) +struct eud_soc_data { + bool secure_eud_en; + bool tcsr_check_enable; +}; + struct eud_chip { struct device *dev; struct usb_role_switch *role_sw; + const struct eud_soc_data *eud_data; void __iomem *base; void __iomem *mode_mgr; unsigned int int_status; int irq; bool enabled; bool usb_attached; + phys_addr_t mode_mgr_phys_base; + phys_addr_t tcsr_check_phys_base; + }; static int enable_eud(struct eud_chip *priv) @@ -46,7 +57,11 @@ static int enable_eud(struct eud_chip *priv) writel(EUD_ENABLE, priv->base + EUD_REG_CSR_EUD_EN); writel(EUD_INT_VBUS | EUD_INT_SAFE_MODE, priv->base + EUD_REG_INT1_EN_MASK); - writel(1, priv->mode_mgr + EUD_REG_EUD_EN2); + + if (priv->eud_data->secure_eud_en) + qcom_scm_io_writel(priv->mode_mgr_phys_base + EUD_REG_EUD_EN2, BIT(0)); + else + writel(1, priv->mode_mgr + EUD_REG_EUD_EN2); return usb_role_switch_set_role(priv->role_sw, USB_ROLE_DEVICE); } @@ -54,7 +69,11 @@ static int enable_eud(struct eud_chip *priv) static void disable_eud(struct eud_chip *priv) { writel(0, priv->base + EUD_REG_CSR_EUD_EN); - writel(0, priv->mode_mgr + EUD_REG_EUD_EN2); + + if (priv->eud_data->secure_eud_en) + qcom_scm_io_writel(priv->mode_mgr_phys_base + EUD_REG_EUD_EN2, 0); + else + writel(0, priv->mode_mgr + EUD_REG_EUD_EN2); } static ssize_t enable_show(struct device *dev, @@ -178,12 +197,15 @@ static void eud_role_switch_release(void *data) static int eud_probe(struct platform_device *pdev) { struct eud_chip *chip; + struct resource *res; int ret; chip = devm_kzalloc(&pdev->dev, sizeof(*chip), GFP_KERNEL); if (!chip) return -ENOMEM; + chip->eud_data = of_device_get_match_data(&pdev->dev); + chip->dev = &pdev->dev; chip->role_sw = usb_role_switch_get(&pdev->dev); @@ -200,10 +222,25 @@ static int eud_probe(struct platform_device *pdev) if (IS_ERR(chip->base)) return PTR_ERR(chip->base); - chip->mode_mgr = devm_platform_ioremap_resource(pdev, 1); + chip->mode_mgr = devm_platform_get_and_ioremap_resource(pdev, 1, &res); if (IS_ERR(chip->mode_mgr)) return PTR_ERR(chip->mode_mgr); + if (chip->eud_data->secure_eud_en) + chip->mode_mgr_phys_base = res->start; + + if (chip->eud_data->tcsr_check_enable) { + res = platform_get_resource(pdev, IORESOURCE_MEM, 2); + if (!res) + return dev_err_probe(chip->dev, -ENODEV, "failed to get tcsr reg base\n"); + + chip->tcsr_check_phys_base = res->start; + + ret = qcom_scm_io_writel(chip->tcsr_check_phys_base, BIT(0)); + if (ret) + return dev_err_probe(chip->dev, ret, "failed to write tcsr check reg\n"); + } + chip->irq = platform_get_irq(pdev, 0); ret = devm_request_threaded_irq(&pdev->dev, chip->irq, handle_eud_irq, handle_eud_irq_thread, IRQF_ONESHOT, NULL, chip); @@ -230,8 +267,14 @@ static int eud_remove(struct platform_device *pdev) return 0; } +static const struct eud_soc_data sm6115_eud_data = { + .secure_eud_en = true, + .tcsr_check_enable = true, +}; + static const struct of_device_id eud_dt_match[] = { { .compatible = "qcom,sc7280-eud" }, + { .compatible = "qcom,sm6115-eud", .data = &sm6115_eud_data }, { } }; MODULE_DEVICE_TABLE(of, eud_dt_match);