From patchwork Wed Sep 9 20:09:26 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Anderson X-Patchwork-Id: 1361013 X-Patchwork-Delegate: uboot@andestech.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=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com 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=cF23YhGZ; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (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 4BmtS05BBTz9sTK for ; Thu, 10 Sep 2020 06:10:40 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 9C957822F8; Wed, 9 Sep 2020 22:09:58 +0200 (CEST) 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="cF23YhGZ"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id DCD00822C3; Wed, 9 Sep 2020 22:09:53 +0200 (CEST) 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,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-qt1-x842.google.com (mail-qt1-x842.google.com [IPv6:2607:f8b0:4864:20::842]) (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 497A582284 for ; Wed, 9 Sep 2020 22:09:51 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=seanga2@gmail.com Received: by mail-qt1-x842.google.com with SMTP id g3so3000077qtq.10 for ; Wed, 09 Sep 2020 13:09:51 -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 :mime-version:content-transfer-encoding; bh=84Dz2pFPzm/8gPXbqgsJclH4SsItjAAam8glmVJEulg=; b=cF23YhGZ0njLt6E1R5pIMMeN2bYlSLtjeBUTBbmbbxXzGbtSyV7FHdFn+R503TPYya m10pP6GN5eFPFsg1iRTZSWL0jLIsrMI0zEfa1AFZsa3/p71lQ37NoOhYFVgDdNNsUevY sRMvek+ewtGqRLPHsI+EipNYSPsoWdBEv3FcWVD1UbgCSqKfdyGdFN8cpQgiQMSrYDyX PUFP7Bdgen/Jd9hXw/wU78Zj3W46yjppfE9OhDAPsAY+a3BZRlzz46phsoXx7FkZcMx9 hValhjuKPNuJ6wvojMwrjtmvMvHZZ0V1P0YzARSeFTaCgSj0NJHzjzp0GxbI7TuKJhyk Ew9A== 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=84Dz2pFPzm/8gPXbqgsJclH4SsItjAAam8glmVJEulg=; b=t356txoNiB85UUep1Ft5fJYjeRm2k5yGRlQtt3dtC08URVES8uaHW+ouvxRzaRxNdL UFCwzbY8fkGDRB86xAmLL2xlc98A0o2n1SApu+uJSPmX0xHcccqylUOl3XTzDTi5aPuQ 2rI+YluCc7yq/xySiDHJ28s+Zd92JZfTF94hGKEyf/stnp3pvLhqUtkzx4CfJIW1T7Az TWXfYH5c3/ivNli+7Aebqnu16NZvJlPIztQsY4lvL6wBj+pfQ63/UlqgLjBS6N8xYggq +g5Ruvdy/cA2cD2xIfhxqi8DMRJlZN9a8dE9Z831uvnnqeaBROd1upP0kwhse9MFyken USwg== X-Gm-Message-State: AOAM5312ArdzhfE58AZxvGekuKgX2+V6qflcN/NWmk7yqbkGCQNcGgeu mHLg+r0e8/eiwUTs1vHqPsyKUzyyKeibMSiO X-Google-Smtp-Source: ABdhPJyofJfDIaCNLIwbDE5vJSeg9xEmdDyy2htj1YNFtkMAG5rrtKrEsuvtLolx4aqrq0WX3+iGfQ== X-Received: by 2002:ac8:3175:: with SMTP id h50mr4848844qtb.185.1599682189984; Wed, 09 Sep 2020 13:09:49 -0700 (PDT) Received: from godwin.fios-router.home (pool-108-51-35-162.washdc.fios.verizon.net. [108.51.35.162]) by smtp.gmail.com with ESMTPSA id s30sm4342831qth.65.2020.09.09.13.09.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Sep 2020 13:09:49 -0700 (PDT) From: Sean Anderson To: u-boot@lists.denx.de Cc: Anup Patel , Pragnesh Patel , Bin Meng , Rick Chen , Sean Anderson , Bin Meng Subject: [PATCH v4 4/8] riscv: Clean up initialization in Andes PLIC Date: Wed, 9 Sep 2020 16:09:26 -0400 Message-Id: <20200909200930.232174-5-seanga2@gmail.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200909200930.232174-1-seanga2@gmail.com> References: <20200909200930.232174-1-seanga2@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.3 at phobos.denx.de X-Virus-Status: Clean This merges the PLIC initialization code from two functions into one. Signed-off-by: Sean Anderson Reviewed-by: Bin Meng --- This patch builds but has NOT been tested. (no changes since v1) arch/riscv/lib/andes_plic.c | 58 ++++++++++++++++--------------------- 1 file changed, 25 insertions(+), 33 deletions(-) diff --git a/arch/riscv/lib/andes_plic.c b/arch/riscv/lib/andes_plic.c index c2a8fe4d9e..267d6a191b 100644 --- a/arch/riscv/lib/andes_plic.c +++ b/arch/riscv/lib/andes_plic.c @@ -41,53 +41,45 @@ static int enable_ipi(int hart) return 0; } -static int init_plic(void) +int riscv_init_ipi(void) { - struct udevice *dev; - ofnode node; int ret; + long *base = syscon_get_first_range(RISCV_SYSCON_PLIC); + ofnode node; + struct udevice *dev; u32 reg; + if (IS_ERR(base)) + return PTR_ERR(base); + gd->arch.plic = base; + ret = uclass_find_first_device(UCLASS_CPU, &dev); if (ret) return ret; + else if (!dev) + return -ENODEV; - if (dev) { - ofnode_for_each_subnode(node, dev_ofnode(dev->parent)) { - const char *device_type; + ofnode_for_each_subnode(node, dev_ofnode(dev->parent)) { + const char *device_type; - device_type = ofnode_read_string(node, "device_type"); - if (!device_type) - continue; + device_type = ofnode_read_string(node, "device_type"); + if (!device_type) + continue; - if (strcmp(device_type, "cpu")) - continue; + if (strcmp(device_type, "cpu")) + continue; - /* skip if hart is marked as not available */ - if (!ofnode_is_available(node)) - continue; + /* skip if hart is marked as not available */ + if (!ofnode_is_available(node)) + continue; - /* read hart ID of CPU */ - ret = ofnode_read_u32(node, "reg", ®); - if (ret == 0) - enable_ipi(reg); - } - - return 0; + /* read hart ID of CPU */ + ret = ofnode_read_u32(node, "reg", ®); + if (ret == 0) + enable_ipi(reg); } - return -ENODEV; -} - -int riscv_init_ipi(void) -{ - long *ret = syscon_get_first_range(RISCV_SYSCON_PLIC); - - if (IS_ERR(ret)) - return PTR_ERR(ret); - gd->arch.plic = ret; - - return init_plic(); + return 0; } int riscv_send_ipi(int hart)