From patchwork Tue Oct 1 16:06:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Neil Armstrong X-Patchwork-Id: 831876 Delivered-To: patch@linaro.org Received: by 2002:a5d:43d2:0:b0:367:895a:4699 with SMTP id v18csp366085wrr; Tue, 1 Oct 2024 09:06:31 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVXuawv7od3nulCg9PJE5Usssu09c+wFkEy2HBV6jiZ2UvNAO5ujgRqZ5vYgQBOdD2c/1p7zg==@linaro.org X-Google-Smtp-Source: AGHT+IGu6SrsewKsNKgy+aWA0nh2grrWMT32OysjPDf6tO19JL3ZkBfzqrgq4pMLMCzehWsnpwEs X-Received: by 2002:a05:6602:1553:b0:82d:129f:acb6 with SMTP id ca18e2360f4ac-834d84d4e60mr29996539f.14.1727798791588; Tue, 01 Oct 2024 09:06:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1727798791; cv=none; d=google.com; s=arc-20240605; b=Z9WzQ4EHYFbVaimXUNu9bdIDgp5h41l+kRamvF7QSls0T3BWJoBpOZmO/xtHn+VViz BIOu/CbqKlUTByrVuNfioSYhX+SeabbAAj9bh5EFfQEWmA4KceL/4Yfq5MZv/49mCsKs 4HytEjQffjpfdrwgnQ6+BsuZav4h4XQwKnv/RqDs0DQHvQjab4W64Ubyi4JosAZxT94f Hv1AbzIJZvdpJ1vQXibBrYhC+B4HqjgyKqsIqmXXobq3e6+qHsIY+qjGzUxpoNugtZvw b+Awy4Qt+toINarWd4YRaQF2C8cFVfrAvCiWNAyig9k6y0vX5dlJTWWezLqPFANyvspo xF4A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:cc:to:in-reply-to:references :message-id:content-transfer-encoding:mime-version:subject:date:from :dkim-signature; bh=zPT7IEaifr7cc3qzcBWzLfjVOjkO3GNKvWCF8gXypWc=; fh=gVvPckQTdIFP8in3wfAgEkE0Tgsxc0zPfKfhRZP7np0=; b=IwLRS58SvLgDwrgYsIA6vE4sRItp01t8ohr5s9OwK9AN8N5QR2uT13o2r66n/vQg4E zIqUMLhw+1vHgNC/b7OqiXukdGJal8IzaEDiFiffXjd/PV4JLWc9a896A8gbCDSCicvF 3YT4C8tLNNi7HWCnza2g7PWv0GjiJu3D9LSMA9U0VZSJsnB+TfOX7sesTrx1wPV6vZqA xOX8HRUvLC5l+FGKf2bIcR3RVyReX/2NyqWcT+gcUEW4N8N8mSosYWq/iCDYdmviWLcK 5Tx9NfyiwjojT60IYai1ms9XznsuYZX0XYDtSCiSURyPIn+hFy96JGMmKfw1l1r9dUVB kvew==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=PCgQ9X6y; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Return-Path: Received: from phobos.denx.de (phobos.denx.de. [2a01:238:438b:c500:173d:9f52:ddab:ee01]) by mx.google.com with ESMTPS id ca18e2360f4ac-8349374c9f4si461600339f.147.2024.10.01.09.06.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Oct 2024 09:06:31 -0700 (PDT) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=PCgQ9X6y; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 6AAA689240; Tue, 1 Oct 2024 18:06:21 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="PCgQ9X6y"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 81AC08924A; Tue, 1 Oct 2024 18:06:20 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: 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_BLOCKED, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-lf1-x12c.google.com (mail-lf1-x12c.google.com [IPv6:2a00:1450:4864:20::12c]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 639AD8923F for ; Tue, 1 Oct 2024 18:06:17 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=neil.armstrong@linaro.org Received: by mail-lf1-x12c.google.com with SMTP id 2adb3069b0e04-53993c115cfso2964710e87.2 for ; Tue, 01 Oct 2024 09:06:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1727798777; x=1728403577; darn=lists.denx.de; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=zPT7IEaifr7cc3qzcBWzLfjVOjkO3GNKvWCF8gXypWc=; b=PCgQ9X6yzcXsmQuS3i9xm3Dr3HJ+7SW7z179EBtvKgkt2bDx90CyUxZwajb8f9MMK8 NghIpBOVc1MyUF5RiqgartHP2VdCeitONo94Rgm6TWYcTB1T06AP374BmhatRGdWyuOS duzTo3alpF9l0tBJe95Mh6T7pkVMpoJpXQqoLFKCXrYe+Qd2JQ9rYexOFv3tJC2fzcbq KC49ZkpzcPyz+uzW1mL39QaJJH4/Mx4lqXGvzP75aTmrwWVVlNf9PS+EVWp5MASv9NUM eAiuorsVGAAtrKLDbrB6ZuESmmw0Bn3XTKeAuNZUIzEyQEEMlTHCdACN0vWdJGiA2aeh kLtQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727798777; x=1728403577; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=zPT7IEaifr7cc3qzcBWzLfjVOjkO3GNKvWCF8gXypWc=; b=NlD7cvqbsQSzr6/gkSq8okyJwaUrmoIWLFXy+mQvfDs0rDZOOU1rzNysYAh74OBol6 ju7BrJukoEPLNFAqVkph/ZaUUCZPLgvYtPTPBkVgJHFHEjTB4aefmX0iQngoVd5xzMIX DtM9Brt6Urqf8VadXwfmJk3kwWXQ3xL88jDHbHlJJqyAOCl83/OvWd7eBce1XXjIIX/9 md+NbK1YUjIjU2y6fOfcHmCuSZf8YrPZHnC4mFImEo4NPW3E5txaMDtW/YqWr1cNfq0C q5rJYQwjDfHqh1ntWVqys35iPmga7WYSGbC045pIMmmth5cjLrlYE2N9KSrpmbMuyjEn WgiQ== X-Gm-Message-State: AOJu0YwhUn1x3rdFj2Zt7h+QRLlu9rdxqSUsd+IpYqxXK83G+pnWu1oH J81TQs53rFwFQ9tFJQrne/T/4+qmMrLo1bC7mlXaT7Wbi6Wb7++p/92rVu0y1zg= X-Received: by 2002:a05:6512:3f12:b0:539:94cf:e32f with SMTP id 2adb3069b0e04-53994cfe516mr4944588e87.43.1727798776577; Tue, 01 Oct 2024 09:06:16 -0700 (PDT) Received: from arrakeen.starnux.net ([2a01:e0a:982:cbb0:52eb:f6ff:feb3:451a]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-37cd574282esm12031460f8f.104.2024.10.01.09.06.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Oct 2024 09:06:16 -0700 (PDT) From: Neil Armstrong Date: Tue, 01 Oct 2024 18:06:11 +0200 Subject: [PATCH v2 1/2] spi: add DM_SPI_FLASH compatibility inline functions MIME-Version: 1.0 Message-Id: <20241001-uboot-topic-dfu-sf-dt-v2-1-67f7acfa3ff5@linaro.org> References: <20241001-uboot-topic-dfu-sf-dt-v2-0-67f7acfa3ff5@linaro.org> In-Reply-To: <20241001-uboot-topic-dfu-sf-dt-v2-0-67f7acfa3ff5@linaro.org> To: Lukasz Majewski , Mattijs Korpershoek , Tom Rini , Jagan Teki , Vignesh R Cc: u-boot@lists.denx.de, Neil Armstrong X-Mailer: b4 0.14.1 X-Developer-Signature: v=1; a=openpgp-sha256; l=1881; i=neil.armstrong@linaro.org; h=from:subject:message-id; bh=Eukxa3DiDu2LYKdr009Y7wkbd2+ubH4fPU5lobm+NEc=; b=owEBbQKS/ZANAwAKAXfc29rIyEnRAcsmYgBm/B329/EPYY/ieTdTH9HhUwRxkUl8OxWRjdyOVEwN 4gkp+fyJAjMEAAEKAB0WIQQ9U8YmyFYF/h30LIt33NvayMhJ0QUCZvwd9gAKCRB33NvayMhJ0fMeEA CJkTrjbNIfwpX8faPiwiGtGaXYQ8vzGJ9WG89LIvoO7FvoI2lKOqDANGk1m4KuoLOjy0tYml6b8D/I MVIvf+IxzqDwgLNEz8fqfQyGvWWtdiSvx2AFxQIgmO0i2U/Acd6hXCkAUeaSg/b03/nAys0OOSmB19 9PwS2ZDVJrfWNaxsTvsM0TSqzWk66fcLArBUmBPULvcqZi9MY74mL5pPhJhyQB6YHEMnA9ZPa/MImT tdftOSS4+in1kdQvFpU5wB1Y4glDj7wJMV9LMzX87bzTdC9/vXVT4SX+OXN4eNxsqnbG9WFn2Y30jz z5ytjamMSeba5N5EqOauilaer2qu93IERfbIqREr0Jcjy7cZC+TgTJyynOMSzGeYgDjcTrDjnsJpX6 0/Vj5mezjzfHdTNR9jx8D+EOr0x7tH8DZ3ZdwGBT4ei6ukk5x60HrtXvU9WRFlPJ3oZa2run/Op1xp g8mY5lWUtWttyCBYHGWkqVHQAU2gXMXYmijgjxtWkalcA+WRFbg4SS9UXneq3PzbH0S2cAo7PZSMpl 37e3bM7ZBGRDK7sb1NM5zqD31liLhJIZNQSUIbiBw4izvzXASvrNNfAyw5SNesrllXn9yBzXnlFr9r QvCNpkUmosfHd/Pk6h73LDxsaQYT6CIsf0MwvgGlu9/dU9BWEMAwgpI6VoBA== X-Developer-Key: i=neil.armstrong@linaro.org; a=openpgp; fpr=89EC3D058446217450F22848169AB7B1A4CFF8AE X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean To smoothly handle the transition from the legacy SPI FLASH API to the the driver model API, add the DM functions as dummy inline functions. Today, client code uses #if/#else conditionals, but it's better to use if(IS_ENABLED()) to make sure all code builds fine and avoid configuration hell, leaving the compiler remove the dead code. An example is cmd/sf, which could make use of those dummy functions to drop the conditional compilation. Signed-off-by: Neil Armstrong --- include/spi_flash.h | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/include/spi_flash.h b/include/spi_flash.h index 10d19fd4b11..2e703e85250 100644 --- a/include/spi_flash.h +++ b/include/spi_flash.h @@ -139,6 +139,40 @@ int sandbox_sf_bind_emul(struct sandbox_state *state, int busnum, int cs, void sandbox_sf_unbind_emul(struct sandbox_state *state, int busnum, int cs); #else +/* Compatibility functions for when DM_SPI_FLASH is disabled */ +static inline int spi_flash_probe_bus_cs(unsigned int busnum, unsigned int cs, + struct udevice **devp) +{ + return -ENODEV; +} + +static inline int spi_flash_read_dm(struct udevice *dev, u32 offset, size_t len, + void *buf) +{ + return -ENODEV; +} + +static inline int spi_flash_write_dm(struct udevice *dev, u32 offset, size_t len, + const void *buf) +{ + return -ENODEV; +} + +static inline int spi_flash_erase_dm(struct udevice *dev, u32 offset, size_t len) +{ + return -ENODEV; +} + +static inline int spl_flash_get_sw_write_prot(struct udevice *dev) +{ + return -ENODEV; +} + +static inline int spi_flash_std_probe(struct udevice *dev) +{ + return -ENODEV; +} + struct spi_flash *spi_flash_probe(unsigned int bus, unsigned int cs, unsigned int max_hz, unsigned int spi_mode); From patchwork Tue Oct 1 16:06:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Neil Armstrong X-Patchwork-Id: 831877 Delivered-To: patch@linaro.org Received: by 2002:a5d:43d2:0:b0:367:895a:4699 with SMTP id v18csp366213wrr; Tue, 1 Oct 2024 09:06:43 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVc3XeNcjRik5fcXTlFirunc/YIFIsPLqSg3DRmGotcwygA8YJMfnV3MBQ3UEqrlKKkPbk5+w==@linaro.org X-Google-Smtp-Source: AGHT+IGAsHj2MuD1HTR/ji/VzFvS2HpMsWy5s3s/5pQxgiPdnWnq+OdeS4/cq2b+q+eRj0ziYLRs X-Received: by 2002:a05:6870:4193:b0:277:d195:ab88 with SMTP id 586e51a60fabf-28710bcc3ddmr10345588fac.32.1727798802689; Tue, 01 Oct 2024 09:06:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1727798802; cv=none; d=google.com; s=arc-20240605; b=dV2DVohBZ6z7dMsf9NPUGvnAFgIawQTifzBQNFa5fhOsW8R/4j3MbaPBQ7/Vvu9m7h LuGqqh2jKA7AO+S27r5nN/b6PtVKylmTqFYwd4ScBX602EpsHqQKe1YkTE/F8h27WGOR SipYowvD/aI+K9ROPiGDPfC/yJTZpwItHLXx2zIcxvWJ5M9qMrFH2V7s0KufIPYFS2JI rTGsw22B6MvJwKDusC3XEFP2rxUu+/JNkBoqsqN/VD1epOLkiT6o5hqJj/UWt5ynoeGf gFN3QAwzVD/TNvu9NgsiTYqRdsxYm1Ex74e0wv+DgveQGjtBgJi8n2Ta5/Xy8Dy5wEv4 UqAg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:cc:to:in-reply-to:references :message-id:content-transfer-encoding:mime-version:subject:date:from :dkim-signature; bh=y2N7QVIQOxTKQ1LJHZqwIMoE5JXGIrIr6uvDym5gOtQ=; fh=gVvPckQTdIFP8in3wfAgEkE0Tgsxc0zPfKfhRZP7np0=; b=A0vPxPM53gT+nc3i0lpzQFinhmv0kZoHDK29H/qwsc266yTlFMxFBPHwCUXyea0aOg /D3gUljkgEh1ord/K5/nThy0asLDfSGRDI2GWVZ5ee9MTmqTKQUV7HfgcCudvt8/vGaw s6n01tTgC6YVV6eUEYEfXCH1vhMXseciB3PYsyNto5PuiYiQZLoUPYpx8QCbwuaeU7Nh QP1oICqxZgU15t5QY9wjFcPuOcIo57DEoDUMEJG3HqyaMlOfocMhJNOTV791z6hG62t/ TrCznzbw6cSQ4gy95S0gLWpEQYUBSZ4N//E7U/H02U/KTfKZGWN9GcraD0klA1y0WjXV 1tYw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=rm6JjIn3; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Return-Path: Received: from phobos.denx.de (phobos.denx.de. [85.214.62.61]) by mx.google.com with ESMTPS id 8926c6da1cb9f-4d8888f098fsi5089902173.158.2024.10.01.09.06.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Oct 2024 09:06:42 -0700 (PDT) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) client-ip=85.214.62.61; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=rm6JjIn3; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id EBD3489247; Tue, 1 Oct 2024 18:06:21 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="rm6JjIn3"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 9347A8923F; Tue, 1 Oct 2024 18:06:20 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: 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_BLOCKED, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.2 Received: from mail-wm1-x333.google.com (mail-wm1-x333.google.com [IPv6:2a00:1450:4864:20::333]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 1286089246 for ; Tue, 1 Oct 2024 18:06:18 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=neil.armstrong@linaro.org Received: by mail-wm1-x333.google.com with SMTP id 5b1f17b1804b1-42cb58d810eso40343205e9.0 for ; Tue, 01 Oct 2024 09:06:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1727798777; x=1728403577; darn=lists.denx.de; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=y2N7QVIQOxTKQ1LJHZqwIMoE5JXGIrIr6uvDym5gOtQ=; b=rm6JjIn3q8A+fgZocxQDTcE6xu6WSk+guadjtgWvs1lUibMTE3sl49sGeP+DJj+TpH ry32JMg7mIXosq3eWVzd+Xeajnj2GlIU6uQaY0uKVC2OvX/zcrCBQ82fgF/mSPMjSYdZ UMFSSitw9dFNYnqWs3y90OQSZj9drgy2kRfx0YtKAOA59crQuC/d0NHi2ssIjEWVTg3N /9Vg7nyR+eMFv/HxVn3PAYujptagva3jQ0kJRVVzyPSQvIhp+Ni2JGrBUyElClxJYnls czXjg6r7R54C4ZFzQ+yV+5Lh2bMP0jrx2IEg7jpkQPLrWzYFZi6HnVpuwek0fU8jk894 GQrQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727798777; x=1728403577; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=y2N7QVIQOxTKQ1LJHZqwIMoE5JXGIrIr6uvDym5gOtQ=; b=ADTKTjGRPhnNneaYf02E3w3GONfKN2WBVIB5+EbCLERmjgnburmHDPlnqBZ4p5bpvG 1u6gV3MzLfZO+f6i5Pg8hgyj5dkMG4ovIKMT4ohudAaleZ47mJeW/wy64Y8no6R6UV72 JD5qnY4DE7R7M+AA4MF1MbES53kmey3BjueL4xjwVpxrHtqI9TQv7BktsqHMaSSTnlJE 10ZlcvVxH5/TixO7mLXsrUOI/otLifKOIfKq7BU23tEbYM3RpC9XJ2xkuxJmf688EZ8o Os8ExBC9WlE6Vr19kFKm2BSXfv+Q/5/VQMSkvXjXLB/iqTu3brcjlJ3UAomJRDoLKQpo R3Bg== X-Gm-Message-State: AOJu0YxFNMFhx9yFTdnJ1bjhq9dzUOdl6rSTca78YowQsXXPXMGBn2RK MesfjWVj/u0yaIbGBmZMACjQqHm1VJ3wqwaHWeUvbYamKWIcZdWVjZnpG/SmjfQtDv1T/Yx0n11 5Xzs= X-Received: by 2002:a5d:47ad:0:b0:374:c692:42e2 with SMTP id ffacd0b85a97d-37cf28a4902mr3077907f8f.9.1727798777355; Tue, 01 Oct 2024 09:06:17 -0700 (PDT) Received: from arrakeen.starnux.net ([2a01:e0a:982:cbb0:52eb:f6ff:feb3:451a]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-37cd574282esm12031460f8f.104.2024.10.01.09.06.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Oct 2024 09:06:17 -0700 (PDT) From: Neil Armstrong Date: Tue, 01 Oct 2024 18:06:12 +0200 Subject: [PATCH v2 2/2] dfu: sf: rely on DT for spi speed and mode MIME-Version: 1.0 Message-Id: <20241001-uboot-topic-dfu-sf-dt-v2-2-67f7acfa3ff5@linaro.org> References: <20241001-uboot-topic-dfu-sf-dt-v2-0-67f7acfa3ff5@linaro.org> In-Reply-To: <20241001-uboot-topic-dfu-sf-dt-v2-0-67f7acfa3ff5@linaro.org> To: Lukasz Majewski , Mattijs Korpershoek , Tom Rini , Jagan Teki , Vignesh R Cc: u-boot@lists.denx.de, Neil Armstrong X-Mailer: b4 0.14.1 X-Developer-Signature: v=1; a=openpgp-sha256; l=2088; i=neil.armstrong@linaro.org; h=from:subject:message-id; bh=+eSzwLgnncjjcshwxwRtGSp+PsCoVao/vE2s3X76g0M=; b=owEBbQKS/ZANAwAKAXfc29rIyEnRAcsmYgBm/B32jXzvTu5UCvAcD6uavigc2qarJ8+X8YrSNbg2 UWAkFpGJAjMEAAEKAB0WIQQ9U8YmyFYF/h30LIt33NvayMhJ0QUCZvwd9gAKCRB33NvayMhJ0XfHD/ 9pUVpJTzsom5T+KVQKJfRxIrEJxwwg0WfQ75h4oQ3hcWQyHceOo6JbHXN9hp8msRbATBLT+nJiLR2l q56Mb8qK29xpaBKhweC3aG+dLlu5l4HCk2YKGdqXTcieSEv9QwomPwbXrLMg2WgRB8almi1OSVXYRQ NVeoJiiVmXRefH5Arxn5GLsTdEURppqWF8cfyXaGF2uCCmYHCZrHdmhSXa97LCkKQItGz07pFt/NUb +aeRjBTg/hbtQuANI9mlqVAksPxmVXYHD4R88FbQYKNcgHvqEtzz0eztpx1zdoStU3rA2ZKUgC+UwU 88Nlk19a206LU+Q4dZdFuR5WpTKgHctJnay37R//30VEoWhvGGzbB0fUxaO5H1b5WBTOQD5BHMhdOp Oy2p+81tEOu32MeiB1Z5JEkvYSbAjkukBdxa8QVH4RXVolCSEZJ6Z8/NjeGm54NE5KjYLm40mdBS6O Zk4EcQbHzrsamHUg8JvaJcmILmVyrg+VCNmKp32T6jVDWPrjROYiOj7OCs+0Il19RNasYoqqw5PhK3 AbpOacu6P3Ql8pB2OifxMoCXGpTRCvsySlaAuCSUj330g+e/Z5bBUxSjelHaF/Rkq/Nbkw73CdygiY N9h2ktdNUnxsewII703gkiYuCOYEwcSdFNPdyvQpmtlBKiGTusPNCmScPeVA== X-Developer-Key: i=neil.armstrong@linaro.org; a=openpgp; fpr=89EC3D058446217450F22848169AB7B1A4CFF8AE X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean Align with cmd_sf, and try to rely on DT for spi speed and mode, and still fallback on spi_flash_probe() if it fails. With the current scheme, spi_flash_probe() will be called with CONFIG_SF_DEFAULT_SPEED and CONFIG_SF_DEFAULT_MODE with are set to 0 by default on DT platforms using DM_SPI_FLASH. Like cmd_sf, keep the option to specify the speed and mode from the dfu_alt_mode string, but rely on DT properties if not specified. Using CONFIG_SF_DEFAULT_SPEED and CONFIG_SF_DEFAULT_MODE makes the SPIFC controller on Amlogic Meson G12B & SM1 hardware fail and is unable to recover until a system reboot. Signed-off-by: Neil Armstrong --- drivers/dfu/dfu_sf.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/drivers/dfu/dfu_sf.c b/drivers/dfu/dfu_sf.c index 7c1c0f9e2dc..8f7296adec6 100644 --- a/drivers/dfu/dfu_sf.c +++ b/drivers/dfu/dfu_sf.c @@ -123,6 +123,7 @@ static struct spi_flash *parse_dev(char *devstr) unsigned int mode = CONFIG_SF_DEFAULT_MODE; char *s, *endp; struct spi_flash *dev; + bool use_dt = true; s = strsep(&devstr, ":"); if (!s || !*s || (bus = simple_strtoul(s, &endp, 0), *endp)) { @@ -143,6 +144,8 @@ static struct spi_flash *parse_dev(char *devstr) printf("Invalid SPI speed %s\n", s); return NULL; } + if (IS_ENABLED(CONFIG_DM_SPI_FLASH)) + use_dt = false; } s = strsep(&devstr, ":"); @@ -152,9 +155,20 @@ static struct spi_flash *parse_dev(char *devstr) printf("Invalid SPI mode %s\n", s); return NULL; } + if (IS_ENABLED(CONFIG_DM_SPI_FLASH)) + use_dt = false; } - dev = spi_flash_probe(bus, cs, speed, mode); + if (IS_ENABLED(CONFIG_DM_SPI_FLASH) && use_dt) { + struct udevice *new; + + if (!spi_flash_probe_bus_cs(bus, cs, &new)) + dev = dev_get_uclass_priv(new); + else + dev = NULL; + } else { + dev = spi_flash_probe(bus, cs, speed, mode); + } if (!dev) { printf("Failed to create SPI flash at %u:%u:%u:%u\n", bus, cs, speed, mode);