From patchwork Fri Mar 4 16:15:08 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexandre Bailon X-Patchwork-Id: 12769436 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 952A1C433F5 for ; Fri, 4 Mar 2022 16:24:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=hae1CNmSw+fxRsKGrZHYR43MqPtk07eiiRp3ddsU0+I=; b=dPeNmYS9jBHFGT KTISFCtdgcBnVuV0PtJx+gb1NlQ5tMvEtusllbEfPNRlkXHS+Y1hwl/cqnBlQMu0q/+wM7gAEgP5c 0BiVwqiZPVT4pUNWBQkfyZStJ1KyrjGf6wBuhFM4lx/YUg+cPxjU67uVxYHveKte/SUZAhzJESDav qSuDNfK69SLx2UKuokOCGmzY7zAxyVU1z5yahxrn4c6TtJXi2pHxfVkQmkoWpPXzIjy84a7A0C8FT E9tRanOc1mgZQ2bCG04N7mnoafhSCzdkOSBYT8YcVlTd9hXk8My3yQQzANREKSF0fnz1qzoa7qiPk gtDgKlsPESe0XoXnObLA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nQAhJ-00B0cQ-Po; Fri, 04 Mar 2022 16:22:31 +0000 Received: from mail-wr1-x42f.google.com ([2a00:1450:4864:20::42f]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nQAaW-00AxmG-Vi for linux-arm-kernel@lists.infradead.org; Fri, 04 Mar 2022 16:15:32 +0000 Received: by mail-wr1-x42f.google.com with SMTP id p9so13394366wra.12 for ; Fri, 04 Mar 2022 08:15:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=8Nqj3Wj2afL4vH+AWQbMmnZZbmdqpSeJYR5BS2/Kv0Y=; b=OOS1o/jw7tYZCPMkqoGNeane3XqwRqfkrZVcw7gh/2d4grjXT+DEjE7qawH3IEvUOS KjJIsANa0cft/ebHmTMCPxTg0ND7PA5GXVbZpkAe9fWpLNJfkhz6iIBNBFMXYmLaNMfo fonMddZ/xVAAAyHlU1wySfS63mLMTTTK6gZ3mCbX4nmmBeaccJd6X2bsfzS2nYoP1EbR GrTAnaJ3qvyV9Y4woTsVIZsMYMF/znKif6xNvdbWnqb6M8tvluHkNcrdL1SUlDv1ODmP bRXLomEr0uYQBtlHOnZnz4TdVhWoqzw0Q8fn9jyOvof+Sk/VHY0zASNZJSABovJTPT19 F2tQ== 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=8Nqj3Wj2afL4vH+AWQbMmnZZbmdqpSeJYR5BS2/Kv0Y=; b=PyQbo8SpY+fZO2iElrEo6qCPrMLP+D4CIJf+V3sQxnOYMqVJbS6qeAxqzNdmdi6ejt rIRNVNl9Fh+mU7+nLaqyEUKWCb/ELczXGGmNtwvQzTBZdUyZnoeaho9Nf9v4Mev1s8U9 y0bbZgM2dEdMGbyrHHx+5WrXyoZDO+nm2R/s6zWhJcRaUhzgTU/PBJnhJeGSKhdCk9LD Pc9AEgNKP4WLvOWVZi90YKZW3IpHhyJmWM8ncTlXC/WKMo/0P4l1Hh82K6LFPUeqcwNX kp+u8BYsf8DvbEWXd6f071O/A7sseZ/7fD84iljARjJEHufOMed9FSGFYdVeO+RcZeqD 2WNQ== X-Gm-Message-State: AOAM532seXm6qPAp7DmLEknHv/nQAzQvDkVhz7YmkzCr5g/G4pwERCIC DTY+vCbAaUtJrYRzzk+X6b5Tuw== X-Google-Smtp-Source: ABdhPJzNkPllUg3CGamJ/9qQ6VEA0o7v+Nic7Ku68JBY2CRMOsrZPqCMPRFONhuaEBXE9kW5K1f9Fw== X-Received: by 2002:a05:6000:186d:b0:1e8:49fc:69ce with SMTP id d13-20020a056000186d00b001e849fc69cemr30513168wri.80.1646410526620; Fri, 04 Mar 2022 08:15:26 -0800 (PST) Received: from xps-9300.baylibre (laubervilliers-658-1-213-31.w90-63.abo.wanadoo.fr. [90.63.244.31]) by smtp.gmail.com with ESMTPSA id g6-20020a5d5406000000b001f049726044sm4937307wrv.79.2022.03.04.08.15.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Mar 2022 08:15:26 -0800 (PST) From: Alexandre Bailon To: ohad@wizery.com, bjorn.andersson@linaro.org, mathieu.poirier@linaro.org, robh+dt@kernel.or Cc: matthias.bgg@gmail.com, linux-remoteproc@vger.kernel.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, linux-kernel@vger.kernel.org, stephane.leprovost@mediatek.com, khilman@baylibre.com, Alexandre Bailon Subject: [PATCH v4 1/7] dt bindings: remoteproc: Add bindings for the MT8183 APU Date: Fri, 4 Mar 2022 17:15:08 +0100 Message-Id: <20220304161514.994128-2-abailon@baylibre.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220304161514.994128-1-abailon@baylibre.com> References: <20220304161514.994128-1-abailon@baylibre.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220304_081529_068359_3ED4DE23 X-CRM114-Status: GOOD ( 14.24 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org This adds dt bindings for the APU present in the MT8183. Signed-off-by: Alexandre Bailon --- .../bindings/remoteproc/mtk,apu.yaml | 122 ++++++++++++++++++ 1 file changed, 122 insertions(+) create mode 100644 Documentation/devicetree/bindings/remoteproc/mtk,apu.yaml diff --git a/Documentation/devicetree/bindings/remoteproc/mtk,apu.yaml b/Documentation/devicetree/bindings/remoteproc/mtk,apu.yaml new file mode 100644 index 000000000000..b640aa96d678 --- /dev/null +++ b/Documentation/devicetree/bindings/remoteproc/mtk,apu.yaml @@ -0,0 +1,122 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 + +--- +$id: "http://devicetree.org/schemas/remoteproc/mtk,apu.yaml#" +$schema: "http://devicetree.org/meta-schemas/core.yaml#" + +title: Mediatek AI Processor Unit (APU) + +description: + This document defines the binding for the APU, a co-processor that could + offload the CPU for machine learning and neural network. + +maintainers: + - Alexandre Bailon + +properties: + compatible: + const: mediatek,mt8183-apu + + reg: + maxItems: 1 + + interrupts: + maxItems: 1 + + clocks: + minItems: 3 + maxItems: 3 + + clock-names: + items: + - const: axi + - const: ipu + - const: jtag + + iommus: + maxItems: 3 + + memory-region: + maxItems: 3 + + memory-region-da: + description: + Array of APU device address. This is used to map the APU device address + to a physical address. + maxItems: 3 + + power-domains: + maxItems: 1 + + pinctrl: + description: pinctrl handles, required to configure pins for JTAG. + + pinctrl-names: + items: + - const: jtag + +required: + - compatible + - reg + - interrupts + - clocks + - clock-names + - iommus + - memory-region + - memory-region-da + - power-domains + +additionalProperties: false + +examples: + - | + #include + #include + #include + #include + + reserved-memory { + #address-cells = <1>; + #size-cells = <1>; + ranges; + + vdev0buffer: vdev0buffer@52900000 { + compatible = "shared-dma-pool"; + reg = <0x52900000 0x4000>; + no-map; + }; + + vdev0vring0: vdev0vring0@52904000 { + compatible = "shared-dma-pool"; + reg = <0x52904000 0x2000>; + no-map; + }; + + vdev0vring1: vdev0vring1@52906000 { + compatible = "shared-dma-pool"; + reg = <0x52906000 0x2000>; + no-map; + }; + }; + + apu0: apu@19100000 { + compatible = "mediatek,mt8183-apu"; + reg = <0x19180000 0x14000>; + interrupts = ; + + iommus = <&iommu M4U_PORT_IMG_IPUO>, + <&iommu M4U_PORT_IMG_IPU3O>, + <&iommu M4U_PORT_IMG_IPUI>; + + clocks = <&ipu_core0 CLK_IPU_CORE0_AXI>, + <&ipu_core0 CLK_IPU_CORE0_IPU>, + <&ipu_core0 CLK_IPU_CORE0_JTAG>; + + clock-names = "axi", "ipu", "jtag"; + + power-domains = <&scpsys MT8183_POWER_DOMAIN_VPU_CORE0>; + memory-region = <&vdev0buffer>, <&vdev0vring0>, <&vdev0vring1>; + memory-region-da = <0x6fff8000>, <0x6fffc000>, <0x6fffe000>; + }; +... From patchwork Fri Mar 4 16:15:09 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexandre Bailon X-Patchwork-Id: 12769430 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id E8AA1C433EF for ; Fri, 4 Mar 2022 16:23:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=JVMw5GJfYE+uCEY0w43UsAdG5UvKM6MM3WBDvqZp8ds=; b=s613KLco+yv+XD 3X6PM1Grj60eDliEj0wAJ0YBnSB0RNNDsx8arQTtbq7FYyag2BkBoX5J72r0kkOFodhrhE92bhE8X y/I3gcmnZeiHTNv/8TxKIfOv3cqsVYbHU+FZCG2Ur8QAOA6b2qV8hoQ7Yf3KXVXwGGQPlw5jtAaWI BQEFtsxT9Bgb51OA4ioFX8KeuhBxPgUV0XlkSO/BlSnSTAMD1jUMaDGFRdAbkPArVaDIVfvOk5DMl oekL1uuBUEWRvLrvMPK/XlHDuH9ErRJ6ZA80jAXPU8gMIVP6gf5J4NhsPYfMoKic34rNqfwsyQkBC hlIcBZ2oQg2Ds4PngJkw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nQAgT-00B0Kp-FP; Fri, 04 Mar 2022 16:21:38 +0000 Received: from mail-wr1-x434.google.com ([2a00:1450:4864:20::434]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nQAaW-00AxmV-VC for linux-arm-kernel@lists.infradead.org; Fri, 04 Mar 2022 16:15:32 +0000 Received: by mail-wr1-x434.google.com with SMTP id b5so13447380wrr.2 for ; Fri, 04 Mar 2022 08:15:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=qo1oLJMa/Juuiz/8tm0dlUbpsAehCK6hY4TsDvEil64=; b=4ucNsu73371QER1iVg/SYxU4sTtNkFz4mcETt58TIUbIzHX0UQsNiv7/hpQbphueQp uE41tjRPPJVp+8VjH9CzBcNeqohZ/thG3VeH2awR9qE8+VdDciUao7ZtKsklp2Q7HMcS 4MFMXWb80oYj5s6RUBwMkBasfLcAC3kFBfxZDTH2oFa4Zbf2w5MNjrHHTa70XJyYta// iv7RK5ax6bqFepe4Uuz0kwBN6Z2qVletNxzWFgc+MX18zxn024mFy01NHrKFkMHUDCnE c3I369eg/D7s8/pCtCAwrkXnmc9A9qotLgCQpCQn9rmDz/m6r3OM6U6LksGIJuV9Fl5m Qsvw== 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=qo1oLJMa/Juuiz/8tm0dlUbpsAehCK6hY4TsDvEil64=; b=jmLdYg+/1cQ5zke8xNqgrh9kLrN06xgEFtQXCBbIDR3LmhsZeplCIMBY9Jvg1fHZVy ujih7XUdgbY2Z44xukoKivWbQSSdRrTD2C15v5ygmpo7pRptYnaGSOgy7wGbuiwYdN5w R0N+pixVLYFhQ7nK0ogpUXobMXTQoF62siWooZvaTXD80Ld7Py5+ZgqSji8fGKvKI4ah L6AnZRoxgG18AgBrTIO2l7aDdMGNQ184Ur1lr3sn8TUWiWMW8eUEbu9DJsAFV3qH9JMI f2RG6mENNXga05My3/UwKgmUBfx8ep/vfA3NnqVpXB+W5UvuF791RYTbwkd7AsXmYVZL 9NUw== X-Gm-Message-State: AOAM530LQqFzhxoXuVuKmue2l8WILid+7aaEKt+HquA6v6wK0ulk0xdK nOOLANMgCjnhaNF/sHktPn+5fw== X-Google-Smtp-Source: ABdhPJypiVdEpBXufX/LYg2TlJODChhaQvP/Mg/mSfLKFI5Q9apmvXFWuBYOHKLyb5PE/15fMYRUaw== X-Received: by 2002:a05:6000:15cb:b0:1ea:7db2:f5bb with SMTP id y11-20020a05600015cb00b001ea7db2f5bbmr29322769wry.709.1646410527460; Fri, 04 Mar 2022 08:15:27 -0800 (PST) Received: from xps-9300.baylibre (laubervilliers-658-1-213-31.w90-63.abo.wanadoo.fr. [90.63.244.31]) by smtp.gmail.com with ESMTPSA id g6-20020a5d5406000000b001f049726044sm4937307wrv.79.2022.03.04.08.15.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Mar 2022 08:15:27 -0800 (PST) From: Alexandre Bailon To: ohad@wizery.com, bjorn.andersson@linaro.org, mathieu.poirier@linaro.org, robh+dt@kernel.or Cc: matthias.bgg@gmail.com, linux-remoteproc@vger.kernel.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, linux-kernel@vger.kernel.org, stephane.leprovost@mediatek.com, khilman@baylibre.com, Alexandre Bailon Subject: [PATCH v4 2/7] dt-bindings: remoteproc: Add bindings for the MT8365 APU Date: Fri, 4 Mar 2022 17:15:09 +0100 Message-Id: <20220304161514.994128-3-abailon@baylibre.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220304161514.994128-1-abailon@baylibre.com> References: <20220304161514.994128-1-abailon@baylibre.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220304_081529_085553_02336B40 X-CRM114-Status: UNSURE ( 9.95 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org This updates the Mediatek APU bindings to support the MT8365. Signed-off-by: Alexandre Bailon --- .../bindings/remoteproc/mtk,apu.yaml | 45 ++++++++++++++++--- 1 file changed, 39 insertions(+), 6 deletions(-) diff --git a/Documentation/devicetree/bindings/remoteproc/mtk,apu.yaml b/Documentation/devicetree/bindings/remoteproc/mtk,apu.yaml index b640aa96d678..388352ccb2b5 100644 --- a/Documentation/devicetree/bindings/remoteproc/mtk,apu.yaml +++ b/Documentation/devicetree/bindings/remoteproc/mtk,apu.yaml @@ -16,7 +16,9 @@ maintainers: properties: compatible: - const: mediatek,mt8183-apu + enum: + - mediatek,mt8183-apu + - mediatek,mt8365-apu reg: maxItems: 1 @@ -26,13 +28,11 @@ properties: clocks: minItems: 3 - maxItems: 3 + maxItems: 8 clock-names: - items: - - const: axi - - const: ipu - - const: jtag + minItems: 3 + maxItems: 8 iommus: maxItems: 3 @@ -69,6 +69,39 @@ required: additionalProperties: false +allOf: + - if: + properties: + compatible: + contains: + enum: + - mediatek,mt8183-apu + then: + properties: + clock-names: + items: + - const: axi + - const: ipu + - const: jtag + - if: + properties: + compatible: + contains: + enum: + - mediatek,mt8365-apu + then: + properties: + clock-names: + items: + - const: if_ck + - const: edma + - const: ahb + - const: axi + - const: ipu + - const: jtag + - const: smi_cam + - const: ifr_apu_axi + examples: - | #include From patchwork Fri Mar 4 16:15:10 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexandre Bailon X-Patchwork-Id: 12769438 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id B839BC43217 for ; Fri, 4 Mar 2022 16:27:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=bozId5T3o+OVG5ZHHEj2m1+CnKazcpghcNxlWUuTHuw=; b=00BzWhRlq4Dpjr eq/TWfxb/FoizPVzZbgrEBeSuJXrH0pQJoaX/UCxbLshiFOjS3yaxY6YyaS/NVrqUREqVFx17k5RS yrgaYG3aHc6j7usZmi0lqbTASOjeSfTih8w63xTuex7PW9aWejp+YNlWx8pwVyo8XX2duWYyApHwz fsmKtZuBsfq9js1k3tzfHp2hMyNDhhiy6lRXisJsbjJHWzTN8ig6Gf+Plt4pvGRTER+Rl0IfyRnbY RNf6X6pWp/yMfTcbyA5SH/B3aUpJwRloSiKUCpelA88bVmbTgaNDkyEjvhyjVAkQIQ6mVnlKakeXk UeF7/H98b6QJz85D+p1w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nQAkl-00B1vp-1S; Fri, 04 Mar 2022 16:26:05 +0000 Received: from mail-wr1-x42f.google.com ([2a00:1450:4864:20::42f]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nQAaY-00AxoH-0i for linux-arm-kernel@lists.infradead.org; Fri, 04 Mar 2022 16:15:36 +0000 Received: by mail-wr1-x42f.google.com with SMTP id u10so11783226wra.9 for ; Fri, 04 Mar 2022 08:15:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=A5BQTOw/sXp3TYshwTZm9beWJAVLkCvWgXDxaIwyMSA=; b=dia3oXp7q/1VjrCfFLkAy+mPg5LwHgobOELdYWi3Z9dN6Shze/dwz/uopWDUgcShMT LWmn7K89YF9pI7AbweONu4D6ImhQY7kdEKga7xxDUMMmLWf+4+pIW0d/XjSVt7VteyCj sFaT+UD8QFdcYk7jfAImoFpyEuGxAskWUOkxEC/qQc2V1uIljxXLI6k4vg0w7k2Wr3ct JPzgjgdLxUeVYY2IRM6RjU+Tyo2eB1rzhIr1uJLJmvyjj9Pp62FqAIy6SaZkQj9YUi7Y yJSre1ellL7hMYy60GkcVEJmkY4x5M2yO0WC5pzb+KbrkLIU73Ci5tWsp56jpRCrSk4g gz2Q== 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=A5BQTOw/sXp3TYshwTZm9beWJAVLkCvWgXDxaIwyMSA=; b=F93K2GdM5Zypl56zi4Pew0qNqaCYkLlqDmOevtQed2Q0k9AICt9HKmdRO03f0gvRz6 1qQfg+HnKqS+jIjI3/6uV88lx7ksjTq3t8qb5cqogD8gCTSG0F8CQJ04jO1m4c6i7Jk/ ZQuyf73U6QeilujarOQa8mNw0RxtH1oY0BI2NbmRzmX//OYY7QLZ7IalT5lSSzyyt76a F4PkcezCmz6BNSFU/Xwr5rV/kozKiwfgtWOLTAKVku8b5Q48YH2HLTqcX57OZB4FvNUs r6kyNsDJYGXbs5sUJqTLml53OLABOShCg3U4Var7SWkuBZDBY7z1zhZeh7LTLIphKsdq l/JA== X-Gm-Message-State: AOAM533rWwlcQZ9BPvc//1O+bwwf3+zkzTgGF/ETVen0FW1T6OUHdwbE sKM6NZl1YqzDmC1CDkXJud6t0A== X-Google-Smtp-Source: ABdhPJy3avM7h1zWOCFAbWXeckRHWDmyJ1lmQgTKMw5y5k07tM3CGmgyGL90bbNcQ5hbA47XiHbodg== X-Received: by 2002:adf:f34c:0:b0:1ef:fde2:6d83 with SMTP id e12-20020adff34c000000b001effde26d83mr15098505wrp.637.1646410528617; Fri, 04 Mar 2022 08:15:28 -0800 (PST) Received: from xps-9300.baylibre (laubervilliers-658-1-213-31.w90-63.abo.wanadoo.fr. [90.63.244.31]) by smtp.gmail.com with ESMTPSA id g6-20020a5d5406000000b001f049726044sm4937307wrv.79.2022.03.04.08.15.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Mar 2022 08:15:28 -0800 (PST) From: Alexandre Bailon To: ohad@wizery.com, bjorn.andersson@linaro.org, mathieu.poirier@linaro.org, robh+dt@kernel.or Cc: matthias.bgg@gmail.com, linux-remoteproc@vger.kernel.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, linux-kernel@vger.kernel.org, stephane.leprovost@mediatek.com, khilman@baylibre.com, Alexandre Bailon Subject: [PATCH v4 3/7] remoteproc: Add a remoteproc driver for the MT8183's APU Date: Fri, 4 Mar 2022 17:15:10 +0100 Message-Id: <20220304161514.994128-4-abailon@baylibre.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220304161514.994128-1-abailon@baylibre.com> References: <20220304161514.994128-1-abailon@baylibre.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220304_081530_241821_5466387B X-CRM114-Status: GOOD ( 27.77 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org This adds a driver to control the APU present in the MT8183. This loads the firmware and start the DSP. Signed-off-by: Alexandre Bailon --- drivers/remoteproc/Kconfig | 10 + drivers/remoteproc/Makefile | 1 + drivers/remoteproc/mtk_apu.c | 486 +++++++++++++++++++++++++++++++++++ 3 files changed, 497 insertions(+) create mode 100644 drivers/remoteproc/mtk_apu.c diff --git a/drivers/remoteproc/Kconfig b/drivers/remoteproc/Kconfig index 341156e2a29b..959d24e9492c 100644 --- a/drivers/remoteproc/Kconfig +++ b/drivers/remoteproc/Kconfig @@ -64,6 +64,16 @@ config MTK_SCP It's safe to say N here. +config MTK_APU + tristate "Mediatek APU remoteproc support" + depends on ARCH_MEDIATEK + depends on MTK_IOMMU + help + Say y to support the Mediatek's AI Processing Unit (APU) via + the remote processor framework. + + It's safe to say N here. + config OMAP_REMOTEPROC tristate "OMAP remoteproc support" depends on ARCH_OMAP4 || SOC_OMAP5 || SOC_DRA7XX diff --git a/drivers/remoteproc/Makefile b/drivers/remoteproc/Makefile index 0ac256b6c977..0ab4461c33af 100644 --- a/drivers/remoteproc/Makefile +++ b/drivers/remoteproc/Makefile @@ -15,6 +15,7 @@ obj-$(CONFIG_IMX_REMOTEPROC) += imx_rproc.o obj-$(CONFIG_IMX_DSP_REMOTEPROC) += imx_dsp_rproc.o obj-$(CONFIG_INGENIC_VPU_RPROC) += ingenic_rproc.o obj-$(CONFIG_MTK_SCP) += mtk_scp.o mtk_scp_ipi.o +obj-$(CONFIG_MTK_APU) += mtk_apu.o obj-$(CONFIG_OMAP_REMOTEPROC) += omap_remoteproc.o obj-$(CONFIG_WKUP_M3_RPROC) += wkup_m3_rproc.o obj-$(CONFIG_DA8XX_REMOTEPROC) += da8xx_remoteproc.o diff --git a/drivers/remoteproc/mtk_apu.c b/drivers/remoteproc/mtk_apu.c new file mode 100644 index 000000000000..867b4682b507 --- /dev/null +++ b/drivers/remoteproc/mtk_apu.c @@ -0,0 +1,486 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright (C) 2020 BayLibre SAS + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "remoteproc_internal.h" + +#define SW_RST (0x0000000C) +#define SW_RST_OCD_HALT_ON_RST BIT(12) +#define SW_RST_IPU_D_RST BIT(8) +#define SW_RST_IPU_B_RST BIT(4) +#define CORE_CTRL (0x00000110) +#define CORE_CTRL_PDEBUG_ENABLE BIT(31) +#define CORE_CTRL_SRAM_64K_iMEM (0x00 << 27) +#define CORE_CTRL_SRAM_96K_iMEM (0x01 << 27) +#define CORE_CTRL_SRAM_128K_iMEM (0x02 << 27) +#define CORE_CTRL_SRAM_192K_iMEM (0x03 << 27) +#define CORE_CTRL_SRAM_256K_iMEM (0x04 << 27) +#define CORE_CTRL_PBCLK_ENABLE BIT(26) +#define CORE_CTRL_RUN_STALL BIT(23) +#define CORE_CTRL_STATE_VECTOR_SELECT BIT(19) +#define CORE_CTRL_PIF_GATED BIT(17) +#define CORE_CTRL_NMI BIT(0) +#define CORE_XTENSA_INT (0x00000114) +#define CORE_CTL_XTENSA_INT (0x00000118) +#define CORE_DEFAULT0 (0x0000013C) +#define CORE_DEFAULT0_QOS_SWAP_0 (0x00 << 28) +#define CORE_DEFAULT0_QOS_SWAP_1 (0x01 << 28) +#define CORE_DEFAULT0_QOS_SWAP_2 (0x02 << 28) +#define CORE_DEFAULT0_QOS_SWAP_3 (0x03 << 28) +#define CORE_DEFAULT0_ARUSER_USE_IOMMU (0x10 << 23) +#define CORE_DEFAULT0_AWUSER_USE_IOMMU (0x10 << 18) +#define CORE_DEFAULT1 (0x00000140) +#define CORE_DEFAULT0_ARUSER_IDMA_USE_IOMMU (0x10 << 0) +#define CORE_DEFAULT0_AWUSER_IDMA_USE_IOMMU (0x10 << 5) +#define CORE_XTENSA_ALTRESETVEC (0x000001F8) + +#define VDEV_MEM_COUNT (3) + +#define APU_RESET_DELAY (27) + +struct mtk_apu_rproc { + struct device *dev; + void __iomem *base; + int irq; + unsigned int num_clks; + struct clk_bulk_data *clks; + struct iommu_domain *domain; + struct list_head mappings; +}; + +static const char * const mt8183_clk_names[] = { + "ipu", + "axi", + "jtag" +}; + +static int mtk_apu_iommu_map(struct rproc *rproc, struct rproc_mem_entry *entry) +{ + struct mtk_apu_rproc *apu_rproc = rproc->priv; + struct device *dev = rproc->dev.parent; + struct rproc_mem_entry *mapping; + int ret; + u64 pa; + + /* vdev buffer and vring are already mapped */ + if (strstr(entry->name, "vdev")) + return 0; + + mapping = kzalloc(sizeof(*mapping), GFP_KERNEL); + if (!mapping) + return -ENOMEM; + + if (!entry->va) + pa = entry->dma; + else + pa = rproc_va_to_pa(entry->va); + + ret = iommu_map(apu_rproc->domain, entry->da, pa, entry->len, entry->flags); + if (ret) { + dev_err(dev, "iommu_map failed: %d\n", ret); + goto free_mapping; + } + + mapping->da = entry->da; + mapping->len = entry->len; + list_add_tail(&mapping->node, &apu_rproc->mappings); + + return 0; + +free_mapping: + kfree(mapping); + + return ret; +} + +static void mtk_apu_iommu_unmap_all(struct rproc *rproc) +{ + struct mtk_apu_rproc *apu_rproc = rproc->priv; + struct device *dev = rproc->dev.parent; + struct rproc_mem_entry *entry, *tmp; + + /* clean up iommu mapping entries */ + list_for_each_entry_safe(entry, tmp, &apu_rproc->mappings, node) { + size_t unmapped; + + unmapped = iommu_unmap(apu_rproc->domain, entry->da, entry->len); + if (unmapped != entry->len) { + /* nothing much to do besides complaining */ + dev_err(dev, "failed to unmap %zx/%zu\n", entry->len, + unmapped); + } + + list_del(&entry->node); + kfree(entry); + } +} + +static int mtk_apu_rproc_alloc_carveout(struct rproc *rproc, + struct rproc_mem_entry *mem) +{ + int flags = IOMMU_READ | IOMMU_READ | IOMMU_NOEXEC; + struct device *dev = rproc->dev.parent; + int ret; + + struct iommu_domain *domain = iommu_get_domain_for_dev(dev); + + mem->va = memremap(mem->dma, mem->len, MEMREMAP_WC); + if (IS_ERR_OR_NULL(mem->va)) { + dev_err(dev, "Unable to map memory region: %pa+%zu\n", + &mem->dma, mem->len); + return PTR_ERR(mem->va); + } + + ret = iommu_map(domain, mem->da, mem->dma, mem->len, flags); + if (ret) + memunmap(mem->va); + + return 0; +} + +static int mtk_apu_rproc_release_carveout(struct rproc *rproc, + struct rproc_mem_entry *mem) +{ + struct mtk_apu_rproc *apu_rproc = rproc->priv; + struct device *dev = apu_rproc->dev; + struct iommu_domain *domain; + size_t unmapped; + + domain = iommu_get_domain_for_dev(dev); + unmapped = iommu_unmap(domain, mem->da, mem->len); + if (unmapped != mem->len) { + /* nothing much to do besides complaining */ + dev_err(dev, "failed to unmap %zx/%zu\n", mem->len, unmapped); + } + memunmap(mem->va); + + return 0; +} + +static int mtk_apu_rproc_vdev_mem_init(struct rproc *rproc) +{ + struct mtk_apu_rproc *apu_rproc = rproc->priv; + struct device *dev = apu_rproc->dev; + struct device_node *np = dev->of_node; + struct reserved_mem *rmem; + struct rproc_mem_entry *mem; + u32 da[VDEV_MEM_COUNT]; + int ret; + int i; + + ret = of_property_read_u32_array(np, "memory-region-da", da, VDEV_MEM_COUNT); + if (ret) + return ret; + + for (i = 0; i < VDEV_MEM_COUNT; i++) { + struct device_node *target; + char *name; + + target = of_parse_phandle(np, "memory-region", i); + if (!target) + return -EINVAL; + + rmem = of_reserved_mem_lookup(target); + of_node_put(target); + + if (!rmem) + return -ENOMEM; + + ret = strcspn(rmem->name, "@"); + if (!ret) + return -EINVAL; + + name = kstrndup(rmem->name, ret, GFP_KERNEL); + if (!name) + return -ENOMEM; + + mem = rproc_mem_entry_init(dev, NULL, rmem->base, rmem->size, + da[i], + mtk_apu_rproc_alloc_carveout, + mtk_apu_rproc_release_carveout, + name); + kfree(name); + if (!mem) + return -ENOMEM; + + rproc_add_carveout(rproc, mem); + } + + return 0; +} + +static int mtk_apu_rproc_prepare(struct rproc *rproc) +{ + struct mtk_apu_rproc *apu_rproc = rproc->priv; + int ret; + + ret = clk_bulk_prepare_enable(apu_rproc->num_clks, apu_rproc->clks); + if (ret) + dev_err(apu_rproc->dev, "Failed to enable clocks\n"); + + ret = mtk_apu_rproc_vdev_mem_init(rproc); + if (ret) { + dev_err(apu_rproc->dev, "Failed to init vdev memory\n"); + clk_bulk_disable_unprepare(apu_rproc->num_clks, apu_rproc->clks); + + } + + return ret; +} + +static int mtk_apu_rproc_unprepare(struct rproc *rproc) +{ + struct mtk_apu_rproc *apu_rproc = rproc->priv; + + clk_bulk_disable_unprepare(apu_rproc->num_clks, apu_rproc->clks); + + return 0; +} + +static int mtk_apu_rproc_start(struct rproc *rproc) +{ + struct mtk_apu_rproc *apu_rproc = rproc->priv; + u32 core_ctrl; + + /* Set reset vector of APU firmware boot address */ + writel(rproc->bootaddr, apu_rproc->base + CORE_XTENSA_ALTRESETVEC); + + /* Turn on the clocks and stall the APU */ + core_ctrl = readl(apu_rproc->base + CORE_CTRL); + core_ctrl |= CORE_CTRL_PDEBUG_ENABLE | CORE_CTRL_PBCLK_ENABLE | + CORE_CTRL_STATE_VECTOR_SELECT | CORE_CTRL_RUN_STALL | + CORE_CTRL_PIF_GATED; + writel(core_ctrl, apu_rproc->base + CORE_CTRL); + + /* Reset the APU: this requires 27 ns to be effective on any platform */ + writel(SW_RST_OCD_HALT_ON_RST | SW_RST_IPU_B_RST | SW_RST_IPU_D_RST, + apu_rproc->base + SW_RST); + ndelay(APU_RESET_DELAY); + writel(0, apu_rproc->base + SW_RST); + + core_ctrl &= ~CORE_CTRL_PIF_GATED; + writel(core_ctrl, apu_rproc->base + CORE_CTRL); + + /* Configure memory accesses to go through the IOMMU */ + writel(CORE_DEFAULT0_AWUSER_USE_IOMMU | CORE_DEFAULT0_ARUSER_USE_IOMMU | + CORE_DEFAULT0_QOS_SWAP_1, apu_rproc->base + CORE_DEFAULT0); + writel(CORE_DEFAULT0_AWUSER_IDMA_USE_IOMMU | + CORE_DEFAULT0_ARUSER_IDMA_USE_IOMMU, + apu_rproc->base + CORE_DEFAULT1); + + /* Release the APU */ + core_ctrl &= ~CORE_CTRL_RUN_STALL; + writel(core_ctrl, apu_rproc->base + CORE_CTRL); + + return 0; +} + +static int mtk_apu_rproc_stop(struct rproc *rproc) +{ + struct mtk_apu_rproc *apu_rproc = rproc->priv; + u32 core_ctrl; + + core_ctrl = readl(apu_rproc->base + CORE_CTRL); + writel(core_ctrl | CORE_CTRL_RUN_STALL, apu_rproc->base + CORE_CTRL); + + mtk_apu_iommu_unmap_all(rproc); + + return 0; +} + +static void mtk_apu_rproc_kick(struct rproc *rproc, int vqid) +{ + struct mtk_apu_rproc *apu_rproc = rproc->priv; + + writel(1 << vqid, apu_rproc->base + CORE_CTL_XTENSA_INT); +} + +static int mtk_apu_load(struct rproc *rproc, const struct firmware *fw) + +{ + struct rproc_mem_entry *entry, *tmp; + int ret; + + ret = rproc_elf_load_segments(rproc, fw); + if (ret) + return ret; + + list_for_each_entry_safe(entry, tmp, &rproc->carveouts, node) { + ret = mtk_apu_iommu_map(rproc, entry); + if (ret) + goto err_unmap_all; + } + + return 0; + +err_unmap_all: + mtk_apu_iommu_unmap_all(rproc); + + return ret; +} + +static const struct rproc_ops mtk_apu_rproc_ops = { + .prepare = mtk_apu_rproc_prepare, + .unprepare = mtk_apu_rproc_unprepare, + .start = mtk_apu_rproc_start, + .stop = mtk_apu_rproc_stop, + .kick = mtk_apu_rproc_kick, + .load = mtk_apu_load, + .parse_fw = rproc_elf_load_rsc_table, + .find_loaded_rsc_table = rproc_elf_find_loaded_rsc_table, + .sanity_check = rproc_elf_sanity_check, + .get_boot_addr = rproc_elf_get_boot_addr, +}; + +static irqreturn_t mtk_apu_rproc_callback(int irq, void *data) +{ + struct rproc *rproc = data; + struct mtk_apu_rproc *apu_rproc = (struct mtk_apu_rproc *)rproc->priv; + + writel(1, apu_rproc->base + CORE_XTENSA_INT); + + return IRQ_WAKE_THREAD; +} + +static int mtk_apu_rproc_probe(struct platform_device *pdev) +{ + struct device *dev = &pdev->dev; + struct mtk_apu_rproc *apu_rproc; + struct rproc *rproc; + struct resource *res; + int ret; + int i; + + ret = of_property_count_elems_of_size(dev->of_node, "memory-region", + sizeof(phandle)); + if (ret != VDEV_MEM_COUNT) + return -EINVAL; + + ret = of_property_count_elems_of_size(dev->of_node, "memory-region-da", + sizeof(u32)); + if (ret != VDEV_MEM_COUNT) + return -EINVAL; + + rproc = rproc_alloc(dev, dev_name(dev), &mtk_apu_rproc_ops, NULL, + sizeof(*apu_rproc)); + if (!rproc) + return -ENOMEM; + + rproc->recovery_disabled = true; + rproc->has_iommu = false; + rproc->auto_boot = false; + + apu_rproc = rproc->priv; + apu_rproc->dev = dev; + INIT_LIST_HEAD(&apu_rproc->mappings); + + platform_set_drvdata(pdev, rproc); + + apu_rproc->domain = iommu_get_domain_for_dev(dev); + if (!apu_rproc->domain) { + ret = -ENODEV; + goto free_rproc; + } + + res = platform_get_resource(pdev, IORESOURCE_MEM, 0); + apu_rproc->base = devm_ioremap_resource(dev, res); + if (IS_ERR(apu_rproc->base)) { + dev_err(dev, "Failed to map mmio\n"); + ret = PTR_ERR(apu_rproc->base); + goto free_rproc; + } + + apu_rproc->irq = platform_get_irq(pdev, 0); + if (apu_rproc->irq < 0) { + ret = apu_rproc->irq; + goto free_rproc; + } + + apu_rproc->domain = iommu_get_domain_for_dev(dev); + if (!apu_rproc->domain) { + ret = -ENODEV; + goto free_rproc; + } + + ret = devm_request_threaded_irq(dev, apu_rproc->irq, + mtk_apu_rproc_callback, handle_event, + IRQF_SHARED | IRQF_ONESHOT, + NULL, rproc); + if (ret) { + dev_err(dev, "devm_request_threaded_irq error: %d\n", ret); + goto free_rproc; + } + + apu_rproc->num_clks = ARRAY_SIZE(mt8183_clk_names); + apu_rproc->clks = devm_kcalloc(dev, apu_rproc->num_clks, + sizeof(*apu_rproc->clks), GFP_KERNEL); + for (i = 0; i < apu_rproc->num_clks; ++i) + apu_rproc->clks[i].id = mt8183_clk_names[i]; + + ret = devm_clk_bulk_get(dev, apu_rproc->num_clks, apu_rproc->clks); + if (ret) { + dev_err(dev, "Failed to get clocks\n"); + goto free_rproc; + } + + ret = rproc_add(rproc); + if (ret) { + dev_err(dev, "rproc_add failed: %d\n", ret); + goto free_rproc; + } + + return 0; + +free_rproc: + rproc_free(rproc); + + return ret; +} + +static int mtk_apu_rproc_remove(struct platform_device *pdev) +{ + struct rproc *rproc = platform_get_drvdata(pdev); + struct mtk_apu_rproc *apu_rproc = (struct mtk_apu_rproc *)rproc->priv; + struct device *dev = &pdev->dev; + + disable_irq(apu_rproc->irq); + + rproc_del(rproc); + of_reserved_mem_device_release(dev); + rproc_free(rproc); + + return 0; +} + +static const struct of_device_id mtk_apu_rproc_of_match[] = { + { .compatible = "mediatek,mt8183-apu", }, + { /* sentinel */ }, +}; +MODULE_DEVICE_TABLE(of, mtk_apu_rproc_of_match); + +static struct platform_driver mtk_apu_rproc_driver = { + .probe = mtk_apu_rproc_probe, + .remove = mtk_apu_rproc_remove, + .driver = { + .name = "mtk_apu-rproc", + .of_match_table = of_match_ptr(mtk_apu_rproc_of_match), + }, +}; +module_platform_driver(mtk_apu_rproc_driver); + +MODULE_LICENSE("GPL v2"); +MODULE_AUTHOR("Alexandre Bailon"); +MODULE_DESCRIPTION("MTK APU Remote Processor control driver"); From patchwork Fri Mar 4 16:15:11 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexandre Bailon X-Patchwork-Id: 12769437 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 8E122C433EF for ; Fri, 4 Mar 2022 16:26:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=Y9AKZJnsYH2v4kUBA/cusl6pTczlqXFVxluxUU/S8Is=; b=jnt9nWUlr0uae/ YGkka4N74zCE/BlOHMGzPmj8oJt+sHY4n5FodK3f5j0yxh04pMxBwIxtkZLvoUeNDpc+HthezWQnJ JfRIDBM34tTAFQY+PfGSgp7jPvj5HvCq1vAWHWJdtZth4Ed32Pt7axd9CqKwE+WfRb0QCVYZq8qmy D7nnjtalmRoACFM30AxLsJLEN8K8pF3R9qySAE06lMLDkSvCdO+0z2MFkR4zORiMmsznBTNOxj1tP uHcFMnTo3aDkrwdBgEIxwXWVwe0MCgdHpcX702xOTZoz3pJPwls4GmPr18eV/nvSZP/w8qn/ZyLM9 I3FltaLMwjPmtJpA+ZCg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nQAjA-00B1HW-9i; Fri, 04 Mar 2022 16:24:25 +0000 Received: from mail-wm1-x32d.google.com ([2a00:1450:4864:20::32d]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nQAaZ-00AxpC-Gk for linux-arm-kernel@lists.infradead.org; Fri, 04 Mar 2022 16:15:35 +0000 Received: by mail-wm1-x32d.google.com with SMTP id 19so5050637wmy.3 for ; Fri, 04 Mar 2022 08:15:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=DFsuyCOMy/pl+DrmLQk2yMUaSrmiytEYHpzUyHLsV8M=; b=MfM51jgPq7iaGaLlQsyEHm/9ew1UFuusyy1unUC+zh3q+Nmf1L3n9YE7xcAwnx9FCJ XjtkR6AKg8+cAcFPWYX11uhdoCZKFxdDbKBnWuA2daTUlTHTqk86YT+PSJaC/tniMNdH NMr5Cu842/zTYHMn7BZe8/XaTj11PTamnDTomm4/kLFCTM24KBVCEJIiDCGe6yQwZtV9 CaNd7/iKn+K2+Pse/Ff5skhlz4Dk+neOVxd4jbOOX9w+pMODz5V+jzlNFm3NxSOLHR8Q OqpES/+l3HarKWoFkFL3upi6aue2PIPgM1lNOAPpJM+EfwpXtKiA3095r/sMi/nGfNDm DKQg== 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=DFsuyCOMy/pl+DrmLQk2yMUaSrmiytEYHpzUyHLsV8M=; b=aWlf+nYzf/tMA+0FXSBb5bg9J0h73BFx50BbBwTg2p1djkkVq4eMXrVVzFoF4FITbs 1xr5HZSH+aXq1uBZ/NBe3gKBkZ38+hPjx9gG0iI5qbcdNxIUoSmJkcaXXDrbrLi5xR9g Z7E5CUge5+U1sHa8hoYKwHN+zqQcQjBxILyD9xrkZ3qHfwWBb/v8MbEuguFKT77ufWQA lu8tlye0j7K8+1WUF7+64ZWaS6hgC4vT1QuGVtT9Tdrff91dG1IYXW/ma+GVeogWtcyU BcaOLPZ5MnZUoMV9n/8f7miRFiNizsrIMi4caR/9XqVXz6Opy2XBIokwfhVVKu60uiW6 5T/A== X-Gm-Message-State: AOAM531i/yFa7bBuft6XbHFPl99CR4KVPZyXzaZKSQz+9/NF1FFsEvCO t2Pxo5LeDf3YC8us1Cq4CC8tBA== X-Google-Smtp-Source: ABdhPJyBJOcBWjTtm8HY+gNhpkU9m234PAZ12suoskfo+8t/6sjPrUd+bewsHN/nHvszJDXwairsFA== X-Received: by 2002:a05:600c:3c9b:b0:380:be98:6204 with SMTP id bg27-20020a05600c3c9b00b00380be986204mr8063300wmb.121.1646410529792; Fri, 04 Mar 2022 08:15:29 -0800 (PST) Received: from xps-9300.baylibre (laubervilliers-658-1-213-31.w90-63.abo.wanadoo.fr. [90.63.244.31]) by smtp.gmail.com with ESMTPSA id g6-20020a5d5406000000b001f049726044sm4937307wrv.79.2022.03.04.08.15.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Mar 2022 08:15:29 -0800 (PST) From: Alexandre Bailon To: ohad@wizery.com, bjorn.andersson@linaro.org, mathieu.poirier@linaro.org, robh+dt@kernel.or Cc: matthias.bgg@gmail.com, linux-remoteproc@vger.kernel.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, linux-kernel@vger.kernel.org, stephane.leprovost@mediatek.com, khilman@baylibre.com, Alexandre Bailon Subject: [PATCH v4 4/7] remoteproc: mtk_apu: Add support of JTAG Date: Fri, 4 Mar 2022 17:15:11 +0100 Message-Id: <20220304161514.994128-5-abailon@baylibre.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220304161514.994128-1-abailon@baylibre.com> References: <20220304161514.994128-1-abailon@baylibre.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220304_081531_625448_ADD3C8B4 X-CRM114-Status: GOOD ( 23.14 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org The DSP could be debugged using JTAG. The support of JTAG could enabled at build time and it could be enabled using debugfs. Signed-off-by: Alexandre Bailon --- drivers/remoteproc/Kconfig | 9 +++ drivers/remoteproc/mtk_apu.c | 147 ++++++++++++++++++++++++++++++++++- 2 files changed, 155 insertions(+), 1 deletion(-) diff --git a/drivers/remoteproc/Kconfig b/drivers/remoteproc/Kconfig index 959d24e9492c..28140cf04d8a 100644 --- a/drivers/remoteproc/Kconfig +++ b/drivers/remoteproc/Kconfig @@ -74,6 +74,15 @@ config MTK_APU It's safe to say N here. +config MTK_APU_JTAG + bool "Enable support of JTAG" + depends on MTK_APU + help + Say y to enable support of JTAG. + By default, JTAG will remain disabled until it is enabled using + debugfs: remoteproc/remoteproc0/jtag. Write 1 to enable it and + 0 to disable it. + config OMAP_REMOTEPROC tristate "OMAP remoteproc support" depends on ARCH_OMAP4 || SOC_OMAP5 || SOC_DRA7XX diff --git a/drivers/remoteproc/mtk_apu.c b/drivers/remoteproc/mtk_apu.c index 867b4682b507..3905eb5b7174 100644 --- a/drivers/remoteproc/mtk_apu.c +++ b/drivers/remoteproc/mtk_apu.c @@ -5,12 +5,14 @@ #include #include +#include #include #include #include #include #include #include +#include #include #include #include @@ -45,6 +47,11 @@ #define CORE_DEFAULT1 (0x00000140) #define CORE_DEFAULT0_ARUSER_IDMA_USE_IOMMU (0x10 << 0) #define CORE_DEFAULT0_AWUSER_IDMA_USE_IOMMU (0x10 << 5) +#define CORE_DEFAULT2 (0x00000144) +#define CORE_DEFAULT2_DBG_EN BIT(3) +#define CORE_DEFAULT2_NIDEN BIT(2) +#define CORE_DEFAULT2_SPNIDEN BIT(1) +#define CORE_DEFAULT2_SPIDEN BIT(0) #define CORE_XTENSA_ALTRESETVEC (0x000001F8) #define VDEV_MEM_COUNT (3) @@ -59,6 +66,13 @@ struct mtk_apu_rproc { struct clk_bulk_data *clks; struct iommu_domain *domain; struct list_head mappings; + +#ifdef CONFIG_MTK_APU_JTAG + struct pinctrl *pinctrl; + struct pinctrl_state *pinctrl_jtag; + bool jtag_enabled; + struct mutex jtag_mutex; +#endif }; static const char * const mt8183_clk_names[] = { @@ -355,6 +369,133 @@ static irqreturn_t mtk_apu_rproc_callback(int irq, void *data) return IRQ_WAKE_THREAD; } +#ifdef CONFIG_MTK_APU_JTAG + +static int apu_enable_jtag(struct mtk_apu_rproc *apu_rproc) +{ + int ret = 0; + + mutex_lock(&apu_rproc->jtag_mutex); + if (apu_rproc->jtag_enabled) + goto err_mutex_unlock; + + writel(CORE_DEFAULT2_SPNIDEN | CORE_DEFAULT2_SPIDEN | + CORE_DEFAULT2_NIDEN | CORE_DEFAULT2_DBG_EN, + apu_rproc->base + CORE_DEFAULT2); + + apu_rproc->jtag_enabled = 1; + +err_mutex_unlock: + mutex_unlock(&apu_rproc->jtag_mutex); + + return ret; +} + +static int apu_disable_jtag(struct mtk_apu_rproc *apu_rproc) +{ + int ret = 0; + + mutex_lock(&apu_rproc->jtag_mutex); + if (!apu_rproc->jtag_enabled) + goto err_mutex_unlock; + + writel(0, apu_rproc->base + CORE_DEFAULT2); + + apu_rproc->jtag_enabled = 0; + +err_mutex_unlock: + mutex_unlock(&apu_rproc->jtag_mutex); + + return ret; +} + +static ssize_t rproc_jtag_read(struct file *filp, char __user *userbuf, + size_t count, loff_t *ppos) +{ + struct rproc *rproc = filp->private_data; + struct mtk_apu_rproc *apu_rproc = (struct mtk_apu_rproc *)rproc->priv; + char *buf = apu_rproc->jtag_enabled ? "enabled\n" : "disabled\n"; + + return simple_read_from_buffer(userbuf, count, ppos, buf, strlen(buf)); +} + +static ssize_t rproc_jtag_write(struct file *filp, const char __user *user_buf, + size_t count, loff_t *ppos) +{ + struct rproc *rproc = filp->private_data; + struct mtk_apu_rproc *apu_rproc = (struct mtk_apu_rproc *)rproc->priv; + char buf[10]; + int ret; + + if (count < 1 || count > sizeof(buf)) + return -EINVAL; + + ret = copy_from_user(buf, user_buf, count); + if (ret) + return -EFAULT; + + /* remove end of line */ + if (buf[count - 1] == '\n') + buf[count - 1] = '\0'; + + if (!strncmp(buf, "enabled", count)) + ret = apu_enable_jtag(apu_rproc); + else if (!strncmp(buf, "disabled", count)) + ret = apu_disable_jtag(apu_rproc); + else + return -EINVAL; + + return ret ? ret : count; +} + +static const struct file_operations rproc_jtag_ops = { + .read = rproc_jtag_read, + .write = rproc_jtag_write, + .open = simple_open, +}; + +static int apu_jtag_probe(struct mtk_apu_rproc *apu_rproc) +{ + int ret; + + if (!apu_rproc->rproc->dbg_dir) + return -ENODEV; + + apu_rproc->pinctrl = devm_pinctrl_get(apu_rproc->dev); + if (IS_ERR(apu_rproc->pinctrl)) { + dev_warn(apu_rproc->dev, "Failed to find JTAG pinctrl\n"); + return PTR_ERR(apu_rproc->pinctrl); + } + + apu_rproc->pinctrl_jtag = pinctrl_lookup_state(apu_rproc->pinctrl, + "jtag"); + if (IS_ERR(apu_rproc->pinctrl_jtag)) + return PTR_ERR(apu_rproc->pinctrl_jtag); + + ret = pinctrl_select_state(apu_rproc->pinctrl, + apu_rproc->pinctrl_jtag); + if (ret < 0) + return ret; + + mutex_init(&apu_rproc->jtag_mutex); + + debugfs_create_file("jtag", 0600, apu_rproc->rproc->dbg_dir, + apu_rproc->rproc, &rproc_jtag_ops); + + return 0; +} +#else +static int apu_jtag_probe(struct mtk_apu_rproc *apu_rproc) +{ + return 0; +} + +static int apu_disable_jtag(struct mtk_apu_rproc *apu_rproc) +{ + return 0; +} +#endif /* CONFIG_MTK_APU_JTAG */ + static int mtk_apu_rproc_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; @@ -442,6 +583,10 @@ static int mtk_apu_rproc_probe(struct platform_device *pdev) goto free_rproc; } + ret = apu_jtag_probe(apu_rproc); + if (ret) + dev_warn(dev, "Failed to configure jtag\n"); + return 0; free_rproc: @@ -457,7 +602,7 @@ static int mtk_apu_rproc_remove(struct platform_device *pdev) struct device *dev = &pdev->dev; disable_irq(apu_rproc->irq); - + apu_disable_jtag(apu_rproc); rproc_del(rproc); of_reserved_mem_device_release(dev); rproc_free(rproc); From patchwork Fri Mar 4 16:15:12 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexandre Bailon X-Patchwork-Id: 12769439 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 1BBE7C433F5 for ; Fri, 4 Mar 2022 16:29:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=AIk5LQT1h0ZALXQcL++Bp+ObnlENmvarbp8EjCL9mB8=; b=m/aGGR0oL8Wbc4 9VUJtDGgVqUl4ZINjv40ub0gu7gntA+iN7Qu7J9VDOmzaf+dqyd9+C2fj5wHFLWxH4Nr2XsQj3gbA J4Qk9PIlBi1Q3fmT6SSfSyi14B72L34XQt0ilR3pSNcVrXAWXSkXalPD5cEVaWQ2aqXIK1waSQnTv ScjaMX6z73tYw0b9TwklV5DtdKQo0j9gMLpIc48iyndALWzHWBC/P/chSSutO2Q/xYoLDkdxrSQr2 NKOWnyJO/jOoBjf4iXdgdvjJIEwTeZ9wLmuLV5Z0FSxeBmA7nSMHj81nCXSjyqr4ItcPt78RRBK5p O6c7ujVT6vBjiWxZ4V3g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nQAm4-00B2Q5-1U; Fri, 04 Mar 2022 16:27:24 +0000 Received: from mail-wr1-x431.google.com ([2a00:1450:4864:20::431]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nQAaa-00AxqB-VO for linux-arm-kernel@lists.infradead.org; Fri, 04 Mar 2022 16:15:37 +0000 Received: by mail-wr1-x431.google.com with SMTP id j26so3056181wrb.1 for ; Fri, 04 Mar 2022 08:15:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=n+My/nqfiMsUFME5jSzdOaKmEvDAySulF7VBL4+IJf4=; b=PnqV9wYmLqfFTc4OFJc5UAuaMvtmWEJJN1yL6Rm7H2Q2mStp4J3ChxMgn06ydCvXyK UVRtV/otmLgWI2azaSmPvS4xLdRkV3dkpCcAM6LMGr8w+AwDloylveLMcJBdDQosT0q5 KPsoJe0mc+UridMf98U3NAi8nlEXwLZWoGI3R2UzOvVn1t8KlwaJZlZvWSBH4JdmARrb akkAOnaXLWabkA7OwsKaB8vjC2N/RQOQJb3V3D7vfckSt1zL+lkoaFiaTEfO/g8DDgbe zgYKdl4HKH63UGK6xrr+AByFwFqoA8+ajW49r1XlNolMOOXw3kyLLtWl1STMzHFKGZZ+ zIiA== 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=n+My/nqfiMsUFME5jSzdOaKmEvDAySulF7VBL4+IJf4=; b=r2rKKAJmvgvqBk3gBYJ76lfOrmdZp6wFw07kabD8gXNVYUcb5Siyn/p8JpzeTO3clj Z+bW8TX878dzyeTx8q0NsQNbwV1H3+c53uS6Dq3KLGnLmOcA7D+FS8EAKA1Ni4aXHMmZ 6rWBuXy4xuaHx6i8ZmZaUfyL1zz8yreMzaxFNOkIN9/Vj1k+tkg/hxnu4LAXq4mXBJSa ESfQP0xg3t2KuzESmrETcwcp7/HKve0iL2Q43ivyLRilXlJk1Agl79M9ARzSpInX5l3H E3+89Z3EZc9FdbWVFITfUKL2EXDLf1ac8ZnEVT4Ff7iVWcKzMhSO9hxwDC5aSz2REA64 Wd+Q== X-Gm-Message-State: AOAM5301wTA8FtQ19XDs409FfC6RuXzjEvwLXgKT7GkOvd2WU2i3XWgf LeIHLuVOyUEi6LETWgwtSr/cGw== X-Google-Smtp-Source: ABdhPJyfHIvzkrsMlpfQsnDvygOuOwOVs1EDwFq3zpjNDBuNMMUBYWWaEnz39fCgj1Cxh74/FkXKDg== X-Received: by 2002:adf:ef81:0:b0:1f0:95f:30a7 with SMTP id d1-20020adfef81000000b001f0095f30a7mr13676692wro.636.1646410531281; Fri, 04 Mar 2022 08:15:31 -0800 (PST) Received: from xps-9300.baylibre (laubervilliers-658-1-213-31.w90-63.abo.wanadoo.fr. [90.63.244.31]) by smtp.gmail.com with ESMTPSA id g6-20020a5d5406000000b001f049726044sm4937307wrv.79.2022.03.04.08.15.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Mar 2022 08:15:30 -0800 (PST) From: Alexandre Bailon To: ohad@wizery.com, bjorn.andersson@linaro.org, mathieu.poirier@linaro.org, robh+dt@kernel.or Cc: matthias.bgg@gmail.com, linux-remoteproc@vger.kernel.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, linux-kernel@vger.kernel.org, stephane.leprovost@mediatek.com, khilman@baylibre.com, Julien STEPHAN , Alexandre Bailon Subject: [PATCH v4 5/7] remoteproc: mtk_apu: Use match_data Date: Fri, 4 Mar 2022 17:15:12 +0100 Message-Id: <20220304161514.994128-6-abailon@baylibre.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220304161514.994128-1-abailon@baylibre.com> References: <20220304161514.994128-1-abailon@baylibre.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220304_081533_045656_CA5EE639 X-CRM114-Status: GOOD ( 18.44 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Julien STEPHAN This commits prepare the driver to be more generic in order to support multiple platform using the compatible property. To do that, put some register values and the clocks names inside private data. Signed-off-by: Julien STEPHAN Signed-off-by: Alexandre Bailon --- drivers/remoteproc/mtk_apu.c | 35 ++++++++++++++++++++++++++++------- 1 file changed, 28 insertions(+), 7 deletions(-) diff --git a/drivers/remoteproc/mtk_apu.c b/drivers/remoteproc/mtk_apu.c index 3905eb5b7174..deec51b86ba5 100644 --- a/drivers/remoteproc/mtk_apu.c +++ b/drivers/remoteproc/mtk_apu.c @@ -58,12 +58,20 @@ #define APU_RESET_DELAY (27) +struct mtk_apu_conf { + u32 core_default0; + u32 core_default1; + u32 num_clks; + const char * const *clk_names; +}; + struct mtk_apu_rproc { struct device *dev; void __iomem *base; int irq; unsigned int num_clks; struct clk_bulk_data *clks; + struct mtk_apu_conf *conf; struct iommu_domain *domain; struct list_head mappings; @@ -81,6 +89,13 @@ static const char * const mt8183_clk_names[] = { "jtag" }; +static const struct mtk_apu_conf mt8183_conf = { + .core_default0 = (0x10 << 23) | (0x10 << 18), + .core_default1 = (0x10 << 0) | (0x10 << 5), + .num_clks = ARRAY_SIZE(mt8183_clk_names), + .clk_names = mt8183_clk_names +}; + static int mtk_apu_iommu_map(struct rproc *rproc, struct rproc_mem_entry *entry) { struct mtk_apu_rproc *apu_rproc = rproc->priv; @@ -289,10 +304,9 @@ static int mtk_apu_rproc_start(struct rproc *rproc) writel(core_ctrl, apu_rproc->base + CORE_CTRL); /* Configure memory accesses to go through the IOMMU */ - writel(CORE_DEFAULT0_AWUSER_USE_IOMMU | CORE_DEFAULT0_ARUSER_USE_IOMMU | - CORE_DEFAULT0_QOS_SWAP_1, apu_rproc->base + CORE_DEFAULT0); - writel(CORE_DEFAULT0_AWUSER_IDMA_USE_IOMMU | - CORE_DEFAULT0_ARUSER_IDMA_USE_IOMMU, + writel(apu_rproc->conf->core_default0 | CORE_DEFAULT0_QOS_SWAP_1, + apu_rproc->base + CORE_DEFAULT0); + writel(apu_rproc->conf->core_default1, apu_rproc->base + CORE_DEFAULT1); /* Release the APU */ @@ -565,11 +579,18 @@ static int mtk_apu_rproc_probe(struct platform_device *pdev) goto free_rproc; } - apu_rproc->num_clks = ARRAY_SIZE(mt8183_clk_names); + + apu_rproc->conf = (struct mtk_apu_conf *)device_get_match_data(dev); + if (!apu_rproc->conf) { + ret = -ENODEV; + goto free_rproc; + } + + apu_rproc->num_clks = apu_rproc->conf->num_clks; apu_rproc->clks = devm_kcalloc(dev, apu_rproc->num_clks, sizeof(*apu_rproc->clks), GFP_KERNEL); for (i = 0; i < apu_rproc->num_clks; ++i) - apu_rproc->clks[i].id = mt8183_clk_names[i]; + apu_rproc->clks[i].id = apu_rproc->conf->clk_names[i]; ret = devm_clk_bulk_get(dev, apu_rproc->num_clks, apu_rproc->clks); if (ret) { @@ -611,7 +632,7 @@ static int mtk_apu_rproc_remove(struct platform_device *pdev) } static const struct of_device_id mtk_apu_rproc_of_match[] = { - { .compatible = "mediatek,mt8183-apu", }, + { .compatible = "mediatek,mt8183-apu", .data = &mt8183_conf }, { /* sentinel */ }, }; MODULE_DEVICE_TABLE(of, mtk_apu_rproc_of_match); From patchwork Fri Mar 4 16:15:13 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexandre Bailon X-Patchwork-Id: 12769446 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id C1F71C433EF for ; Fri, 4 Mar 2022 16:30:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=XDatAo43LfwoqcYbQsJkfS9ffYSgWUmOan3lBCgw/qc=; b=cJZ0RV9DIK2VN2 Z4cwNTI8YyOC87yPkrp57WRVxTKdQYTGvahZKBpDuqEppMDH+m1vk89P9WVvmMQJtbSAmSMkneDNe mZTgozSX623AG4UmVCBaK8phL3yYfmI5GqgyAnkmonl6G2mj9/TXA92Fr/UUIP47y5dOb5FlGEsG9 ZZxQNPviwIyIJb9124l+9l4FmeL0X2t7W4RQyMD8I1pOsUtuk79eGrDjjgNVen9ICr2Lc8QlfqiXk f/h/Q/3MOEIyy+A3iEDw3vlR1R3OzpiugyS5Gc7r+FQie26Gzr90wsT71c5vBFQMAS2n2hvjo/YS9 VxN9cmk6SibKrTFE7jbA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nQAnc-00B2u9-Ei; Fri, 04 Mar 2022 16:29:01 +0000 Received: from mail-wr1-x432.google.com ([2a00:1450:4864:20::432]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nQAab-00Axqx-WA for linux-arm-kernel@lists.infradead.org; Fri, 04 Mar 2022 16:15:38 +0000 Received: by mail-wr1-x432.google.com with SMTP id p9so13394834wra.12 for ; Fri, 04 Mar 2022 08:15:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=16aGvyY6fmPhhVYfQXbNCxfZJxOVo7nnrPOm+3Luipg=; b=kN8p92NuWAbYqs8bwZlnLzwcZDbsVEWD4vm0t5XrNfLzL7aH0vHtHEcRtcG0C/1Uu7 9hdsGCdU1rbTrLacXL/Ft91zYh/W1JDQIBszrzrit1TsPj5F50AHGLBhangCud91sOb+ 0xmv5DAhd0EuvQ6glDl85z8F4M80x30xSzPfnpcNAC1bot0hw0gQVwnEHiXptu+KFEVT KtTKvHh8xyMPof3zdp+DP48Co+7DZGEpI3DZVEPQvWJu+Y5HaN7E9H5vK0HfJYoUpwXb uu+Xszyy+It68nNjX8tuaNzrkWGn+hyALM66vu0FpOGsNNU/MyaZYPtYRPeDWog4idkA Hajw== 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=16aGvyY6fmPhhVYfQXbNCxfZJxOVo7nnrPOm+3Luipg=; b=xHI0/UIFsl3JkPwDAhM1clO7TZdnttvwfEZSrgmZ+UQXe3xP1J84pRyTH1b7J35hX2 ADJva9sEHnUHZR/lyiAfH15aZuv9ePJJucWTPx/lm0sXyf6tiWtitnTkqfhwQ7ryMo16 ia33x6XlOJA+pjtFi4DnCjsgX6l4XqMX4Wzpb8LDwKKyiGcqTIROzObxrJJXE2YjcKBj AW7VROBi5xYzgiSf451tXt7Xb5LdnDI56Tmlr/yQxh/1/z1QZzajZAZYuIqJOZoWO/Dm i+U7y2b8K83Aq7u+5NtHvlB8LYmRFIUrRYmZn9lxRth+F0tn9XRPIl8rfuzrqZyNFuAw Livw== X-Gm-Message-State: AOAM532sQLU2SyLR9eAujCLx+m007En7bhRPy7mChzIE7VBmCls4Dij6 FWRz2QNVRc2I6/JPWymVJ3P2iA== X-Google-Smtp-Source: ABdhPJwD4uW+a+b6q8YWzK9KzYjz7dwuWWKnSwI9jSPWBcToFrXnKiJsKNXtvqLT5eUBLCFLIqBmsg== X-Received: by 2002:adf:ed0c:0:b0:1f0:63a5:36aa with SMTP id a12-20020adfed0c000000b001f063a536aamr4767846wro.588.1646410532349; Fri, 04 Mar 2022 08:15:32 -0800 (PST) Received: from xps-9300.baylibre (laubervilliers-658-1-213-31.w90-63.abo.wanadoo.fr. [90.63.244.31]) by smtp.gmail.com with ESMTPSA id g6-20020a5d5406000000b001f049726044sm4937307wrv.79.2022.03.04.08.15.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Mar 2022 08:15:31 -0800 (PST) From: Alexandre Bailon To: ohad@wizery.com, bjorn.andersson@linaro.org, mathieu.poirier@linaro.org, robh+dt@kernel.or Cc: matthias.bgg@gmail.com, linux-remoteproc@vger.kernel.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, linux-kernel@vger.kernel.org, stephane.leprovost@mediatek.com, khilman@baylibre.com, Julien STEPHAN , Alexandre Bailon Subject: [PATCH v4 6/7] remoteproc: mtk-apu: Add support of MT8365 Date: Fri, 4 Mar 2022 17:15:13 +0100 Message-Id: <20220304161514.994128-7-abailon@baylibre.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220304161514.994128-1-abailon@baylibre.com> References: <20220304161514.994128-1-abailon@baylibre.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220304_081534_098215_2B405B90 X-CRM114-Status: GOOD ( 13.10 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Julien STEPHAN This adds support of APU available in the MT8365. Signed-off-by: Julien STEPHAN Signed-off-by: Alexandre Bailon --- drivers/remoteproc/mtk_apu.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/drivers/remoteproc/mtk_apu.c b/drivers/remoteproc/mtk_apu.c index deec51b86ba5..57dd73c63d3f 100644 --- a/drivers/remoteproc/mtk_apu.c +++ b/drivers/remoteproc/mtk_apu.c @@ -96,6 +96,24 @@ static const struct mtk_apu_conf mt8183_conf = { .clk_names = mt8183_clk_names }; +static const char * const mt8365_clk_names[] = { + "if_ck", + "edma", + "ahb", + "axi", + "ipu", + "jtag", + "smi_cam", + "ifr_apu_axi", +}; + +static const struct mtk_apu_conf mt8365_conf = { + .core_default0 = BIT(26) | BIT(20), + .core_default1 = BIT(3) | BIT(7), + .num_clks = ARRAY_SIZE(mt8365_clk_names), + .clk_names = mt8365_clk_names +}; + static int mtk_apu_iommu_map(struct rproc *rproc, struct rproc_mem_entry *entry) { struct mtk_apu_rproc *apu_rproc = rproc->priv; @@ -633,6 +651,7 @@ static int mtk_apu_rproc_remove(struct platform_device *pdev) static const struct of_device_id mtk_apu_rproc_of_match[] = { { .compatible = "mediatek,mt8183-apu", .data = &mt8183_conf }, + { .compatible = "mediatek,mt8365-apu", .data = &mt8365_conf }, { /* sentinel */ }, }; MODULE_DEVICE_TABLE(of, mtk_apu_rproc_of_match); From patchwork Fri Mar 4 16:15:14 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexandre Bailon X-Patchwork-Id: 12769447 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 2EFE9C433F5 for ; Fri, 4 Mar 2022 16:32:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=Jwtrul3mZePHap7jScI1JqTxL5W++2yV2rVRoJE+Ehc=; b=0KcsACwRe5NU9G /4YhZyIrXlzinfrVlAjBmryGZcgVjAwNVNgQLTpd1ZJhRYcaoZJxjdBA8BmX5MRDyTA5ZhW2Hzxsm z6Uh7trBfEXr7TX36ueRE8nk0dc7zaPjOrG+jHADqc1LRYZtyUPcv/Crpq3Wk0jANLLo99nFPMFYa RfN4TqvL1NjnLciqCnbfz31cEzc/b/yNueWPRMwkoL+XrZifs/pyfATSKLLpWmR8MrRDcZd2Eb2VE Azxi8HIESZt7g+6Z9CCzuHGqzzRNMZny5jPATYCb/AIjn7V1EUkHVFCGnmUP1j+Kwin1/VC8KtSNq eTyywcaQDeOx8JZJC6Cw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nQAow-00B3Ot-TQ; Fri, 04 Mar 2022 16:30:25 +0000 Received: from mail-wr1-x42d.google.com ([2a00:1450:4864:20::42d]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nQAad-00Axrj-4Q for linux-arm-kernel@lists.infradead.org; Fri, 04 Mar 2022 16:15:39 +0000 Received: by mail-wr1-x42d.google.com with SMTP id b5so13447914wrr.2 for ; Fri, 04 Mar 2022 08:15:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=xJskNak95cvJcdUCyQawVbbPcPNz7aQv6i/qtIFC/D0=; b=1py/SiRHzXJFbv03+N9Hala6db1fZOCrZVfBakEeZ1XEqEzCNZ68ScYMDGX6fAyeUO hYeZgwCDOPK/5etYhM6FF8r9BmtRRtkdHxuM6ptY/4J01I0SZKaL44Od/4tjZVDGnMFj REa9Xex5sJEPK0jvhX7ZjrY0JsNUccCEe6WyqWZTYC4U8q+ZiWsj7fVnoA+9zkoj3gjl SEMRy8iuTI7qojEl+wDMmPnofqFSIxB2Q7JMb0bwuUUCK+MZfBo5s9I1XyZ5sUVm1++L XBxUYl0Pkvq9A2mdS3WgiOtdryfXlaz1zQdLnumxQLuwBiYtfBB8mrsBzW07IQ3I+Cpc np3w== 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=xJskNak95cvJcdUCyQawVbbPcPNz7aQv6i/qtIFC/D0=; b=7wzP8chq69RQk/ChLwbLfp+6PAu9LpfHQPKPA/m36TpvUMpPeMOjX8VUQEGMgUb5N8 C38TGwgokzLw6aDPzuM+TpgrQDUIjUphwWB3eXYIwOyKdT03SPARGaLX3HNleAvzIOnd Zx645+MtGq+LoUMa8zKFjx2ctb9ibsjdiOIlayYvf1qsCz/ARRLjlZvzcDii3xAs5irI NS5ppJRlA3F8QaQXp96iM/QcyUiryHEnzmy/g+2JMJym49ci2cTzKivYWA4TL2xXt9F7 xlW8C5Hd2HmfF2YsVN2pfE4rwIh0KW1cvye3efHIuYMl9Kyn853rOJVOvXtzxKuDp0xC Usyg== X-Gm-Message-State: AOAM532U7/rrDsaStXwTiP8NL4xzXysfzE3ArDRVkjy2TTeS/LLWzSeB Uu+RN7Br7EuOmhmv2r3oUHhjLQ== X-Google-Smtp-Source: ABdhPJwbTnyZIIz3MhW8i2qeaIJqAT8wW1Pa+ypKCSwBrOZfy77WETAvGz5t2zqL46vAdLT4K0tDtw== X-Received: by 2002:adf:f389:0:b0:1ef:5f0f:cb83 with SMTP id m9-20020adff389000000b001ef5f0fcb83mr26228592wro.26.1646410533312; Fri, 04 Mar 2022 08:15:33 -0800 (PST) Received: from xps-9300.baylibre (laubervilliers-658-1-213-31.w90-63.abo.wanadoo.fr. [90.63.244.31]) by smtp.gmail.com with ESMTPSA id g6-20020a5d5406000000b001f049726044sm4937307wrv.79.2022.03.04.08.15.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Mar 2022 08:15:32 -0800 (PST) From: Alexandre Bailon To: ohad@wizery.com, bjorn.andersson@linaro.org, mathieu.poirier@linaro.org, robh+dt@kernel.or Cc: matthias.bgg@gmail.com, linux-remoteproc@vger.kernel.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, linux-kernel@vger.kernel.org, stephane.leprovost@mediatek.com, khilman@baylibre.com, Alexandre Bailon Subject: [PATCH v4 7/7] ARM64: mt8183: Add support of APU to mt8183 Date: Fri, 4 Mar 2022 17:15:14 +0100 Message-Id: <20220304161514.994128-8-abailon@baylibre.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220304161514.994128-1-abailon@baylibre.com> References: <20220304161514.994128-1-abailon@baylibre.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220304_081535_215339_D6F6686D X-CRM114-Status: UNSURE ( 9.87 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org This adds the support of APU to mt8183. Signed-off-by: Alexandre Bailon --- .../boot/dts/mediatek/mt8183-pumpkin.dts | 50 +++++++++++++++++++ arch/arm64/boot/dts/mediatek/mt8183.dtsi | 40 +++++++++++++++ 2 files changed, 90 insertions(+) diff --git a/arch/arm64/boot/dts/mediatek/mt8183-pumpkin.dts b/arch/arm64/boot/dts/mediatek/mt8183-pumpkin.dts index ee912825cfc6..155c89c998d3 100644 --- a/arch/arm64/boot/dts/mediatek/mt8183-pumpkin.dts +++ b/arch/arm64/boot/dts/mediatek/mt8183-pumpkin.dts @@ -37,6 +37,42 @@ scp_mem_reserved: scp_mem_region@50000000 { reg = <0 0x50000000 0 0x2900000>; no-map; }; + + vdev0buffer: vdev0buffer@52900000 { + compatible = "shared-dma-pool"; + reg = <0 0x52900000 0 0x4000>; + no-map; + }; + + vdev0vring0: vdev0vring0@52904000 { + compatible = "shared-dma-pool"; + reg = <0 0x52904000 0 0x2000>; + no-map; + }; + + vdev0vring1: vdev0vring1@52906000 { + compatible = "shared-dma-pool"; + reg = <0 0x52906000 0 0x2000>; + no-map; + }; + + vdev1buffer: vdev1buffer@52908000 { + compatible = "shared-dma-pool"; + reg = <0 0x52908000 0 0x4000>; + no-map; + }; + + vdev1vring0: vdev1vring0@5290C000 { + compatible = "shared-dma-pool"; + reg = <0 0x5290C000 0 0x2000>; + no-map; + }; + + vdev1vring1: vdev1vring1@5290E000 { + compatible = "shared-dma-pool"; + reg = <0 0x5290E000 0 0x2000>; + no-map; + }; }; leds { @@ -381,3 +417,17 @@ &scp { &dsi0 { status = "disabled"; }; + +&apu0 { + memory-region = <&vdev0buffer>, <&vdev0vring0>, <&vdev0vring1>; + memory-region-names = "vdev0buffer", "vdev0vring0", "vdev0vring1"; + memory-region-da = <0x6fff8000>, <0x6fffc000>, <0x6fffe000>; + status = "okay"; +}; + +&apu1 { + memory-region = <&vdev1buffer>, <&vdev1vring0>, <&vdev1vring1>; + memory-region-names = "vdev1buffer", "vdev1vring0", "vdev1vring1"; + memory-region-da = <0x6fff0000>, <0x6fff4000>, <0x6fff6000>; + status = "okay"; +}; diff --git a/arch/arm64/boot/dts/mediatek/mt8183.dtsi b/arch/arm64/boot/dts/mediatek/mt8183.dtsi index ba4584faca5a..cb02f57e000d 100644 --- a/arch/arm64/boot/dts/mediatek/mt8183.dtsi +++ b/arch/arm64/boot/dts/mediatek/mt8183.dtsi @@ -1542,12 +1542,52 @@ ipu_adl: syscon@19010000 { #clock-cells = <1>; }; + apu0: apu@0x19100000 { + compatible = "mediatek,mt8183-apu"; + reg = <0 0x19180000 0 0x14000>; + interrupts = ; + + iommus = <&iommu M4U_PORT_IMG_IPUO>, + <&iommu M4U_PORT_IMG_IPU3O>, + <&iommu M4U_PORT_IMG_IPUI>; + + clocks = <&ipu_core0 CLK_IPU_CORE0_AXI>, + <&ipu_core0 CLK_IPU_CORE0_IPU>, + <&ipu_core0 CLK_IPU_CORE0_JTAG>; + + clock-names = "axi", "ipu", "jtag"; + + power-domains = <&spm MT8183_POWER_DOMAIN_VPU_CORE0>; + + status = "disabled"; + }; + ipu_core0: syscon@19180000 { compatible = "mediatek,mt8183-ipu_core0", "syscon"; reg = <0 0x19180000 0 0x1000>; #clock-cells = <1>; }; + apu1: apu@19200000 { + compatible = "mediatek,mt8183-apu"; + reg = <0 0x19280000 0 0x14000>; + interrupts = ; + + iommus = <&iommu M4U_PORT_CAM_IPUO>, + <&iommu M4U_PORT_CAM_IPU2O>, + <&iommu M4U_PORT_CAM_IPU3O>; + + clocks = <&ipu_core0 CLK_IPU_CORE1_AXI>, + <&ipu_core0 CLK_IPU_CORE1_IPU>, + <&ipu_core0 CLK_IPU_CORE1_JTAG>; + + clock-names = "axi", "ipu", "jtag"; + + power-domains = <&spm MT8183_POWER_DOMAIN_VPU_CORE1>; + + status = "disabled"; + }; + ipu_core1: syscon@19280000 { compatible = "mediatek,mt8183-ipu_core1", "syscon"; reg = <0 0x19280000 0 0x1000>;