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 84C5CC32771 for ; Mon, 26 Sep 2022 11:58:08 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 64FA1845EF; Mon, 26 Sep 2022 13:58:04 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=denx.de Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=denx.de; s=phobos-20191101; t=1664193486; bh=6HVHyYLFyLwXiVqITBlJiSIT5Fx40F2qfpZ4gBA1CHs=; h=Date:Subject:To:Cc:References:From:In-Reply-To:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=or9cV2G4NBBar1jwowHVgyDA+6fsTwW9PhAV25G4M0UfLxzqujHYQdTWJ9UNmKum7 gkteBM4IHmmzzVpOCsTVwJqWHP7SV8naQPpdvMxHe3bzWU0QxvyAIeCVHZAJzeQDHq MUgP5FKsleb6m+QKIrAVUiWwA+WiKRraBvvdPAAS2HVrhrYwmSFxuUwDug2Cgj4ktU g6CRwsg4qvp9EVnEpCO1fF7oIkfD2n6lw7DnXDSvG0nn6b9ELZShB2UG4juF8m3lbj E9AgAeNfB+96OuBF/IdyKLCHLMmf3MawerU/2CP37eLbEfGg0qepbCiHwxXrnuJPtF 7mqiaMU8qpiIg== Received: by phobos.denx.de (Postfix, from userid 109) id 268E384B18; Mon, 26 Sep 2022 13:58:00 +0200 (CEST) Received: from mout-u-204.mailbox.org (mout-u-204.mailbox.org [IPv6:2001:67c:2050:101:465::204]) (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 C8B7A83FFF for ; Mon, 26 Sep 2022 13:57:57 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=denx.de Authentication-Results: phobos.denx.de; spf=fail smtp.mailfrom=sr@denx.de Received: from smtp2.mailbox.org (smtp2.mailbox.org [10.196.197.2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-u-204.mailbox.org (Postfix) with ESMTPS id 4Mbh8g6mCCz9sSh; Mon, 26 Sep 2022 13:57:55 +0200 (CEST) Message-ID: <1bf10f05-1b4e-fee9-0e55-8f46a715e63f@denx.de> Date: Mon, 26 Sep 2022 13:57:55 +0200 MIME-Version: 1.0 Subject: Re: [PATCH] gpio: turris_omnia_mcu: Fix registering gpios Content-Language: en-US To: =?UTF-8?Q?Pali_Roh=c3=a1r?= , =?UTF-8?Q?Marek_Beh=c3=ban?= Cc: u-boot@lists.denx.de References: <20220922112513.24241-1-pali@kernel.org> From: Stefan Roese In-Reply-To: <20220922112513.24241-1-pali@kernel.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit 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 22.09.22 13:25, Pali Rohár wrote: > Currently all GPIOs supported by CMD_EXT_CONTROL/CMD_GET_EXT_CONTROL_STATUS > commands (last 16 GPIOs) are available only when FEAT_PERIPH_MCU feature > bit is set. So do not register these GPIOs by U-Boot driver when this > feature bit is not set, so U-Boot 'gpio' command would see only GPIOs which > really exists. > > Fixes: 5e4d24ccc115 ("gpio: Add Turris Omnia MCU driver") > Signed-off-by: Pali Rohár Applied to u-boot-marvell/master Thanks, Stefan > --- > drivers/gpio/turris_omnia_mcu.c | 19 +++++++++++++++---- > 1 file changed, 15 insertions(+), 4 deletions(-) > > diff --git a/drivers/gpio/turris_omnia_mcu.c b/drivers/gpio/turris_omnia_mcu.c > index 986ccde6bc70..2d2bf2d1dd69 100644 > --- a/drivers/gpio/turris_omnia_mcu.c > +++ b/drivers/gpio/turris_omnia_mcu.c > @@ -16,6 +16,8 @@ enum commands_e { > > /* available if FEAT_EXT_CMDS bit is set in features */ > CMD_GET_EXT_STATUS_DWORD = 0x11, > + > + /* available if FEAT_EXT_CMDS and FEAT_PERIPH_MCU bits are set in featurs */ > CMD_EXT_CONTROL = 0x12, > CMD_GET_EXT_CONTROL_STATUS = 0x13, > }; > @@ -54,6 +56,7 @@ enum ctl_byte_e { > > /* CMD_GET_FEATURES */ > enum features_e { > + FEAT_PERIPH_MCU = BIT(0), > FEAT_EXT_CMDS = BIT(1), > }; > > @@ -84,10 +87,12 @@ static int turris_omnia_mcu_get_function(struct udevice *dev, uint offset) > return -EINVAL; > return GPIOF_INPUT; > > - /* bank 2 - supported only when FEAT_EXT_CMDS is set */ > + /* bank 2 - supported only when FEAT_EXT_CMDS and FEAT_PERIPH_MCU is set */ > case (16 + 32 + 0) ... (16 + 32 + 15): > if (!(info->features & FEAT_EXT_CMDS)) > return -EINVAL; > + if (!(info->features & FEAT_PERIPH_MCU)) > + return -EINVAL; > return GPIOF_OUTPUT; > > default: > @@ -120,10 +125,12 @@ static int turris_omnia_mcu_get_value(struct udevice *dev, uint offset) > return ((((u32)val32[3] << 24) | ((u32)val32[2] << 16) | > ((u32)val32[1] << 8) | val32[0]) >> (offset - 16)) & 0x1; > > - /* bank 2 - supported only when FEAT_EXT_CMDS is set */ > + /* bank 2 - supported only when FEAT_EXT_CMDS and FEAT_PERIPH_MCU is set */ > case (16 + 32 + 0) ... (16 + 32 + 15): > if (!(info->features & FEAT_EXT_CMDS)) > return -EINVAL; > + if (!(info->features & FEAT_PERIPH_MCU)) > + return -EINVAL; > ret = dm_i2c_read(dev, CMD_GET_EXT_CONTROL_STATUS, val16, 2); > if (ret) > return ret; > @@ -162,10 +169,12 @@ static int turris_omnia_mcu_set_value(struct udevice *dev, uint offset, int valu > val16[0] = value ? val16[1] : 0; > return dm_i2c_write(dev, CMD_GENERAL_CONTROL, val16, sizeof(val16)); > > - /* bank 2 - supported only when FEAT_EXT_CMDS is set */ > + /* bank 2 - supported only when FEAT_EXT_CMDS and FEAT_PERIPH_MCU is set */ > case (16 + 32 + 0) ... (16 + 32 + 15): > if (!(info->features & FEAT_EXT_CMDS)) > return -EINVAL; > + if (!(info->features & FEAT_PERIPH_MCU)) > + return -EINVAL; > val32[3] = BIT(offset - 16 - 32) >> 8; > val32[2] = BIT(offset - 16 - 32) & 0xff; > val32[1] = value ? val32[3] : 0; > @@ -282,8 +291,10 @@ static int turris_omnia_mcu_probe(struct udevice *dev) > > uc_priv->bank_name = "mcu_"; > > - if (info->features & FEAT_EXT_CMDS) > + if ((info->features & FEAT_EXT_CMDS) && (info->features & FEAT_PERIPH_MCU)) > uc_priv->gpio_count = 16 + 32 + 16; > + else if (info->features & FEAT_EXT_CMDS) > + uc_priv->gpio_count = 16 + 32; > else > uc_priv->gpio_count = 16; > Viele Grüße, Stefan Roese -- DENX Software Engineering GmbH, Managing Director: Wolfgang Denk HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-51 Fax: (+49)-8142-66989-80 Email: sr@denx.de