From mboxrd@z Thu Jan 1 00:00:00 1970 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 AAA4DC433F5 for ; Wed, 2 Mar 2022 12:46:16 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 7FD0783C60; Wed, 2 Mar 2022 13:46:14 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=quarantine dis=none) header.from=nic.cz 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; secure) header.d=nic.cz header.i=@nic.cz header.b="eDtEvzfN"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 3B45883C93; Wed, 2 Mar 2022 13:46:12 +0100 (CET) Received: from mail.nic.cz (mail.nic.cz [IPv6:2001:1488:800:400::400]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id E3A65831B5 for ; Wed, 2 Mar 2022 13:46:07 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=quarantine dis=none) header.from=nic.cz Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=marek.behun@nic.cz Received: from dellmb (unknown [IPv6:2001:1488:fffe:6:8747:7254:5571:3010]) by mail.nic.cz (Postfix) with ESMTPSA id 9B91B140A47; Wed, 2 Mar 2022 13:46:07 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=nic.cz; s=default; t=1646225167; bh=jISJSNyhsdGnK1LhCDSp9Y+4lrXV+82n1rKyLDJTfVM=; h=Date:From:To; b=eDtEvzfNcfBe5qWv6akZEPMN+tPP8up46OLNlDomk7ULTahqv7h9H8YQ1lMu3dWHP ixvrBB35r47eLVDsyBFx4fCbichsgTRk2uSeIdIktuvX02T2aPi6cbTnYm/KU+nVI6 N4aILLe+VfH4T5cvZJUo1xL1eWe2c1aryJ+H4waU= Date: Wed, 2 Mar 2022 13:46:07 +0100 From: Marek =?UTF-8?B?QmVow7pu?= To: Pali =?UTF-8?B?Um9ow6Fy?= Cc: Stefan Roese , u-boot@lists.denx.de Subject: Re: [PATCH u-boot-marvell 8/8] arm: mvebu: turris_omnia: Add support for USB3.0 mode in WWAN MiniPCIe slot Message-ID: <20220302134607.69f4a36c@dellmb> In-Reply-To: <20220302114758.21787-9-pali@kernel.org> References: <20220302114758.21787-1-pali@kernel.org> <20220302114758.21787-9-pali@kernel.org> X-Mailer: Claws Mail 3.18.0 (GTK+ 2.24.33; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable 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.5 at phobos.denx.de X-Virus-Status: Clean On Wed, 2 Mar 2022 12:47:58 +0100 Pali Roh=C3=A1r wrote: > PCIe Mini CEM 2.1 spec added support for USB3.0 mode on MiniPCIe cards. > USB3.0 and PCIe share same pins and only one function can be active at the > same time. PCIe Mini CEM 2.1 spec says that determining function is > platform specific and spec does not define any dedicated pin which could > say if card is USB3.0-based or PCIe-based. >=20 > Implement this platform specific decision (USB3.0 vs PCIe) for WWAN > MiniPCIe slot on Turris Omnia via U-Boot env variable "omnia_wwan_slot", > similarly like is implemented forced mode for MiniPCIe/mSATA slot via > "omnia_msata_slot" env variable. Value "usb3" for "omnia_wwan_slot" would > mean to set USB3.0 mode and value "pcie" original PCIe mode. >=20 > A385 SoC on Turris Omnia has configurable fifth SerDes line (exported to > MiniPCIe WWAN slot with SIM card) either to USB3.0 or PCIe functionality, > so implementation of this new PCIe Mini CEM 2.1 feature is simple, by just > configuring SerDes to USB 3.0 mode. >=20 > Other twos MiniPCIe slots on Turris Omnia do not have this new > functionality as their SerDes lines cannot be switched to USB3.0 > functionality. >=20 > Note that A385 SoC does not have too many USB3.0 blocks, so activating > USB3.0 in MiniPCIe cause that one external USB3.0 USB-A port would loose > USB3.0 functionality and would be downgraded just to USB2.0. >=20 > By default this MiniPCIe WWAN slot is in PCIe mode, like before. >=20 > To set this MiniPCIe WWAN slot to USB3.0 mode, call U-Boot commands: >=20 > =3D> setenv omnia_wwan_slot usb3 > =3D> saveenv > =3D> reset =20 >=20 > Signed-off-by: Pali Roh=C3=A1r > --- > board/CZ.NIC/turris_omnia/turris_omnia.c | 57 ++++++++++++++++++++++++ > 1 file changed, 57 insertions(+) >=20 > diff --git a/board/CZ.NIC/turris_omnia/turris_omnia.c b/board/CZ.NIC/turr= is_omnia/turris_omnia.c > index e2f4daa827ed..83cfc80d1930 100644 > --- a/board/CZ.NIC/turris_omnia/turris_omnia.c > +++ b/board/CZ.NIC/turris_omnia/turris_omnia.c > @@ -246,6 +246,22 @@ static bool omnia_detect_sata(const char *msata_slot) > return stsword & MSATA_IND_STSBIT ? true : false; > } > =20 > +static bool omnia_detect_wwan_usb3(const char *wwan_slot) > +{ > + puts("WWAN slot configuration... "); > + > + if (wwan_slot && strcmp(wwan_slot, "usb3") =3D=3D 0) { > + puts("USB3.0\n"); > + return true; > + } > + > + if (wwan_slot && strcmp(wwan_slot, "pcie") !=3D 0) > + printf("unsupported env value '%s', fallback to... ", wwan_slot); If I recall correctly, Linux' and U-Boot's code style (in contrast to TF-A) normally wants if (expr) instead of if (expr !=3D 0) and if (!expr) instead of if (expr =3D=3D 0) Sometimes in spite of this style it is better to use =3D=3D or !=3D operato= r, for example in cases where one wants to compare a character to multiple literals: if (c =3D=3D 0x13 || c =3D=3D 0x12 || c =3D=3D 0x00) But for strcmp() and friends, we normaly just use if (!strcmp()) This is just a nitpick, I don't mind that much. Just saying this so you are aware of this in the future... > + > + puts("PCIe+USB2.0\n"); > + return false; > +} > + > void *env_sf_get_env_addr(void) > { > /* SPI Flash is mapped to address 0xD4000000 only in SPL */ > @@ -276,6 +292,20 @@ int hws_board_topology_load(struct serdes_map **serd= es_map_array, u8 *count) > board_serdes_map[0].serdes_mode =3D SERDES_DEFAULT_MODE; > } > =20 > +#ifdef CONFIG_SPL_ENV_SUPPORT > + /* beware that env_get() returns static allocated memory */ > + env_value =3D has_env ? env_get("omnia_wwan_slot") : NULL; > +#endif Use if (IS_ENABLED(CONFIG_SPL_ENV_SUPPORT)) instead of macro wherever possible, so that an error can be caught by the compiler even if it is in the disabled part of the code. Marek