From patchwork Sun Mar 14 05:14:59 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bin Meng X-Patchwork-Id: 1452629 X-Patchwork-Delegate: priyanka.jain@nxp.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=MnnYgfqC; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4Dynr63Rlyz9sRR for ; Sun, 14 Mar 2021 16:17:58 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 0E3DB828EA; Sun, 14 Mar 2021 06:16:07 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com 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=gmail.com header.i=@gmail.com header.b="MnnYgfqC"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 32D7B828E8; Sun, 14 Mar 2021 06:16:03 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,SPF_HELO_NONE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-pf1-x42b.google.com (mail-pf1-x42b.google.com [IPv6:2607:f8b0:4864:20::42b]) (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 6607282879 for ; Sun, 14 Mar 2021 06:15:59 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=bmeng.cn@gmail.com Received: by mail-pf1-x42b.google.com with SMTP id r16so3250775pfh.10 for ; Sat, 13 Mar 2021 21:15:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=9dSNKTSayTT0L1hLG91qjEwWju36NrKIan2inJF10U4=; b=MnnYgfqCJ85HJLMfMaWjOHDdAn5WYsiFiLa7Pl8aIYBZG6WYdWaoyVDXT1VElnJqhW DlTI4XBkBlzjCBvLgbXeFbWGmGhMzZAHxRSWfDFCZ7IaFwT8TkHIns+/JjC1cz0MJwHc INGf/9sRFReOmpILPket4Cvvttf+VvAiWeMWjyl9cNvZZ0pQ6SVZqp9tzV5PXE5b/XPK Nsva+AjG4R8/bIlgZ2yIQP801YhZzesNtNljbhmVctdukCYK+K3gYAjelCgUdiZnvuUd A2XT4N2HuAExu6SWLYGcJzhOuk9TXODlQ36Yc/UXxZN6dCGgwNC+Es4v63nq+cQFLVCG goMw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=9dSNKTSayTT0L1hLG91qjEwWju36NrKIan2inJF10U4=; b=PIvcWQBBG27+65AJ05pl7zaE7TQhFRY44MeNct2VJbNazqVG7BzEY4FH0Ip6DobRkp k4i4JYy1d8nQv2Ygd3FwqL62pQ0LNKFsDyy95pPtNubMRMmq4IoVmLkp68iRutGY/9ac srC1Hrdv2QdNGp9aXgbkjyb/4G6y5Hc4VjKeVnBJbjPZgykV7+mBIufiWKa7qprhvls7 HZvU1WL214LDGz2xRt50YrtO/vUbjYqrJAvMTAZNjIffZieqQvdNWHFrrL+wUz6qrSI4 AWd+l+fyftT+gARFdJvVWMy0NvZ5c1vBihNpKjpekUtNkydBAnJXxvrGIyUv80yOZwJ+ 0HAQ== X-Gm-Message-State: AOAM532oyTTErxsH58/ZPmuUZ3nubTpf6ZkBhOo/z+vLd/FzuDAyD/HM vvPxzQFMt3C4OHFiX9ana4M= X-Google-Smtp-Source: ABdhPJz754TXVZiUKTDYrkazbY/EYFzDnv8uhBvY6k6hN40KiXF+Te6oSo2vpIJv+fMvIGYgzkE5OA== X-Received: by 2002:a63:ea51:: with SMTP id l17mr13165652pgk.117.1615698957995; Sat, 13 Mar 2021 21:15:57 -0800 (PST) Received: from i9-aorus-gtx1080.localdomain (144.168.56.201.16clouds.com. [144.168.56.201]) by smtp.gmail.com with ESMTPSA id 186sm10497309pfb.143.2021.03.13.21.15.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 13 Mar 2021 21:15:57 -0800 (PST) From: Bin Meng To: Priyanka Jain , Ramon Fried , Simon Glass , u-boot@lists.denx.de Cc: Tom Rini , Vladimir Oltean , Bin Meng Subject: [PATCH v3 11/22] net: phy: fixed: Support the old DT binding Date: Sun, 14 Mar 2021 13:14:59 +0800 Message-Id: <20210314051510.26628-12-bmeng.cn@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210314051510.26628-1-bmeng.cn@gmail.com> References: <20210314051510.26628-1-bmeng.cn@gmail.com> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 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.102.4 at phobos.denx.de X-Virus-Status: Clean Update fixedphy_probe() to support the old DT binding. Signed-off-by: Bin Meng Reviewed-by: Ramon Fried Reviewed-by: Vladimir Oltean --- Changes in v3: - sort variable definitions by line length drivers/net/phy/fixed.c | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/drivers/net/phy/fixed.c b/drivers/net/phy/fixed.c index 304e506554..1192915ee5 100644 --- a/drivers/net/phy/fixed.c +++ b/drivers/net/phy/fixed.c @@ -27,6 +27,8 @@ static int fixedphy_config(struct phy_device *phydev) { ofnode node = phy_get_ofnode(phydev); struct fixed_link *priv; + bool old_binding = false; + u32 old_val[5]; u32 val; if (!ofnode_valid(node)) @@ -34,6 +36,18 @@ static int fixedphy_config(struct phy_device *phydev) /* check for mandatory properties within fixed-link node */ val = ofnode_read_u32_default(node, "speed", 0); + + if (!val) { + /* try old binding */ + old_binding = true; + if (ofnode_read_u32_array(node, "fixed-link", old_val, + ARRAY_SIZE(old_val))) { + printf("ERROR: no/invalid property!\n"); + return -ENOENT; + } + val = old_val[2]; + } + if (val != SPEED_10 && val != SPEED_100 && val != SPEED_1000 && val != SPEED_2500 && val != SPEED_10000) { printf("ERROR: no/invalid speed given in fixed-link node!\n"); @@ -48,9 +62,15 @@ static int fixedphy_config(struct phy_device *phydev) phydev->priv = priv; priv->link_speed = val; - priv->duplex = ofnode_read_bool(node, "full-duplex"); - priv->pause = ofnode_read_bool(node, "pause"); - priv->asym_pause = ofnode_read_bool(node, "asym-pause"); + if (!old_binding) { + priv->duplex = ofnode_read_bool(node, "full-duplex"); + priv->pause = ofnode_read_bool(node, "pause"); + priv->asym_pause = ofnode_read_bool(node, "asym-pause"); + } else { + priv->duplex = old_val[1]; + priv->pause = old_val[3]; + priv->asym_pause = old_val[4]; + } return 0; }