From patchwork Tue Dec 5 18:47:34 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Markus Mayer X-Patchwork-Id: 750506 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b="QtEMLXZR" Received: from mail-oo1-xc36.google.com (mail-oo1-xc36.google.com [IPv6:2607:f8b0:4864:20::c36]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A4C0CD43 for ; Tue, 5 Dec 2023 10:48:15 -0800 (PST) Received: by mail-oo1-xc36.google.com with SMTP id 006d021491bc7-58dd5193db4so501424eaf.1 for ; Tue, 05 Dec 2023 10:48:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; t=1701802095; x=1702406895; darn=vger.kernel.org; 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=vDgn1SrDftxmBi54zNdMtJUWGA9ZxIzk+fgRKHhw/lM=; b=QtEMLXZR5fcHbcLUT4m6kHVdo/6Rk4WgCFLe8+Wzei1nyhxKG/CO046VvhXG5s+von i3FjB3oStaA7mNvXRZGy7c6bkqfPvM/chff/5l6veCF/5LNhLxvkaXtVHBuHbxniBrUD eY0/r2q+GWA2SxnfRdJZVdIspWd058+ENn784= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701802095; x=1702406895; 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=vDgn1SrDftxmBi54zNdMtJUWGA9ZxIzk+fgRKHhw/lM=; b=SB0Yzih5837kG8l6BCigRKuR/lR9+ybLzOE8TcIZGS/NsY3ZN8W86XFTQcHtjf0XHl eS/6KE5wOHF3krA1jtLcf+m4h5+TLts4Hvr030J2FeFz+OhDmtkJDnlfyDh0Ol0Hkutp qVg87lPbKrkUwnZMqCVLI3AucBaXlY8rBXt4oW9mmsVWB1Bnz5EE7pqGjU6rcx3NOToD GqSOt6G5wpuuB+H2nGSHcvuWTruP70iaQU7Cltlu2YYEvAURwpwOjvtyB+HOZ9/ZHYQf ikwzYZztFYbq5oMSGcW2P6IFNpKfAIa1133Mr12zp9K9epaoMLdd+bAniGTDolscoHSf SOLQ== X-Gm-Message-State: AOJu0Yw2K5ONfPgMSwd69XY7HRa0sPYaGD4J7q+WFNflwikR0xl09Zfh gvXagWHg1Z/W0Yi+nTxKIeShrA== X-Google-Smtp-Source: AGHT+IFI1UF+i4Lmh7XXhTATcjR+n/TABBYg+KiFDvGwEmkJJjxPFfcqdC4o+UQvAJ0jSDdQON+qcg== X-Received: by 2002:a05:6359:a25:b0:16e:4d4c:68a2 with SMTP id el37-20020a0563590a2500b0016e4d4c68a2mr20644814rwb.2.1701802094712; Tue, 05 Dec 2023 10:48:14 -0800 (PST) Received: from lbrmn-mmayer.ric.broadcom.net ([192.19.161.248]) by smtp.gmail.com with ESMTPSA id m27-20020a637d5b000000b005c6746620cfsm3151046pgn.51.2023.12.05.10.48.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Dec 2023 10:48:13 -0800 (PST) Received: by lbrmn-mmayer.ric.broadcom.net (Postfix, from userid 1000) id DC55DD02; Tue, 5 Dec 2023 10:48:10 -0800 (PST) From: Markus Mayer To: Krzysztof Kozlowski , Florian Fainelli , Rob Herring , Conor Dooley Cc: Markus Mayer , Linux ARM Kernel List , Device Tree Mailing List , Linux Kernel Mailing List Subject: [PATCH 1/4] dt-bindings: memory: additional compatible strings for Broadcom DPFE Date: Tue, 5 Dec 2023 10:47:34 -0800 Message-ID: <20231205184741.3092376-2-mmayer@broadcom.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20231205184741.3092376-1-mmayer@broadcom.com> References: <20231205184741.3092376-1-mmayer@broadcom.com> Precedence: bulk X-Mailing-List: devicetree@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Add versioned compatible strings for Broadcom DPFE. These take the form brcm,dpfe-cpu-v where is a number from 1 to 4. These API version related compatible strings are more specific than the catch-all "brcm,dpfe-cpu" and more generic than chip-specific compatible strings. Signed-off-by: Markus Mayer --- .../bindings/memory-controllers/brcm,dpfe-cpu.yaml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Documentation/devicetree/bindings/memory-controllers/brcm,dpfe-cpu.yaml b/Documentation/devicetree/bindings/memory-controllers/brcm,dpfe-cpu.yaml index 08cbdcddfead..6dffa7b62baf 100644 --- a/Documentation/devicetree/bindings/memory-controllers/brcm,dpfe-cpu.yaml +++ b/Documentation/devicetree/bindings/memory-controllers/brcm,dpfe-cpu.yaml @@ -16,6 +16,11 @@ properties: - enum: - brcm,bcm7271-dpfe-cpu - brcm,bcm7268-dpfe-cpu + - enum: + - brcm,dpfe-cpu-v1 + - brcm,dpfe-cpu-v2 + - brcm,dpfe-cpu-v3 + - brcm,dpfe-cpu-v4 - const: brcm,dpfe-cpu reg: @@ -40,7 +45,8 @@ additionalProperties: false examples: - | dpfe-cpu@f1132000 { - compatible = "brcm,bcm7271-dpfe-cpu", "brcm,dpfe-cpu"; + compatible = "brcm,bcm7271-dpfe-cpu", "brcm,dpfe-cpu-v1", + "brcm,dpfe-cpu"; reg = <0xf1132000 0x180>, <0xf1134000 0x1000>, <0xf1138000 0x4000>; From patchwork Tue Dec 5 18:47:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Markus Mayer X-Patchwork-Id: 751415 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b="gpEQpc62" Received: from mail-pf1-x431.google.com (mail-pf1-x431.google.com [IPv6:2607:f8b0:4864:20::431]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CF09FD43 for ; Tue, 5 Dec 2023 10:48:21 -0800 (PST) Received: by mail-pf1-x431.google.com with SMTP id d2e1a72fcca58-6ce6f4d3dafso166662b3a.0 for ; Tue, 05 Dec 2023 10:48:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; t=1701802101; x=1702406901; darn=vger.kernel.org; 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=NMuwtjnej1x8HFalp3Q3/OE/xfiviC9gRjxwKKTrR6w=; b=gpEQpc62O1bItJgwaYS33n3QRx0bg7SaxQZ+UbpjC8QwzanI0+gn9nayYjx+p3VEoQ IOVL8qx7o7ZF9TzF+j1URzR9MJsJemhepUEQv3HX9DxZVfv4p/Dz14OMvIJQPzqmJ44h QClHW7S4s88WtIOGPEeT8fAwTPMDdNWD4o/Sw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701802101; x=1702406901; 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=NMuwtjnej1x8HFalp3Q3/OE/xfiviC9gRjxwKKTrR6w=; b=XCg5eXDfNyd4CQimxH8KgmqdM5SSCsHt8w6j2ZB24PsZINyxF9D95H6jE8Ed9S86Is yL9ko+JirnuBjmtlDVN0uzhelaXCymzNqlxEjXSTfAZ5FKJGekhZ5BlpThNaKZ8sAioP MZ3MhHe006FJr4rVruKmvyF9eQe5dOzvS+M6CuoXrVasKAIO9DBjf3XGmHrHgfLwhOlA 1f8nzrwdE+MpUh69ntDPQMGo98C02bRPCnddBHcCnalWY2LslHgx/eWeV91+mZejfFVm UPQbNz10ywFV2C6FyzwpZqcFAxWdWoxPAtxb1Y2ZS/8RX75NpurNIW7mQPwD38j264Jc LqRw== X-Gm-Message-State: AOJu0YyHhcy9stYpoAYr+WROzpTJ1qmy4044w9TTFLPIwjrUj4i+ArCv XHRdEwDqZ7dFXEmq74t0UtDLeQ== X-Google-Smtp-Source: AGHT+IG46+Q5aksBlxRdZwdbXbmdyxxtbUSk8xgwaeO6yDd7b65xBm2D2UXEYhMABHOhQrKOMFxh8w== X-Received: by 2002:aa7:88c6:0:b0:6ce:4c49:58e4 with SMTP id k6-20020aa788c6000000b006ce4c4958e4mr8321583pff.0.1701802101086; Tue, 05 Dec 2023 10:48:21 -0800 (PST) Received: from lbrmn-mmayer.ric.broadcom.net ([192.19.161.248]) by smtp.gmail.com with ESMTPSA id k14-20020aa788ce000000b006ce5b404f5csm3213329pff.134.2023.12.05.10.48.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Dec 2023 10:48:20 -0800 (PST) Received: by lbrmn-mmayer.ric.broadcom.net (Postfix, from userid 1000) id 5BF12D04; Tue, 5 Dec 2023 10:48:19 -0800 (PST) From: Markus Mayer To: Krzysztof Kozlowski , Florian Fainelli , Rob Herring , Conor Dooley Cc: Markus Mayer , Linux ARM Kernel List , Device Tree Mailing List , Linux Kernel Mailing List Subject: [PATCH 2/4] memory: brcmstb_dpfe: introduce version-specific compatible strings Date: Tue, 5 Dec 2023 10:47:35 -0800 Message-ID: <20231205184741.3092376-3-mmayer@broadcom.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20231205184741.3092376-1-mmayer@broadcom.com> References: <20231205184741.3092376-1-mmayer@broadcom.com> Precedence: bulk X-Mailing-List: devicetree@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Introduce compatible strings brcm,dpfe-cpu-v1 through brcm,dpfe-cpu-v3 to the Broadcom DPFE driver. Signed-off-by: Markus Mayer --- drivers/memory/brcmstb_dpfe.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/memory/brcmstb_dpfe.c b/drivers/memory/brcmstb_dpfe.c index a7ab3d377206..66876b409e59 100644 --- a/drivers/memory/brcmstb_dpfe.c +++ b/drivers/memory/brcmstb_dpfe.c @@ -924,6 +924,12 @@ static const struct of_device_id brcmstb_dpfe_of_match[] = { { .compatible = "brcm,bcm7271-dpfe-cpu", .data = &dpfe_api_old_v2 }, { .compatible = "brcm,bcm7278-dpfe-cpu", .data = &dpfe_api_old_v2 }, { .compatible = "brcm,bcm7211-dpfe-cpu", .data = &dpfe_api_new_v2 }, + + /* Match specific DCPU versions */ + { .compatible = "brcm,dpfe-cpu-v1", .data = &dpfe_api_old_v2 }, + { .compatible = "brcm,dpfe-cpu-v2", .data = &dpfe_api_new_v2 }, + { .compatible = "brcm,dpfe-cpu-v3", .data = &dpfe_api_v3 }, + /* API v3 is the default going forward */ { .compatible = "brcm,dpfe-cpu", .data = &dpfe_api_v3 }, {} From patchwork Tue Dec 5 18:47:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Markus Mayer X-Patchwork-Id: 750505 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b="Sd1uSfKe" Received: from mail-il1-x133.google.com (mail-il1-x133.google.com [IPv6:2607:f8b0:4864:20::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7411BD64 for ; Tue, 5 Dec 2023 10:48:31 -0800 (PST) Received: by mail-il1-x133.google.com with SMTP id e9e14a558f8ab-35d626e4f79so3414905ab.0 for ; Tue, 05 Dec 2023 10:48:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; t=1701802110; x=1702406910; darn=vger.kernel.org; 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=c83gTiuSNlfK6LuG6NDT4lKYycGtpFWRhFgpMEcF2f0=; b=Sd1uSfKeg/vkyrL7j+/8c8WoxdnHmQ94waLtsfDQly9ykwlOR7CW5OVXw9//l1UmB7 sbdpANDp7hAgHPBb3XYD5a5jzrNuKK87Xlw2M3gKE1BcOed9zJmYRHsdmpzAmvKHwPRq IAl1Z0mGy1taoEqa7iD5PYMf+07ubTz/JQOkg= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701802110; x=1702406910; 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=c83gTiuSNlfK6LuG6NDT4lKYycGtpFWRhFgpMEcF2f0=; b=xIwgZ1yUgTxSYScfywjItVY6zIWV2iIGktpnY1agUyhFAn0AbsrlXcy+aWN0r3+DRQ kq285dBiC0gr1xsGEHVS3JKzv8dnSqZe4m4E1jKEDhZW6tfpWi0Kui/N+Tm+FvnyqNUO k1mpSTlbDL1VJAWs3EoCYv6Ur7HwdKmYchcsLlaQKlU1ub4Ypd3t40jFUpFDj1cn0Jbk GkKEhPGIQKk0w7E8EUZYzMsHiAk2bz0fuyYjQqJdfPJDRttw5BnHjwZNAVN3O+TUiZxp Ks9e2CIxIT/D03sWmQd3ZCIPn0ovokc96/KgmFzsAf8vrLvOeZmrF5zh4ggbkT35ruh7 DKPQ== X-Gm-Message-State: AOJu0YyALb9FRXuClKdVCfDKqkDwDOly0knrER3aVLKGPjIOb3EKggpp /kjW7YqTLAdwAkOgVq7SBbiHWQ== X-Google-Smtp-Source: AGHT+IGfGYG2l4gFdK0OsrZ02weECf9cy2uaEaj17cAMQGSoXntfIxayPGE2QlhNtQlxn10jqttbVw== X-Received: by 2002:a05:6e02:2195:b0:35d:5550:76b7 with SMTP id j21-20020a056e02219500b0035d555076b7mr13324536ila.0.1701802110636; Tue, 05 Dec 2023 10:48:30 -0800 (PST) Received: from lbrmn-mmayer.ric.broadcom.net ([192.19.161.248]) by smtp.gmail.com with ESMTPSA id bd9-20020a656e09000000b0058ee60f8e4dsm8440189pgb.34.2023.12.05.10.48.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Dec 2023 10:48:29 -0800 (PST) Received: by lbrmn-mmayer.ric.broadcom.net (Postfix, from userid 1000) id AD769D06; Tue, 5 Dec 2023 10:48:28 -0800 (PST) From: Markus Mayer To: Krzysztof Kozlowski , Florian Fainelli , Rob Herring , Conor Dooley Cc: Markus Mayer , Linux ARM Kernel List , Device Tree Mailing List , Linux Kernel Mailing List Subject: [PATCH 3/4] memory: brcmstb_dpfe: support DPFE API v4 Date: Tue, 5 Dec 2023 10:47:36 -0800 Message-ID: <20231205184741.3092376-4-mmayer@broadcom.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20231205184741.3092376-1-mmayer@broadcom.com> References: <20231205184741.3092376-1-mmayer@broadcom.com> Precedence: bulk X-Mailing-List: devicetree@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Add support for version 4 of the DPFE API. This new version is largely identical to version 3. The main difference is that all commands now take the MHS version number as the first argument. Any other arguments have been pushed down by one (i.e. what used to be arg0 in v3 is arg1 in v4). Signed-off-by: Markus Mayer Reviewed-by: Florian Fainelli --- drivers/memory/brcmstb_dpfe.c | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/drivers/memory/brcmstb_dpfe.c b/drivers/memory/brcmstb_dpfe.c index 66876b409e59..0b0a9b85b605 100644 --- a/drivers/memory/brcmstb_dpfe.c +++ b/drivers/memory/brcmstb_dpfe.c @@ -37,6 +37,9 @@ #define DRVNAME "brcmstb-dpfe" +/* Generic constants */ +#define MHS_VERSION 0x04000000 + /* DCPU register offsets */ #define REG_DCPU_RESET 0x0 #define REG_TO_DCPU_MBOX 0x10 @@ -301,6 +304,28 @@ static const struct dpfe_api dpfe_api_v3 = { }, }; +/* API v4 firmware commands */ +static struct dpfe_api dpfe_api_v4 = { + .version = 4, + .fw_name = NULL, /* We expect the firmware to have been downloaded! */ + .sysfs_attrs = dpfe_v3_groups, /* Same as v3 */ + .command = { + [DPFE_CMD_GET_INFO] = { + [MSG_HEADER] = DPFE_MSG_TYPE_COMMAND, + [MSG_COMMAND] = 0x0101, + [MSG_ARG_COUNT] = 2, + [MSG_ARG0] = MHS_VERSION, + [MSG_ARG0 + 1] = 1, /* Now the 2nd argument */ + }, + [DPFE_CMD_GET_REFRESH] = { + [MSG_HEADER] = DPFE_MSG_TYPE_COMMAND, + [MSG_COMMAND] = 0x0202, + [MSG_ARG_COUNT] = 1, + [MSG_ARG0] = MHS_VERSION, + }, + }, +}; + static const char *get_error_text(unsigned int i) { static const char * const error_text[] = { @@ -929,8 +954,12 @@ static const struct of_device_id brcmstb_dpfe_of_match[] = { { .compatible = "brcm,dpfe-cpu-v1", .data = &dpfe_api_old_v2 }, { .compatible = "brcm,dpfe-cpu-v2", .data = &dpfe_api_new_v2 }, { .compatible = "brcm,dpfe-cpu-v3", .data = &dpfe_api_v3 }, + { .compatible = "brcm,dpfe-cpu-v4", .data = &dpfe_api_v4 }, - /* API v3 is the default going forward */ + /* + * For historical reasons, API v3 is the default if nothing else is + * specified. + */ { .compatible = "brcm,dpfe-cpu", .data = &dpfe_api_v3 }, {} }; From patchwork Tue Dec 5 18:47:37 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Markus Mayer X-Patchwork-Id: 751414 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b="X3OP25Y9" 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 DA0FE1A1 for ; Tue, 5 Dec 2023 10:49:03 -0800 (PST) Received: by mail-pl1-x633.google.com with SMTP id d9443c01a7336-1d0c7330ad9so1882875ad.1 for ; Tue, 05 Dec 2023 10:49:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; t=1701802143; x=1702406943; darn=vger.kernel.org; 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=PAOApdPILCdz/7NHT0OHgRBW5hnPP0BdQ0o84+NjOww=; b=X3OP25Y9cGtbJfxd/TpsfVR5t5AMcrx/bRiB811CBgxscBISvPbkE8Qxdxn/E/ee8f d1IIsu88aXlGnr2n5/Eh5ozyuumTFbEhOu4V2pfu1d8+efJgUiLG7kIJS23upwVl88+5 y1XvRxGzRPoHyQIR5D6LsHM/wUI84w1gRWP6s= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701802143; x=1702406943; 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=PAOApdPILCdz/7NHT0OHgRBW5hnPP0BdQ0o84+NjOww=; b=RaJPDdP/BFX5rOhbJ+885OH50aSjGgIL6aA2/vM0lRfuHj2H+CaeqYxLIJfmDnc5xT bZyfQNR8eGcl3FTEp45opY9IfBtzoWwsKhpN9Ecy9zgKxOEOcORiQyIuHG1oDpEyxIPs L8NSy+Ni8vJOIPQLVCIo3edf6ddGVuc3AT38Df7/l7zbZQgH3ruj4/BSlK7zZX8sWjiu VEHZlyDOXWtfqB26k3VgUkofleJA7t2XgfTaWI2NsrguBpGZxpmGSxs4hG0l8tILUZPG 9tTHRqCZfC9mx86gouwtSrm2ijyVy+iqxAmBCCnlyRET9IQCyV7xR6+IOOCvylINEvnu vh0g== X-Gm-Message-State: AOJu0YypywQC4srahmlP0pc5A2rg8dmnxYAA5fSAVLlJqNkRDqR9EepQ ryh1vjVe96z6gMGvKwWKlQW6Vg== X-Google-Smtp-Source: AGHT+IEZojP/nyAWpgMigLVhprQ+6SsnFxupIzO7E7slzYCKwS+2sSVt+xGjKRttOqRPDieBqvJUCA== X-Received: by 2002:a17:903:1cf:b0:1d0:83bc:5648 with SMTP id e15-20020a17090301cf00b001d083bc5648mr9728581plh.2.1701802143229; Tue, 05 Dec 2023 10:49:03 -0800 (PST) Received: from lbrmn-mmayer.ric.broadcom.net ([192.19.161.248]) by smtp.gmail.com with ESMTPSA id ik12-20020a170902ab0c00b001d06b93c66dsm7219130plb.233.2023.12.05.10.49.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Dec 2023 10:49:02 -0800 (PST) Received: by lbrmn-mmayer.ric.broadcom.net (Postfix, from userid 1000) id 8AAEBD08; Tue, 5 Dec 2023 10:48:37 -0800 (PST) From: Markus Mayer To: Krzysztof Kozlowski , Florian Fainelli , Rob Herring , Conor Dooley Cc: Markus Mayer , Linux ARM Kernel List , Device Tree Mailing List , Linux Kernel Mailing List Subject: [PATCH 4/4] memory: brcmstb_dpfe: introduce best-effort API detection Date: Tue, 5 Dec 2023 10:47:37 -0800 Message-ID: <20231205184741.3092376-5-mmayer@broadcom.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20231205184741.3092376-1-mmayer@broadcom.com> References: <20231205184741.3092376-1-mmayer@broadcom.com> Precedence: bulk X-Mailing-List: devicetree@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Add a best-effort probe function that tries all known DPFE versions to see if one might actually work. This helps in cases where device tree doesn't provide the proper version information for whatever reason. In that case, the driver may still be able to register if one of the known API versions ends up working. Caveat: we have to skip "v1" during our best effort attempts. This is due to the fact that attempting a firmware download as required by v1 will result in a memory access violation on anything but v1 hardware. This would crash the kernel. Since we don't know the HW version, we need to play it safe and skip v1. Signed-off-by: Markus Mayer --- drivers/memory/brcmstb_dpfe.c | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/drivers/memory/brcmstb_dpfe.c b/drivers/memory/brcmstb_dpfe.c index 0b0a9b85b605..15f4ee3b8535 100644 --- a/drivers/memory/brcmstb_dpfe.c +++ b/drivers/memory/brcmstb_dpfe.c @@ -879,6 +879,50 @@ static int brcmstb_dpfe_resume(struct platform_device *pdev) return brcmstb_dpfe_download_firmware(priv); } +static int brcmstb_dpfe_probe_best_effort(struct platform_device *pdev) +{ + const char versioned_compat[] = "brcm,dpfe-cpu-v"; + const char v1_str[] = "-v1"; + const struct of_device_id *matches; + const struct dpfe_api *orig_dpfe_api; + struct device *dev = &pdev->dev; + struct brcmstb_dpfe_priv *priv; + int ret = -ENODEV; + + priv = dev_get_drvdata(dev); + orig_dpfe_api = priv->dpfe_api; + matches = dev->driver->of_match_table; + + /* Loop over all compatible strings */ + for (; matches->compatible[0]; matches++) { + const char *compat = matches->compatible; + /* Find the ones that start with "brcm,dpfe-cpu-v" */ + if (strstr(compat, versioned_compat) == compat) { + char *v1_ptr = strstr(compat, v1_str); + /* + * We must skip v1, since we don't know the hardware + * version and attempting a firmware download on v2 and + * newer would crash the kernel due to a memory access + * violation. + * We make sure to match "-v1" at the end of the string + * only. + */ + if (v1_ptr && v1_ptr[sizeof(v1_str)] == '\0') + continue; + priv->dpfe_api = matches->data; + /* Fingers crossed... */ + ret = brcmstb_dpfe_download_firmware(priv); + if (!ret) + return 0; + } + } + + /* It didn't work, so let's clean up. */ + priv->dpfe_api = orig_dpfe_api; + + return ret; +} + static int brcmstb_dpfe_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; @@ -923,8 +967,20 @@ static int brcmstb_dpfe_probe(struct platform_device *pdev) } ret = brcmstb_dpfe_download_firmware(priv); + if (ret && ret != -EPROBE_DEFER) { + /* + * If the information provided by Device Tree didn't work, let's + * try all known version. Maybe one will work. + */ + dev_warn(dev, + "DPFE v%d didn't work, reverting to best-effort\n", + priv->dpfe_api->version); + dev_warn(dev, + "Device Tree and / or the driver should be updated\n"); + ret = brcmstb_dpfe_probe_best_effort(pdev); + } if (ret) - return dev_err_probe(dev, ret, "Couldn't download firmware\n"); + return dev_err_probe(dev, ret, "Unable to talk to DCPU\n"); ret = sysfs_create_groups(&pdev->dev.kobj, priv->dpfe_api->sysfs_attrs); if (!ret)