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 Reviewed-by: Mattijs Korpershoek --- 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);