From patchwork Fri Jan 18 11:18:48 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anup Patel X-Patchwork-Id: 1027214 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=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=wdc.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=wdc.com header.i=@wdc.com header.b="EkfvWbLk"; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=sharedspace.onmicrosoft.com header.i=@sharedspace.onmicrosoft.com header.b="c+gDH75u"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 43gz4N18tVz9sBQ for ; Fri, 18 Jan 2019 22:19:48 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id C657EC2201F; Fri, 18 Jan 2019 11:19:12 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=KHOP_BIG_TO_CC, T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id C27F5C22095; Fri, 18 Jan 2019 11:19:00 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 24E9FC2208B; Fri, 18 Jan 2019 11:18:56 +0000 (UTC) Received: from esa5.hgst.iphmx.com (esa5.hgst.iphmx.com [216.71.153.144]) by lists.denx.de (Postfix) with ESMTPS id 70B95C21E36 for ; Fri, 18 Jan 2019 11:18:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1547810333; x=1579346333; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=M75QEe9v7F0NLcP5nKtAQVdwk6PlbFlpL3vzTePeySg=; b=EkfvWbLkoKLZ3boxl1qk2gpN5btiYhN389YQMr49RX2Qv6Ve9P9U9baP 2+jBBzZz21/tFgEalxkAmzre4WhDbhTp7y3bZ0BNDlZ/HF+YP5lbOTwy5 KQqt4BKOgGNfCaL8LXs00e1KZ3lAKqBXQ7SRGtNTgaYMDT1AbRKXcom6M /KUpCFBKSzdSyydpYJJcGscJR6AweoMyhd9lS5LJtx7NDeDe51z496Shu 1/9Y4vFsTDOkGyJSIIPrANVVB8lCdonne4zndWfrd/FbUtQ7gCsBiLbs9 KFdsI4mZSvSE1tGbnnimjFsr6QeaYgKvelARCQydvudvVRUjUoB2qVEKD g==; X-IronPort-AV: E=Sophos;i="5.56,491,1539619200"; d="scan'208";a="100370961" Received: from mail-dm3nam03lp2050.outbound.protection.outlook.com (HELO NAM03-DM3-obe.outbound.protection.outlook.com) ([104.47.41.50]) by ob1.hgst.iphmx.com with ESMTP; 18 Jan 2019 19:18:50 +0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sharedspace.onmicrosoft.com; s=selector1-wdc-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=XLRZ89twNBMzS2CV68W/M0EgR3jqTyuKk0M+s8Nvd9U=; b=c+gDH75u8zUGhhr/9bMUdiWh3eochRXRKynChF2P9WAMOLaDO/mHeaELJW42ThTqb2Nw8hlr99ITFLZ63HcNyhw82I6xGjMr4NvKqTeq+A9aYKBRmdrCCquORw+CSKPcD9m5Hjnj6fzXAyTbl7Jo0T+YLBR6Zk2hPg5crBPkXvE= Received: from BYAPR04MB5303.namprd04.prod.outlook.com (20.178.49.148) by BYAPR04MB5016.namprd04.prod.outlook.com (52.135.235.10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1537.24; Fri, 18 Jan 2019 11:18:48 +0000 Received: from BYAPR04MB5303.namprd04.prod.outlook.com ([fe80::add1:92cc:65d7:5d94]) by BYAPR04MB5303.namprd04.prod.outlook.com ([fe80::add1:92cc:65d7:5d94%2]) with mapi id 15.20.1537.018; Fri, 18 Jan 2019 11:18:48 +0000 From: Anup Patel To: Rick Chen , Bin Meng , Joe Hershberger , Lukas Auer , Masahiro Yamada , Simon Glass Thread-Topic: [PATCH v2 01/11] riscv: Rename cpu/qemu to cpu/generic Thread-Index: AQHUrx+VoPZE+wbl9022u2txuQPlpA== Date: Fri, 18 Jan 2019 11:18:48 +0000 Message-ID: <20190118111820.71349-2-anup.patel@wdc.com> References: <20190118111820.71349-1-anup.patel@wdc.com> In-Reply-To: <20190118111820.71349-1-anup.patel@wdc.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: MA1PR01CA0115.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a00:1::31) To BYAPR04MB5303.namprd04.prod.outlook.com (2603:10b6:a03:c8::20) authentication-results: spf=none (sender IP is ) smtp.mailfrom=Anup.Patel@wdc.com; x-ms-exchange-messagesentrepresentingtype: 1 x-mailer: git-send-email 2.17.1 x-originating-ip: [49.207.48.211] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; BYAPR04MB5016; 6:1Otl0nwZvJW1nH2tEl6iRfagUDB4iJHa0zevd8J7mc9PB6A7G2Bke2u2cY9eyvunRoj/Ws4/+EfpjNfHUA2O2M0Umhq1mMInRQmGWlo+v5G0RHJUtXmmzyf3Rb+51TcsOFyDkgLkh2KER71r7TQvjcdXr3up2IcKf45RgpxPB+U2go+R1kPF+qcdBlZITJVyh9MCuOFwsvNBBrvfCJkTlLhlSQKvmTRV/BBQKujnPhz8fiBX+4tL3dJKvHcAuHqtUI4/lRQ3/xxF+SNVhMiYTF1ZWKvk4MdlJfgEP4drsPBuQ8FwTJzMnRjlX/YQMN6/Aj9p9+mqyEgF/Yo5PvtkoR+qpSD4ZJ+bscwYx96/8MaYFFC6YWLCfOKhjLmU/B2KmQvd07K8meJ1oW7u9ExLVa8pz0yxQf7v/V4r18mOHWqEuVQOa434DDF1TySXm2RDMVFUknJvAUxEZaYsk2lUmw==; 5:dLQClQu9RYCcI53sZKJG9N0D9NEr4Qd9pJ+iXDsEFIc1IzZHHKaBXJTV+rAzJHxy2DnQI2uKV7Wjb4ehmmN8vr1FS9mQFEeusAh6/SCwqYnm/XJvAqghpWPpJtIQchAIEp12cAA/nOeNsQSrdmJ+gF0GLrbaDpBYaLpAYaDnO/Y/OPTC8arn7epENc7L0IReWSUBKGOuibdwZ0tXKqGmHw==; 7:SgckCvyHG5ubRnNl0LRrSArl1q/vb68UpvZlnBaLsXzpVzIhhP+l08ghDmm8MRL1GVn2gUDHK4lB/VVpR1VCL6csUU+HH0NUf5LD/A3OOffTGjHElDz59PEKs86WaXAiMkJm+pQer0HJkdFhrvWRHw== x-ms-office365-filtering-correlation-id: 899a48fc-728d-4aa9-0ec0-08d67d36b7a8 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(7168020)(4627221)(201703031133081)(201702281549075)(8990200)(5600109)(711020)(4618075)(2017052603328)(7153060)(7193020); SRVR:BYAPR04MB5016; x-ms-traffictypediagnostic: BYAPR04MB5016: wdcipoutbound: EOP-TRUE x-microsoft-antispam-prvs: x-forefront-prvs: 0921D55E4F x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(39860400002)(136003)(346002)(366004)(376002)(396003)(189003)(199004)(81156014)(81166006)(2906002)(14454004)(8676002)(36756003)(4326008)(39060400002)(305945005)(68736007)(478600001)(7736002)(8936002)(50226002)(97736004)(256004)(2616005)(486006)(476003)(25786009)(72206003)(105586002)(106356001)(6436002)(6486002)(6512007)(44832011)(1076003)(110136005)(54906003)(6116002)(3846002)(71190400001)(386003)(11346002)(316002)(71200400001)(102836004)(6506007)(55236004)(26005)(186003)(53936002)(446003)(86362001)(7416002)(52116002)(5660300001)(76176011)(99286004)(66066001)(41533002); DIR:OUT; SFP:1102; SCL:1; SRVR:BYAPR04MB5016; H:BYAPR04MB5303.namprd04.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: rJJvBfH0NVENs+r+0KqLO1oLODoaPZY6ciGXorLCD+GluIPuyLmY1yRG8VTQAnA8lsE+lkKNDSeg/RGQn9l1WxLGh0e3W2O3OxdE/5WGvl2XSHBM1LFfPeOdiTpzdsFCKCM0jNkzl1usst9qx+uR9Livh1hWoVqTGHTv65MkhtRB97rFUFfKSAiswfACbI7rhvS0dvwM5u3q+xqwYOkc+ytJfD38Omgt2L4BIa9sMKFUn43D5/wczm4Y0AILlS/c8fxzmCrbVCkTYIbzx7DVgvltrt9jB3wsIJ9k/C5vwS4gk46Dpz3O7eX/z3gpyTHd3jTjk5RCc4dFPmW4E0BcwhcqGliH4MIO42oszctuFFsVxAyer7DVz1hPk7lmzDLrAMpdaVpRpGW1ZHccFW2XeKIaYq0XNCSnqZAbqGMWZjw= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: wdc.com X-MS-Exchange-CrossTenant-Network-Message-Id: 899a48fc-728d-4aa9-0ec0-08d67d36b7a8 X-MS-Exchange-CrossTenant-originalarrivaltime: 18 Jan 2019 11:18:44.9954 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: b61c8803-16f3-4c35-9b17-6f65f441df86 X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR04MB5016 Cc: Palmer Dabbelt , U-Boot Mailing List , Alexander Graf , Christoph Hellwig , Paul Walmsley Subject: [U-Boot] [PATCH v2 01/11] riscv: Rename cpu/qemu to cpu/generic X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 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" The QEMU CPU support under arch/riscv is pretty much generic and works fine for SiFive Unleashed as well. In fact, there will be quite a few RISC-V SOCs for which QEMU CPU support will work fine. This patch renames cpu/qemu to cpu/generic to indicate the above fact. If there are SOC specific errata workarounds required in cpu/generic then those can be done at runtime in cpu/generic based on CPU vendor specific DT compatible string. Signed-off-by: Anup Patel Reviewed-by: Alexander Graf Reviewed-by: Lukas Auer Reviewed-by: Bin Meng --- arch/riscv/Kconfig | 2 +- arch/riscv/cpu/{qemu => generic}/Kconfig | 2 +- arch/riscv/cpu/{qemu => generic}/Makefile | 0 arch/riscv/cpu/{qemu => generic}/cpu.c | 0 arch/riscv/cpu/{qemu => generic}/dram.c | 0 board/emulation/qemu-riscv/Kconfig | 4 ++-- 6 files changed, 4 insertions(+), 4 deletions(-) rename arch/riscv/cpu/{qemu => generic}/Kconfig (91%) rename arch/riscv/cpu/{qemu => generic}/Makefile (100%) rename arch/riscv/cpu/{qemu => generic}/cpu.c (100%) rename arch/riscv/cpu/{qemu => generic}/dram.c (100%) diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig index c45e4d73a8..6879047ff7 100644 --- a/arch/riscv/Kconfig +++ b/arch/riscv/Kconfig @@ -22,7 +22,7 @@ source "board/emulation/qemu-riscv/Kconfig" # platform-specific options below source "arch/riscv/cpu/ax25/Kconfig" -source "arch/riscv/cpu/qemu/Kconfig" +source "arch/riscv/cpu/generic/Kconfig" # architecture-specific options below diff --git a/arch/riscv/cpu/qemu/Kconfig b/arch/riscv/cpu/generic/Kconfig similarity index 91% rename from arch/riscv/cpu/qemu/Kconfig rename to arch/riscv/cpu/generic/Kconfig index f48751e6de..1d6ab5032d 100644 --- a/arch/riscv/cpu/qemu/Kconfig +++ b/arch/riscv/cpu/generic/Kconfig @@ -2,7 +2,7 @@ # # Copyright (C) 2018, Bin Meng -config QEMU_RISCV +config GENERIC_RISCV bool select ARCH_EARLY_INIT_R imply CPU diff --git a/arch/riscv/cpu/qemu/Makefile b/arch/riscv/cpu/generic/Makefile similarity index 100% rename from arch/riscv/cpu/qemu/Makefile rename to arch/riscv/cpu/generic/Makefile diff --git a/arch/riscv/cpu/qemu/cpu.c b/arch/riscv/cpu/generic/cpu.c similarity index 100% rename from arch/riscv/cpu/qemu/cpu.c rename to arch/riscv/cpu/generic/cpu.c diff --git a/arch/riscv/cpu/qemu/dram.c b/arch/riscv/cpu/generic/dram.c similarity index 100% rename from arch/riscv/cpu/qemu/dram.c rename to arch/riscv/cpu/generic/dram.c diff --git a/board/emulation/qemu-riscv/Kconfig b/board/emulation/qemu-riscv/Kconfig index 0d865acf10..88d07d568e 100644 --- a/board/emulation/qemu-riscv/Kconfig +++ b/board/emulation/qemu-riscv/Kconfig @@ -7,7 +7,7 @@ config SYS_VENDOR default "emulation" config SYS_CPU - default "qemu" + default "generic" config SYS_CONFIG_NAME default "qemu-riscv" @@ -18,7 +18,7 @@ config SYS_TEXT_BASE config BOARD_SPECIFIC_OPTIONS # dummy def_bool y - select QEMU_RISCV + select GENERIC_RISCV imply SYS_NS16550 imply VIRTIO_MMIO imply VIRTIO_NET From patchwork Fri Jan 18 11:18:52 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anup Patel X-Patchwork-Id: 1027215 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=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=wdc.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=wdc.com header.i=@wdc.com header.b="P1pisUIc"; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=sharedspace.onmicrosoft.com header.i=@sharedspace.onmicrosoft.com header.b="fnfHO9nZ"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 43gz4y0yyfz9sCs for ; Fri, 18 Jan 2019 22:20:18 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id BC7ACC21DFD; Fri, 18 Jan 2019 11:19:29 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=KHOP_BIG_TO_CC, T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 9F835C220A5; Fri, 18 Jan 2019 11:19:11 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id E6689C220A3; Fri, 18 Jan 2019 11:19:00 +0000 (UTC) Received: from esa5.hgst.iphmx.com (esa5.hgst.iphmx.com [216.71.153.144]) by lists.denx.de (Postfix) with ESMTPS id F388CC220AE for ; Fri, 18 Jan 2019 11:18:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1547810337; x=1579346337; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=reZQCpOTYUU4uchFWfvrCyeZqRlfpjOUsPYYIqCgq7w=; b=P1pisUIccal7OZrm56oq2/smTP15BjtM+0nAKufqO3cc05JwDLgFKm3o LJhQ0AGighdRxsWNuW33eGF2gRa1UG+vMATVKvj3ieGl27eWamgeJ4pQQ OPaRJnwvDV3ErFn7b6cWBQ2p+3G8KqslNeYr22+6FK9sW8jKZUVpSPCJL NN32tdAw5CciVpDiKXkTmadtcoFz82N56O61WO4OEXfklCRcCKB+1xrYM X/kgEU63V1Z5RE+Z4AEJ2J6cKo9Zk8/Kr4wIiYiOS8+kuYETkXE1R3+BI yPb2WDp6zfTvC3QOGlpzsup9hXrDAEKNdLyly5/uAtb9P/PbINvfK+Cf4 A==; X-IronPort-AV: E=Sophos;i="5.56,491,1539619200"; d="scan'208";a="100370966" Received: from mail-dm3nam03lp2053.outbound.protection.outlook.com (HELO NAM03-DM3-obe.outbound.protection.outlook.com) ([104.47.41.53]) by ob1.hgst.iphmx.com with ESMTP; 18 Jan 2019 19:18:54 +0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sharedspace.onmicrosoft.com; s=selector1-wdc-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=pe1ArEZBcBIXCZh+jFVrcmZTZpicr90roC4JRYhjadw=; b=fnfHO9nZTYeoRbdVoZvr2HgSikiT+cJaoKS2p3xL44E9E7RiqBGv1hZivzcOx3n/2TzuWOj5ttVvz+zVU3hb99PUV8Jn/wfy4Yony3MX3gHhX4p3N2PC82ZP2+5dmj5uQcftFARXbXU5wmZNQwyA3BaSGudMsz/IdnSbS+kNH/M= Received: from BYAPR04MB5303.namprd04.prod.outlook.com (20.178.49.148) by BYAPR04MB5016.namprd04.prod.outlook.com (52.135.235.10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1537.24; Fri, 18 Jan 2019 11:18:53 +0000 Received: from BYAPR04MB5303.namprd04.prod.outlook.com ([fe80::add1:92cc:65d7:5d94]) by BYAPR04MB5303.namprd04.prod.outlook.com ([fe80::add1:92cc:65d7:5d94%2]) with mapi id 15.20.1537.018; Fri, 18 Jan 2019 11:18:53 +0000 From: Anup Patel To: Rick Chen , Bin Meng , Joe Hershberger , Lukas Auer , Masahiro Yamada , Simon Glass Thread-Topic: [PATCH v2 02/11] riscv: Add asm/dma-mapping.h for DMA mappings Thread-Index: AQHUrx+X32FQmhOaG0quZv5x3us1+A== Date: Fri, 18 Jan 2019 11:18:52 +0000 Message-ID: <20190118111820.71349-3-anup.patel@wdc.com> References: <20190118111820.71349-1-anup.patel@wdc.com> In-Reply-To: <20190118111820.71349-1-anup.patel@wdc.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: MA1PR01CA0115.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a00:1::31) To BYAPR04MB5303.namprd04.prod.outlook.com (2603:10b6:a03:c8::20) authentication-results: spf=none (sender IP is ) smtp.mailfrom=Anup.Patel@wdc.com; x-ms-exchange-messagesentrepresentingtype: 1 x-mailer: git-send-email 2.17.1 x-originating-ip: [49.207.48.211] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; BYAPR04MB5016; 6:BW11RGniynFkTRf/iXBgVfb8V9hjWeFQUPhVPY1BneyyeDeuEPu0TCsA6/gHo/1pnLzDZ4Osg+2FDlqUalTYBIbcxDezjx2GGKIW3AKMU913L01I4Ly1odSjGC8KcR0O7tFTsIdXYxAj6d/SWUVdHoJctkWaa5nCRBtLKq15Z7bTXKPxStLN/GCHu+MXOGpFeZH0NluqAVzkpH0j5qDvmUWgLDwDAd1esNAB5FO1E9l56b4Bz2g3Q9tOMKwx62gxrKMVZSy6o70QQR9c74vSPWYAYYKUBx2HgzR4hAPInRnbY9i9NwGkrNXHPexoZzfoMaAXy2HDOXHyDM5kvsNpOrVJcPLvr+QF5Q3hLmgPIhdy3N6UwFn8bnzgubQwmagc+3ZAl7cRxQYEfNJy2edOVYBkP5249wcvZKfPg3L3k6fY2ramAe+YADL2DxIUDzyaN+4Op/+TGYBTu0zFhBgN2w==; 5:31PwAWBJkuTEtJvhuS/xmR26kg3tT2yTlUcyxZWqcIO+fQ3Z/TN7Mhv1eLLxm7yK8rOG7DyMUUPr7Q+RkHxAsLTYFGqdKl3o00mF+1JdHFTL8OhXH7AOuATzutNymYOi6RN1oDWNAcjmeB+rt5VamjHABTvzM6aCPbc7LLIfD9haI676G+HfIbnjpxXGYKSJTl3caeBn4E9i/OREY6mtOw==; 7:2auGKv2YwlPVCrQ9NEIP7Hc/4R/ZFtytv31VEVkvTlp6qYpw7RprTZckXJ2dvO+r3iHjtU1kzk4ItGzd0d4PfB2a/pdmeNueNAJXI3xyJmrtCT8oIWE+Mbv+zcskyfh7Tgw0qxTGsX4HPeeGFLfp5w== x-ms-office365-filtering-correlation-id: b881a6e2-6e3f-408f-1565-08d67d36ba59 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(7168020)(4627221)(201703031133081)(201702281549075)(8990200)(5600109)(711020)(4618075)(2017052603328)(7153060)(7193020); SRVR:BYAPR04MB5016; x-ms-traffictypediagnostic: BYAPR04MB5016: wdcipoutbound: EOP-TRUE x-microsoft-antispam-prvs: x-forefront-prvs: 0921D55E4F x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(39860400002)(136003)(346002)(366004)(376002)(396003)(189003)(199004)(81156014)(81166006)(2906002)(14454004)(8676002)(36756003)(4326008)(39060400002)(305945005)(68736007)(478600001)(7736002)(8936002)(50226002)(97736004)(256004)(2616005)(486006)(476003)(25786009)(72206003)(105586002)(106356001)(6436002)(6486002)(6512007)(44832011)(1076003)(110136005)(54906003)(6116002)(3846002)(71190400001)(386003)(11346002)(316002)(71200400001)(102836004)(6506007)(55236004)(26005)(186003)(53936002)(446003)(86362001)(7416002)(52116002)(5660300001)(76176011)(99286004)(66066001); DIR:OUT; SFP:1102; SCL:1; SRVR:BYAPR04MB5016; H:BYAPR04MB5303.namprd04.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: OQ45aT6zdUu8cfcxoRZdGAaxPG5OnKtzxKZ4uPGVY7nE5fSPN0B/4J3UmbqZQcEfMOKhygeTN3ssF3WVyn2oeyxOjfb5N7lwsPJsGWjOWJMVxwsdUGpavfbCMPaIaFpCWW7RJINyAuva9Jus71GCwivIgLH4KLM1x237hcnbAdlqANN1VYhy4WVVHDt9KqHc07/alc5j+NRudr5E4Fs+gCZJY4uw3TZlL1qSp1Aezq/cVNopCDEl9Ak5/zTT4hhPnUqiftnWvlATeRCp/mIWUUj0huP00fUAibhR/0GcSaRnO4YG4S+ajcq93pmEuF4kUmght2yDFWSZt7OP1Q1nQISCR8lqhSWQWlsch9yqWr4xE+eqoyt+ZkOcFYyhDGCoFILT5u5gkfUlav8+xod0NtJR2D/yiLhOLnsb9jc+dRE= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: wdc.com X-MS-Exchange-CrossTenant-Network-Message-Id: b881a6e2-6e3f-408f-1565-08d67d36ba59 X-MS-Exchange-CrossTenant-originalarrivaltime: 18 Jan 2019 11:18:49.4954 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: b61c8803-16f3-4c35-9b17-6f65f441df86 X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR04MB5016 Cc: Palmer Dabbelt , U-Boot Mailing List , Alexander Graf , Christoph Hellwig , Paul Walmsley Subject: [U-Boot] [PATCH v2 02/11] riscv: Add asm/dma-mapping.h for DMA mappings X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 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" This patch adds asm/dma-mapping.h for Linux-like DMA mappings APIs required by some of the drivers (such as, Cadance MACB Ethernet driver). Signed-off-by: Anup Patel Reviewed-by: Bin Meng Reviewed-by: Alexander Graf Reviewed-by: Lukas Auer --- arch/riscv/include/asm/dma-mapping.h | 38 ++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 arch/riscv/include/asm/dma-mapping.h diff --git a/arch/riscv/include/asm/dma-mapping.h b/arch/riscv/include/asm/dma-mapping.h new file mode 100644 index 0000000000..3d930c90ec --- /dev/null +++ b/arch/riscv/include/asm/dma-mapping.h @@ -0,0 +1,38 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* + * Copyright (c) 2018 Western Digital Corporation or its affiliates. + * + * Authors: + * Anup Patel + */ + +#ifndef __ASM_RISCV_DMA_MAPPING_H +#define __ASM_RISCV_DMA_MAPPING_H + +#include + +#define dma_mapping_error(x, y) 0 + +static inline void *dma_alloc_coherent(size_t len, unsigned long *handle) +{ + *handle = (unsigned long)memalign(ARCH_DMA_MINALIGN, len); + return (void *)*handle; +} + +static inline void dma_free_coherent(void *addr) +{ + free(addr); +} + +static inline unsigned long dma_map_single(volatile void *vaddr, size_t len, + enum dma_data_direction dir) +{ + return (unsigned long)vaddr; +} + +static inline void dma_unmap_single(volatile void *vaddr, size_t len, + unsigned long paddr) +{ +} + +#endif /* __ASM_RISCV_DMA_MAPPING_H */ From patchwork Fri Jan 18 11:18:57 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anup Patel X-Patchwork-Id: 1027216 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=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=wdc.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=wdc.com header.i=@wdc.com header.b="g+Jbq68c"; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=sharedspace.onmicrosoft.com header.i=@sharedspace.onmicrosoft.com header.b="ottdlCOY"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 43gz5K04rGz9sCs for ; Fri, 18 Jan 2019 22:20:33 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id C66D2C21E1D; Fri, 18 Jan 2019 11:19:47 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=KHOP_BIG_TO_CC, T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 9AAF3C22047; Fri, 18 Jan 2019 11:19:16 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 41ED2C21E2F; Fri, 18 Jan 2019 11:19:04 +0000 (UTC) Received: from esa5.hgst.iphmx.com (esa5.hgst.iphmx.com [216.71.153.144]) by lists.denx.de (Postfix) with ESMTPS id E78AAC2207C for ; Fri, 18 Jan 2019 11:18:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1547810340; x=1579346340; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=Gfv9ZnTTGS6e+uF+IyobhrEH77Ik14qqBYiKkuvaONQ=; b=g+Jbq68csGtySmgQYznhvMDysurWQ4mbm5Q+870uQO5jh1/MJOucuz9i OxqwIRI+Jo/FA0Q3qmPP73eERypFEA4Ws1LOMtEXP8B7t/gTouYFhpelZ lPaAOfsE+muHWUCvnYm+1RucuiDJkH468e/X0jx4MOlR0sGRJ2DfEEQCp 1DQssiPiGQXC3XCPQSgKAjH0HultQmQvfwNWxMtpqv3TnziuIJuA+47ep jmvG+UPUW8MlBh74xKx4KzZWM/AgVKddWxpXXm1pbC8+z9DBtgPaeBphY CyUkDxqgLBjLp8g6Stto90sJ1FEYDXkKepBBJIDCd9CrTIyXh7gcPL8tC Q==; X-IronPort-AV: E=Sophos;i="5.56,491,1539619200"; d="scan'208";a="100370971" Received: from mail-dm3nam03lp2059.outbound.protection.outlook.com (HELO NAM03-DM3-obe.outbound.protection.outlook.com) ([104.47.41.59]) by ob1.hgst.iphmx.com with ESMTP; 18 Jan 2019 19:18:59 +0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sharedspace.onmicrosoft.com; s=selector1-wdc-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=JoBWog3qv68wqK+fW40QM+LF+JCbWnPilmdvcMd01L8=; b=ottdlCOYpn2oTC8NtNU1nKvi8+KiA6KeargTOhT2b7b+oX/jxAbhJhxaR84SH8t7XZRCeBv26XTlQ1PFiMntU8G4Tuon6sBmApQzMIKYvoko6PMHUd6yaiKA2LpOv4RuZnBrAPWHedxVjNY9AL3wd+8m6DhA/moBtrHQMus71qQ= Received: from BYAPR04MB5303.namprd04.prod.outlook.com (20.178.49.148) by BYAPR04MB5016.namprd04.prod.outlook.com (52.135.235.10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1537.24; Fri, 18 Jan 2019 11:18:57 +0000 Received: from BYAPR04MB5303.namprd04.prod.outlook.com ([fe80::add1:92cc:65d7:5d94]) by BYAPR04MB5303.namprd04.prod.outlook.com ([fe80::add1:92cc:65d7:5d94%2]) with mapi id 15.20.1537.018; Fri, 18 Jan 2019 11:18:57 +0000 From: Anup Patel To: Rick Chen , Bin Meng , Joe Hershberger , Lukas Auer , Masahiro Yamada , Simon Glass Thread-Topic: [PATCH v2 03/11] riscv: generic: Ensure that U-Boot runs within 4GB for 64bit systems Thread-Index: AQHUrx+azUeR95vAC0uI0MtEfw6i5Q== Date: Fri, 18 Jan 2019 11:18:57 +0000 Message-ID: <20190118111820.71349-4-anup.patel@wdc.com> References: <20190118111820.71349-1-anup.patel@wdc.com> In-Reply-To: <20190118111820.71349-1-anup.patel@wdc.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: MA1PR01CA0115.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a00:1::31) To BYAPR04MB5303.namprd04.prod.outlook.com (2603:10b6:a03:c8::20) authentication-results: spf=none (sender IP is ) smtp.mailfrom=Anup.Patel@wdc.com; x-ms-exchange-messagesentrepresentingtype: 1 x-mailer: git-send-email 2.17.1 x-originating-ip: [49.207.48.211] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; BYAPR04MB5016; 6:ReHnQkglrpeR9LPB9ZUjYBuloBHLrRnzswzcPLjb2ckC6Vqm/9G0qXjImzm0cnSPIVpdWRDvRR8TMiMJV4h1ke7OCrJUQnElJQc1FH8lTUQiShcjQysxNv0yJsaf/J42SqQXSFUG/QozomQKW5wcqhM8k0H5BkcANrmmAgZ/gi7DSjfCfeazZVyx0jAUrNH443L8dvnecCbzxfei7UoaextEq+DZB/26xQAT40WGuWWfM2yt3c46m5qr6k4Ipq5X32vlSPmpg7PG+WhMWbkv8DIC07PPUP9Aa06TWhHGi9hHXA2El9y3o5kzKM/LB6qdOdzudI4x8rWTeiVdSPuwy5VZ2tit2v8CM8l2G4+4yC2ItJkLYqouwpcmv5LAIcujGxLxvMJdZLcvljoZsB6axkFmSPAKeEi3cIK2F+5h9vSoWQjiwK9mCgeVUqSniKbziNYeXyP1krT86IIHkN84Dg==; 5:TrKRzsawMTAwHTRIzpWHqympyGmptF4dWg1OruLNCuUDTan1O2Qh/dbvMu3PBeXuIx/D4xIvnfFGOMvXKec2aScYkG+6Vbc+C7hZ8zt1CPFNFqEbOhUUAwuUQUaH1vZ8gTZxWt/xdxQKLN5zuawgTUatzcJUwvvxCHkEf/CCeIZR+dzBOOZfQGoRLTh4hlebiG8d7hu7RG+wO05XxjRR2g==; 7:uCqe68cTjaa7t+Mo8jOSmkhI2VGe70JAObf+EtjeOzOX5AZoNH6t+50Gir6iqPPDsA85YxUxLEnbaLkQa5K6eVUaWEfoTROwO+b0KMHOitRcovORDtFyQhE24E5GRkSOib/GS0eBmo1gsudSma5vkA== x-ms-office365-filtering-correlation-id: cc27d46b-de55-4094-07d1-08d67d36bd16 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(7168020)(4627221)(201703031133081)(201702281549075)(8990200)(5600109)(711020)(4618075)(2017052603328)(7153060)(7193020); SRVR:BYAPR04MB5016; x-ms-traffictypediagnostic: BYAPR04MB5016: wdcipoutbound: EOP-TRUE x-microsoft-antispam-prvs: x-forefront-prvs: 0921D55E4F x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(39860400002)(136003)(346002)(366004)(376002)(396003)(189003)(199004)(81156014)(81166006)(2906002)(14454004)(8676002)(36756003)(4326008)(39060400002)(305945005)(68736007)(478600001)(7736002)(8936002)(50226002)(97736004)(256004)(2616005)(486006)(476003)(25786009)(72206003)(105586002)(106356001)(6436002)(6486002)(6512007)(44832011)(1076003)(110136005)(54906003)(6116002)(3846002)(71190400001)(386003)(11346002)(316002)(71200400001)(102836004)(6506007)(55236004)(26005)(186003)(53936002)(446003)(86362001)(7416002)(52116002)(5660300001)(76176011)(99286004)(66066001)(41533002); DIR:OUT; SFP:1102; SCL:1; SRVR:BYAPR04MB5016; H:BYAPR04MB5303.namprd04.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: 9s6iwlKl+GlAuJZvxpah97Q/TA1cJASDz2AG01X4VDJWu+X66sZCyeYmXdYhD6u5PP04pPZOLkbPmTtLOiIgR7knv6DzHI4Nt9QFGZRzgEAossyxKXFYq9Xo7+Dgk4Yo0fL3qigx7RH/bTMViqZi2Rs8VTffaKMBaP/BEl3M/fg8ow49dDvyAKiQe0sgFyDjndUULIsKhB4Kvr1ai+TqVb0uL1t8GVRYMRDnRlKx3PydUDTLzrLk33eF6n7C16T5iAxetEk/7R54Nfq29mjlqfUlvOJ7xkzF501EaK8DNKswFQRJrgcDqLeGkENbybCAHMS/gzNyrZi4lgYXKR1/y/vHJUMjWXkdlD0ph6umlOvKRAn/bdWYQVg64zFgRHUioon4g0HUSg1b8RcE3V+QMduoohVRtWo4raYvFD0IF8A= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: wdc.com X-MS-Exchange-CrossTenant-Network-Message-Id: cc27d46b-de55-4094-07d1-08d67d36bd16 X-MS-Exchange-CrossTenant-originalarrivaltime: 18 Jan 2019 11:18:54.1047 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: b61c8803-16f3-4c35-9b17-6f65f441df86 X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR04MB5016 Cc: Palmer Dabbelt , U-Boot Mailing List , Alexander Graf , Christoph Hellwig , Paul Walmsley Subject: [U-Boot] [PATCH v2 03/11] riscv: generic: Ensure that U-Boot runs within 4GB for 64bit systems X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 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" On 64bit systems, the DRAM top can be easily beyond 4GB and U-Boot DMA mapping APIs will generate DMA addresses beyond 4GB. This breaks DMA programming in 32bit DMA capable devices (such as Cadence MACB ethernet). For example, If DRAM is more then 2GB on QEMU sifive_u machine then Cadence MACB ethernet stops working for U-Boot because it is a 32bit DMA capable device. To handle 32bit DMA capable devices on 64bit systems, we provide custom implementation of board_get_usable_ram_top() which ensures that usable ram top is not more then 4GB. This in-turn ensures that U-Boot always runs within 4GB hence DMA addresses generated by DMA mapping APIs will be within 4GB too. Signed-off-by: Atish Patra Signed-off-by: Anup Patel Reviewed-by: Alexander Graf Reviewed-by: Lukas Auer Reviewed-by: Bin Meng --- arch/riscv/cpu/generic/dram.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/arch/riscv/cpu/generic/dram.c b/arch/riscv/cpu/generic/dram.c index 84d87d2a7f..5725d3c7ae 100644 --- a/arch/riscv/cpu/generic/dram.c +++ b/arch/riscv/cpu/generic/dram.c @@ -5,6 +5,9 @@ #include #include +#include + +DECLARE_GLOBAL_DATA_PTR; int dram_init(void) { @@ -15,3 +18,20 @@ int dram_init_banksize(void) { return fdtdec_setup_memory_banksize(); } + +ulong board_get_usable_ram_top(ulong total_size) +{ +#ifdef CONFIG_64BIT + /* + * Ensure that we run from first 4GB so that all + * addresses used by U-Boot are 32bit addresses. + * + * This in-turn ensures that 32bit DMA capabale + * devices work fine because DMA mapping APIs will + * provide 32bit DMA addresses only. + */ + if (gd->ram_top > SZ_4G) + return SZ_4G; +#endif + return gd->ram_top; +} From patchwork Fri Jan 18 11:19:02 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anup Patel X-Patchwork-Id: 1027217 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=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=wdc.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=wdc.com header.i=@wdc.com header.b="Oa9uLTsf"; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=sharedspace.onmicrosoft.com header.i=@sharedspace.onmicrosoft.com header.b="izTdCrcV"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 43gz6F27NJz9sLt for ; Fri, 18 Jan 2019 22:21:25 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id F3352C21E42; Fri, 18 Jan 2019 11:20:07 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=KHOP_BIG_TO_CC, T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 9D5ECC220CA; Fri, 18 Jan 2019 11:19:31 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id EF510C22095; Fri, 18 Jan 2019 11:19:09 +0000 (UTC) Received: from esa5.hgst.iphmx.com (esa5.hgst.iphmx.com [216.71.153.144]) by lists.denx.de (Postfix) with ESMTPS id DE0C5C220BD for ; Fri, 18 Jan 2019 11:19:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1547810345; x=1579346345; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=kRcPLFAsU2o2yMzuXb0YnwAk9QvygLqiUMAD8N23fPw=; b=Oa9uLTsfhuKxQhcj33svDKpENwFOLjLPcnOI0lNxYNoBc4UB/5Pn4iHo 0gyd0ROPy3s+rSWFW9cVC+04y8NNV6nH4dhVakdT1mX5ZvzdXBvosrdOi 3eu5fcDzS9pTDS+5irdIfy5xpFWPZs1dHP2ltneiF4xFw4VV6+DTVIF5z C3AwwtZxj10zWGu6RuEfFuWFV1lC0gVwNgUpG6Vskic7ytYuJNJpxvR3j w5Vl69fyrp7iYKNj6POgB6RZiQHt+ArDgxu8PTMRAD6GsxRu1EKbOl+kl iFr5LcF7m1PsHLddYp/ak/bdl04Wyf4TTLcwnBZcj3s/yEF0TYDYLEKvO A==; X-IronPort-AV: E=Sophos;i="5.56,491,1539619200"; d="scan'208";a="100370978" Received: from mail-dm3nam03lp2055.outbound.protection.outlook.com (HELO NAM03-DM3-obe.outbound.protection.outlook.com) ([104.47.41.55]) by ob1.hgst.iphmx.com with ESMTP; 18 Jan 2019 19:19:04 +0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sharedspace.onmicrosoft.com; s=selector1-wdc-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=o4KeDLVqkO48Ddjegvmc2e7FwpMq7mnJBXPVMJxU9yc=; b=izTdCrcV3wCTW0BFUCRXJoQDlvpOoxQhj8vk0LdkL+BI9e/XYiea15xefrOS9aVXE+zxazRtPj0QeB5lhj/RyB8ThHS5OFw2UCxgeUFPGlZ4oC3YG/hxh7g80IOUIJCIIjrMLmLyrrlR8Ke4sm7SRwYo7+xABL5R+vsJYwDpbLA= Received: from BYAPR04MB5303.namprd04.prod.outlook.com (20.178.49.148) by BYAPR04MB5016.namprd04.prod.outlook.com (52.135.235.10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1537.24; Fri, 18 Jan 2019 11:19:02 +0000 Received: from BYAPR04MB5303.namprd04.prod.outlook.com ([fe80::add1:92cc:65d7:5d94]) by BYAPR04MB5303.namprd04.prod.outlook.com ([fe80::add1:92cc:65d7:5d94%2]) with mapi id 15.20.1537.018; Fri, 18 Jan 2019 11:19:02 +0000 From: Anup Patel To: Rick Chen , Bin Meng , Joe Hershberger , Lukas Auer , Masahiro Yamada , Simon Glass Thread-Topic: [PATCH v2 04/11] net: macb: Fix clk API usage for RISC-V systems Thread-Index: AQHUrx+dJ2IwaLUPnEC6kh1EbGq+kw== Date: Fri, 18 Jan 2019 11:19:02 +0000 Message-ID: <20190118111820.71349-5-anup.patel@wdc.com> References: <20190118111820.71349-1-anup.patel@wdc.com> In-Reply-To: <20190118111820.71349-1-anup.patel@wdc.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: MA1PR01CA0115.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a00:1::31) To BYAPR04MB5303.namprd04.prod.outlook.com (2603:10b6:a03:c8::20) authentication-results: spf=none (sender IP is ) smtp.mailfrom=Anup.Patel@wdc.com; x-ms-exchange-messagesentrepresentingtype: 1 x-mailer: git-send-email 2.17.1 x-originating-ip: [49.207.48.211] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; BYAPR04MB5016; 6:4MTdW+5mrutcrK9BSmlhfFWms9bV/as0rqotzVuGgBvzbnQMWiZ6D2v3a20btlWlROeKwczGhw9OC1A5wv0apaUoVLujRfwLtuWFusMPSvlPZBpLEqF5izr9Hre2gpDvSJLHfTz79ItBpEdJ2u0sQXjmLX/1ANqgJEGcGQpVfAG3JzHc7Q0B+6ne8EwuN4iGvt2peOSqn7w3ci8w/wWT6BoUCcGevXC6Wxr1N4HzFNeM4uF4oy38HV8D06PLrQTkUZ9+819uDQtMybUHf1twXhSECR7qz+wGmdOXoNgJkzNWSZX+bI1oNZjlN+oJ/HW3ouL+sdiu+2oQSGHxhBGNqWP0gs8oDbatgnUj+zhGAaxTUP/wcMcu4/c5IolhoaBPKIZQrJawEDnp0iMSb5CLvfY3YZrFMnXvpXGzKcoI+psmUHwKzppKgJg+d1qqOGZ9Y9EVp9z/sq65Vuibhr786A==; 5:X+L8W2nG2bY/YaysENbRSntf/HzYiNP/nmd7GVs/wMF1/Vi86bVWNM1W8F+Z6c6rSAuXBp0dbr+934V+XnhLB8TnfHm3towaiOdDwZl2LYoEJvNn61oryQKnjoEycp8cLUb/R4qjyigBBjSpSQKl3QjjcCTFPIlu294/d8vQXTmuLf+IzUnS6jSFoy4iNLa8WNm7qLYZL5WyWfrhWHnWYA==; 7:+Cw2LrUgUM3Q0Eai662+kP3knYw76a/evbtjHLLLfQPaIvrIyppRN4V/NrA3iujWpJj5d15e5vlXpdb9r2xoT5CftY7D6uZfQl+R9FQzQ6N3G843IlduHjmYcULJlhysbT7i6ayk5Cr3lQQyIBymNg== x-ms-office365-filtering-correlation-id: cb563f83-7412-4dd9-bee0-08d67d36bfd7 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(7168020)(4627221)(201703031133081)(201702281549075)(8990200)(5600109)(711020)(4618075)(2017052603328)(7153060)(7193020); SRVR:BYAPR04MB5016; x-ms-traffictypediagnostic: BYAPR04MB5016: wdcipoutbound: EOP-TRUE x-microsoft-antispam-prvs: x-forefront-prvs: 0921D55E4F x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(39860400002)(136003)(346002)(366004)(376002)(396003)(189003)(199004)(81156014)(81166006)(2906002)(14454004)(8676002)(36756003)(4326008)(39060400002)(305945005)(68736007)(478600001)(7736002)(8936002)(14444005)(50226002)(97736004)(256004)(2616005)(486006)(476003)(4744005)(25786009)(72206003)(105586002)(106356001)(6436002)(6486002)(6512007)(44832011)(1076003)(110136005)(54906003)(6116002)(3846002)(71190400001)(386003)(11346002)(316002)(71200400001)(102836004)(6506007)(55236004)(26005)(186003)(53936002)(446003)(86362001)(7416002)(52116002)(5660300001)(76176011)(99286004)(66066001); DIR:OUT; SFP:1102; SCL:1; SRVR:BYAPR04MB5016; H:BYAPR04MB5303.namprd04.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: /jqz/W+41Li5KYbZOtjBfI3g8IcclHPxe+1oWnRe5ybEBe9gySosFlbIhs9YBCMfLFsaYYOp9CuasGAFsmF2F0dEUCnXUORXGgyQNs8YOLTzTNuJJx000BS5sifdrDgjksIS/FOtffWBA1A3i4JeY/IOMd6EVYpBsufoAqfdJETkyhWQwHZRCo+51TxITashUr/oHtEh+Vvpoomx2Nih8r7ela6kzfKzC6aokcCN8lLTGO8uoTFcE7jD30EQzBd9SPSHDEVoaRS+NxakTHBKpgw7XY/wiX+GLGELV3IZevJJ3ySH5CdzI664LQerfqlbCabNpS0B4uQFDsVfsrLYOf04Z3QzF7cH6f/TTUok4u/28suRUQrsIY+e6u7e8bXEsO2/gtUjTVphR0ZxFFsZB/3qGVmKraC9ZxPu9cMxOjA= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: wdc.com X-MS-Exchange-CrossTenant-Network-Message-Id: cb563f83-7412-4dd9-bee0-08d67d36bfd7 X-MS-Exchange-CrossTenant-originalarrivaltime: 18 Jan 2019 11:18:58.7609 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: b61c8803-16f3-4c35-9b17-6f65f441df86 X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR04MB5016 Cc: Palmer Dabbelt , U-Boot Mailing List , Alexander Graf , Christoph Hellwig , Paul Walmsley Subject: [U-Boot] [PATCH v2 04/11] net: macb: Fix clk API usage for RISC-V systems X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 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" This patch does following fixes in MACB ethernet driver for using it on RISC-V systems (particularly QEMU sifive_u machine): 1. asm/arch/clk.h is not available on RISC-V port so include it only for non-RISC-V systems. 2. Don't fail in macb_enable_clk() if clk_enable() returns -ENOSYS because we get -ENOSYS for fixed-rate clocks. Signed-off-by: Anup Patel Reviewed-by: Bin Meng --- drivers/net/macb.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/net/macb.c b/drivers/net/macb.c index 94c89c762b..9a06b523cc 100644 --- a/drivers/net/macb.c +++ b/drivers/net/macb.c @@ -38,7 +38,9 @@ #include #include #include +#ifndef CONFIG_RISCV #include +#endif #include #include "macb.h" @@ -1066,7 +1068,7 @@ static int macb_enable_clk(struct udevice *dev) */ #ifndef CONFIG_MACB_ZYNQ ret = clk_enable(&clk); - if (ret) + if (ret && ret != -ENOSYS) return ret; #endif From patchwork Fri Jan 18 11:19:06 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anup Patel X-Patchwork-Id: 1027220 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=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=wdc.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=wdc.com header.i=@wdc.com header.b="c0i0gNip"; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=sharedspace.onmicrosoft.com header.i=@sharedspace.onmicrosoft.com header.b="enMLvmYp"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 43gz8P0XjHz9sBQ for ; Fri, 18 Jan 2019 22:23:16 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id 90AD0C21E96; Fri, 18 Jan 2019 11:20:25 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=KHOP_BIG_TO_CC, T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id A02BEC220DC; Fri, 18 Jan 2019 11:19:40 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 114F9C220C4; Fri, 18 Jan 2019 11:19:13 +0000 (UTC) Received: from esa5.hgst.iphmx.com (esa5.hgst.iphmx.com [216.71.153.144]) by lists.denx.de (Postfix) with ESMTPS id 5C414C220C2 for ; Fri, 18 Jan 2019 11:19:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1547810350; x=1579346350; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=6/o6AaOOpmmh6o5vo6F9ErYWOOdcK+2MvdcsNVXvHlk=; b=c0i0gNip8NyT0dKpd3B36+jgd5OK4KbN5+15/1gH9bGdYzCMHuakOdTQ m2U/ZqXhlHvtF3bztGQMCHwTLFELCz8KWrdiDs272gzSbmvr+TJzZvQJI TRdeTiz+HcI3cwWPkhcOfI0DF08mGRjAzk7ZdQD7DO7oV6iaUqjJgbRB5 8xFfj3vIBT1aiFL1+Q9Dbq6xkgPfnmwdJPN6Zk3UL/VbVrkkkhbyrqNLW bswwS9iP16UaU8q1Mmrqxk7MPPGVJXU1Iu9034HP9yNjduwpOOXlpyQne D2pkhaEUcf7cVvxOnnuadnW4km0Bpm9WKJl0K1iDqW0mD+i+IJBSaq1FH g==; X-IronPort-AV: E=Sophos;i="5.56,491,1539619200"; d="scan'208";a="100370986" Received: from mail-dm3nam03lp2055.outbound.protection.outlook.com (HELO NAM03-DM3-obe.outbound.protection.outlook.com) ([104.47.41.55]) by ob1.hgst.iphmx.com with ESMTP; 18 Jan 2019 19:19:08 +0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sharedspace.onmicrosoft.com; s=selector1-wdc-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=7H4/zESXtrRQT142Dcku1S+qsbm62gQJ9Ct9rLQpHbA=; b=enMLvmYpuogV4DczgY517Xfzl5QjIDijDntW7FBFF2EUoU3dUMkLLwqvG4XAeFFsbFDVUUiIosK5BKHdmBQIhN9KdPCoyzFGDZGsBVVJtT/GfqnV7T+Byuxb0ZKsbDdaP6a5coF1j3UHykgE28TYFFhlN961M8O7wmZxuVNCQzA= Received: from BYAPR04MB5303.namprd04.prod.outlook.com (20.178.49.148) by BYAPR04MB5016.namprd04.prod.outlook.com (52.135.235.10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1537.24; Fri, 18 Jan 2019 11:19:07 +0000 Received: from BYAPR04MB5303.namprd04.prod.outlook.com ([fe80::add1:92cc:65d7:5d94]) by BYAPR04MB5303.namprd04.prod.outlook.com ([fe80::add1:92cc:65d7:5d94%2]) with mapi id 15.20.1537.018; Fri, 18 Jan 2019 11:19:07 +0000 From: Anup Patel To: Rick Chen , Bin Meng , Joe Hershberger , Lukas Auer , Masahiro Yamada , Simon Glass Thread-Topic: [PATCH v2 05/11] net: macb: Fix GEM hardware detection Thread-Index: AQHUrx+gzi7qTJ7/tE2FZwU5yM32JQ== Date: Fri, 18 Jan 2019 11:19:06 +0000 Message-ID: <20190118111820.71349-6-anup.patel@wdc.com> References: <20190118111820.71349-1-anup.patel@wdc.com> In-Reply-To: <20190118111820.71349-1-anup.patel@wdc.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: MA1PR01CA0115.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a00:1::31) To BYAPR04MB5303.namprd04.prod.outlook.com (2603:10b6:a03:c8::20) authentication-results: spf=none (sender IP is ) smtp.mailfrom=Anup.Patel@wdc.com; x-ms-exchange-messagesentrepresentingtype: 1 x-mailer: git-send-email 2.17.1 x-originating-ip: [49.207.48.211] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; BYAPR04MB5016; 6:fHWlAPnENlbW9TvNfO4ASEZ16PR+3dvm99yh65PWrar7eRWqJh/gCK0QeiPLAsGSLU6hfYMQIRMjwk5JPaRyG5o1g0aXavCtbZi5SQs/q1sLIzWhy4ZQRoeDn5Z+ItP+BdtCqbFDz5J8jxqJcv2kHF6i+s/jQI1KWr7HrVlTkS1T3a1IHeKCZZ02OzL6g+F8qt/jieeLHB8Kho4/7tK4MZEgP+3XGZSNGVP+L/9UH/zu5I7qjGK2Fr6IiuaffbkGpln7B28QJKPbhV+C7gl6+CPUdcxyGXYKu2rq4m8J3vsKjo0Kn0Cib8ajZ7jvUON6rs7K2AcwJ6kCGYLos5cWYCrNeHIWOCwyAyjSkOYuek4FQ3nyIhHD70DFW9qI2uFnYqQNcPp+IBygLwfltwd0yNrpKor3qk0Hte+yEdXcTwX6MTGzCXtoBPSyLtTDzG4VFidbwA6Bhx067OXsuLX+0w==; 5:dC3aBCy1ubgp9wdMsk5IXnMexwRVpCMOUnvL9ggmQdLOiY+1c40n3TZBojF76AmSSPIM4Kac4J/fIwPNujt2IvS5UFyl3jrRbuW7WWEqnD2csKYtyjro4hU34qbe54N0Ln1clPe+C+1cMpy+PvJ625cBYyvDTQCXqeXLKHAechW7GMzCs9P6YleBoNGD+PUDoKg6E1OpNadW0sOzefVmmA==; 7:ARl+VfDa96k6ZuxMQNNeeV68m3Eigt4+77nHQoUbcbv5QkbPXp5OT6nhKdzEJVy6hk411Q7z09mlfDrjTOl6lNuLPh0GBosZmcHehz7gWbM4+1Dw9WFCFmky2/44vKtLq/18wSAOFDWoTacdnZFltQ== x-ms-office365-filtering-correlation-id: a2fda9e3-a373-47c5-9d0e-08d67d36c2a0 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(7168020)(4627221)(201703031133081)(201702281549075)(8990200)(5600109)(711020)(4618075)(2017052603328)(7153060)(7193020); SRVR:BYAPR04MB5016; x-ms-traffictypediagnostic: BYAPR04MB5016: wdcipoutbound: EOP-TRUE x-microsoft-antispam-prvs: x-forefront-prvs: 0921D55E4F x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(39860400002)(136003)(346002)(366004)(376002)(396003)(189003)(199004)(81156014)(81166006)(2906002)(14454004)(8676002)(36756003)(4326008)(39060400002)(305945005)(68736007)(478600001)(7736002)(8936002)(14444005)(50226002)(97736004)(256004)(2616005)(486006)(476003)(4744005)(25786009)(72206003)(105586002)(106356001)(6436002)(6486002)(6512007)(44832011)(1076003)(110136005)(54906003)(6116002)(3846002)(71190400001)(386003)(11346002)(316002)(71200400001)(102836004)(6506007)(55236004)(26005)(186003)(53936002)(446003)(86362001)(7416002)(52116002)(5660300001)(76176011)(99286004)(66066001); DIR:OUT; SFP:1102; SCL:1; SRVR:BYAPR04MB5016; H:BYAPR04MB5303.namprd04.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: BljmLjUUhfPkQ9jPALoxy9gB3kxqkosg3cjM4xf/LQw03LZ2g6Tbum41ovlX0uHS+PAyN2Rhgh1tpKZeakgLqNn5JcEBSgJMublcB7uqw3aRaB5NH5LUzSQQaR7DUuQjJRW5rpRLCW1tF4Az4Zaj/A/yGMz/qgV4RgzmI8XecOKovxV8YQ5Z2NyEe9qGak+AWNX/YnZmmmcOEHLAheKUKMXjeyoD1i66oQOtN1jhVB9HyiRYyUUgt3IHkHG2pq2lE6MMcKUZzyvgEtrur5HSAIyh83HHhaoQAA6Ez+XN/JKXZmwpWPQGkAOVIc14ijuP2phq+M+6Bwtp5JyIRSR/fcVcR/r7nZnHPZIDH8Ei4lxktFB7XdFZylxu/Vw4ftABKGy9u4z2URI27OkglFLHXjJjRHUC1nBcsw8udfywRDY= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: wdc.com X-MS-Exchange-CrossTenant-Network-Message-Id: a2fda9e3-a373-47c5-9d0e-08d67d36c2a0 X-MS-Exchange-CrossTenant-originalarrivaltime: 18 Jan 2019 11:19:03.4015 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: b61c8803-16f3-4c35-9b17-6f65f441df86 X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR04MB5016 Cc: Palmer Dabbelt , U-Boot Mailing List , Alexander Graf , Christoph Hellwig , Paul Walmsley Subject: [U-Boot] [PATCH v2 05/11] net: macb: Fix GEM hardware detection X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 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" From: Atish Patra Fix MID bit field check to correctly identify all GEM hardwares. The check is updated as per macb driver in Linux location: /drivers/net/ethernet/cadence/macb_main.c:259 Signed-off-by: Atish Patra Reviewed-by: Alexander Graf Reviewed-by: Lukas Auer --- drivers/net/macb.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/macb.c b/drivers/net/macb.c index 9a06b523cc..e04ec9a0a3 100644 --- a/drivers/net/macb.c +++ b/drivers/net/macb.c @@ -145,7 +145,7 @@ struct macb_device { static int macb_is_gem(struct macb_device *macb) { - return MACB_BFEXT(IDNUM, macb_readl(macb, MID)) == 0x2; + return MACB_BFEXT(IDNUM, macb_readl(macb, MID)) >= 0x2; } #ifndef cpu_is_sama5d2 From patchwork Fri Jan 18 11:19:11 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anup Patel X-Patchwork-Id: 1027223 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=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=wdc.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=wdc.com header.i=@wdc.com header.b="rbJ1Tb14"; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=sharedspace.onmicrosoft.com header.i=@sharedspace.onmicrosoft.com header.b="g49Q8iyk"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 43gz9q0Rmvz9sBQ for ; Fri, 18 Jan 2019 22:24:30 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id B4845C22095; Fri, 18 Jan 2019 11:21:07 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=KHOP_BIG_TO_CC, T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 8FA31C220AE; Fri, 18 Jan 2019 11:19:58 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id B357BC220AE; Fri, 18 Jan 2019 11:19:21 +0000 (UTC) Received: from esa1.hgst.iphmx.com (esa1.hgst.iphmx.com [68.232.141.245]) by lists.denx.de (Postfix) with ESMTPS id BF84CC21D8E for ; Fri, 18 Jan 2019 11:19:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1547810356; x=1579346356; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=sIj3Fya5Rj1RYeKWtESlttf+kPTBA712F90rUx9dopo=; b=rbJ1Tb14lrtXc2DYX/ZbTqJl1bHcTthEW5IyaGrZwXcdzt6C79tR14o3 s0pWyRNkKWSeR271p6vNYuvKz5dp1IYt6fImS0Vi5C6OQWJUo7BxmPdIF cXpWDA1T9fQ8ajrNbAdfRD6G+B4B3oiO8Dnfkhcn0/D46b7DwzBzvpPHV Pd9x2zvtUriydjlTAWAVma74JdMUfZDdC654ZtnNXAj17clxz80jlS9zE iUBeTYf+dn/SsUn4+hKTgkaldIBzb0UeqPV9wZInHgaleOvaW/jGumuEB YkyW/Sv63T3O2ZPjBhShMhM6m3Q66u2dcyQzKxpLoUCrnoW2HLPT2wC6C Q==; X-IronPort-AV: E=Sophos;i="5.56,491,1539619200"; d="scan'208";a="204130023" Received: from mail-dm3nam03lp2052.outbound.protection.outlook.com (HELO NAM03-DM3-obe.outbound.protection.outlook.com) ([104.47.41.52]) by ob1.hgst.iphmx.com with ESMTP; 18 Jan 2019 19:19:13 +0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sharedspace.onmicrosoft.com; s=selector1-wdc-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=/8FC7tvVBRLXtyqUCU/0/kHfnTOev7e8VqOXyY0zmOc=; b=g49Q8iykXLVhFV4YdOqAUDpu+TJW4sqoRIEPvIExxF9Ch6EXVUiY/1+CHdSK+274YKbN37uWOSaNVfWBgYnqpiiPwgVYmlXnz4B4JOJ3Zwxtih49MiNy+SNt3LaCluSXjajJfjulZR2RjzwAYIfqwylX8qvd8J87Lx0YtiUZzKA= Received: from BYAPR04MB5303.namprd04.prod.outlook.com (20.178.49.148) by BYAPR04MB5016.namprd04.prod.outlook.com (52.135.235.10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1537.24; Fri, 18 Jan 2019 11:19:11 +0000 Received: from BYAPR04MB5303.namprd04.prod.outlook.com ([fe80::add1:92cc:65d7:5d94]) by BYAPR04MB5303.namprd04.prod.outlook.com ([fe80::add1:92cc:65d7:5d94%2]) with mapi id 15.20.1537.018; Fri, 18 Jan 2019 11:19:11 +0000 From: Anup Patel To: Rick Chen , Bin Meng , Joe Hershberger , Lukas Auer , Masahiro Yamada , Simon Glass Thread-Topic: [PATCH v2 06/11] clk: Add SiFive FU540 PRCI clock driver Thread-Index: AQHUrx+j6n2g5C/inU+qBbJrKvReUQ== Date: Fri, 18 Jan 2019 11:19:11 +0000 Message-ID: <20190118111820.71349-7-anup.patel@wdc.com> References: <20190118111820.71349-1-anup.patel@wdc.com> In-Reply-To: <20190118111820.71349-1-anup.patel@wdc.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: MA1PR01CA0115.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a00:1::31) To BYAPR04MB5303.namprd04.prod.outlook.com (2603:10b6:a03:c8::20) authentication-results: spf=none (sender IP is ) smtp.mailfrom=Anup.Patel@wdc.com; x-ms-exchange-messagesentrepresentingtype: 1 x-mailer: git-send-email 2.17.1 x-originating-ip: [49.207.48.211] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; BYAPR04MB5016; 6:aUKlmFPxXpNOeY/QCtfBa2LNcfcRgOZYzBh3vOfNliaZ6/t5oB/KxuuzoH1+U8oLvkUUWvUnZk6LSX18yoWi6eUSWOI7SnE5JwnkgOdNx6e1M+p3iz6DFVqVS9GF4X036lmE1SKRj+HDOFtYaDy2E4ZVikIeTWsknt+QCx4wfeTvskvrlfwEHTrCF0Oxdj4wHtUzT0B/r5Y0dvbNlU1sKMFi9F649Bo+Lnaz2TH5Mb6IdBmYirx2m0MvmTixGeCjS06OcSvf1MPYEe/ITFn5ThEGvJ98EbmKEeWGzNIjt5XJ8i8b5XpV6hGc8USRiWTBiDl1jRu4B5kFGQpqbSVsD2XzYLUGChKXIgMBB7x8ktLyO05mP55SCVB8vFwRI+1EqXqvcXsA/YQ9hIxtrg7S8AMsXcoY0GJeEq/MxMMFgHYzZyHQKnlDX59Gk4H3U7q6Vi4AKrYwFwU3M2UrFzFSdg==; 5:sNaf536cM44IsR5frkHWEgkZd7hCVB6aE2sHINCE9rUAF4ku/1gv+4uhQ0LjntdIvuWAqC4Q39xyENKtw0NSTZQf7bKeP1ZJKF5spSi4D3SbFx/V7KV9iCP0o1jQwLdO8C0JDOv4+s99BBs59vc/AbMDEm5aMNrJZAzBQ82Kx6yW0TIwQNwBA7B/8fFwQxt9AKpIQBjR1GXlqnZoSpQAEg==; 7:zCnVSAWH95/LZZ92BcZjHE1tEJs8wMgW0lTN12Jvn620g4Xm9DnFlCHPGLmYykA18jQJqW6JWmX7zQt5FA6yhMOlMHpDx57Q0nVujGzz3iAl9jiQ+m1VIb28mHLTS6kOAJeSLSYZKqO+ERsdDBOd4A== x-ms-office365-filtering-correlation-id: 3948eb2d-b29c-4d86-3fe3-08d67d36c56e x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(7168020)(4627221)(201703031133081)(201702281549075)(8990200)(5600109)(711020)(4618075)(2017052603328)(7153060)(7193020); SRVR:BYAPR04MB5016; x-ms-traffictypediagnostic: BYAPR04MB5016: wdcipoutbound: EOP-TRUE x-microsoft-antispam-prvs: x-forefront-prvs: 0921D55E4F x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(6029001)(39860400002)(136003)(346002)(366004)(376002)(396003)(189003)(199004)(81156014)(81166006)(2906002)(14454004)(8676002)(36756003)(4326008)(39060400002)(305945005)(68736007)(478600001)(7736002)(8936002)(14444005)(50226002)(97736004)(256004)(2616005)(486006)(476003)(30864003)(25786009)(72206003)(105586002)(106356001)(6436002)(6486002)(966005)(6512007)(6306002)(44832011)(1076003)(110136005)(54906003)(6116002)(3846002)(71190400001)(386003)(11346002)(316002)(71200400001)(102836004)(53946003)(6506007)(55236004)(26005)(186003)(53936002)(446003)(86362001)(7416002)(52116002)(5660300001)(76176011)(99286004)(66066001)(2004002)(579004)(559001)(569006); DIR:OUT; SFP:1102; SCL:1; SRVR:BYAPR04MB5016; H:BYAPR04MB5303.namprd04.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: 3OwhIP2cakyUtmIeDpPF6NPF80nmGc6rYeDbyAnRyLI1tujXWY/ADkmUsgsRBykf079oMKZP1xGwvqS8rfrZnxA0My5+ob1t7+JlveUhctzG7iCnuwLjXkTK9HbU4Wj050GMgpMxWUmu9F3gRlCUrKWFhK29licV8HzUxLb30BostNQ9ILxy88K2johfhfTtBSfC6COsrPWJ77z/lakd7NG3e0m+vkWadAY/kKqSN4DmpeZBxymYBncQZAm6KW1r31GfvTTx72yXA50FtNHOASEuK1h+ld9fI2MvlTzOUVF+4/iV1X7YAENXrxi+4LJq7YmUoVpR2oi59Cs1sEfjMzU3I/BbbNaJOcrj3wZ2JsPBpxoHqC2v4OAzuswV+Utp5prP+Vkn4zfUSC7PzGymR83GR7mnOxtYB5nD7lV88TE= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: wdc.com X-MS-Exchange-CrossTenant-Network-Message-Id: 3948eb2d-b29c-4d86-3fe3-08d67d36c56e X-MS-Exchange-CrossTenant-originalarrivaltime: 18 Jan 2019 11:19:08.1046 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: b61c8803-16f3-4c35-9b17-6f65f441df86 X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR04MB5016 Cc: Palmer Dabbelt , U-Boot Mailing List , Alexander Graf , Christoph Hellwig , Paul Walmsley Subject: [U-Boot] [PATCH v2 06/11] clk: Add SiFive FU540 PRCI clock driver X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 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" Add driver code for the SiFive FU540 PRCI IP block. This IP block handles reset and clock control for the SiFive FU540 device and implements SoC-level clock tree controls and dividers. Based on code written by Wesley Terpstra found in commit 999529edf517ed75b56659d456d221b2ee56bb60 of: https://github.com/riscv/riscv-linux Boot and PLL rate change were tested on a SiFive HiFive Unleashed board. Signed-off-by: Paul Walmsley Signed-off-by: Atish Patra Signed-off-by: Anup Patel Reviewed-by: Alexander Graf --- drivers/clk/Kconfig | 1 + drivers/clk/Makefile | 1 + drivers/clk/sifive/Kconfig | 19 + drivers/clk/sifive/Makefile | 5 + .../clk/sifive/analogbits-wrpll-cln28hpc.h | 101 +++ drivers/clk/sifive/fu540-prci.c | 604 ++++++++++++++++++ drivers/clk/sifive/wrpll-cln28hpc.c | 390 +++++++++++ include/dt-bindings/clk/sifive-fu540-prci.h | 29 + 8 files changed, 1150 insertions(+) create mode 100644 drivers/clk/sifive/Kconfig create mode 100644 drivers/clk/sifive/Makefile create mode 100644 drivers/clk/sifive/analogbits-wrpll-cln28hpc.h create mode 100644 drivers/clk/sifive/fu540-prci.c create mode 100644 drivers/clk/sifive/wrpll-cln28hpc.c create mode 100644 include/dt-bindings/clk/sifive-fu540-prci.h diff --git a/drivers/clk/Kconfig b/drivers/clk/Kconfig index eadf7f8250..ce462f5717 100644 --- a/drivers/clk/Kconfig +++ b/drivers/clk/Kconfig @@ -104,6 +104,7 @@ source "drivers/clk/imx/Kconfig" source "drivers/clk/mvebu/Kconfig" source "drivers/clk/owl/Kconfig" source "drivers/clk/renesas/Kconfig" +source "drivers/clk/sifive/Kconfig" source "drivers/clk/tegra/Kconfig" source "drivers/clk/uniphier/Kconfig" diff --git a/drivers/clk/Makefile b/drivers/clk/Makefile index 9acbb1a650..2f4446568c 100644 --- a/drivers/clk/Makefile +++ b/drivers/clk/Makefile @@ -22,6 +22,7 @@ obj-$(CONFIG_CLK_HSDK) += clk-hsdk-cgu.o obj-$(CONFIG_CLK_MPC83XX) += mpc83xx_clk.o obj-$(CONFIG_CLK_OWL) += owl/ obj-$(CONFIG_CLK_RENESAS) += renesas/ +obj-$(CONFIG_CLK_SIFIVE) += sifive/ obj-$(CONFIG_CLK_STM32F) += clk_stm32f.o obj-$(CONFIG_CLK_STM32MP1) += clk_stm32mp1.o obj-$(CONFIG_CLK_UNIPHIER) += uniphier/ diff --git a/drivers/clk/sifive/Kconfig b/drivers/clk/sifive/Kconfig new file mode 100644 index 0000000000..81fc9f8fda --- /dev/null +++ b/drivers/clk/sifive/Kconfig @@ -0,0 +1,19 @@ +# SPDX-License-Identifier: GPL-2.0 + +config CLK_ANALOGBITS_WRPLL_CLN28HPC + bool + +config CLK_SIFIVE + bool "SiFive SoC driver support" + depends on CLK + help + SoC drivers for SiFive Linux-capable SoCs. + +config CLK_SIFIVE_FU540_PRCI + bool "PRCI driver for SiFive FU540 SoCs" + depends on CLK_SIFIVE + select CLK_ANALOGBITS_WRPLL_CLN28HPC + help + Supports the Power Reset Clock interface (PRCI) IP block found in + FU540 SoCs. If this kernel is meant to run on a SiFive FU540 SoC, + enable this driver. diff --git a/drivers/clk/sifive/Makefile b/drivers/clk/sifive/Makefile new file mode 100644 index 0000000000..1155e07e37 --- /dev/null +++ b/drivers/clk/sifive/Makefile @@ -0,0 +1,5 @@ +# SPDX-License-Identifier: GPL-2.0+ + +obj-$(CONFIG_CLK_ANALOGBITS_WRPLL_CLN28HPC) += wrpll-cln28hpc.o + +obj-$(CONFIG_CLK_SIFIVE_FU540_PRCI) += fu540-prci.o diff --git a/drivers/clk/sifive/analogbits-wrpll-cln28hpc.h b/drivers/clk/sifive/analogbits-wrpll-cln28hpc.h new file mode 100644 index 0000000000..4432e24749 --- /dev/null +++ b/drivers/clk/sifive/analogbits-wrpll-cln28hpc.h @@ -0,0 +1,101 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * Copyright (c) 2019 Western Digital Corporation or its affiliates. + * + * Copyright (C) 2018 SiFive, Inc. + * Wesley Terpstra + * Paul Walmsley + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + */ + +#ifndef __LINUX_CLK_ANALOGBITS_WRPLL_CLN28HPC_H +#define __LINUX_CLK_ANALOGBITS_WRPLL_CLN28HPC_H + +#include + +/* DIVQ_VALUES: number of valid DIVQ values */ +#define DIVQ_VALUES 6 + +/* + * Bit definitions for struct analogbits_wrpll_cfg.flags + * + * WRPLL_FLAGS_BYPASS_FLAG: if set, the PLL is either in bypass, or should be + * programmed to enter bypass + * WRPLL_FLAGS_RESET_FLAG: if set, the PLL is in reset + * WRPLL_FLAGS_INT_FEEDBACK_FLAG: if set, the PLL is configured for internal + * feedback mode + * WRPLL_FLAGS_EXT_FEEDBACK_FLAG: if set, the PLL is configured for external + * feedback mode (not yet supported by this driver) + * + * The flags WRPLL_FLAGS_INT_FEEDBACK_FLAG and WRPLL_FLAGS_EXT_FEEDBACK_FLAG are + * mutually exclusive. If both bits are set, or both are zero, the struct + * analogbits_wrpll_cfg record is uninitialized or corrupt. + */ +#define WRPLL_FLAGS_BYPASS_SHIFT 0 +#define WRPLL_FLAGS_BYPASS_MASK BIT(WRPLL_FLAGS_BYPASS_SHIFT) +#define WRPLL_FLAGS_RESET_SHIFT 1 +#define WRPLL_FLAGS_RESET_MASK BIT(WRPLL_FLAGS_RESET_SHIFT) +#define WRPLL_FLAGS_INT_FEEDBACK_SHIFT 2 +#define WRPLL_FLAGS_INT_FEEDBACK_MASK BIT(WRPLL_FLAGS_INT_FEEDBACK_SHIFT) +#define WRPLL_FLAGS_EXT_FEEDBACK_SHIFT 3 +#define WRPLL_FLAGS_EXT_FEEDBACK_MASK BIT(WRPLL_FLAGS_EXT_FEEDBACK_SHIFT) + +/** + * struct analogbits_wrpll_cfg - WRPLL configuration values + * @divr: reference divider value (6 bits), as presented to the PLL signals. + * @divf: feedback divider value (9 bits), as presented to the PLL signals. + * @divq: output divider value (3 bits), as presented to the PLL signals. + * @flags: PLL configuration flags. See above for more information. + * @range: PLL loop filter range. See below for more information. + * @_output_rate_cache: cached output rates, swept across DIVQ. + * @_parent_rate: PLL refclk rate for which values are valid + * @_max_r: maximum possible R divider value, given @parent_rate + * @_init_r: initial R divider value to start the search from + * + * @divr, @divq, @divq, @range represent what the PLL expects to see + * on its input signals. Thus @divr and @divf are the actual divisors + * minus one. @divq is a power-of-two divider; for example, 1 = + * divide-by-2 and 6 = divide-by-64. 0 is an invalid @divq value. + * + * When initially passing a struct analogbits_wrpll_cfg record, the + * record should be zero-initialized with the exception of the @flags + * field. The only flag bits that need to be set are either + * WRPLL_FLAGS_INT_FEEDBACK or WRPLL_FLAGS_EXT_FEEDBACK. + * + * Field names beginning with an underscore should be considered + * private to the wrpll-cln28hpc.c code. + */ +struct analogbits_wrpll_cfg { + u8 divr; + u8 divq; + u8 range; + u8 flags; + u16 divf; + u32 _output_rate_cache[DIVQ_VALUES]; + unsigned long _parent_rate; + u8 _max_r; + u8 _init_r; +}; + +/* + * Function prototypes + */ + +int analogbits_wrpll_configure_for_rate(struct analogbits_wrpll_cfg *c, + u32 target_rate, + unsigned long parent_rate); + +unsigned int analogbits_wrpll_calc_max_lock_us(struct analogbits_wrpll_cfg *c); + +unsigned long analogbits_wrpll_calc_output_rate(struct analogbits_wrpll_cfg *c, + unsigned long parent_rate); + +#endif /* __LINUX_CLK_ANALOGBITS_WRPLL_CLN28HPC_H */ diff --git a/drivers/clk/sifive/fu540-prci.c b/drivers/clk/sifive/fu540-prci.c new file mode 100644 index 0000000000..e1b5f8e6a9 --- /dev/null +++ b/drivers/clk/sifive/fu540-prci.c @@ -0,0 +1,604 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright (c) 2019 Western Digital Corporation or its affiliates. + * + * Copyright (C) 2018 SiFive, Inc. + * Wesley Terpstra + * Paul Walmsley + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * The FU540 PRCI implements clock and reset control for the SiFive + * FU540-C000 chip. This driver assumes that it has sole control + * over all PRCI resources. + * + * This driver is based on the PRCI driver written by Wesley Terpstra. + * + * Refer, commit 999529edf517ed75b56659d456d221b2ee56bb60 of: + * https://github.com/riscv/riscv-linux + * + * References: + * - SiFive FU540-C000 manual v1p0, Chapter 7 "Clocking and Reset" + */ + +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#include "analogbits-wrpll-cln28hpc.h" + +/* + * EXPECTED_CLK_PARENT_COUNT: how many parent clocks this driver expects: + * hfclk and rtcclk + */ +#define EXPECTED_CLK_PARENT_COUNT 2 + +/* + * Register offsets and bitmasks + */ + +/* COREPLLCFG0 */ +#define PRCI_COREPLLCFG0_OFFSET 0x4 +#define PRCI_COREPLLCFG0_DIVR_SHIFT 0 +#define PRCI_COREPLLCFG0_DIVR_MASK (0x3f << PRCI_COREPLLCFG0_DIVR_SHIFT) +#define PRCI_COREPLLCFG0_DIVF_SHIFT 6 +#define PRCI_COREPLLCFG0_DIVF_MASK (0x1ff << PRCI_COREPLLCFG0_DIVF_SHIFT) +#define PRCI_COREPLLCFG0_DIVQ_SHIFT 15 +#define PRCI_COREPLLCFG0_DIVQ_MASK (0x7 << PRCI_COREPLLCFG0_DIVQ_SHIFT) +#define PRCI_COREPLLCFG0_RANGE_SHIFT 18 +#define PRCI_COREPLLCFG0_RANGE_MASK (0x7 << PRCI_COREPLLCFG0_RANGE_SHIFT) +#define PRCI_COREPLLCFG0_BYPASS_SHIFT 24 +#define PRCI_COREPLLCFG0_BYPASS_MASK (0x1 << PRCI_COREPLLCFG0_BYPASS_SHIFT) +#define PRCI_COREPLLCFG0_FSE_SHIFT 25 +#define PRCI_COREPLLCFG0_FSE_MASK (0x1 << PRCI_COREPLLCFG0_FSE_SHIFT) +#define PRCI_COREPLLCFG0_LOCK_SHIFT 31 +#define PRCI_COREPLLCFG0_LOCK_MASK (0x1 << PRCI_COREPLLCFG0_LOCK_SHIFT) + +/* DDRPLLCFG0 */ +#define PRCI_DDRPLLCFG0_OFFSET 0xc +#define PRCI_DDRPLLCFG0_DIVR_SHIFT 0 +#define PRCI_DDRPLLCFG0_DIVR_MASK (0x3f << PRCI_DDRPLLCFG0_DIVR_SHIFT) +#define PRCI_DDRPLLCFG0_DIVF_SHIFT 6 +#define PRCI_DDRPLLCFG0_DIVF_MASK (0x1ff << PRCI_DDRPLLCFG0_DIVF_SHIFT) +#define PRCI_DDRPLLCFG0_DIVQ_SHIFT 15 +#define PRCI_DDRPLLCFG0_DIVQ_MASK (0x7 << PRCI_DDRPLLCFG0_DIVQ_SHIFT) +#define PRCI_DDRPLLCFG0_RANGE_SHIFT 18 +#define PRCI_DDRPLLCFG0_RANGE_MASK (0x7 << PRCI_DDRPLLCFG0_RANGE_SHIFT) +#define PRCI_DDRPLLCFG0_BYPASS_SHIFT 24 +#define PRCI_DDRPLLCFG0_BYPASS_MASK (0x1 << PRCI_DDRPLLCFG0_BYPASS_SHIFT) +#define PRCI_DDRPLLCFG0_FSE_SHIFT 25 +#define PRCI_DDRPLLCFG0_FSE_MASK (0x1 << PRCI_DDRPLLCFG0_FSE_SHIFT) +#define PRCI_DDRPLLCFG0_LOCK_SHIFT 31 +#define PRCI_DDRPLLCFG0_LOCK_MASK (0x1 << PRCI_DDRPLLCFG0_LOCK_SHIFT) + +/* DDRPLLCFG1 */ +#define PRCI_DDRPLLCFG1_OFFSET 0x10 +#define PRCI_DDRPLLCFG1_CKE_SHIFT 24 +#define PRCI_DDRPLLCFG1_CKE_MASK (0x1 << PRCI_DDRPLLCFG1_CKE_SHIFT) + +/* GEMGXLPLLCFG0 */ +#define PRCI_GEMGXLPLLCFG0_OFFSET 0x1c +#define PRCI_GEMGXLPLLCFG0_DIVR_SHIFT 0 +#define PRCI_GEMGXLPLLCFG0_DIVR_MASK \ + (0x3f << PRCI_GEMGXLPLLCFG0_DIVR_SHIFT) +#define PRCI_GEMGXLPLLCFG0_DIVF_SHIFT 6 +#define PRCI_GEMGXLPLLCFG0_DIVF_MASK \ + (0x1ff << PRCI_GEMGXLPLLCFG0_DIVF_SHIFT) +#define PRCI_GEMGXLPLLCFG0_DIVQ_SHIFT 15 +#define PRCI_GEMGXLPLLCFG0_DIVQ_MASK (0x7 << PRCI_GEMGXLPLLCFG0_DIVQ_SHIFT) +#define PRCI_GEMGXLPLLCFG0_RANGE_SHIFT 18 +#define PRCI_GEMGXLPLLCFG0_RANGE_MASK \ + (0x7 << PRCI_GEMGXLPLLCFG0_RANGE_SHIFT) +#define PRCI_GEMGXLPLLCFG0_BYPASS_SHIFT 24 +#define PRCI_GEMGXLPLLCFG0_BYPASS_MASK \ + (0x1 << PRCI_GEMGXLPLLCFG0_BYPASS_SHIFT) +#define PRCI_GEMGXLPLLCFG0_FSE_SHIFT 25 +#define PRCI_GEMGXLPLLCFG0_FSE_MASK \ + (0x1 << PRCI_GEMGXLPLLCFG0_FSE_SHIFT) +#define PRCI_GEMGXLPLLCFG0_LOCK_SHIFT 31 +#define PRCI_GEMGXLPLLCFG0_LOCK_MASK (0x1 << PRCI_GEMGXLPLLCFG0_LOCK_SHIFT) + +/* GEMGXLPLLCFG1 */ +#define PRCI_GEMGXLPLLCFG1_OFFSET 0x20 +#define PRCI_GEMGXLPLLCFG1_CKE_SHIFT 24 +#define PRCI_GEMGXLPLLCFG1_CKE_MASK (0x1 << PRCI_GEMGXLPLLCFG1_CKE_SHIFT) + +/* CORECLKSEL */ +#define PRCI_CORECLKSEL_OFFSET 0x24 +#define PRCI_CORECLKSEL_CORECLKSEL_SHIFT 0 +#define PRCI_CORECLKSEL_CORECLKSEL_MASK \ + (0x1 << PRCI_CORECLKSEL_CORECLKSEL_SHIFT) + +/* DEVICESRESETREG */ +#define PRCI_DEVICESRESETREG_OFFSET 0x28 +#define PRCI_DEVICESRESETREG_DDR_CTRL_RST_N_SHIFT 0 +#define PRCI_DEVICESRESETREG_DDR_CTRL_RST_N_MASK \ + (0x1 << PRCI_DEVICESRESETREG_DDR_CTRL_RST_N_SHIFT) +#define PRCI_DEVICESRESETREG_DDR_AXI_RST_N_SHIFT 1 +#define PRCI_DEVICESRESETREG_DDR_AXI_RST_N_MASK \ + (0x1 << PRCI_DEVICESRESETREG_DDR_AXI_RST_N_SHIFT) +#define PRCI_DEVICESRESETREG_DDR_AHB_RST_N_SHIFT 2 +#define PRCI_DEVICESRESETREG_DDR_AHB_RST_N_MASK \ + (0x1 << PRCI_DEVICESRESETREG_DDR_AHB_RST_N_SHIFT) +#define PRCI_DEVICESRESETREG_DDR_PHY_RST_N_SHIFT 3 +#define PRCI_DEVICESRESETREG_DDR_PHY_RST_N_MASK \ + (0x1 << PRCI_DEVICESRESETREG_DDR_PHY_RST_N_SHIFT) +#define PRCI_DEVICESRESETREG_GEMGXL_RST_N_SHIFT 5 +#define PRCI_DEVICESRESETREG_GEMGXL_RST_N_MASK \ + (0x1 << PRCI_DEVICESRESETREG_GEMGXL_RST_N_SHIFT) + +/* CLKMUXSTATUSREG */ +#define PRCI_CLKMUXSTATUSREG_OFFSET 0x2c +#define PRCI_CLKMUXSTATUSREG_TLCLKSEL_STATUS_SHIFT 1 +#define PRCI_CLKMUXSTATUSREG_TLCLKSEL_STATUS_MASK \ + (0x1 << PRCI_CLKMUXSTATUSREG_TLCLKSEL_STATUS_SHIFT) + +/* + * Private structures + */ + +/** + * struct __prci_data - per-device-instance data + * @va: base virtual address of the PRCI IP block + * @parent: parent clk instance + * + * PRCI per-device instance data + */ +struct __prci_data { + void *base; + struct clk parent; +}; + +/** + * struct __prci_wrpll_data - WRPLL configuration and integration data + * @c: WRPLL current configuration record + * @bypass: fn ptr to code to bypass the WRPLL (if applicable; else NULL) + * @no_bypass: fn ptr to code to not bypass the WRPLL (if applicable; else NULL) + * @cfg0_offs: WRPLL CFG0 register offset (in bytes) from the PRCI base address + * + * @bypass and @no_bypass are used for WRPLL instances that contain a separate + * external glitchless clock mux downstream from the PLL. The WRPLL internal + * bypass mux is not glitchless. + */ +struct __prci_wrpll_data { + struct analogbits_wrpll_cfg c; + void (*bypass)(struct __prci_data *pd); + void (*no_bypass)(struct __prci_data *pd); + u8 cfg0_offs; +}; + +struct __prci_clock; + +struct __prci_clock_ops { + int (*set_rate)(struct __prci_clock *pc, + unsigned long rate, + unsigned long parent_rate); + unsigned long (*round_rate)(struct __prci_clock *pc, + unsigned long rate, + unsigned long *parent_rate); + unsigned long (*recalc_rate)(struct __prci_clock *pc, + unsigned long parent_rate); +}; + +/** + * struct __prci_clock - describes a clock device managed by PRCI + * @name: user-readable clock name string - should match the manual + * @parent_name: parent name for this clock + * @ops: struct clk_ops for the Linux clock framework to use for control + * @hw: Linux-private clock data + * @pwd: WRPLL-specific data, associated with this clock (if not NULL) + * @pd: PRCI-specific data associated with this clock (if not NULL) + * + * PRCI clock data. Used by the PRCI driver to register PRCI-provided + * clocks to the Linux clock infrastructure. + */ +struct __prci_clock { + const char *name; + const char *parent_name; + const struct __prci_clock_ops *ops; + struct __prci_wrpll_data *pwd; + struct __prci_data *pd; +}; + +/* + * Private functions + */ + +/** + * __prci_readl() - read from a PRCI register + * @pd: PRCI context + * @offs: register offset to read from (in bytes, from PRCI base address) + * + * Read the register located at offset @offs from the base virtual + * address of the PRCI register target described by @pd, and return + * the value to the caller. + * + * Context: Any context. + * + * Return: the contents of the register described by @pd and @offs. + */ +static u32 __prci_readl(struct __prci_data *pd, u32 offs) +{ + return readl(pd->base + offs); +} + +static void __prci_writel(u32 v, u32 offs, struct __prci_data *pd) +{ + return writel(v, pd->base + offs); +} + +/* WRPLL-related private functions */ + +/** + * __prci_wrpll_unpack() - unpack WRPLL configuration registers into parameters + * @c: ptr to a struct analogbits_wrpll_cfg record to write config into + * @r: value read from the PRCI PLL configuration register + * + * Given a value @r read from an FU540 PRCI PLL configuration register, + * split it into fields and populate it into the WRPLL configuration record + * pointed to by @c. + * + * The COREPLLCFG0 macros are used below, but the other *PLLCFG0 macros + * have the same register layout. + * + * Context: Any context. + */ +static void __prci_wrpll_unpack(struct analogbits_wrpll_cfg *c, u32 r) +{ + u32 v; + + v = r & PRCI_COREPLLCFG0_DIVR_MASK; + v >>= PRCI_COREPLLCFG0_DIVR_SHIFT; + c->divr = v; + + v = r & PRCI_COREPLLCFG0_DIVF_MASK; + v >>= PRCI_COREPLLCFG0_DIVF_SHIFT; + c->divf = v; + + v = r & PRCI_COREPLLCFG0_DIVQ_MASK; + v >>= PRCI_COREPLLCFG0_DIVQ_SHIFT; + c->divq = v; + + v = r & PRCI_COREPLLCFG0_RANGE_MASK; + v >>= PRCI_COREPLLCFG0_RANGE_SHIFT; + c->range = v; + + c->flags &= (WRPLL_FLAGS_INT_FEEDBACK_MASK | + WRPLL_FLAGS_EXT_FEEDBACK_MASK); + + if (r & PRCI_COREPLLCFG0_FSE_MASK) + c->flags |= WRPLL_FLAGS_INT_FEEDBACK_MASK; + else + c->flags |= WRPLL_FLAGS_EXT_FEEDBACK_MASK; +} + +/** + * __prci_wrpll_pack() - pack PLL configuration parameters into a register value + * @c: pointer to a struct analogbits_wrpll_cfg record containing the PLL's cfg + * + * Using a set of WRPLL configuration values pointed to by @c, + * assemble a PRCI PLL configuration register value, and return it to + * the caller. + * + * Context: Any context. Caller must ensure that the contents of the + * record pointed to by @c do not change during the execution + * of this function. + * + * Returns: a value suitable for writing into a PRCI PLL configuration + * register + */ +static u32 __prci_wrpll_pack(struct analogbits_wrpll_cfg *c) +{ + u32 r = 0; + + r |= c->divr << PRCI_COREPLLCFG0_DIVR_SHIFT; + r |= c->divf << PRCI_COREPLLCFG0_DIVF_SHIFT; + r |= c->divq << PRCI_COREPLLCFG0_DIVQ_SHIFT; + r |= c->range << PRCI_COREPLLCFG0_RANGE_SHIFT; + if (c->flags & WRPLL_FLAGS_INT_FEEDBACK_MASK) + r |= PRCI_COREPLLCFG0_FSE_MASK; + + return r; +} + +/** + * __prci_wrpll_read_cfg() - read the WRPLL configuration from the PRCI + * @pd: PRCI context + * @pwd: PRCI WRPLL metadata + * + * Read the current configuration of the PLL identified by @pwd from + * the PRCI identified by @pd, and store it into the local configuration + * cache in @pwd. + * + * Context: Any context. Caller must prevent the records pointed to by + * @pd and @pwd from changing during execution. + */ +static void __prci_wrpll_read_cfg(struct __prci_data *pd, + struct __prci_wrpll_data *pwd) +{ + __prci_wrpll_unpack(&pwd->c, __prci_readl(pd, pwd->cfg0_offs)); +} + +/** + * __prci_wrpll_write_cfg() - write WRPLL configuration into the PRCI + * @pd: PRCI context + * @pwd: PRCI WRPLL metadata + * @c: WRPLL configuration record to write + * + * Write the WRPLL configuration described by @c into the WRPLL + * configuration register identified by @pwd in the PRCI instance + * described by @c. Make a cached copy of the WRPLL's current + * configuration so it can be used by other code. + * + * Context: Any context. Caller must prevent the records pointed to by + * @pd and @pwd from changing during execution. + */ +static void __prci_wrpll_write_cfg(struct __prci_data *pd, + struct __prci_wrpll_data *pwd, + struct analogbits_wrpll_cfg *c) +{ + __prci_writel(__prci_wrpll_pack(c), pwd->cfg0_offs, pd); + + memcpy(&pwd->c, c, sizeof(struct analogbits_wrpll_cfg)); +} + +/* Core clock mux control */ + +/** + * __prci_coreclksel_use_hfclk() - switch the CORECLK mux to output HFCLK + * @pd: struct __prci_data * for the PRCI containing the CORECLK mux reg + * + * Switch the CORECLK mux to the HFCLK input source; return once complete. + * + * Context: Any context. Caller must prevent concurrent changes to the + * PRCI_CORECLKSEL_OFFSET register. + */ +static void __prci_coreclksel_use_hfclk(struct __prci_data *pd) +{ + u32 r; + + r = __prci_readl(pd, PRCI_CORECLKSEL_OFFSET); + r |= PRCI_CORECLKSEL_CORECLKSEL_MASK; + __prci_writel(r, PRCI_CORECLKSEL_OFFSET, pd); + + r = __prci_readl(pd, PRCI_CORECLKSEL_OFFSET); /* barrier */ +} + +/** + * __prci_coreclksel_use_corepll() - switch the CORECLK mux to output COREPLL + * @pd: struct __prci_data * for the PRCI containing the CORECLK mux reg + * + * Switch the CORECLK mux to the PLL output clock; return once complete. + * + * Context: Any context. Caller must prevent concurrent changes to the + * PRCI_CORECLKSEL_OFFSET register. + */ +static void __prci_coreclksel_use_corepll(struct __prci_data *pd) +{ + u32 r; + + r = __prci_readl(pd, PRCI_CORECLKSEL_OFFSET); + r &= ~PRCI_CORECLKSEL_CORECLKSEL_MASK; + __prci_writel(r, PRCI_CORECLKSEL_OFFSET, pd); + + r = __prci_readl(pd, PRCI_CORECLKSEL_OFFSET); /* barrier */ +} + +static unsigned long sifive_fu540_prci_wrpll_recalc_rate( + struct __prci_clock *pc, + unsigned long parent_rate) +{ + struct __prci_wrpll_data *pwd = pc->pwd; + + return analogbits_wrpll_calc_output_rate(&pwd->c, parent_rate); +} + +static unsigned long sifive_fu540_prci_wrpll_round_rate( + struct __prci_clock *pc, + unsigned long rate, + unsigned long *parent_rate) +{ + struct __prci_wrpll_data *pwd = pc->pwd; + struct analogbits_wrpll_cfg c; + + memcpy(&c, &pwd->c, sizeof(c)); + + analogbits_wrpll_configure_for_rate(&c, rate, *parent_rate); + + return analogbits_wrpll_calc_output_rate(&c, *parent_rate); +} + +static int sifive_fu540_prci_wrpll_set_rate(struct __prci_clock *pc, + unsigned long rate, + unsigned long parent_rate) +{ + struct __prci_wrpll_data *pwd = pc->pwd; + struct __prci_data *pd = pc->pd; + int r; + + r = analogbits_wrpll_configure_for_rate(&pwd->c, rate, parent_rate); + if (r) + return -ERANGE; + + if (pwd->bypass) + pwd->bypass(pd); + + __prci_wrpll_write_cfg(pd, pwd, &pwd->c); + + udelay(analogbits_wrpll_calc_max_lock_us(&pwd->c)); + + if (pwd->no_bypass) + pwd->no_bypass(pd); + + return 0; +} + +static const struct __prci_clock_ops sifive_fu540_prci_wrpll_clk_ops = { + .set_rate = sifive_fu540_prci_wrpll_set_rate, + .round_rate = sifive_fu540_prci_wrpll_round_rate, + .recalc_rate = sifive_fu540_prci_wrpll_recalc_rate, +}; + +static const struct __prci_clock_ops sifive_fu540_prci_wrpll_ro_clk_ops = { + .recalc_rate = sifive_fu540_prci_wrpll_recalc_rate, +}; + +/* TLCLKSEL clock integration */ + +static unsigned long sifive_fu540_prci_tlclksel_recalc_rate( + struct __prci_clock *pc, + unsigned long parent_rate) +{ + struct __prci_data *pd = pc->pd; + u32 v; + u8 div; + + v = __prci_readl(pd, PRCI_CLKMUXSTATUSREG_OFFSET); + v &= PRCI_CLKMUXSTATUSREG_TLCLKSEL_STATUS_MASK; + div = v ? 1 : 2; + + return div_u64(parent_rate, div); +} + +static const struct __prci_clock_ops sifive_fu540_prci_tlclksel_clk_ops = { + .recalc_rate = sifive_fu540_prci_tlclksel_recalc_rate, +}; + +/* + * PRCI integration data for each WRPLL instance + */ + +static struct __prci_wrpll_data __prci_corepll_data = { + .cfg0_offs = PRCI_COREPLLCFG0_OFFSET, + .bypass = __prci_coreclksel_use_hfclk, + .no_bypass = __prci_coreclksel_use_corepll, +}; + +static struct __prci_wrpll_data __prci_ddrpll_data = { + .cfg0_offs = PRCI_DDRPLLCFG0_OFFSET, +}; + +static struct __prci_wrpll_data __prci_gemgxlpll_data = { + .cfg0_offs = PRCI_GEMGXLPLLCFG0_OFFSET, +}; + +/* + * List of clock controls provided by the PRCI + */ + +static struct __prci_clock __prci_init_clocks[] = { + [PRCI_CLK_COREPLL] = { + .name = "corepll", + .parent_name = "hfclk", + .ops = &sifive_fu540_prci_wrpll_clk_ops, + .pwd = &__prci_corepll_data, + }, + [PRCI_CLK_DDRPLL] = { + .name = "ddrpll", + .parent_name = "hfclk", + .ops = &sifive_fu540_prci_wrpll_ro_clk_ops, + .pwd = &__prci_ddrpll_data, + }, + [PRCI_CLK_GEMGXLPLL] = { + .name = "gemgxlpll", + .parent_name = "hfclk", + .ops = &sifive_fu540_prci_wrpll_clk_ops, + .pwd = &__prci_gemgxlpll_data, + }, + [PRCI_CLK_TLCLK] = { + .name = "tlclk", + .parent_name = "corepll", + .ops = &sifive_fu540_prci_tlclksel_clk_ops, + }, +}; + +static ulong sifive_fu540_prci_get_rate(struct clk *clk) +{ + struct __prci_clock *pc; + + if (ARRAY_SIZE(__prci_init_clocks) <= clk->id) + return -ENXIO; + + pc = &__prci_init_clocks[clk->id]; + if (!pc->pd || !pc->ops->recalc_rate) + return -ENXIO; + + return pc->ops->recalc_rate(pc, clk_get_rate(&pc->pd->parent)); +} + +static ulong sifive_fu540_prci_set_rate(struct clk *clk, ulong rate) +{ + int err; + struct __prci_clock *pc; + + if (ARRAY_SIZE(__prci_init_clocks) <= clk->id) + return -ENXIO; + + pc = &__prci_init_clocks[clk->id]; + if (!pc->pd || !pc->ops->set_rate) + return -ENXIO; + + err = pc->ops->set_rate(pc, rate, clk_get_rate(&pc->pd->parent)); + if (err) + return err; + + return rate; +} + +static int sifive_fu540_prci_probe(struct udevice *dev) +{ + int i, err; + struct __prci_clock *pc; + struct __prci_data *pd = dev_get_priv(dev); + + pd->base = (void *)dev_read_addr(dev); + if (IS_ERR(pd->base)) + return PTR_ERR(pd->base); + + err = clk_get_by_index(dev, 0, &pd->parent); + if (err) + return err; + + for (i = 0; i < ARRAY_SIZE(__prci_init_clocks); ++i) { + pc = &__prci_init_clocks[i]; + pc->pd = pd; + if (pc->pwd) + __prci_wrpll_read_cfg(pd, pc->pwd); + } + + return 0; +} + +static struct clk_ops sifive_fu540_prci_ops = { + .set_rate = sifive_fu540_prci_set_rate, + .get_rate = sifive_fu540_prci_get_rate, +}; + +static const struct udevice_id sifive_fu540_prci_ids[] = { + { .compatible = "sifive,fu540-c000-prci0" }, + { .compatible = "sifive,aloeprci0" }, + { } +}; + +U_BOOT_DRIVER(sifive_fu540_prci) = { + .name = "sifive-fu540-prci", + .id = UCLASS_CLK, + .of_match = sifive_fu540_prci_ids, + .probe = sifive_fu540_prci_probe, + .ops = &sifive_fu540_prci_ops, + .priv_auto_alloc_size = sizeof(struct __prci_data), +}; diff --git a/drivers/clk/sifive/wrpll-cln28hpc.c b/drivers/clk/sifive/wrpll-cln28hpc.c new file mode 100644 index 0000000000..d377849693 --- /dev/null +++ b/drivers/clk/sifive/wrpll-cln28hpc.c @@ -0,0 +1,390 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright (c) 2019 Western Digital Corporation or its affiliates. + * + * Copyright (C) 2018 SiFive, Inc. + * Wesley Terpstra + * Paul Walmsley + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * This library supports configuration parsing and reprogramming of + * the CLN28HPC variant of the Analog Bits Wide Range PLL. The + * intention is for this library to be reusable for any device that + * integrates this PLL; thus the register structure and programming + * details are expected to be provided by a separate IP block driver. + * + * The bulk of this code is primarily useful for clock configurations + * that must operate at arbitrary rates, as opposed to clock configurations + * that are restricted by software or manufacturer guidance to a small, + * pre-determined set of performance points. + * + * References: + * - Analog Bits "Wide Range PLL Datasheet", version 2015.10.01 + * - SiFive FU540-C000 Manual v1p0, Chapter 7 "Clocking and Reset" + */ + +#include +#include +#include +#include + +#include "analogbits-wrpll-cln28hpc.h" + +/* MIN_INPUT_FREQ: minimum input clock frequency, in Hz (Fref_min) */ +#define MIN_INPUT_FREQ 7000000 + +/* MAX_INPUT_FREQ: maximum input clock frequency, in Hz (Fref_max) */ +#define MAX_INPUT_FREQ 600000000 + +/* MIN_POST_DIVIDE_REF_FREQ: minimum post-divider reference frequency, in Hz */ +#define MIN_POST_DIVR_FREQ 7000000 + +/* MAX_POST_DIVIDE_REF_FREQ: maximum post-divider reference frequency, in Hz */ +#define MAX_POST_DIVR_FREQ 200000000 + +/* MIN_VCO_FREQ: minimum VCO frequency, in Hz (Fvco_min) */ +#define MIN_VCO_FREQ 2400000000UL + +/* MAX_VCO_FREQ: maximum VCO frequency, in Hz (Fvco_max) */ +#define MAX_VCO_FREQ 4800000000ULL + +/* MAX_DIVQ_DIVISOR: maximum output divisor. Selected by DIVQ = 6 */ +#define MAX_DIVQ_DIVISOR 64 + +/* MAX_DIVR_DIVISOR: maximum reference divisor. Selected by DIVR = 63 */ +#define MAX_DIVR_DIVISOR 64 + +/* MAX_LOCK_US: maximum PLL lock time, in microseconds (tLOCK_max) */ +#define MAX_LOCK_US 70 + +/* + * ROUND_SHIFT: number of bits to shift to avoid precision loss in the rounding + * algorithm + */ +#define ROUND_SHIFT 20 + +/* + * Private functions + */ + +/** + * __wrpll_calc_filter_range() - determine PLL loop filter bandwidth + * @post_divr_freq: input clock rate after the R divider + * + * Select the value to be presented to the PLL RANGE input signals, based + * on the input clock frequency after the post-R-divider @post_divr_freq. + * This code follows the recommendations in the PLL datasheet for filter + * range selection. + * + * Return: The RANGE value to be presented to the PLL configuration inputs, + * or -1 upon error. + */ +static int __wrpll_calc_filter_range(unsigned long post_divr_freq) +{ + u8 range; + + if (post_divr_freq < MIN_POST_DIVR_FREQ || + post_divr_freq > MAX_POST_DIVR_FREQ) { + WARN(1, "%s: post-divider reference freq out of range: %lu", + __func__, post_divr_freq); + return -1; + } + + if (post_divr_freq < 11000000) + range = 1; + else if (post_divr_freq < 18000000) + range = 2; + else if (post_divr_freq < 30000000) + range = 3; + else if (post_divr_freq < 50000000) + range = 4; + else if (post_divr_freq < 80000000) + range = 5; + else if (post_divr_freq < 130000000) + range = 6; + else + range = 7; + + return range; +} + +/** + * __wrpll_calc_fbdiv() - return feedback fixed divide value + * @c: ptr to a struct analogbits_wrpll_cfg record to read from + * + * The internal feedback path includes a fixed by-two divider; the + * external feedback path does not. Return the appropriate divider + * value (2 or 1) depending on whether internal or external feedback + * is enabled. This code doesn't test for invalid configurations + * (e.g. both or neither of WRPLL_FLAGS_*_FEEDBACK are set); it relies + * on the caller to do so. + * + * Context: Any context. Caller must protect the memory pointed to by + * @c from simultaneous modification. + * + * Return: 2 if internal feedback is enabled or 1 if external feedback + * is enabled. + */ +static u8 __wrpll_calc_fbdiv(struct analogbits_wrpll_cfg *c) +{ + return (c->flags & WRPLL_FLAGS_INT_FEEDBACK_MASK) ? 2 : 1; +} + +/** + * __wrpll_calc_divq() - determine DIVQ based on target PLL output clock rate + * @target_rate: target PLL output clock rate + * @vco_rate: pointer to a u64 to store the computed VCO rate into + * + * Determine a reasonable value for the PLL Q post-divider, based on the + * target output rate @target_rate for the PLL. Along with returning the + * computed Q divider value as the return value, this function stores the + * desired target VCO rate into the variable pointed to by @vco_rate. + * + * Context: Any context. Caller must protect the memory pointed to by + * @vco_rate from simultaneous access or modification. + * + * Return: a positive integer DIVQ value to be programmed into the hardware + * upon success, or 0 upon error (since 0 is an invalid DIVQ value) + */ +static u8 __wrpll_calc_divq(u32 target_rate, u64 *vco_rate) +{ + u64 s; + u8 divq = 0; + + if (!vco_rate) { + WARN_ON(1); + goto wcd_out; + } + + s = div_u64(MAX_VCO_FREQ, target_rate); + if (s <= 1) { + divq = 1; + *vco_rate = MAX_VCO_FREQ; + } else if (s > MAX_DIVQ_DIVISOR) { + divq = ilog2(MAX_DIVQ_DIVISOR); + *vco_rate = MIN_VCO_FREQ; + } else { + divq = ilog2(s); + *vco_rate = target_rate << divq; + } + +wcd_out: + return divq; +} + +/** + * __wrpll_update_parent_rate() - update PLL data when parent rate changes + * @c: ptr to a struct analogbits_wrpll_cfg record to write PLL data to + * @parent_rate: PLL input refclk rate (pre-R-divider) + * + * Pre-compute some data used by the PLL configuration algorithm when + * the PLL's reference clock rate changes. The intention is to avoid + * computation when the parent rate remains constant - expected to be + * the common case. + * + * Returns: 0 upon success or -1 if the reference clock rate is out of range. + */ +static int __wrpll_update_parent_rate(struct analogbits_wrpll_cfg *c, + unsigned long parent_rate) +{ + u8 max_r_for_parent; + + if (parent_rate > MAX_INPUT_FREQ || parent_rate < MIN_POST_DIVR_FREQ) + return -1; + + c->_parent_rate = parent_rate; + max_r_for_parent = div_u64(parent_rate, MIN_POST_DIVR_FREQ); + c->_max_r = min_t(u8, MAX_DIVR_DIVISOR, max_r_for_parent); + + /* Round up */ + c->_init_r = div_u64(parent_rate + MAX_POST_DIVR_FREQ - 1, + MAX_POST_DIVR_FREQ); + + return 0; +} + +/* + * Public functions + */ + +/** + * analogbits_wrpll_configure() - compute PLL configuration for a target rate + * @c: ptr to a struct analogbits_wrpll_cfg record to write into + * @target_rate: target PLL output clock rate (post-Q-divider) + * @parent_rate: PLL input refclk rate (pre-R-divider) + * + * Given a pointer to a PLL context @c, a desired PLL target output + * rate @target_rate, and a reference clock input rate @parent_rate, + * compute the appropriate PLL signal configuration values. PLL + * reprogramming is not glitchless, so the caller should switch any + * downstream logic to a different clock source or clock-gate it + * before presenting these values to the PLL configuration signals. + * + * The caller must pass this function a pre-initialized struct + * analogbits_wrpll_cfg record: either initialized to zero (with the + * exception of the .name and .flags fields) or read from the PLL. + * + * Context: Any context. Caller must protect the memory pointed to by @c + * from simultaneous access or modification. + * + * Return: 0 upon success; anything else upon failure. + */ +int analogbits_wrpll_configure_for_rate(struct analogbits_wrpll_cfg *c, + u32 target_rate, + unsigned long parent_rate) +{ + unsigned long ratio; + u64 target_vco_rate, delta, best_delta, f_pre_div, vco, vco_pre; + u32 best_f, f, post_divr_freq, fbcfg; + u8 fbdiv, divq, best_r, r; + + if (!c) + return -1; + + if (c->flags == 0) { + WARN(1, "%s called with uninitialized PLL config", __func__); + return -1; + } + + fbcfg = WRPLL_FLAGS_INT_FEEDBACK_MASK | WRPLL_FLAGS_EXT_FEEDBACK_MASK; + if ((c->flags & fbcfg) == fbcfg) { + WARN(1, "%s called with invalid PLL config", __func__); + return -1; + } + + if (c->flags == WRPLL_FLAGS_EXT_FEEDBACK_MASK) { + WARN(1, "%s: external feedback mode not currently supported", + __func__); + return -1; + } + + /* Initialize rounding data if it hasn't been initialized already */ + if (parent_rate != c->_parent_rate) { + if (__wrpll_update_parent_rate(c, parent_rate)) { + pr_err("%s: PLL input rate is out of range\n", + __func__); + return -1; + } + } + + c->flags &= ~WRPLL_FLAGS_RESET_MASK; + + /* Put the PLL into bypass if the user requests the parent clock rate */ + if (target_rate == parent_rate) { + c->flags |= WRPLL_FLAGS_BYPASS_MASK; + return 0; + } + c->flags &= ~WRPLL_FLAGS_BYPASS_MASK; + + /* Calculate the Q shift and target VCO rate */ + divq = __wrpll_calc_divq(target_rate, &target_vco_rate); + if (divq == 0) + return -1; + c->divq = divq; + + /* Precalculate the pre-Q divider target ratio */ + ratio = div64_u64((target_vco_rate << ROUND_SHIFT), parent_rate); + + fbdiv = __wrpll_calc_fbdiv(c); + best_r = 0; + best_f = 0; + best_delta = MAX_VCO_FREQ; + + /* + * Consider all values for R which land within + * [MIN_POST_DIVR_FREQ, MAX_POST_DIVR_FREQ]; prefer smaller R + */ + for (r = c->_init_r; r <= c->_max_r; ++r) { + /* What is the best F we can pick in this case? */ + f_pre_div = ratio * r; + f = (f_pre_div + (1 << ROUND_SHIFT)) >> ROUND_SHIFT; + f >>= (fbdiv - 1); + + post_divr_freq = div_u64(parent_rate, r); + vco_pre = fbdiv * post_divr_freq; + vco = vco_pre * f; + + /* Ensure rounding didn't take us out of range */ + if (vco > target_vco_rate) { + --f; + vco = vco_pre * f; + } else if (vco < MIN_VCO_FREQ) { + ++f; + vco = vco_pre * f; + } + + delta = abs(target_rate - vco); + if (delta < best_delta) { + best_delta = delta; + best_r = r; + best_f = f; + } + } + + c->divr = best_r - 1; + c->divf = best_f - 1; + + post_divr_freq = div_u64(parent_rate, best_r); + + /* Pick the best PLL jitter filter */ + c->range = __wrpll_calc_filter_range(post_divr_freq); + + return 0; +} + +/** + * analogbits_wrpll_calc_output_rate() - calculate the PLL's target output rate + * @c: ptr to a struct analogbits_wrpll_cfg record to read from + * @parent_rate: PLL refclk rate + * + * Given a pointer to the PLL's current input configuration @c and the + * PLL's input reference clock rate @parent_rate (before the R + * pre-divider), calculate the PLL's output clock rate (after the Q + * post-divider) + * + * Context: Any context. Caller must protect the memory pointed to by @c + * from simultaneous modification. + * + * Return: the PLL's output clock rate, in Hz. + */ +unsigned long analogbits_wrpll_calc_output_rate(struct analogbits_wrpll_cfg *c, + unsigned long parent_rate) +{ + u8 fbdiv; + u64 n; + + WARN(c->flags & WRPLL_FLAGS_EXT_FEEDBACK_MASK, + "external feedback mode not yet supported"); + + fbdiv = __wrpll_calc_fbdiv(c); + n = parent_rate * fbdiv * (c->divf + 1); + n = div_u64(n, (c->divr + 1)); + n >>= c->divq; + + return n; +} + +/** + * analogbits_wrpll_calc_max_lock_us() - return the time for the PLL to lock + * @c: ptr to a struct analogbits_wrpll_cfg record to read from + * + * Return the minimum amount of time (in microseconds) that the caller + * must wait after reprogramming the PLL to ensure that it is locked + * to the input frequency and stable. This is likely to depend on the DIVR + * value; this is under discussion with the manufacturer. + * + * Return: the minimum amount of time the caller must wait for the PLL + * to lock (in microseconds) + */ +unsigned int analogbits_wrpll_calc_max_lock_us(struct analogbits_wrpll_cfg *c) +{ + return MAX_LOCK_US; +} diff --git a/include/dt-bindings/clk/sifive-fu540-prci.h b/include/dt-bindings/clk/sifive-fu540-prci.h new file mode 100644 index 0000000000..531523ea62 --- /dev/null +++ b/include/dt-bindings/clk/sifive-fu540-prci.h @@ -0,0 +1,29 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * Copyright (c) 2019 Western Digital Corporation or its affiliates. + * + * Copyright (C) 2018 SiFive, Inc. + * Wesley Terpstra + * Paul Walmsley + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + */ + +#ifndef __LINUX_CLK_SIFIVE_FU540_PRCI_H +#define __LINUX_CLK_SIFIVE_FU540_PRCI_H + +/* Clock indexes for use by Device Tree data */ + +#define PRCI_CLK_COREPLL 0 +#define PRCI_CLK_DDRPLL 1 +#define PRCI_CLK_GEMGXLPLL 2 +#define PRCI_CLK_TLCLK 3 + +#endif From patchwork Fri Jan 18 11:19:16 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anup Patel X-Patchwork-Id: 1027221 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=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=wdc.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=wdc.com header.i=@wdc.com header.b="dzx5Ix2l"; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=sharedspace.onmicrosoft.com header.i=@sharedspace.onmicrosoft.com header.b="dsq98jU9"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 43gz8r56XPz9sBQ for ; Fri, 18 Jan 2019 22:23:40 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id 57EA0C220EF; Fri, 18 Jan 2019 11:22:10 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=KHOP_BIG_TO_CC, T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id C0EF4C22078; Fri, 18 Jan 2019 11:20:03 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 662B3C220A0; Fri, 18 Jan 2019 11:19:23 +0000 (UTC) Received: from esa1.hgst.iphmx.com (esa1.hgst.iphmx.com [68.232.141.245]) by lists.denx.de (Postfix) with ESMTPS id CEEFDC21E2F for ; Fri, 18 Jan 2019 11:19:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1547810359; x=1579346359; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=CFTWpT6jr2IliMFzd/adz460wYZWLR24eObvaBtmnCM=; b=dzx5Ix2l0aRPn50Vl93Ddn64oxJT8RSp8ki3pziqXqBSm/XyeBvfajpV pm4MF66C8J/h7uPNFm+/EGp5OoPggCaGzVrELjJOuGZxz4oZ15/G982Wf NzkD7hckphQApjpZl2VciyX1k8z2XNo+Jao8QUqIn3izTB3Urbw0XZBD9 SYW0cHlihjDAB5MdrIdeW07I/knd6MZPpQjjCbDfjgjxTTBvlA97wuqWe mzlu+LVMWCj90diPfYiG2tVO51wdKbILbG1glZo+E769z5+3RwM2ImkLO X+A715FsJPumN7IGshWdNIhZIpyWn1ei6tdMNEkmhK9ruvKVSKjYFC1ZG g==; X-IronPort-AV: E=Sophos;i="5.56,491,1539619200"; d="scan'208";a="204130029" Received: from mail-dm3nam03lp2053.outbound.protection.outlook.com (HELO NAM03-DM3-obe.outbound.protection.outlook.com) ([104.47.41.53]) by ob1.hgst.iphmx.com with ESMTP; 18 Jan 2019 19:19:17 +0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sharedspace.onmicrosoft.com; s=selector1-wdc-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=3Rgmhd5NyRs5iBAoae37KTyB/XxBmZiStWVz5eHVvLc=; b=dsq98jU9Qaqx883Waw9eOArL9uSFNOMKSFuCLy3ZV7imxP1s5ZSCvBDH4RZ8J9LxtoTud0asbLmN9x3OsX2Xex5JPS02AWs/SPv7qduOiFrE0btvsCNTKLMrSr8ttiUrChZ/9+G7P7+AJQ38eEqEb6VtBoLSld1cC4RvTLn/NeM= Received: from BYAPR04MB5303.namprd04.prod.outlook.com (20.178.49.148) by BYAPR04MB5016.namprd04.prod.outlook.com (52.135.235.10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1537.24; Fri, 18 Jan 2019 11:19:16 +0000 Received: from BYAPR04MB5303.namprd04.prod.outlook.com ([fe80::add1:92cc:65d7:5d94]) by BYAPR04MB5303.namprd04.prod.outlook.com ([fe80::add1:92cc:65d7:5d94%2]) with mapi id 15.20.1537.018; Fri, 18 Jan 2019 11:19:16 +0000 From: Anup Patel To: Rick Chen , Bin Meng , Joe Hershberger , Lukas Auer , Masahiro Yamada , Simon Glass Thread-Topic: [PATCH v2 07/11] clk: Add fixed-factor clock driver Thread-Index: AQHUrx+l3u7Ton1kB06nNgQ2OZP7Hg== Date: Fri, 18 Jan 2019 11:19:16 +0000 Message-ID: <20190118111820.71349-8-anup.patel@wdc.com> References: <20190118111820.71349-1-anup.patel@wdc.com> In-Reply-To: <20190118111820.71349-1-anup.patel@wdc.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: MA1PR01CA0115.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a00:1::31) To BYAPR04MB5303.namprd04.prod.outlook.com (2603:10b6:a03:c8::20) authentication-results: spf=none (sender IP is ) smtp.mailfrom=Anup.Patel@wdc.com; x-ms-exchange-messagesentrepresentingtype: 1 x-mailer: git-send-email 2.17.1 x-originating-ip: [49.207.48.211] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; BYAPR04MB5016; 6:DCptIO7gOZM2fhwT7X+iMD5BCc0kNM1A3e6c4/M9rs+yJF75jGqUmgQ8ib2uzK5LGp6JE5X1ihVpaMTx0QY2IHFNEoIaCiDfKiQXiCC527h4BtkZTTghyW29gKpCO7jJbxwh1wv9ZwfJ9Uhv9cx7Eik1fyfVe9N0k21/oQkmUtV5R1qhzi3oxgvyVWWCL7H+d+tOf1e/cB9j1EsT8RlMclSnVXqjK/I68WUxNLjNrfgF2cLUA3pMPlE4VHVx8mfA80uiUwNyn1b96cryZrGTIbLP9b0jJOcFD+kMVAzp0NsRInGDKBl/GoPzW29ojEmSmbBXDzL3f2vx7jyKnfJyESJ2SfPGo4p2ayZVrWg/p0csxNO31CWx5gpcG9Qz33N8PIx56CLJG0uhMWI6U8xzIkysIXJ8bui5nz69fizQzq2fHYTIhZmo/A06ZGvOJ3q9GQRm98DRBRmV35ce+31yqw==; 5:BUQ3Amm2MJsQ90qpKVsb+aBC70HHPJhKDKiDSCSKMScv9QkMJ9YmhorVxgWtoSAE0tO37f4V75o44BHmIftUEBE13CZQntMyhj7Mag7mCqBZM5rn4JkcdCUg+pbbk1fitWNgiGwgBzVxHiicCXn7oq1UMV8lboTFKOVAjI9b2opisW+ZtaKHefi3cCCNvvUqBA39e0X9nIV/jd0q5zj3Yg==; 7:VbHA44fZWOObuFLkaSZQiO9l2WgJMT2KWrR++0bOjIq1zt2paYqi2bwe5p13tMp2VS7KmaK9B13ThIWfyyoHEBp1XQMbKUbCnjRG7WD4olQo7QPi4yBZnvcB/pAf0hX6/wl7/8sCDlIGqWRpMA/XvQ== x-ms-office365-filtering-correlation-id: 0db81bd2-92b5-48ec-ba33-08d67d36c853 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(7168020)(4627221)(201703031133081)(201702281549075)(8990200)(5600109)(711020)(4618075)(2017052603328)(7153060)(7193020); SRVR:BYAPR04MB5016; x-ms-traffictypediagnostic: BYAPR04MB5016: wdcipoutbound: EOP-TRUE x-microsoft-antispam-prvs: x-forefront-prvs: 0921D55E4F x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(39860400002)(136003)(346002)(366004)(376002)(396003)(189003)(199004)(81156014)(81166006)(2906002)(14454004)(8676002)(36756003)(4326008)(39060400002)(305945005)(68736007)(478600001)(7736002)(8936002)(14444005)(50226002)(97736004)(256004)(2616005)(486006)(476003)(25786009)(72206003)(105586002)(106356001)(6436002)(6486002)(6512007)(44832011)(1076003)(110136005)(54906003)(6116002)(3846002)(71190400001)(386003)(11346002)(316002)(71200400001)(102836004)(6506007)(55236004)(26005)(186003)(53936002)(446003)(86362001)(7416002)(52116002)(5660300001)(76176011)(99286004)(66066001); DIR:OUT; SFP:1102; SCL:1; SRVR:BYAPR04MB5016; H:BYAPR04MB5303.namprd04.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: jEeYnuDBTrWBSwQCjP+mFkbLn9MIZuE4ZohadBNL8iLAIg+bblUczfNLPGZXLKVKVxhUlE71F7z/VI+vgapMjaU80CCbaPL5CKUdO8EVAbpUi0phRfuXqdZOFqKtdM2LOPcGca4XGNPK9V6xXle9ztCZ5YtiOAwFMFNo1fnJVR6N6nBqbEmddH4Kgstg0Aku6jB/NnDSNKI/RZD60jm4y09LJ2F9XuyM7/5Fx3nLDe0Aa1u+fhmbLDh+ADWKFMAuVtc+a+5VrdeaESJpixeso5Dx5ggS5nFAT8yOHkRa5I+Ap5QYem7Mml0qwfLgNSXFlO8G5QUnwqgu6BZyVq9ClHU+L+VfOhMo13z7KWe2dtYYmjc8577h3f5E+Fp75szxSV3A9zrCs5FUIaYUyxVyBDRL3gzb1ELWT7logY7+BdM= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: wdc.com X-MS-Exchange-CrossTenant-Network-Message-Id: 0db81bd2-92b5-48ec-ba33-08d67d36c853 X-MS-Exchange-CrossTenant-originalarrivaltime: 18 Jan 2019 11:19:12.9796 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: b61c8803-16f3-4c35-9b17-6f65f441df86 X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR04MB5016 Cc: Palmer Dabbelt , U-Boot Mailing List , Alexander Graf , Christoph Hellwig , Paul Walmsley Subject: [U-Boot] [PATCH v2 07/11] clk: Add fixed-factor clock driver X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 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" This patch adds fixed-factor clock driver which derives clock rate by dividing (div) and multiplying (mult) fixed factors to a parent clock. Signed-off-by: Atish Patra Signed-off-by: Anup Patel --- drivers/clk/Makefile | 4 +- drivers/clk/clk_fixed_factor.c | 74 ++++++++++++++++++++++++++++++++++ 2 files changed, 77 insertions(+), 1 deletion(-) create mode 100644 drivers/clk/clk_fixed_factor.c diff --git a/drivers/clk/Makefile b/drivers/clk/Makefile index 2f4446568c..fa59259ea3 100644 --- a/drivers/clk/Makefile +++ b/drivers/clk/Makefile @@ -4,7 +4,9 @@ # Wolfgang Denk, DENX Software Engineering, wd@denx.de. # -obj-$(CONFIG_$(SPL_TPL_)CLK) += clk-uclass.o clk_fixed_rate.o +obj-$(CONFIG_$(SPL_TPL_)CLK) += clk-uclass.o +obj-$(CONFIG_$(SPL_TPL_)CLK) += clk_fixed_rate.o +obj-$(CONFIG_$(SPL_TPL_)CLK) += clk_fixed_factor.o obj-y += imx/ obj-y += tegra/ diff --git a/drivers/clk/clk_fixed_factor.c b/drivers/clk/clk_fixed_factor.c new file mode 100644 index 0000000000..eab1724c26 --- /dev/null +++ b/drivers/clk/clk_fixed_factor.c @@ -0,0 +1,74 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Copyright (c) 2019 Western Digital Corporation or its affiliates. + * + * Author: Anup Patel + */ + +#include +#include +#include +#include + +struct clk_fixed_factor { + struct clk parent; + unsigned int div; + unsigned int mult; +}; + +#define to_clk_fixed_factor(dev) \ + ((struct clk_fixed_factor *)dev_get_platdata(dev)) + +static ulong clk_fixed_factor_get_rate(struct clk *clk) +{ + int ret; + struct clk_fixed_factor *ff = to_clk_fixed_factor(clk->dev); + + if (clk->id != 0) + return -EINVAL; + + ret = clk_get_rate(&ff->parent); + if (IS_ERR_VALUE(ret)) + return ret; + + do_div(ret, ff->div); + + return ret * ff->mult; +} + +const struct clk_ops clk_fixed_factor_ops = { + .get_rate = clk_fixed_factor_get_rate, +}; + +static int clk_fixed_factor_ofdata_to_platdata(struct udevice *dev) +{ +#if !CONFIG_IS_ENABLED(OF_PLATDATA) + int err; + struct clk_fixed_factor *ff = to_clk_fixed_factor(dev); + + err = clk_get_by_index(dev, 0, &ff->parent); + if (err) + return err; + + ff->div = dev_read_u32_default(dev, "clock-div", 1); + ff->mult = dev_read_u32_default(dev, "clock-mult", 1); +#endif + + return 0; +} + +static const struct udevice_id clk_fixed_factor_match[] = { + { + .compatible = "fixed-factor-clock", + }, + { /* sentinel */ } +}; + +U_BOOT_DRIVER(clk_fixed_factor) = { + .name = "fixed_factor_clock", + .id = UCLASS_CLK, + .of_match = clk_fixed_factor_match, + .ofdata_to_platdata = clk_fixed_factor_ofdata_to_platdata, + .platdata_auto_alloc_size = sizeof(struct clk_fixed_factor), + .ops = &clk_fixed_factor_ops, +}; From patchwork Fri Jan 18 11:19:20 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anup Patel X-Patchwork-Id: 1027222 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=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=wdc.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=wdc.com header.i=@wdc.com header.b="ERfcpAjb"; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=sharedspace.onmicrosoft.com header.i=@sharedspace.onmicrosoft.com header.b="caI9Qiwc"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 43gz900l5zz9sBQ for ; Fri, 18 Jan 2019 22:23:47 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id A792AC21E3E; Fri, 18 Jan 2019 11:20:43 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=KHOP_BIG_TO_CC, T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 7CD11C220D6; Fri, 18 Jan 2019 11:19:45 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id D72D7C220D6; Fri, 18 Jan 2019 11:19:27 +0000 (UTC) Received: from esa1.hgst.iphmx.com (esa1.hgst.iphmx.com [68.232.141.245]) by lists.denx.de (Postfix) with ESMTPS id 7E803C220A3 for ; Fri, 18 Jan 2019 11:19:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1547810363; x=1579346363; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=Y0VoDNxfVxdqy2uL1esPtQdG6GJZe51oD7DhRIWWdK0=; b=ERfcpAjbut38ZnBsnJJ2K8lIawaMrZ6Syx8W0yzwh3USx6YmX6d92mp8 AlRurEk2m7HWXtCFQLFGiKnTWmg9MiLzFkPn5xIgQx1rt+63yMcjuhiJ6 QINOHtvdtXGS6t3PZc0bmWpENdYpgM3Qj8/NdTNzponToMub5DUMu6S8h wXB45VbWvgHgfxx1TamJOMO83417SscrZAWNKuSpmCZZUuxtag56Xk8ox 1JMtG4Rpz+ffS2pN8fFPssalDyLBWHP94QGdR9yOqwzGO0LlX2wrl6v4j 88fxlLqEc2+JbNuMZVSKhTlZVl35ydrQarMtczkdcBTk4vSqmeq2uCBS8 g==; X-IronPort-AV: E=Sophos;i="5.56,491,1539619200"; d="scan'208";a="204130033" Received: from mail-dm3nam03lp2059.outbound.protection.outlook.com (HELO NAM03-DM3-obe.outbound.protection.outlook.com) ([104.47.41.59]) by ob1.hgst.iphmx.com with ESMTP; 18 Jan 2019 19:19:21 +0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sharedspace.onmicrosoft.com; s=selector1-wdc-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=seHWmE1D1pU/sj2nyRRbXRF3wIA5tCTswp8PrUP6Vzo=; b=caI9QiwcQ1/H8fdH/N3EaOw0zcjNUoboV21/Am56pSXa929SyXP72j2pYH3uyiENh+BHHc99jUcLyFSD2WMz0xATl2Ep6P8a4AV1QiDuGWMiHz5mrQbN6rKDDQpMF4owG3G1gaEl3Fu7B5C9hCx6K29b4ySjlMOx/nREcbgl+pM= Received: from BYAPR04MB5303.namprd04.prod.outlook.com (20.178.49.148) by BYAPR04MB5016.namprd04.prod.outlook.com (52.135.235.10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1537.24; Fri, 18 Jan 2019 11:19:21 +0000 Received: from BYAPR04MB5303.namprd04.prod.outlook.com ([fe80::add1:92cc:65d7:5d94]) by BYAPR04MB5303.namprd04.prod.outlook.com ([fe80::add1:92cc:65d7:5d94%2]) with mapi id 15.20.1537.018; Fri, 18 Jan 2019 11:19:21 +0000 From: Anup Patel To: Rick Chen , Bin Meng , Joe Hershberger , Lukas Auer , Masahiro Yamada , Simon Glass Thread-Topic: [PATCH v2 08/11] drivers: serial_sifive: Fix baud rate calculation Thread-Index: AQHUrx+oBVjLVXnakkGRBJg+no+I6w== Date: Fri, 18 Jan 2019 11:19:20 +0000 Message-ID: <20190118111820.71349-9-anup.patel@wdc.com> References: <20190118111820.71349-1-anup.patel@wdc.com> In-Reply-To: <20190118111820.71349-1-anup.patel@wdc.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: MA1PR01CA0115.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a00:1::31) To BYAPR04MB5303.namprd04.prod.outlook.com (2603:10b6:a03:c8::20) authentication-results: spf=none (sender IP is ) smtp.mailfrom=Anup.Patel@wdc.com; x-ms-exchange-messagesentrepresentingtype: 1 x-mailer: git-send-email 2.17.1 x-originating-ip: [49.207.48.211] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; BYAPR04MB5016; 6:DHyKYb0FeHDjqvGSYF8VyHY79sLyS65uDPobLlPJ38FynoXifhcvNhD8aJZQznBENeTSNFDf99PcUMoWOm0LZxsqI5ITBeQz14uVn1GdvvJABJfHZFrvPQer3wXMO2WaHL5whNyinmOwQ8lqppCQSLtgcW0plvHULLytEW6iVxA0Z5jzJx29TaKVnpaq1OUt/xipxWH1iSnoH2DVyJ3yBWF7BfC8chT0ddImQOIeegDocGxVU8zGJwzZqiScqPy3RbGjb6at3hi0iRoVPZDLpLaO852yhIYRz9tvRHMmS9hY5XB7jlpCRElkKrWDRtQgJ7Q5asUns95D2G5wRDWaKceL49XZwoSA6nQj5c9bXG2SI8rZq8uFE+08Jgp0Dy5yGpAF3GNb8ZrMVFoZioSEYH6i4VEvbqCWNNiw+Tm2gblszBzWPRrsqv5esX9Puhu4GqmKry/46yXhnZKMDp+/rQ==; 5:MwV1A0EsWNL99Irs2MbKTiunCpNlfo7mmLPCbvwf7cYqkwJ6lnXCC8e9SWLUBvc+beciEps4MxZHEqC4xwtch3gtTirZGhHyHNXYjmLVz5rv1tncsaZYv43GUZO3gu1V1NKwKEBBUJSQLSGTI1nb+uSTz9CZgaXlBiLak96xwWk8aDfwOim4yxbPPi1PxgTkoROTD1EE4eRa0lDsamwaSw==; 7:RQ3L9T8Z/1Mz2qAUBSuRqNtwtkrjmp1MHwlxt65/9cGQmIrc0Vr6a1wumql1tUJGCKbfqrYNRfLrD5P7hTbHcPgS3SwfzN2WGgyOeVd3WaqXxA4fP8F3eYwCz6qxoSbPHzuV8wWHlY9lylf7foH6Sg== x-ms-office365-filtering-correlation-id: 3d234eb3-a136-4cb8-4a3b-08d67d36cb0e x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(7168020)(4627221)(201703031133081)(201702281549075)(8990200)(5600109)(711020)(4618075)(2017052603328)(7153060)(7193020); SRVR:BYAPR04MB5016; x-ms-traffictypediagnostic: BYAPR04MB5016: wdcipoutbound: EOP-TRUE x-microsoft-antispam-prvs: x-forefront-prvs: 0921D55E4F x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(39860400002)(136003)(346002)(366004)(376002)(396003)(189003)(199004)(81156014)(81166006)(2906002)(14454004)(8676002)(36756003)(4326008)(39060400002)(305945005)(68736007)(478600001)(7736002)(8936002)(14444005)(50226002)(97736004)(256004)(2616005)(486006)(476003)(25786009)(72206003)(105586002)(106356001)(6436002)(6486002)(6512007)(44832011)(1076003)(110136005)(54906003)(6116002)(3846002)(71190400001)(386003)(11346002)(316002)(71200400001)(102836004)(6506007)(55236004)(26005)(186003)(53936002)(446003)(86362001)(7416002)(52116002)(5660300001)(76176011)(99286004)(66066001); DIR:OUT; SFP:1102; SCL:1; SRVR:BYAPR04MB5016; H:BYAPR04MB5303.namprd04.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: Iw4UGXXdj5iEcDJjUvGkgFkCZX0W/Q8Uwq4KLRvSwUNgA4f2WmNNfOg/MSWdU8DJvJp+O2T2SnAuqiFxQt3sLW4deiySAwhy2U5po6QGNy2t5WruNMktEgdZ+gBKuqXlKGB566atFQPqXFDGxJh2qiVpc/kYsF+vZZs1hUlr9Grelzq2k/l3SPwTeUAeYIsqx/gbR22u59eL23gpUsKCGI4mHhaWgPQocAVxRGIGLe8n32uxRoku2F0oBcfrkujFmhIb5QPJgG/y6f9QEYGKFMj9ZlxC1A1QeBk92duSiRzf/F6urZEXsZqIvlSVNMaYSZUIh19q16sREhpDgfubXDVDsftUg5XriuJlt7uSuBf74CJJpejpx8Av7yNDRh6b3WbJB2J4R33w2q5fGYHL/YY7rXuBxyn/tHm7sBQ+iD8= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: wdc.com X-MS-Exchange-CrossTenant-Network-Message-Id: 3d234eb3-a136-4cb8-4a3b-08d67d36cb0e X-MS-Exchange-CrossTenant-originalarrivaltime: 18 Jan 2019 11:19:17.5577 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: b61c8803-16f3-4c35-9b17-6f65f441df86 X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR04MB5016 Cc: Palmer Dabbelt , U-Boot Mailing List , Alexander Graf , Christoph Hellwig , Paul Walmsley Subject: [U-Boot] [PATCH v2 08/11] drivers: serial_sifive: Fix baud rate calculation X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 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" From: Atish Patra Compute the baud rate multipler with more precision. Signed-off-by: Atish Patra Reviewed-by: Alexander Graf Reviewed-by: Lukas Auer --- drivers/serial/serial_sifive.c | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/drivers/serial/serial_sifive.c b/drivers/serial/serial_sifive.c index 341728a690..ea4d35d48c 100644 --- a/drivers/serial/serial_sifive.c +++ b/drivers/serial/serial_sifive.c @@ -33,16 +33,40 @@ struct uart_sifive { }; struct sifive_uart_platdata { - unsigned int clock; + unsigned long clock; int saved_input_char; struct uart_sifive *regs; }; +/** + * Find minimum divisor divides in_freq to max_target_hz; + * Based on uart driver n SiFive FSBL. + * + * f_baud = f_in / (div + 1) => div = (f_in / f_baud) - 1 + * The nearest integer solution requires rounding up as to not exceed + * max_target_hz. + * div = ceil(f_in / f_baud) - 1 + * = floor((f_in - 1 + f_baud) / f_baud) - 1 + * This should not overflow as long as (f_in - 1 + f_baud) does not exceed + * 2^32 - 1, which is unlikely since we represent frequencies in kHz. + */ +static inline unsigned int uart_min_clk_divisor(unsigned long in_freq, + unsigned long max_target_hz) +{ + unsigned long quotient = + (in_freq + max_target_hz - 1) / (max_target_hz); + /* Avoid underflow */ + if (quotient == 0) + return 0; + else + return quotient - 1; +} + /* Set up the baud rate in gd struct */ static void _sifive_serial_setbrg(struct uart_sifive *regs, unsigned long clock, unsigned long baud) { - writel((u32)((clock / baud) - 1), ®s->div); + writel((uart_min_clk_divisor(clock, baud)), ®s->div); } static void _sifive_serial_init(struct uart_sifive *regs) From patchwork Fri Jan 18 11:19:25 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anup Patel X-Patchwork-Id: 1027225 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=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=wdc.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=wdc.com header.i=@wdc.com header.b="eE/add3C"; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=sharedspace.onmicrosoft.com header.i=@sharedspace.onmicrosoft.com header.b="fnn/RUeB"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 43gzBl6THBz9sBQ for ; Fri, 18 Jan 2019 22:25:19 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id 91EA4C220D5; Fri, 18 Jan 2019 11:22:27 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=KHOP_BIG_TO_CC, T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 4BAA2C21E3E; Fri, 18 Jan 2019 11:20:59 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 9335CC21E0F; Fri, 18 Jan 2019 11:19:36 +0000 (UTC) Received: from esa5.hgst.iphmx.com (esa5.hgst.iphmx.com [216.71.153.144]) by lists.denx.de (Postfix) with ESMTPS id E2C4BC21E96 for ; Fri, 18 Jan 2019 11:19:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1547810371; x=1579346371; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=AGopGUiXazjgN5ZuY1nzw0BAbdwpOrkv1RV7FfRgwcQ=; b=eE/add3CLmikqV0KDT/c9XYmo1VvNSswyy9O5A7g2tEKx5NeByEZhhDu Wg//cuTSWoEvU4RyeRYJPZ+roaYj4067PH2+FJse4kpOus2UXdb7mMyye ryV80sYNqfeBIq5Rn9Cw4wgVskhoDwa1ZVv23F0xY9Aklvu6JzSA76dg2 ZX3VyiVdwYsO2xHlPeGZSDrFEalL0RTgWlTutc4Dy8pA1Qb90jE0AhqD0 qw3+MU3CpNkcny4XAptwFzfBXKrR4GRPFJxTB8/UTyoYeCzGTBGPz85hb UO0w6X9cDiXUBfwyOeyxFfQVplyPifCWac3toLTtWIttwIbBw95tHU08b A==; X-IronPort-AV: E=Sophos;i="5.56,491,1539619200"; d="scan'208";a="100370992" Received: from mail-sn1nam02lp2056.outbound.protection.outlook.com (HELO NAM02-SN1-obe.outbound.protection.outlook.com) ([104.47.36.56]) by ob1.hgst.iphmx.com with ESMTP; 18 Jan 2019 19:19:28 +0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sharedspace.onmicrosoft.com; s=selector1-wdc-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=u0pk+m+saWEBpumb8AcuizP7KdgAEiXUxCJ16WAWEek=; b=fnn/RUeB8we7BHKUAzkGjxVdX038M4EK63xpuXnHAh2Rx/ouhiofqu30WPBNVCZctt0W0EnG51zqI1ehWEfP+D+4wpLX0BmU7nGYr1I+7U1i8FEp9Ykj2Dl3BZ8PdoDdQczH70SdVYER7+mtKxHTeBx4cMlEmrLrR+1QFKTaXgE= Received: from BYAPR04MB5303.namprd04.prod.outlook.com (20.178.49.148) by BYAPR04MB4197.namprd04.prod.outlook.com (20.176.250.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1537.24; Fri, 18 Jan 2019 11:19:25 +0000 Received: from BYAPR04MB5303.namprd04.prod.outlook.com ([fe80::add1:92cc:65d7:5d94]) by BYAPR04MB5303.namprd04.prod.outlook.com ([fe80::add1:92cc:65d7:5d94%2]) with mapi id 15.20.1537.018; Fri, 18 Jan 2019 11:19:25 +0000 From: Anup Patel To: Rick Chen , Bin Meng , Joe Hershberger , Lukas Auer , Masahiro Yamada , Simon Glass Thread-Topic: [PATCH v2 09/11] drivers: serial_sifive: Skip baudrate config if no input clock Thread-Index: AQHUrx+rF7KuvmNSPEumpy1BMk5tRA== Date: Fri, 18 Jan 2019 11:19:25 +0000 Message-ID: <20190118111820.71349-10-anup.patel@wdc.com> References: <20190118111820.71349-1-anup.patel@wdc.com> In-Reply-To: <20190118111820.71349-1-anup.patel@wdc.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: MA1PR01CA0115.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a00:1::31) To BYAPR04MB5303.namprd04.prod.outlook.com (2603:10b6:a03:c8::20) authentication-results: spf=none (sender IP is ) smtp.mailfrom=Anup.Patel@wdc.com; x-ms-exchange-messagesentrepresentingtype: 1 x-mailer: git-send-email 2.17.1 x-originating-ip: [49.207.48.211] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; BYAPR04MB4197; 6:f7mSmrrugcH4rrUigf36o4Wdhc8twqsFa0yaDz7IDuJjCYgs8Z00APYrUsA6JrwikBYz0dFou4CQ3rBdpVvBTv6PrS+DSGi9R3cuO8Hwdkf33Nx3S9umG7BawiVzUcSRyAMTEEChL7izbVK/kpJA+1ANkaG8a42TYh1okcHes27L/SN7f/hJX/WWSMUkbj2XSJdZSuayVgoNxsLzTeFllAqtj2pBUUtpYr1i5+hC+c1cIpaKnPyF2QioYD44loOgMLUXTZpQmrm1ETeLOHjfIVuI9UydW6cZrz7DOcUdF2YHaz/kBOm2WBG5DIPR52JWdEE/h6jK8TAXBcwC66I6Zeg73UNMnPPDscpghU8W6yvrrMnOPOLqUQz3a/K7FP8V7JVjDWzJGIugpzfzaTjN/Ca8TQq9x6GwjSpHStMZxf3gubCdwzSvv0eMxpwqpxuqoP76ar9w9Huc+sNZmjH8cA==; 5:BR32SEzQOWQ0uSfHZKeoY66TmjyRAcjrNdH/oVHAepzz/Bx5fAZ2ZRIJTD4w4GOF6Y7/4zuHDm1OaESbVa7sXCrNkVIG2NH3Hwtl+l8okAxfUuWGMnMyfQCtoiVQOC4JL8mFtwE30PzPffsxmp16aWGrCQ7hq0SI1tva07XecEHVXL+WcfsYdw2IBeMhtH24bfb4y9u4EeajebaaOUXWgQ==; 7:fFga1NPRuVIN+8gylcERwZdZ5uRaBAqk0veyfkBw81wvmarjJsfoIeCIOYANai69EltDj0XDWsgyNpKzrD137lDFJWqkDZvnDqVxcidbdDN0abYeSYRKt4KPjAW9HUNb0C37LnEygIwQTEwmDMB5bw== x-ms-office365-filtering-correlation-id: 7250ed5f-2972-4f02-129f-08d67d36ce02 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(7168020)(4627221)(201703031133081)(201702281549075)(8990200)(5600109)(711020)(4618075)(2017052603328)(7153060)(7193020); SRVR:BYAPR04MB4197; x-ms-traffictypediagnostic: BYAPR04MB4197: wdcipoutbound: EOP-TRUE x-microsoft-antispam-prvs: x-forefront-prvs: 0921D55E4F x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(136003)(39860400002)(366004)(376002)(396003)(346002)(189003)(199004)(81156014)(81166006)(14454004)(8676002)(7736002)(4326008)(39060400002)(305945005)(36756003)(478600001)(68736007)(8936002)(50226002)(97736004)(2906002)(256004)(25786009)(476003)(486006)(2616005)(105586002)(72206003)(6436002)(6486002)(6512007)(44832011)(1076003)(110136005)(54906003)(71190400001)(71200400001)(106356001)(316002)(386003)(6116002)(76176011)(102836004)(6506007)(26005)(55236004)(186003)(11346002)(53936002)(3846002)(446003)(86362001)(7416002)(52116002)(5660300001)(99286004)(66066001); DIR:OUT; SFP:1102; SCL:1; SRVR:BYAPR04MB4197; H:BYAPR04MB5303.namprd04.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: LEOBf5tZVniukuYEVuSyWJq6BVLq5ULFzyQdUB2fljZpEPT4/uVmn+urFu6KH6xY9mkSpDr1YkZ5+FoEmPX5WqPWouoO4igoaiO05tA0aFGgjkoQzryRNat7qZYjoKO4H0sUqVrwqD/7nomzTCRVeB4RFE+5KLHAiinuFmVi74t7ybSxt6mXsie7eLhBgCNsS+n9vrV8Wp2ajLqpXn0F8PdKHFyn1f6WjzX6PvMxvSr37zrXoDn99CalXJFlCYWjHbe8imahzA951WS67aQ2sJf2J+ER4NWT7uUyweJxjt6XRg4bNVbbOdNLpoijiUhY6mDXgZgnFNRsELQZY9fnRy1DKe2yVEAwtutk08j5JSSffRxJOd8tOCCt14AaBJCG51ap1bV+lR9ed+1plp/oFJ4CDZuZ0AGLuUvI+FunNas= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: wdc.com X-MS-Exchange-CrossTenant-Network-Message-Id: 7250ed5f-2972-4f02-129f-08d67d36ce02 X-MS-Exchange-CrossTenant-originalarrivaltime: 18 Jan 2019 11:19:22.5108 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: b61c8803-16f3-4c35-9b17-6f65f441df86 X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR04MB4197 Cc: Palmer Dabbelt , U-Boot Mailing List , Alexander Graf , Christoph Hellwig , Paul Walmsley Subject: [U-Boot] [PATCH v2 09/11] drivers: serial_sifive: Skip baudrate config if no input clock X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 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" From: Atish Patra It is possible that input clock is not available because clk device was not available and 'clock-frequency' DT property is also not available. In this case, instead of failing we should just skip baudrate config by returning zero. Signed-off-by: Atish Patra Signed-off-by: Anup Patel Reviewed-by: Alexander Graf --- drivers/serial/serial_sifive.c | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/drivers/serial/serial_sifive.c b/drivers/serial/serial_sifive.c index ea4d35d48c..537bc7a975 100644 --- a/drivers/serial/serial_sifive.c +++ b/drivers/serial/serial_sifive.c @@ -99,27 +99,27 @@ static int _sifive_serial_getc(struct uart_sifive *regs) static int sifive_serial_setbrg(struct udevice *dev, int baudrate) { - int err; + int ret; struct clk clk; struct sifive_uart_platdata *platdata = dev_get_platdata(dev); + u32 clock = 0; - err = clk_get_by_index(dev, 0, &clk); - if (!err) { - err = clk_get_rate(&clk); - if (!IS_ERR_VALUE(err)) - platdata->clock = err; - } else if (err != -ENOENT && err != -ENODEV && err != -ENOSYS) { + ret = clk_get_by_index(dev, 0, &clk); + if (IS_ERR_VALUE(ret)) { debug("SiFive UART failed to get clock\n"); - return err; - } - - if (!platdata->clock) - platdata->clock = dev_read_u32_default(dev, "clock-frequency", 0); - if (!platdata->clock) { - debug("SiFive UART clock not defined\n"); - return -EINVAL; + ret = dev_read_u32(dev, "clock-frequency", &clock); + if (IS_ERR_VALUE(ret)) { + debug("SiFive UART clock not defined\n"); + return 0; + } + } else { + clock = clk_get_rate(&clk); + if (IS_ERR_VALUE(clock)) { + debug("SiFive UART clock get rate failed\n"); + return 0; + } } - + platdata->clock = clock; _sifive_serial_setbrg(platdata->regs, platdata->clock, baudrate); return 0; From patchwork Fri Jan 18 11:19:30 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anup Patel X-Patchwork-Id: 1027224 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=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=wdc.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=wdc.com header.i=@wdc.com header.b="eyMK6a6M"; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=sharedspace.onmicrosoft.com header.i=@sharedspace.onmicrosoft.com header.b="dnMhejOW"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 43gzBQ1p0Xz9sCs for ; Fri, 18 Jan 2019 22:25:02 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id C57F6C220D6; Fri, 18 Jan 2019 11:22:45 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=KHOP_BIG_TO_CC, T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 96AB8C21E74; Fri, 18 Jan 2019 11:21:30 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 6C522C21E13; Fri, 18 Jan 2019 11:19:37 +0000 (UTC) Received: from esa5.hgst.iphmx.com (esa5.hgst.iphmx.com [216.71.153.144]) by lists.denx.de (Postfix) with ESMTPS id 8E58FC220BB for ; Fri, 18 Jan 2019 11:19:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1547810374; x=1579346374; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=8vRAvQuFS8l5cJUScEwF1zqozYOyphpdu3sp+7FWWzQ=; b=eyMK6a6M8Wz47CVKOOeywWpwN4tX3+ugI1Vb0L5ihx9nTRJbKjVSIMzE w1QiSvT8BJZJXnXBWI5GD2WHtOOV+I1EXdtPx/Dpnawn58fClW0SIdcxU pf2LZ4rl6Xl6QApVLG3zhRNokM88xbnrieD4rXVvbzg5hQQC5/5qeHQBD hYSmK72aD+mRq9g3IJbaSBRDCHRC7/pM7ZDD7MESFxVWxp4xDMs3CdqzI lVCvzyROot83pWJuZd/JNQfkRliUVL9hMwNtcztksltpMpXNIH1Vzvd60 8eCRAxEvgC8vO2RXS+3rLqhyaghklr88lcf+Fczz91eIk8H65XxcHWaUm A==; X-IronPort-AV: E=Sophos;i="5.56,491,1539619200"; d="scan'208";a="100370996" Received: from mail-sn1nam02lp2056.outbound.protection.outlook.com (HELO NAM02-SN1-obe.outbound.protection.outlook.com) ([104.47.36.56]) by ob1.hgst.iphmx.com with ESMTP; 18 Jan 2019 19:19:32 +0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sharedspace.onmicrosoft.com; s=selector1-wdc-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=wXO//Kfin1gKj/p0yKbWUyJRtCa0TcduIQBkAaUkopc=; b=dnMhejOW6wFXBDVxtCdDvgeZ/L86Oa5wc2fLKyd8OL0fDMCVgBKg9m9EkkH2/Ps2HG7KcPxkk6Quqw7hcw4nT0kV/9/bmZCpDmS1Y2BGImw9zrDl7qIxGptxGvOFFrl7jdNEX3nISjfgaCW+HfFi22Ne+BDTY7etWl1OXvpJdOk= Received: from BYAPR04MB5303.namprd04.prod.outlook.com (20.178.49.148) by BYAPR04MB4197.namprd04.prod.outlook.com (20.176.250.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1537.24; Fri, 18 Jan 2019 11:19:30 +0000 Received: from BYAPR04MB5303.namprd04.prod.outlook.com ([fe80::add1:92cc:65d7:5d94]) by BYAPR04MB5303.namprd04.prod.outlook.com ([fe80::add1:92cc:65d7:5d94%2]) with mapi id 15.20.1537.018; Fri, 18 Jan 2019 11:19:30 +0000 From: Anup Patel To: Rick Chen , Bin Meng , Joe Hershberger , Lukas Auer , Masahiro Yamada , Simon Glass Thread-Topic: [PATCH v2 10/11] cpu: Bind timer driver for boot hart Thread-Index: AQHUrx+uEDn2jxI+dk2pvqMhGC/O6g== Date: Fri, 18 Jan 2019 11:19:30 +0000 Message-ID: <20190118111820.71349-11-anup.patel@wdc.com> References: <20190118111820.71349-1-anup.patel@wdc.com> In-Reply-To: <20190118111820.71349-1-anup.patel@wdc.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: MA1PR01CA0115.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a00:1::31) To BYAPR04MB5303.namprd04.prod.outlook.com (2603:10b6:a03:c8::20) authentication-results: spf=none (sender IP is ) smtp.mailfrom=Anup.Patel@wdc.com; x-ms-exchange-messagesentrepresentingtype: 1 x-mailer: git-send-email 2.17.1 x-originating-ip: [49.207.48.211] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; BYAPR04MB4197; 6:RxVeZ1GM3RQfszerprTnUhvV7wosMBNGjg4dsm3heBohh76PS/YCj4/hrIiAAKdN96Rg8Z+nAShWLLKRilZ3vXVOwcb/pIBY68FIIa+9d56FBdtaQk0J3T0Yrf4qMIjr0DdbUoTUZsM9u7v9FTlhBN/tzv9t5f+BET24UsA8BjxAN2EF4epNrkhGdL4b/5YmmUApjr1oWufAw5WhKVfvu/hsawM9BP1F+rxX5oCUE/LPrGmdu3StO8VLWcvbnNNcD2J59XJzXx+0mrD1yGJbbKLlHVdpl4kT8ENSKTrT4w9o63Y1z6Nfb0B/fujWDgo7UlVbPNWa/tlZ44s5MnbLrK2CMJ42O3jYoSmaqBEdadb95BL/DLCMj9ycfI0CoSPayQutBOstpY0GmNA62UEwv5ZgAhS1OvoToWX1nkj+WTQ2HXxEUmp6ix2L3mpg3HbvG1b0D+/u8Gzi0XrVk0FDbA==; 5:/8K2v80OUC4GAs+ibohB3MRCVNHOOOkzt6IffkDZJj6pp1OCddujRHjHu112uwPFvXrM8OV+LUSHurNnQv0N/gy3GL9H9ijumnTtRSOGwiQByXSTY6Wbz3+O/15zUS8Xbrj6B+pqUkQDXoSsXWZgKj6wXg0YylRyk95wwR/Mf1Ggy1g9ipDZYudqqnkCHWletrTPx91yX+2CfuVZzadU6g==; 7:ChxPwWpf5CEOhZGiy/k11XTLk6vY/cbIQVY5rhhp+idJVMJGxaLro4KEcqoJHnxXS4ZOg1jTolfcyCRvnXMDTmE+e5ELpmTBARLxdvPjn9OMjLf1MN/qptVhglCzDwIvC6ZE8kq1Omk5rx5o8SecKQ== x-ms-office365-filtering-correlation-id: 47852459-ed8d-4820-68da-08d67d36d0a2 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(7168020)(4627221)(201703031133081)(201702281549075)(8990200)(5600109)(711020)(4618075)(2017052603328)(7153060)(7193020); SRVR:BYAPR04MB4197; x-ms-traffictypediagnostic: BYAPR04MB4197: wdcipoutbound: EOP-TRUE x-microsoft-antispam-prvs: x-forefront-prvs: 0921D55E4F x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(136003)(39860400002)(366004)(376002)(396003)(346002)(189003)(199004)(81156014)(81166006)(14454004)(8676002)(7736002)(4326008)(39060400002)(305945005)(36756003)(478600001)(68736007)(8936002)(50226002)(97736004)(2906002)(256004)(25786009)(476003)(486006)(2616005)(105586002)(72206003)(6436002)(6486002)(6512007)(44832011)(1076003)(110136005)(54906003)(71190400001)(71200400001)(106356001)(316002)(386003)(6116002)(76176011)(102836004)(6506007)(26005)(55236004)(186003)(11346002)(53936002)(3846002)(446003)(86362001)(7416002)(52116002)(5660300001)(99286004)(66066001); DIR:OUT; SFP:1102; SCL:1; SRVR:BYAPR04MB4197; H:BYAPR04MB5303.namprd04.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: xOOEhvSXuUqUtlx9tq2JlRN2Mj36q1IY6lG+9XcBdSH8N0+VChSEaWtrZHRa3b9raO3+36gesLWWNa+nYgNtAIOQv+8ayYqe8CKkid4YKwFLBNXGT6UWdPMZFgUdcBfH8pvsnIUHW73FWzkO+YTUjdCprg9eFCdmCChcWX8DkOWXXUaJSikj335jK/mdmsNIdgi+rihcYjvS9CyqIBUR/HumkvfX2HrRUMaeHnHIpJA9oWcNMzxvWou11Ymi3lOJq2tKTnUD4XyUxy3qihMT6ZBlma3XmfiFj9Hrr/XDW0T6xAMgELtxPlj5etZhaKnRJUjHDA/FK6726jbJgN2dJpeWl4ZmaNTDmGsuiE0sfxPkDhFzRoFG7dD/IJhBmuAxoQmYOArq68fWuK9FzSlb75sLUOmVKj1G++A34sRwuuI= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: wdc.com X-MS-Exchange-CrossTenant-Network-Message-Id: 47852459-ed8d-4820-68da-08d67d36d0a2 X-MS-Exchange-CrossTenant-originalarrivaltime: 18 Jan 2019 11:19:26.9014 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: b61c8803-16f3-4c35-9b17-6f65f441df86 X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR04MB4197 Cc: Palmer Dabbelt , U-Boot Mailing List , Alexander Graf , Christoph Hellwig , Paul Walmsley Subject: [U-Boot] [PATCH v2 10/11] cpu: Bind timer driver for boot hart X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 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" From: Atish Patra Currently, timer driver is bound only for hart0. There is no mandatory requirement that hart0 should always come up. In fact, HiFive Unleashed SoC hart0 doesn't boot in S-mode because it only has M-mode. The timer driver should be bound for boot hart. Signed-off-by: Atish Patra Reviewed-by: Alexander Graf Reviewed-by: Lukas Auer Reviewed-by: Bin Meng --- drivers/cpu/riscv_cpu.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/cpu/riscv_cpu.c b/drivers/cpu/riscv_cpu.c index 5e15df590e..f77c126499 100644 --- a/drivers/cpu/riscv_cpu.c +++ b/drivers/cpu/riscv_cpu.c @@ -10,6 +10,8 @@ #include #include +DECLARE_GLOBAL_DATA_PTR; + static int riscv_cpu_get_desc(struct udevice *dev, char *buf, int size) { const char *isa; @@ -62,7 +64,6 @@ static int riscv_cpu_bind(struct udevice *dev) /* save the hart id */ plat->cpu_id = dev_read_addr(dev); - /* first examine the property in current cpu node */ ret = dev_read_u32(dev, "timebase-frequency", &plat->timebase_freq); /* if not found, then look at the parent /cpus node */ @@ -71,7 +72,7 @@ static int riscv_cpu_bind(struct udevice *dev) &plat->timebase_freq); /* - * Bind riscv-timer driver on hart 0 + * Bind riscv-timer driver on boot hart. * * We only instantiate one timer device which is enough for U-Boot. * Pass the "timebase-frequency" value as the driver data for the @@ -80,7 +81,7 @@ static int riscv_cpu_bind(struct udevice *dev) * Return value is not checked since it's possible that the timer * driver is not included. */ - if (!plat->cpu_id && plat->timebase_freq) { + if (plat->cpu_id == gd->arch.boot_hart && plat->timebase_freq) { drv = lists_driver_lookup_name("riscv_timer"); if (!drv) { debug("Cannot find the timer driver, not included?\n"); From patchwork Fri Jan 18 11:19:34 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anup Patel X-Patchwork-Id: 1027229 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=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=wdc.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=wdc.com header.i=@wdc.com header.b="E7j7alSg"; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=sharedspace.onmicrosoft.com header.i=@sharedspace.onmicrosoft.com header.b="KLyCr98s"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 43gzCN4DFxz9sBQ for ; Fri, 18 Jan 2019 22:25:52 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id 1CC83C220F0; Fri, 18 Jan 2019 11:23:02 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=KHOP_BIG_TO_CC, T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 0E345C21E2F; Fri, 18 Jan 2019 11:21:55 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id BF711C220D6; Fri, 18 Jan 2019 11:19:43 +0000 (UTC) Received: from esa4.hgst.iphmx.com (esa4.hgst.iphmx.com [216.71.154.42]) by lists.denx.de (Postfix) with ESMTPS id 024F3C220BB for ; Fri, 18 Jan 2019 11:19:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1547810381; x=1579346381; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=Lhp+MGjWluyAMWpF2NxyEjaIzDU13aDr3iQH+PudOO4=; b=E7j7alSgmFt5XD+LcWj2jjnybimpUqnz45hOybCxubtEON/Xaad4cZWV recX/oSR61VONdS7F5SVqG0R02O6ljn73XygAaXCa9s/RC+mVjChzaZjM xf9YhOxIi7zMp//mhb3l2VqHRRr1eHRPJcqVO9yhANC2K6MH78YdWSU9x EUtG1Io1lusk2pEPGVO6DmKlQcaBC6R0nAAB0pbouZmU825ZfuEOCr3uU WS8J5CK6EFIgSzdm9gcLZfOfnAbci2MaLgQC8+BgqzDbiljhzgmVTdLJ5 eQ3XBHQ7F+Xf4P6U46jYQ7p9yFv3ptYxyfFUM3DloVKaDDCOoQ+1jm87a A==; X-IronPort-AV: E=Sophos;i="5.56,491,1539619200"; d="scan'208";a="99188388" Received: from mail-sn1nam02lp2057.outbound.protection.outlook.com (HELO NAM02-SN1-obe.outbound.protection.outlook.com) ([104.47.36.57]) by ob1.hgst.iphmx.com with ESMTP; 18 Jan 2019 19:19:38 +0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sharedspace.onmicrosoft.com; s=selector1-wdc-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=5qEOaLXW+QVskPcTfcANKCZRG5Fc7FJqN8i5l3pqvik=; b=KLyCr98s9CGz2+donjbIV2njM8Pvg5TKCgTQ7JsJXx5KuF5o4TcF/s+4fYHMflW8grcF2xaPazTPx79ZFiNMR6iktgyNiiyXM5VNt1R8za6EkvTkrsLASqMluh/QEysK+rcTfsB5LPdaV4nb1d8+FsFUgfkEK8Uv8GxA/B4SdRs= Received: from BYAPR04MB5303.namprd04.prod.outlook.com (20.178.49.148) by BYAPR04MB4197.namprd04.prod.outlook.com (20.176.250.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1537.24; Fri, 18 Jan 2019 11:19:34 +0000 Received: from BYAPR04MB5303.namprd04.prod.outlook.com ([fe80::add1:92cc:65d7:5d94]) by BYAPR04MB5303.namprd04.prod.outlook.com ([fe80::add1:92cc:65d7:5d94%2]) with mapi id 15.20.1537.018; Fri, 18 Jan 2019 11:19:34 +0000 From: Anup Patel To: Rick Chen , Bin Meng , Joe Hershberger , Lukas Auer , Masahiro Yamada , Simon Glass Thread-Topic: [PATCH v2 11/11] riscv: Add SiFive FU540 board support Thread-Index: AQHUrx+w1t25kzeq1EexUvBtr70f1g== Date: Fri, 18 Jan 2019 11:19:34 +0000 Message-ID: <20190118111820.71349-12-anup.patel@wdc.com> References: <20190118111820.71349-1-anup.patel@wdc.com> In-Reply-To: <20190118111820.71349-1-anup.patel@wdc.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: MA1PR01CA0115.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a00:1::31) To BYAPR04MB5303.namprd04.prod.outlook.com (2603:10b6:a03:c8::20) authentication-results: spf=none (sender IP is ) smtp.mailfrom=Anup.Patel@wdc.com; x-ms-exchange-messagesentrepresentingtype: 1 x-mailer: git-send-email 2.17.1 x-originating-ip: [49.207.48.211] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; BYAPR04MB4197; 6:0VSQBk1jHy+8LUlmAnXfAzDRjLd2U1i/jdG7IQJPZphjV2e/AzixHZI/aMzv5jY6bMCaiQvrgGCEhak2AwDx2K67PCl6TPXEZzD5jqxYXvEUUU1niV34DTWlGZ9EDhnhUyYXe8soUftw1u2aLKMUgRkXTSMbVR6qadiVsBBAi39jCtfJhHy+SRVedfIxrl0H6mrjwtwGm+eOhIp/UYzVME81Q4sP7BPqaGSra5Hu6OH+yQFPuiqpzS9zqGL7Mir2k56HJ7vi0mXDq/n2s2+IccB/k/RXTBm8RrQ9rV+FIFBn7HFxiLD+aL+mYpm9F6ibzkru74nwbdv/SAMt5bR71gSxMGRHgwzAwMmPYH/FD7sfzOMTyk1fX2fMLMeriK+jwkcAThSBST74/afpe/9Ul10S8CCreCVZqIr4AqH0ZJ4DzD3SYHHVASpbpXrDqnZFQvlvuhT0YJreJXoaCtwgig==; 5:RxFevST3D9gyUWko1+5qDsKqvvnNuV0/jIvH4qnCz1a7NYwj3VizhhgZTk3d9JHuad7fqGJ+8xNDS22OI49UM0g3HAWBjYAZwzyhVudc1FXOsu0aEdp9XrAxLVaLH4tmeVSOtnIvfwrCIGwnB2JmWDnH7sv4msSxZRk/fxWvgimbMaP3G9hr9U/9dCXxkXrS6or6WPzKa1QMwqJOTLOO+Q==; 7:p27nQ33NB9Lhvv2KVhxVwMdYvJ8uxsamImOmW+FPflbx0lPJ/RFE0c7L6L0JCt3dRPLSTMoPlEbYmeQQL7Y/70gU8X5CO1k7vGoNBJtDJeQfzYjlgIU0nd5CAjse2CcYk42RvgFMm7oTkp4AMThEdg== x-ms-office365-filtering-correlation-id: 71531f44-d989-492b-ab7e-08d67d36d34e x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(7168020)(4627221)(201703031133081)(201702281549075)(8990200)(5600109)(711020)(4618075)(2017052603328)(7153060)(7193020); SRVR:BYAPR04MB4197; x-ms-traffictypediagnostic: BYAPR04MB4197: wdcipoutbound: EOP-TRUE x-microsoft-antispam-prvs: x-forefront-prvs: 0921D55E4F x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(6029001)(136003)(39860400002)(366004)(376002)(396003)(346002)(189003)(199004)(81156014)(81166006)(14454004)(8676002)(7736002)(4326008)(39060400002)(305945005)(36756003)(478600001)(68736007)(8936002)(50226002)(97736004)(2906002)(256004)(25786009)(476003)(486006)(2616005)(105586002)(72206003)(6436002)(6486002)(6512007)(44832011)(1076003)(110136005)(54906003)(71190400001)(71200400001)(106356001)(316002)(386003)(6116002)(76176011)(102836004)(6506007)(26005)(55236004)(186003)(11346002)(53936002)(3846002)(446003)(86362001)(7416002)(52116002)(5660300001)(99286004)(66066001); DIR:OUT; SFP:1102; SCL:1; SRVR:BYAPR04MB4197; H:BYAPR04MB5303.namprd04.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: mN6XW6GRt0XRDVBGreR9b1hIDK1p4Q5H24x4wa3CwXX55ZBSfNLG/7X75U4kQLBBFC1/jxFkehPvLO115fjLebVL/zxvf/+TFxy+MePrKq86ngYJFTmXbvbgiR76vQAjtj41hUZm9Q0OR5/z47SmVOqF5E2CUERBrd2cZTBhLAKNCdjhbF5V1Mu3NPCHxvBvSCdcdwBDfd346+qFM2P+c0eQjkyNax45j2yutfI39hbQOEEi137642+Lqo9bvNdoR/9XjgFLFqde/Y2TuLpdrOI19prkseM171lsHyGkJ3FpCR3EXo88UvahEIw3nDRhoOg+5fxamnG9nFJqxspUQl7+Gus65QnKiw5wacBjvUHhjR4tXXrpsEw/SkzS82ZGA5a16vtA1FNi7K/pCscp5d/OV67xm9RLimQXK76L6TY= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: wdc.com X-MS-Exchange-CrossTenant-Network-Message-Id: 71531f44-d989-492b-ab7e-08d67d36d34e X-MS-Exchange-CrossTenant-originalarrivaltime: 18 Jan 2019 11:19:31.3858 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: b61c8803-16f3-4c35-9b17-6f65f441df86 X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR04MB4197 Cc: Palmer Dabbelt , U-Boot Mailing List , Alexander Graf , Christoph Hellwig , Paul Walmsley Subject: [U-Boot] [PATCH v2 11/11] riscv: Add SiFive FU540 board support X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 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" This patch adds SiFive FU540 board support. For now, only SiFive serial, SiFive PRCI, and Cadance MACB drivers are only enabled. The SiFive FU540 defconfig by default builds U-Boot for S-Mode because U-Boot on SiFive FU540 will run in S-Mode as payload of BBL or OpenSBI. Signed-off-by: Atish Patra Signed-off-by: Anup Patel Reviewed-by: Alexander Graf Reviewed-by: Lukas Auer Reviewed-by: Bin Meng --- arch/riscv/Kconfig | 4 ++++ board/sifive/fu540/Kconfig | 42 +++++++++++++++++++++++++++++++++ board/sifive/fu540/MAINTAINERS | 9 +++++++ board/sifive/fu540/Makefile | 5 ++++ board/sifive/fu540/fu540.c | 17 ++++++++++++++ configs/sifive_fu540_defconfig | 11 +++++++++ include/configs/sifive-fu540.h | 43 ++++++++++++++++++++++++++++++++++ 7 files changed, 131 insertions(+) create mode 100644 board/sifive/fu540/Kconfig create mode 100644 board/sifive/fu540/MAINTAINERS create mode 100644 board/sifive/fu540/Makefile create mode 100644 board/sifive/fu540/fu540.c create mode 100644 configs/sifive_fu540_defconfig create mode 100644 include/configs/sifive-fu540.h diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig index 6879047ff7..36512a8995 100644 --- a/arch/riscv/Kconfig +++ b/arch/riscv/Kconfig @@ -14,11 +14,15 @@ config TARGET_AX25_AE350 config TARGET_QEMU_VIRT bool "Support QEMU Virt Board" +config TARGET_SIFIVE_FU540 + bool "Support SiFive FU540 Board" + endchoice # board-specific options below source "board/AndesTech/ax25-ae350/Kconfig" source "board/emulation/qemu-riscv/Kconfig" +source "board/sifive/fu540/Kconfig" # platform-specific options below source "arch/riscv/cpu/ax25/Kconfig" diff --git a/board/sifive/fu540/Kconfig b/board/sifive/fu540/Kconfig new file mode 100644 index 0000000000..6be3d88144 --- /dev/null +++ b/board/sifive/fu540/Kconfig @@ -0,0 +1,42 @@ +if TARGET_SIFIVE_FU540 + +config SYS_BOARD + default "fu540" + +config SYS_VENDOR + default "sifive" + +config SYS_CPU + default "generic" + +config SYS_CONFIG_NAME + default "sifive-fu540" + +config SYS_TEXT_BASE + default 0x80000000 if !RISCV_SMODE + default 0x80200000 if RISCV_SMODE + +config BOARD_SPECIFIC_OPTIONS # dummy + def_bool y + select GENERIC_RISCV + imply CMD_DHCP + imply CMD_EXT2 + imply CMD_EXT4 + imply CMD_FAT + imply CMD_FS_GENERIC + imply CMD_NET + imply CMD_PING + imply CLK_SIFIVE + imply CLK_SIFIVE_FU540_PRCI + imply DOS_PARTITION + imply EFI_PARTITION + imply IP_DYN + imply ISO_PARTITION + imply MACB + imply MII + imply NET_RANDOM_ETHADDR + imply PHY_LIB + imply PHY_MSCC + imply SIFIVE_SERIAL + +endif diff --git a/board/sifive/fu540/MAINTAINERS b/board/sifive/fu540/MAINTAINERS new file mode 100644 index 0000000000..702d803ad8 --- /dev/null +++ b/board/sifive/fu540/MAINTAINERS @@ -0,0 +1,9 @@ +SiFive FU540 BOARD +M: Paul Walmsley +M: Palmer Dabbelt +M: Anup Patel +M: Atish Patra +S: Maintained +F: board/sifive/fu540/ +F: include/configs/sifive-fu540.h +F: configs/sifive_fu540_defconfig diff --git a/board/sifive/fu540/Makefile b/board/sifive/fu540/Makefile new file mode 100644 index 0000000000..6e1862c475 --- /dev/null +++ b/board/sifive/fu540/Makefile @@ -0,0 +1,5 @@ +# SPDX-License-Identifier: GPL-2.0+ +# +# Copyright (c) 2019 Western Digital Corporation or its affiliates. + +obj-y += fu540.o diff --git a/board/sifive/fu540/fu540.c b/board/sifive/fu540/fu540.c new file mode 100644 index 0000000000..5adc4a3d4a --- /dev/null +++ b/board/sifive/fu540/fu540.c @@ -0,0 +1,17 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Copyright (c) 2019 Western Digital Corporation or its affiliates. + * + * Authors: + * Anup Patel + */ + +#include +#include + +int board_init(void) +{ + /* For now nothing to do here. */ + + return 0; +} diff --git a/configs/sifive_fu540_defconfig b/configs/sifive_fu540_defconfig new file mode 100644 index 0000000000..2f8cca9de0 --- /dev/null +++ b/configs/sifive_fu540_defconfig @@ -0,0 +1,11 @@ +CONFIG_RISCV=y +CONFIG_TARGET_SIFIVE_FU540=y +CONFIG_RISCV_SMODE=y +CONFIG_ARCH_RV64I=y +CONFIG_DISTRO_DEFAULTS=y +CONFIG_NR_DRAM_BANKS=1 +CONFIG_FIT=y +CONFIG_DISPLAY_CPUINFO=y +CONFIG_DISPLAY_BOARDINFO=y +CONFIG_CMD_MII=y +CONFIG_OF_PRIOR_STAGE=y diff --git a/include/configs/sifive-fu540.h b/include/configs/sifive-fu540.h new file mode 100644 index 0000000000..7007b5f6af --- /dev/null +++ b/include/configs/sifive-fu540.h @@ -0,0 +1,43 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* + * Copyright (c) 2019 Western Digital Corporation or its affiliates. + * + * Authors: + * Anup Patel + */ + +#ifndef __CONFIG_H +#define __CONFIG_H + +#include + +#define CONFIG_SYS_SDRAM_BASE 0x80000000 +#define CONFIG_SYS_INIT_SP_ADDR (CONFIG_SYS_SDRAM_BASE + SZ_2M) + +#define CONFIG_SYS_LOAD_ADDR (CONFIG_SYS_SDRAM_BASE + SZ_2M) + +#define CONFIG_SYS_MALLOC_LEN SZ_8M + +#define CONFIG_SYS_BOOTM_LEN SZ_16M + +#define CONFIG_STANDALONE_LOAD_ADDR 0x80200000 + +/* Environment options */ +#define CONFIG_ENV_SIZE SZ_4K + +#define BOOT_TARGET_DEVICES(func) \ + func(DHCP, dhcp, na) + +#include + +#define CONFIG_EXTRA_ENV_SETTINGS \ + "fdt_high=0xffffffffffffffff\0" \ + "initrd_high=0xffffffffffffffff\0" \ + "kernel_addr_r=0x80600000\0" \ + "fdt_addr_r=0x82200000\0" \ + "scriptaddr=0x82300000\0" \ + "pxefile_addr_r=0x82400000\0" \ + "ramdisk_addr_r=0x82500000\0" \ + BOOTENV + +#endif /* __CONFIG_H */