From patchwork Fri Aug 14 16:40:52 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bin Meng X-Patchwork-Id: 276426 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_INVALID, DKIM_SIGNED, FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A368AC433DF for ; Fri, 14 Aug 2020 16:50:58 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 6BD25204EA for ; Fri, 14 Aug 2020 16:50:58 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="rM65ZrIR" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6BD25204EA Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:47826 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1k6cuv-0006oh-Ng for qemu-devel@archiver.kernel.org; Fri, 14 Aug 2020 12:50:57 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:47422) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k6cmG-000069-Eq; Fri, 14 Aug 2020 12:42:00 -0400 Received: from mail-pg1-x543.google.com ([2607:f8b0:4864:20::543]:43075) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1k6cmE-0002jp-Rp; Fri, 14 Aug 2020 12:42:00 -0400 Received: by mail-pg1-x543.google.com with SMTP id d19so4782801pgl.10; Fri, 14 Aug 2020 09:41:57 -0700 (PDT) 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; bh=xWM6KDXnU2haYF7jfdME41V1s1evuLW8hUFzTHSoRXs=; b=rM65ZrIRr7SUkTX++aNO9naidmkz+pllYUoakwS2ewObrlyMN20GcwL6J69OB63fMH fBgEpe9cthP8OiMGeF7U8ckVgt5XAHgJiSBqFD0dkn+L9B2KpvSzZKyqAfMQEK1EARZ1 FO0bVZxczgJ+QyIcVusKFnMxTxg+WIVXq/G171ZCM6spYZjsdrrgJzPi0qBdBdAFP1YE C4gzvaDX1DLNkfAedscqbmricsg5jhj92OCFlei5Sc0picJTSq3BaRtcOXa1zH5apec1 PB2GXVCK3MYlEPGmnQ6qrsOjOptmDwqZz/F8qomhch3xbW1QCLsS3flWzXFgNoQ0xyZb gRuA== 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; bh=xWM6KDXnU2haYF7jfdME41V1s1evuLW8hUFzTHSoRXs=; b=ZshvFwC9QRTI0Boo7zMX9auY69RWq06bZ9tPUNDZ/BJifhXlyFIw7MVMqg5TCMOr6T QXVVc9MgFx4+CryeUfWwX4rpfGZFbPuhvTySOjxrJb9+VqkrLuYHoWiTHk28wuZ2t3Jn klavrLTuBvXdt9UbWghlzRmxSaqmUgi42d+hLsv3OdZGXIyfUPZeQKKL6BsaDxBFwxZK rhN6JZ9xcK+vlBfAEZIzM2AJCLCUFo2rIfm9SHouU1imgpF10FNNg95vUkuk9xv0ruiG nbLE0xZQ7XGBdcU+EgwIZtTV+YCim4StSf030n1b6DP8HoDOFyD7HeoXMaSIL+g9oem2 mWRg== X-Gm-Message-State: AOAM531g4as0ONTdH9hXNmb/uHIJ+tsh0nwjGppeojy0IJ6KncwnGNrI CuhTmsw6nIfbZoIuAZLrkeQ= X-Google-Smtp-Source: ABdhPJwM8zddeWZdQ/YbbHkgjC1BvehMGr85sFvBbeaN5TBabJTwaU4aXnkaSe5mnsyNJ4/JmPSxOw== X-Received: by 2002:a05:6a00:1509:: with SMTP id q9mr2460323pfu.24.1597423317031; Fri, 14 Aug 2020 09:41:57 -0700 (PDT) Received: from pek-vx-bsp2.wrs.com (unknown-146-144.windriver.com. [147.11.146.144]) by smtp.gmail.com with ESMTPSA id 16sm9836332pfi.161.2020.08.14.09.41.53 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 14 Aug 2020 09:41:56 -0700 (PDT) From: Bin Meng To: Alistair Francis , Bastian Koppelmann , Palmer Dabbelt , Sagar Karandikar , qemu-devel@nongnu.org, qemu-riscv@nongnu.org Subject: [PATCH 14/18] hw/net: cadence_gem: Add a new 'phy-addr' property Date: Sat, 15 Aug 2020 00:40:52 +0800 Message-Id: <1597423256-14847-15-git-send-email-bmeng.cn@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1597423256-14847-1-git-send-email-bmeng.cn@gmail.com> References: <1597423256-14847-1-git-send-email-bmeng.cn@gmail.com> Received-SPF: pass client-ip=2607:f8b0:4864:20::543; envelope-from=bmeng.cn@gmail.com; helo=mail-pg1-x543.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Alistair Francis , Jason Wang , Bin Meng , qemu-arm@nongnu.org, "Edgar E. Iglesias" Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" From: Bin Meng At present the PHY address of the PHY connected to GEM is hard-coded to either 23 (BOARD_PHY_ADDRESS) or 0. This might not be the case for all boards. Add a new 'phy-addr' property so that board can specify the PHY address for each GEM instance. Signed-off-by: Bin Meng --- hw/net/cadence_gem.c | 7 +++++-- include/hw/net/cadence_gem.h | 2 ++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/hw/net/cadence_gem.c b/hw/net/cadence_gem.c index a93b5c0..9fa03de 100644 --- a/hw/net/cadence_gem.c +++ b/hw/net/cadence_gem.c @@ -1446,7 +1446,8 @@ static uint64_t gem_read(void *opaque, hwaddr offset, unsigned size) uint32_t phy_addr, reg_num; phy_addr = (retval & GEM_PHYMNTNC_ADDR) >> GEM_PHYMNTNC_ADDR_SHFT; - if (phy_addr == BOARD_PHY_ADDRESS || phy_addr == 0) { + if (phy_addr == BOARD_PHY_ADDRESS || phy_addr == 0 || + phy_addr == s->phy_addr) { reg_num = (retval & GEM_PHYMNTNC_REG) >> GEM_PHYMNTNC_REG_SHIFT; retval &= 0xFFFF0000; retval |= gem_phy_read(s, reg_num); @@ -1569,7 +1570,8 @@ static void gem_write(void *opaque, hwaddr offset, uint64_t val, uint32_t phy_addr, reg_num; phy_addr = (val & GEM_PHYMNTNC_ADDR) >> GEM_PHYMNTNC_ADDR_SHFT; - if (phy_addr == BOARD_PHY_ADDRESS || phy_addr == 0) { + if (phy_addr == BOARD_PHY_ADDRESS || phy_addr == 0 || + phy_addr == s->phy_addr) { reg_num = (val & GEM_PHYMNTNC_REG) >> GEM_PHYMNTNC_REG_SHIFT; gem_phy_write(s, reg_num, val); } @@ -1682,6 +1684,7 @@ static Property gem_properties[] = { DEFINE_NIC_PROPERTIES(CadenceGEMState, conf), DEFINE_PROP_UINT32("revision", CadenceGEMState, revision, GEM_MODID_VALUE), + DEFINE_PROP_UINT8("phy-addr", CadenceGEMState, phy_addr, 0), DEFINE_PROP_UINT8("num-priority-queues", CadenceGEMState, num_priority_queues, 1), DEFINE_PROP_UINT8("num-type1-screeners", CadenceGEMState, diff --git a/include/hw/net/cadence_gem.h b/include/hw/net/cadence_gem.h index 54e646f..01c6189 100644 --- a/include/hw/net/cadence_gem.h +++ b/include/hw/net/cadence_gem.h @@ -73,6 +73,8 @@ typedef struct CadenceGEMState { /* Mask of register bits which are write 1 to clear */ uint32_t regs_w1c[CADENCE_GEM_MAXREG]; + /* PHY address */ + uint8_t phy_addr; /* PHY registers backing store */ uint16_t phy_regs[32];