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 phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id E192BC433EF for ; Mon, 4 Jul 2022 10:32:34 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 9E123805FE; Mon, 4 Jul 2022 12:32:32 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=suse.de header.i=@suse.de header.b="DAZ+NM6Q"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="7AqvvOCJ"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id DC5528443D; Mon, 4 Jul 2022 12:32:30 +0200 (CEST) Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 810E780112 for ; Mon, 4 Jul 2022 12:32:28 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=msuchanek@suse.de Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out2.suse.de (Postfix) with ESMTP id 4BA9D1F461; Mon, 4 Jul 2022 10:32:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1656930748; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=hmmsHX/8UksLYmEtjbv4q1V+1H2Df7bMe0eDZ4U4beY=; b=DAZ+NM6QAlm7BDevlOtrLyODoClFgY9axj3qg3D6WpiMbIcJbxVudhfc9VkDMr1OL4MCZz +AM7Qe13A3Re2XVBY6CPJJBQN9lVqDZyXiKlAcyisIYsAFjGO+GQ7SH0lx8cTOkNDBrtuy ER+UT5xUMg1kN3yTB9G0HRMuOvW4zVE= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1656930748; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=hmmsHX/8UksLYmEtjbv4q1V+1H2Df7bMe0eDZ4U4beY=; b=7AqvvOCJ4/kThhmredtaESNhFVZiZO7smoQfanhxrqM3O2apm4SausWn60M7Ne/ZK1jxpB cv1EgFt5LvFBH+DA== Received: from kitsune.suse.cz (kitsune.suse.cz [10.100.12.127]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by relay2.suse.de (Postfix) with ESMTPS id AEFDE2C14E; Mon, 4 Jul 2022 10:32:27 +0000 (UTC) Date: Mon, 4 Jul 2022 12:32:26 +0200 From: Michal =?iso-8859-1?Q?Such=E1nek?= To: Samuel Holland Cc: u-boot@lists.denx.de, Andre Przywara , Simon Glass , Philipp Tomsich , Kever Yang , Jagan Teki , Andre Przywara , Andy Yan , Michal Simek , Igor Opaniuk Subject: Re: [PATCH 0/2] Command for entering mask rom USB download mode Message-ID: <20220704103226.GJ17705@kitsune.suse.cz> References: <87596dac-6072-b0fc-65bf-b3f342b551e0@sholland.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <87596dac-6072-b0fc-65bf-b3f342b551e0@sholland.org> User-Agent: Mutt/1.10.1 (2018-07-13) 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.6 at phobos.denx.de X-Virus-Status: Clean On Sun, Jul 03, 2022 at 06:26:22PM -0500, Samuel Holland wrote: > Hi Michal, > > On 7/3/22 2:20 PM, Michal Suchanek wrote: > > > > Hello, > > > > many ARM SoCs have a mask rom feature that provides interface for > > downloading firmware over USB. > > > > Downstream rockchip u-boot has 'brom' or 'rbrom' command for this > > purpose, and downstream sunxi u-boot provides 'efex' command. p-boot has > > code for entering FEL on A64 SoC. > > > > With this patch I am able to activate the USB downloader on a rk3399 but > > the rkflashtool fails to communicate with the device. On a H2+ I can get > > into the FEL mode and get flash parameters. YMMV > > > > I don't have any great idea how to structure this so that the command > > does not need platform-specific code. Is there an example of a command > > that has platform-specific implementations? > > Generally you would do this by having the driver interact with some DM uclass. > Platforms may or may not provide a driver implementing that uclass; the details > are hidden behind the uclass's interface. All the command has to do is search > for a DM device by uclass, and if one is found, call some operation on it. > > In this case, UCLASS_REBOOT_MODE already exists. It sounds like what we need is > the inverse of dm_reboot_mode_update() -- a function that takes a string and > programs the device with the corresponding mode value. > > To be generic, you could call this function from do_reset() if some positional > argument is provided, allowing usage like "reset bootloader" or "reset fel". > > Rockchip platforms already have syscon-reboot-mode hooked up in their > devicetrees. The driver for this should be trivial. > > Allwinner platforms would need to add a nvmem-reboot-mode node, and a bit more > driver infrastructure. U-Boot does not have NVMEM uclass, so you would need to > add one or reuse UCLASS_MISC. Not sure I understand the DM enough but as firt step I can at least hook it to the do_reset function. Thanks Michal