From patchwork Thu Jan 17 10:38:22 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anup Patel X-Patchwork-Id: 1026599 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="JLpJc5SU"; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=sharedspace.onmicrosoft.com header.i=@sharedspace.onmicrosoft.com header.b="K/WqV5OE"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 43gNZp0z9Xz9sBQ for ; Thu, 17 Jan 2019 23:25:37 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id 99E87C220D0; Thu, 17 Jan 2019 12:23: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 7752BC220ED; Thu, 17 Jan 2019 12:20:50 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 483D2C21D8A; Thu, 17 Jan 2019 10:38:27 +0000 (UTC) Received: from esa2.hgst.iphmx.com (esa2.hgst.iphmx.com [68.232.143.124]) by lists.denx.de (Postfix) with ESMTPS id 8B913C21D4A for ; Thu, 17 Jan 2019 10:38:26 +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=1547721512; x=1579257512; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=auurU12NS1maaas1mLWJhujZVECMUYSyMKlLhVVNbwY=; b=JLpJc5SUvKLCru4zGhZkKyiWlJUMX99o4Eta6qnGdVH+r0VfdbmCDGVY cEBN7IRF+gSY+jlnYdy4rqTEMHxchfrHSrgLVHJp1n8uZuV5GHzFX4SQd YUI5wl/moIFk4ZEBeD8y1Ccq0FZNg731pF5keF5lvM9CyhtuurlVyTeA6 3ujBN2ydY9FtokMU6xnLEKysn7yqYzkxrG5eNhb4TIWzIF6gcGfvBq/p3 cLyFjfr3E+FkBtfmdeZEvL6uAetA4CC4iKhu2IldBXLc+9c7iiAxR4zkk ORSKMV8OCJzkfVrYPLmN/cMW+umNdDIpVVZPd4tsUwSJCIahPO9i5HmmC A==; X-IronPort-AV: E=Sophos;i="5.56,488,1539619200"; d="scan'208";a="197089579" Received: from mail-bn3nam01lp2051.outbound.protection.outlook.com (HELO NAM01-BN3-obe.outbound.protection.outlook.com) ([104.47.33.51]) by ob1.hgst.iphmx.com with ESMTP; 17 Jan 2019 18:38:29 +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=49pZaw41ADwu7SWbErcOrggwkcik05tNY6qzlN+PZvs=; b=K/WqV5OEKC9GMnk2QvLgmkupsFv41eCevJuFp0+Io4Iqk8euIORREp/w1XzaXEyEQy4X0uOyQcHkW9wyxBKweIsibR4exXXY1rdGcbXBaEyhrXeb1OPivPHyYqwDDBP48rW+Ubkdkc7khWy4bXgMMQtbVzKVZw+l1lExMRn90HQ= Received: from BYAPR04MB5303.namprd04.prod.outlook.com (20.178.49.148) by BYAPR04MB6167.namprd04.prod.outlook.com (20.178.235.15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1537.26; Thu, 17 Jan 2019 10:38:22 +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; Thu, 17 Jan 2019 10:38:22 +0000 From: Anup Patel To: Rick Chen , Bin Meng , Joe Hershberger , Lukas Auer , Masahiro Yamada , Simon Glass Thread-Topic: [PATCH 01/11] riscv: Rename cpu/qemu to cpu/generic Thread-Index: AQHUrlDEOph2vF6bQkqXHTUfHB7idQ== Date: Thu, 17 Jan 2019 10:38:22 +0000 Message-ID: <20190117103748.36613-2-anup.patel@wdc.com> References: <20190117103748.36613-1-anup.patel@wdc.com> In-Reply-To: <20190117103748.36613-1-anup.patel@wdc.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: MA1PR0101CA0069.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a00:20::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: [106.51.16.164] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; BYAPR04MB6167; 6:1EP+VrE5FE8eEtg+GuTpQ+qZB96B5JgI4h+SFZ6MKwTYNx5/9c5pTWQZrWp2St2BBmQ5RNdeNyGWbUp92beOjj9Yn7pbrKogGBNRzYXAxQxeRP6UeIy1k5XWfULcv4TUnafZ0CSwc8xpcC4njAhsEnsdSlo/l3bqpKymMsnShm2TBNx0b1kD43Y4SeLpOqu19JWz0BSJ063iKnj7vf2XyaCmA+8o6GI0/TYF3KXON++lYV3AFpoXWQWYajy4NPEADsSJZFCq1Nk192c3t42ZkjYkeQZP74vVtGPRgrFUcHyfbr3Yf5UeZJW+C1OJWzC1S/2LA86CbjAOIipC+WeBktPWFm0LXuF1FKp7hfg+e7SPB1VHvTPJfRVsPisr/Fh/TrYZUuE3umn06ubr7fGzka/ODf92P0n2mn44qRqLuwaznyEzubGqmZGyNKVbB5wjeh5IFxIVOITN5n3CgeRX+Q==; 5:7wqP7v39dAIH3uswdLCCya9NRzVTeKOS4KPoSgx9NbN2LGMbm7dpSS04/l1a8tmrJ03kxKa6U9FA7DB1Hy6jPBW8M+4Fth5T2MKGTeXuYrG1Zyfj83bU740692eK4HY7OxAkiMN+5UKS5ldv/Yl8u40we0SzwyxUB2s9ls5IEw4tO1Zd7m8aPdFtbTfKmECxqadLCKo8OM/sl8Yp7LhDIg==; 7:TBwA9UkL3LcoZHnuCHxRjUdvVZuXBTJQgCe6O+Ler53gAO1Aeh7BogBax82IYs2e9eQI5wsOE+sptnWdhYWLZo6kzZ9FNVJasp24OOhYYNwnuuU4c7WQZBkQ8gnzl+pqUHh7ctbahUi22UXyZTq7eQ== x-ms-office365-filtering-correlation-id: f67bd785-1764-4284-591c-08d67c67e708 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(5600109)(711020)(4618075)(4534185)(7168020)(4627221)(201703031133081)(201702281549075)(8990200)(2017052603328)(7153060)(7193020); SRVR:BYAPR04MB6167; x-ms-traffictypediagnostic: BYAPR04MB6167: wdcipoutbound: EOP-TRUE x-microsoft-antispam-prvs: x-forefront-prvs: 0920602B08 x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(346002)(376002)(366004)(136003)(39860400002)(396003)(199004)(189003)(78486014)(14454004)(256004)(1076003)(72206003)(478600001)(66066001)(36756003)(86362001)(44832011)(6116002)(105586002)(7416002)(106356001)(3846002)(5660300001)(99286004)(476003)(2616005)(26005)(110136005)(11346002)(446003)(2906002)(316002)(25786009)(52116002)(305945005)(6486002)(6436002)(102836004)(53936002)(6506007)(486006)(54906003)(186003)(386003)(68736007)(39060400002)(9456002)(50226002)(4326008)(71190400001)(6512007)(97736004)(81156014)(81166006)(8936002)(76176011)(7736002)(55236004)(8676002)(71200400001)(41533002); DIR:OUT; SFP:1102; SCL:1; SRVR:BYAPR04MB6167; H:BYAPR04MB5303.namprd04.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: MteD3FCJ2fk8beAk1PNNjjM0gWV17p/5CzOcgB0QJiEZjXFx/DDEbBK3GuGrLH3pQQfFNRAsBnybkySdIiIF66ViCmn68UV2FgBea1zz3T5pOC4ouSoRjMiwNQp/SZ3XE39h+7rHHOTTkwVQziwwkEeio1GIBUKKTLjohKqSDIumKOm+DlwhliZhGY8sPEW/wllYdk0UJus2hYwjUFaQHBWW3/Lbn0yXgO/njCjAA3aZcLZkk3jtR8hbTQDcleCLTxFRr8KN9yDqgtm1IEOTnB+0iRQ+hUBiWNuRfhffzxQZ0xK60S37smatDMQzgnIDzRomZNcW4+M6V6jAVRj1V/kkt20hvSaZhlbtqsPQpzyF3jLQ3c1rCha3kb8HT/q9m31r73c55IxexwrNOTntLa5kqzRaHL6wWpTa2zlVjd8= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: wdc.com X-MS-Exchange-CrossTenant-Network-Message-Id: f67bd785-1764-4284-591c-08d67c67e708 X-MS-Exchange-CrossTenant-originalarrivaltime: 17 Jan 2019 10:38:18.5781 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: b61c8803-16f3-4c35-9b17-6f65f441df86 X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR04MB6167 X-Mailman-Approved-At: Thu, 17 Jan 2019 12:20:42 +0000 Cc: Palmer Dabbelt , U-Boot Mailing List , Alexander Graf , Christoph Hellwig , Paul Walmsley Subject: [U-Boot] [PATCH 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 --- 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 Thu Jan 17 10:38:26 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anup Patel X-Patchwork-Id: 1026603 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="QG7n7ial"; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=sharedspace.onmicrosoft.com header.i=@sharedspace.onmicrosoft.com header.b="aUNh94Pq"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 43gNfl6Y44z9sBQ for ; Thu, 17 Jan 2019 23:29:03 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id 37CA0C220E5; Thu, 17 Jan 2019 12:23:22 +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 7463EC220E8; Thu, 17 Jan 2019 12:20:51 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 0DCFAC21D8A; Thu, 17 Jan 2019 10:38:33 +0000 (UTC) Received: from esa2.hgst.iphmx.com (esa2.hgst.iphmx.com [68.232.143.124]) by lists.denx.de (Postfix) with ESMTPS id 47C7FC21D4A for ; Thu, 17 Jan 2019 10:38:32 +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=1547721521; x=1579257521; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=H9Xa9aOq/AdBCfV+7yHKZRC8SwG2AaQUoNpZmRX+PB0=; b=QG7n7ialJS7Tpl7DnvBjI5cHDKElI6Xt/rdlfd9LRI2XA4uHNCNu12iX YrF7ZM10IDSbjhb/oRb/Vdy+LtZYbe6NOhaMMXeRRoa5PNtPcmitbCHax gbyOJl5ZxCEd7AWIa+ZdN6wBZM1IMaEK1bmZc+8NuJcL83hkmisCKH7kC MYLjikThSSlD8o4WSDfW/j5+RwTCbzqIl/QVJjES3hkDhyyOT1poIMhCz XCf0E8F5lsgQQ01Gdbq3SH3SJFHVKZNLXEWw+w3BonqGCjdMzO5LXQK3+ gdTwfOIYq3SiJu0kmnuThvZf9EH6QRAVOq90mwjCzvPKmi28Y3aYKpN1e A==; X-IronPort-AV: E=Sophos;i="5.56,488,1539619200"; d="scan'208";a="197089584" Received: from mail-bn3nam01lp2051.outbound.protection.outlook.com (HELO NAM01-BN3-obe.outbound.protection.outlook.com) ([104.47.33.51]) by ob1.hgst.iphmx.com with ESMTP; 17 Jan 2019 18:38:36 +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=V/nVETTlGKqG3AhOJ9naldYMzWVhLamAEY6DOi7UQQ4=; b=aUNh94Pq+tWw9RsWRk2r1F4/BqyaK49ZMKstGZTHs3Ml84ISC2IwrircuOSsfA3PtlJwyPdEMQc6ltULODe2/+hDnNshbwSorPaV279JDuerj4wuvAqLqF/n6xSg2NMvYEIhgeojkFvGw7l0Ad5TV7hAJMjbIjM2HHd0JM1I324= Received: from BYAPR04MB5303.namprd04.prod.outlook.com (20.178.49.148) by BYAPR04MB6167.namprd04.prod.outlook.com (20.178.235.15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1537.26; Thu, 17 Jan 2019 10:38:26 +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; Thu, 17 Jan 2019 10:38:26 +0000 From: Anup Patel To: Rick Chen , Bin Meng , Joe Hershberger , Lukas Auer , Masahiro Yamada , Simon Glass Thread-Topic: [PATCH 02/11] riscv: Add asm/dma-mapping.h for DMA mappings Thread-Index: AQHUrlDHUQ0txCc+t0ahZ8h5UlonXA== Date: Thu, 17 Jan 2019 10:38:26 +0000 Message-ID: <20190117103748.36613-3-anup.patel@wdc.com> References: <20190117103748.36613-1-anup.patel@wdc.com> In-Reply-To: <20190117103748.36613-1-anup.patel@wdc.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: MA1PR0101CA0069.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a00:20::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: [106.51.16.164] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; BYAPR04MB6167; 6:xViXyfWMzBI7k3Nf7r60bw+a5MOYmSsbmrmRlj3iM1iR2Dj+PPaX363PbbBGwFQO+ZWnXcuno6hKBNBY7ZrNRdpVPi8XKfS81DXA4d0/X8EbpOVpmMvJqAcQfcB9occd0bq1WFDl0G90xiJ1A4Zc7B28JdGpHlswOoZgcjF1SQEEck3fbTmmtFq/aNczFRK4OHGp5czpUaMeZxfDSrg4MQdHedDhFUWVGkMvSuOttV4uPrxc/CMpi6yYVYRdKJo8x6/1q/sIyvAVshzxPZh8Q5mnGrRWhV/j8lg2VD9ovorrCgfIwKKWGk/HmpQy+mDCkZ+3e3KhQLwtNnPskJPzzVvMNI6jtgC1vMruKKlVSfuw8ukx/BgphR5caQ5A3hg4MGWAqAVO52EGI+GM8GdgcwrC1i5DISHTVOhKaWa2rRlgulSlpEeXtOApKC2PHzY0WPBPQJ6uUTW0/iKbRnZRAA==; 5:LJIl0oWIDQYZI+4d+2MUKenV0RcntzTag0pFiR686uvHnqqG3y6/Jp1PS50ikLdRSfn+sjdu4v66p7k1iPgOovJsxfO4UE1pNdhXNBXbJSPJcLxBhnJVxlvPWB6CcpcBALHaWZdTYEG24CNofzsWe0CMP5qWPuxCYdflBxURU23KCfuaRdXRieeDizieqNNmmtzL4WWrVfian4v9oHRfpg==; 7:I+XSoQsNuBHiqp51Kca9UPHzAsaauzj5DDQCwKRk8Q9RSuigzFpqXMZBZub1akg3Ai06VwV088k78o2Y7PVviUokOgpZGn5wCm4BFU58ViX1fWbvMf+8AfE76HGJAPNj+s7AfbFGGP9jTJUHkMzX2w== x-ms-office365-filtering-correlation-id: d829cf61-3807-4d25-3ac5-08d67c67e9d1 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(5600109)(711020)(4618075)(4534185)(7168020)(4627221)(201703031133081)(201702281549075)(8990200)(2017052603328)(7153060)(7193020); SRVR:BYAPR04MB6167; x-ms-traffictypediagnostic: BYAPR04MB6167: wdcipoutbound: EOP-TRUE x-microsoft-antispam-prvs: x-forefront-prvs: 0920602B08 x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(346002)(376002)(366004)(136003)(39860400002)(396003)(199004)(189003)(78486014)(14454004)(256004)(1076003)(72206003)(478600001)(66066001)(36756003)(86362001)(44832011)(6116002)(105586002)(7416002)(106356001)(3846002)(5660300001)(99286004)(476003)(2616005)(26005)(110136005)(11346002)(446003)(2906002)(316002)(25786009)(52116002)(305945005)(6486002)(6436002)(102836004)(53936002)(6506007)(486006)(54906003)(186003)(386003)(68736007)(39060400002)(9456002)(50226002)(4326008)(71190400001)(6512007)(97736004)(81156014)(81166006)(8936002)(76176011)(7736002)(55236004)(8676002)(71200400001); DIR:OUT; SFP:1102; SCL:1; SRVR:BYAPR04MB6167; H:BYAPR04MB5303.namprd04.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: +8A0PtKIyvJ8+Nj26Wpvg7LiY3Pfx8P5VWXgHlpfJekFu754+ma1AuYuLNXEhhs6niDO/MVifHk/zqccr7eACvcjOxiPhzYIr6pO7FyPQ29LEpvNZ/vRBqhpLBNfWCcAanEJtErui3cqViDxSev38YkfQmcoJx9q0CewBQrdWMkaPt5wkStElk2Tjx012qu34/A7S0a3q9EPbMn03HZmlP5Xbtwqbqqiww/ZZW4FVbXtQ1uBdAtxzR0CIsQGBYLENKLqEgCPnC+3ro9yjh+oJeA9kPQ9GO/RGVUqshT6yENv2M88rIvw4g7jvssFFIOTujUqIM9NKzMjtuk947WkwGib6PygO6cpjZJ835bzTIF0UtTNqE/xIso7J09TL0g1u7W9jdLHSxYpsybSgJKirwJo1nCrnPKSwPE2QoPX00Y= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: wdc.com X-MS-Exchange-CrossTenant-Network-Message-Id: d829cf61-3807-4d25-3ac5-08d67c67e9d1 X-MS-Exchange-CrossTenant-originalarrivaltime: 17 Jan 2019 10:38:23.2657 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: b61c8803-16f3-4c35-9b17-6f65f441df86 X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR04MB6167 X-Mailman-Approved-At: Thu, 17 Jan 2019 12:20:42 +0000 Cc: Palmer Dabbelt , U-Boot Mailing List , Alexander Graf , Christoph Hellwig , Paul Walmsley Subject: [U-Boot] [PATCH 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 --- 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 Thu Jan 17 10:38:32 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anup Patel X-Patchwork-Id: 1026610 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="XY1hizpB"; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=sharedspace.onmicrosoft.com header.i=@sharedspace.onmicrosoft.com header.b="oVl2tRhT"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 43gNjQ6kxZz9sBQ for ; Thu, 17 Jan 2019 23:31:22 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id 80378C22103; Thu, 17 Jan 2019 12:23:38 +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 5F857C22103; Thu, 17 Jan 2019 12:20:52 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id BFDB9C21D4A; Thu, 17 Jan 2019 10:38:38 +0000 (UTC) Received: from esa2.hgst.iphmx.com (esa2.hgst.iphmx.com [68.232.143.124]) by lists.denx.de (Postfix) with ESMTPS id 11DB9C21D8A for ; Thu, 17 Jan 2019 10:38:37 +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=1547721529; x=1579257529; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=6S++E/bzQCRf1h3J0kkjgPeRfzXvJYczcZ4ny1i2B+Y=; b=XY1hizpBcx0JEnCEYxvBlw4JpxkaVSFewTh9BTPh/WukbbPPmy8MRGmk 6rK4otKSQaRDNUXB6OhFTrR1TKDgUIxvjPMewO+/uqnQkHRxv9m8Le7CF SHObgSlodbw+j9CAdTQKEnwfPAj4WK9qdXXhdgfcYXtKoVsunFbqgjZEc dqQd02WlC0K5sUSQMIYh1xZ+xmsganVgP+jtyqKQ3joIA8Nq7x6MvN32d RM1VVDOp7E6FP2M6XcrDOJSUzyvHXKeSaoyocEJE4q53m3fl4dRkg1Xok GewUL31cIwlj6RKeFvkn/OcPohJVOQ3xR1T1vTl186ZrNEtjBYQLYYhYr w==; X-IronPort-AV: E=Sophos;i="5.56,488,1539619200"; d="scan'208";a="197089590" Received: from mail-bn3nam01lp2056.outbound.protection.outlook.com (HELO NAM01-BN3-obe.outbound.protection.outlook.com) ([104.47.33.56]) by ob1.hgst.iphmx.com with ESMTP; 17 Jan 2019 18:38:45 +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=K/o7vOwFO726/obQG6WwpXcAg7lAe06K1ZvI5EqVqmM=; b=oVl2tRhTOxTTTrx0ClKfMETiddmey4vALapcVwwhVq8igezrswficajzWFt8YFk0A47XH21MKlDTfeQTNk1r4TC4TLaWP17pRRliTcCfgqgo3Ny6dn7Nrc/mn7g6ZU00DqueUlP5cS+pr8nzK3CUt446pELfHyqYotxa8mbB3kA= Received: from BYAPR04MB5303.namprd04.prod.outlook.com (20.178.49.148) by BYAPR04MB6167.namprd04.prod.outlook.com (20.178.235.15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1537.26; Thu, 17 Jan 2019 10:38:32 +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; Thu, 17 Jan 2019 10:38:32 +0000 From: Anup Patel To: Rick Chen , Bin Meng , Joe Hershberger , Lukas Auer , Masahiro Yamada , Simon Glass Thread-Topic: [PATCH 03/11] riscv: generic: Ensure that U-Boot runs within 4GB for 64bit systems Thread-Index: AQHUrlDKGQ806QrJ/EO66b4QsRkZsQ== Date: Thu, 17 Jan 2019 10:38:32 +0000 Message-ID: <20190117103748.36613-4-anup.patel@wdc.com> References: <20190117103748.36613-1-anup.patel@wdc.com> In-Reply-To: <20190117103748.36613-1-anup.patel@wdc.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: MA1PR0101CA0069.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a00:20::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: [106.51.16.164] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; BYAPR04MB6167; 6:KnpLugGDCuaBHfEd4njlnUf7XzQz4vpSsP0fSmRJeEtf8XetAcRQleolY3DaW6dlkXFE+KPhiJlp5LC7orbNcGtADQchcmYuF6oWoqeMggoAPli2qNvcWrddyOFrD/4w6N23JGMGmRBM4n5REzHtgYqooIpL92bPtMCzO+jY41fyp+KujrDbrxKDcWo4HDl1AHMJwwG46sbrJOZnE5bzIibieh54zgVUMxsZBkx+pFpMWdFI5+Xu/h+rjrzFqfEaiSPy2L/3b8VrJ71XhCTYDrF7XVEe8IcRTtuU5X69oooeIpqCCyaPrcqzXswaJE6i6KzI2gJaqkzxEqvb8k/aUz+NiDJiYGFyt4R1c+4YiNMLT2QZPJmolyyxNx7eyDBTro7gtH2fmjDM0ie8HcLZTIQ3xS81Le36lHb3oz9K3meYkUE9rtMU1xmX5my4aWTklSc0BA59r8vY6YV4Vx0oLA==; 5:ZlB6Kw+vSxkLF61KXGrDXgFOCzVX/WVL/7q5aqjIJg4CFMY1IdO2uIM9Tl0Y/1tVJUnZxlJ/Q8jT/E0zrOSwAm0VJ3yVXjOpWhcFIjIB4HGK+XLOclNLH/hnruF4d4MR3xrBu6KXhIHNPvDyrJasNhh/IGS1g2GqbxFCyCCXHf1okFEYH2gcFMNWqSCSpFHPajMkpyvKMWAxnv16DPXNaA==; 7:Dvdf6Ci35hesmMqrjJcVyTDFxxd2QNRiFzEQ6TdK7ixAs/Z+yvCOZ15JbMI22WAZmV/zRJ90AXUanAVaSnhTA/kw0EaqI9Eie/fMS07Hfzzkk+kkp+7qTxsvKQyZZ6l7sL1uUeBNrN/lMwzg049SaA== x-ms-office365-filtering-correlation-id: 06fa4021-d4cc-4aa4-de40-08d67c67ecdc x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(5600109)(711020)(4618075)(4534185)(7168020)(4627221)(201703031133081)(201702281549075)(8990200)(2017052603328)(7153060)(7193020); SRVR:BYAPR04MB6167; x-ms-traffictypediagnostic: BYAPR04MB6167: wdcipoutbound: EOP-TRUE x-microsoft-antispam-prvs: x-forefront-prvs: 0920602B08 x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(346002)(376002)(366004)(136003)(39860400002)(396003)(199004)(189003)(78486014)(14454004)(256004)(1076003)(72206003)(478600001)(66066001)(36756003)(86362001)(44832011)(6116002)(105586002)(7416002)(106356001)(3846002)(5660300001)(99286004)(476003)(2616005)(26005)(110136005)(11346002)(446003)(2906002)(316002)(25786009)(52116002)(305945005)(6486002)(6436002)(102836004)(53936002)(6506007)(486006)(54906003)(186003)(386003)(68736007)(39060400002)(9456002)(50226002)(4326008)(71190400001)(6512007)(97736004)(81156014)(81166006)(8936002)(76176011)(7736002)(55236004)(8676002)(71200400001)(41533002); DIR:OUT; SFP:1102; SCL:1; SRVR:BYAPR04MB6167; H:BYAPR04MB5303.namprd04.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: GohBg2wgNUan8lKRYgcCoW5iqJAjU2LmVGQORhjJaRl5lm2XAmOAkYPTVZc6Rh+MTSe7NOfI6psRph4F+AyMbUdwXje+27rVTrybB9a/DxeFHR9WKq/QR6C3wEAT6iEG6CYIGnKHLrLjIjDPNVAoLy+FdSnwJM4c1rfg4dGo9bz9tjb2BO8GgbHQlkaG0ImOmp+qP1RE/0QeCRMyp+7A76W+UOn682BeLPP8zqpTgEpdDzKBy++SvEYM24FCq7QjjotYIJQ/vbmKVPV8sbmfQbBTwvTO/t8ZtsN4ehvU+n0sDvsnPyVw7s7MLfOghaMUM9rx8iZSsT2IItP/3tY/F6r13uKpLyKBwO3V8iajQ2YKI/sI6u1fsaaI6TFQ/fiR6eRr7z3MTNjXTSXNQAJXyv/da8JftipDLNr0FZW+BcI= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: wdc.com X-MS-Exchange-CrossTenant-Network-Message-Id: 06fa4021-d4cc-4aa4-de40-08d67c67ecdc X-MS-Exchange-CrossTenant-originalarrivaltime: 17 Jan 2019 10:38:28.1095 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: b61c8803-16f3-4c35-9b17-6f65f441df86 X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR04MB6167 X-Mailman-Approved-At: Thu, 17 Jan 2019 12:20:42 +0000 Cc: Palmer Dabbelt , U-Boot Mailing List , Alexander Graf , Christoph Hellwig , Paul Walmsley Subject: [U-Boot] [PATCH 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: Anup Patel Signed-off-by: Atish Patra Reviewed-by: Alexander Graf --- arch/riscv/cpu/generic/dram.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/arch/riscv/cpu/generic/dram.c b/arch/riscv/cpu/generic/dram.c index 84d87d2a7f..dea2d3701d 100644 --- a/arch/riscv/cpu/generic/dram.c +++ b/arch/riscv/cpu/generic/dram.c @@ -6,6 +6,8 @@ #include #include +DECLARE_GLOBAL_DATA_PTR; + int dram_init(void) { return fdtdec_setup_mem_size_base(); @@ -15,3 +17,23 @@ 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 > 0x100000000UL) + return 0x100000000UL; + else + return gd->ram_top; +#else + return gd->ram_top; +#endif +} From patchwork Thu Jan 17 10:38:39 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anup Patel X-Patchwork-Id: 1026600 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="aabem0vv"; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=sharedspace.onmicrosoft.com header.i=@sharedspace.onmicrosoft.com header.b="oMhfQ2FC"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 43gNb854kKz9sBQ for ; Thu, 17 Jan 2019 23:25:56 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id 4725BC220A0; Thu, 17 Jan 2019 12:23:54 +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 3C012C2210C; Thu, 17 Jan 2019 12:20:53 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 809D8C21D4A; Thu, 17 Jan 2019 10:38:45 +0000 (UTC) Received: from esa2.hgst.iphmx.com (esa2.hgst.iphmx.com [68.232.143.124]) by lists.denx.de (Postfix) with ESMTPS id 91973C21E63 for ; Thu, 17 Jan 2019 10:38:44 +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=1547721539; x=1579257539; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=kRcPLFAsU2o2yMzuXb0YnwAk9QvygLqiUMAD8N23fPw=; b=aabem0vvKFExYMXxz38ljXJcpx48zNe8Hqp04+MyFZedasH7F/yTld08 9LVoIT8qpmeF/9URTTSN+sTKQgd+PMKb1kn6tVqDv12ogcaOe6dVcOmct ibffaenIqvvRgaWSohfiSOaEYYOWHYzclIqzxAczmDnnF8V18LjpWo/J0 bLOjuH+N4LRegqqfJtvmGgvBBF6aozJZqlb2g6amgUBdTX6r1p27Kuh3x uhwuS+5ZRg5AbSTcm44vh65ICkk3JzPI3RPFUgWe9gh1ZkJQ4K30MoyBU 1buWlHoHoJA6YLYhxu+7IvzyLzOnxuHZknfyq+yMpGRTZkctBJV9N+xzX w==; X-IronPort-AV: E=Sophos;i="5.56,488,1539619200"; d="scan'208";a="197089598" Received: from mail-bn3nam01lp2054.outbound.protection.outlook.com (HELO NAM01-BN3-obe.outbound.protection.outlook.com) ([104.47.33.54]) by ob1.hgst.iphmx.com with ESMTP; 17 Jan 2019 18:38: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=o4KeDLVqkO48Ddjegvmc2e7FwpMq7mnJBXPVMJxU9yc=; b=oMhfQ2FCgHc4J/TaJQq8rYmXx8M38aT2OnYTITse1QfOTTDSvUxvtflvpeDxO2upmtaul8IMFJG2sXes1LB5Cbi8+Z6sedd8Av+pXJDcNZ5MTVcFk1XmbU1VKbpVYf8bwllvj05kb6wGtu+eu3E9WGiv7j+X5W31RdPcPj9OMkQ= Received: from BYAPR04MB5303.namprd04.prod.outlook.com (20.178.49.148) by BYAPR04MB6167.namprd04.prod.outlook.com (20.178.235.15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1537.26; Thu, 17 Jan 2019 10:38:39 +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; Thu, 17 Jan 2019 10:38:39 +0000 From: Anup Patel To: Rick Chen , Bin Meng , Joe Hershberger , Lukas Auer , Masahiro Yamada , Simon Glass Thread-Topic: [PATCH 04/11] net: macb: Fix clk API usage for RISC-V systems Thread-Index: AQHUrlDO8xkHNPLX6E+p71LxGXAdNw== Date: Thu, 17 Jan 2019 10:38:39 +0000 Message-ID: <20190117103748.36613-5-anup.patel@wdc.com> References: <20190117103748.36613-1-anup.patel@wdc.com> In-Reply-To: <20190117103748.36613-1-anup.patel@wdc.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: MA1PR0101CA0069.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a00:20::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: [106.51.16.164] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; BYAPR04MB6167; 6:vXszM597wiLuPnaXAk64d0pzp85B1dctWzFov0METSszpXJqQVBP8SxK08c3xWhQwNoi5DloJd1iwvY2SHGUn2U1ahRIIbz/Oca6RRCWqtnzLkdjyR3CfUIwUq7YtEudGxxCMKFPBvuI1N1i1CIqxJnxaKTk8eQXYX2Af+6FHe3a+IwAAMCDazyqLJO7YWyyCDMYllrbpFnSOaLQwVemApu2gmXqIY0ptTPyedMBoN5GhR9Uu7dy3VQUUjdLbMr9XjGdvDyVdkgsPdHtWIYurOCDO07FYKd4ojXlozRhNhRJgqq+pA18xKd7MjS8m6ULbg1yluTwtWoRkvW8FhoGXKex2rsWbo2tvcLW+Hvxni6EV8RoaCwUuVRyU3Bn48wrItbq0jx4PScePCUZwl+4A4YZ3oqXI/vlJyDzpXWBj3ich9sR5U53NGtVKOlMnFl3QW+zEFgBmdBBFFvi8MBmaA==; 5:DoDh+QmAuFxp8UUAe/6ULMblvF3cjfWNIMx0ILj6c54f8vxextgaviG+igWhCd3eiT7SDBM6pvkFiz01GFjO9JK6WKf3jUJPJj56oXMAoO1XzOQWLw6cL/88ir8MZh16WJDPNGImKbghOnKXrgtQDAKaqKEP1ePz06y5lXK+mYdeKsR3eIOC8cohCqTscmXgtCBW0INpe9F0qF0INECJLw==; 7:djcBzfHCH/ibIF0cHQEVq1aiW1Gp/rc+pkAt/E3qKCRntkCS5w6qIeXEqWJQnYl5DN9mf+u4duhOJ2d/o1gV4r7PP8d2pOYeamu7gr5met5kbKZNxSyxKd7Dz6tJ7VFIOlxAiSYdTcn7IB0K2AmH2A== x-ms-office365-filtering-correlation-id: ddd852be-bef5-4db9-9d31-08d67c67f106 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(5600109)(711020)(4618075)(4534185)(7168020)(4627221)(201703031133081)(201702281549075)(8990200)(2017052603328)(7153060)(7193020); SRVR:BYAPR04MB6167; x-ms-traffictypediagnostic: BYAPR04MB6167: wdcipoutbound: EOP-TRUE x-microsoft-antispam-prvs: x-forefront-prvs: 0920602B08 x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(346002)(376002)(366004)(136003)(39860400002)(396003)(199004)(189003)(78486014)(14454004)(256004)(14444005)(1076003)(72206003)(478600001)(66066001)(36756003)(86362001)(44832011)(6116002)(105586002)(7416002)(106356001)(3846002)(5660300001)(99286004)(476003)(2616005)(26005)(110136005)(11346002)(446003)(2906002)(316002)(25786009)(52116002)(305945005)(6486002)(6436002)(102836004)(53936002)(6506007)(486006)(54906003)(186003)(386003)(68736007)(39060400002)(9456002)(50226002)(4326008)(71190400001)(6512007)(97736004)(81156014)(81166006)(8936002)(76176011)(7736002)(4744005)(55236004)(8676002)(71200400001); DIR:OUT; SFP:1102; SCL:1; SRVR:BYAPR04MB6167; H:BYAPR04MB5303.namprd04.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: ho9CKuDetgassHFraoptnFu9O3l177NlmDj4i8PfMxBM61a2wI1zn8Qy7qErN0crL13tfitVf1skz5Svlg8ZRgys7VAXWGtFKDcYtH3MsBNHGQC1iZw3X1Y6u1ffZTGNUyMI4Qg+8irflOgXw/r2ljtA6cvVtQKKFpZxGmcegd9SyxBvRd089N00F5i10WI758YCfKY6MRlaIeobd2EBDAkcxUTFk9o+JJCcbe+F+p6YMJhMV2SSjffbUw06XeJSlOwZLPjg0cMrmK3XUfSUEazltRQFvK5/gcAMb308DplCC5FM/lB5VavNnIvutolEOMdJGbH1px7fsysf29Y1OX1wRzZCcABJ16DUbDFnmnqGjvkam8BxJPm0Lryb15c6aRs4yeWW9Bj84ZaZgQ0HUE8d0+GD9/raWPaROpDvPA0= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: wdc.com X-MS-Exchange-CrossTenant-Network-Message-Id: ddd852be-bef5-4db9-9d31-08d67c67f106 X-MS-Exchange-CrossTenant-originalarrivaltime: 17 Jan 2019 10:38:35.2971 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: b61c8803-16f3-4c35-9b17-6f65f441df86 X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR04MB6167 X-Mailman-Approved-At: Thu, 17 Jan 2019 12:20:42 +0000 Cc: Palmer Dabbelt , U-Boot Mailing List , Alexander Graf , Christoph Hellwig , Paul Walmsley Subject: [U-Boot] [PATCH 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 Thu Jan 17 10:38:44 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anup Patel X-Patchwork-Id: 1026607 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="X+Gmh+jc"; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=sharedspace.onmicrosoft.com header.i=@sharedspace.onmicrosoft.com header.b="hrO02t8Z"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 43gNgW2TzRz9sBQ for ; Thu, 17 Jan 2019 23:29:43 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id B9692C220A3; Thu, 17 Jan 2019 12:24:09 +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 226D8C2211A; Thu, 17 Jan 2019 12:20:54 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id A4FE6C21D8A; Thu, 17 Jan 2019 10:38:49 +0000 (UTC) Received: from esa2.hgst.iphmx.com (esa2.hgst.iphmx.com [68.232.143.124]) by lists.denx.de (Postfix) with ESMTPS id C9D10C21D4A for ; Thu, 17 Jan 2019 10:38:48 +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=1547721546; x=1579257546; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=+/yR43QNlbmFxhPsq1LECIHSE8eP3WC/aLvgdzY+f28=; b=X+Gmh+jcXI4zXrd11DUWrO0IDZpx81/6IVupPHcV4H4b/57W5OOUjjyK hqeVDSTQWAk9mW3zPhPQTqbyUdKQoLlJxr+xXFyikvN3wyokKtmNQIpcm eW0BuBFCvAhFd4r7BJB0jgcXon8KTgGhX7IP3hs/9UNuFrcNwVde+y/71 +Sfz4HhEOkDziK6HmCII95fAHgdIKtW9UnYMWv37M0/ovWNv0mfUeB7ji 2sOihTAFCCAIN9eRk8G74xsFOj3ARTDoVSII6hdppF3zQjWsU90RI8DKi DL+16W32UojR58zQ1OBn1Ig1y1v6btCNU1IQkPmh/HHDCFdiGYLnKEstT Q==; X-IronPort-AV: E=Sophos;i="5.56,488,1539619200"; d="scan'208";a="197089602" Received: from mail-bn3nam01lp2058.outbound.protection.outlook.com (HELO NAM01-BN3-obe.outbound.protection.outlook.com) ([104.47.33.58]) by ob1.hgst.iphmx.com with ESMTP; 17 Jan 2019 18:39:03 +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=pL2aqw6EruZk1eFb/EyJxdJ36HHjMHLmIr5lmoInTkA=; b=hrO02t8Z6MvFUHbLgjCNAkG2B+oe8KH/KBxtPC4pyMiGmrhdCVE3svHAAvBUUBxZK8+L1Bpwayqixf9D9NSkACe7l527F9zixnl1IJU/aDHUavyVocNyvtLmajMxxRNK3VsEXm+Z+14+473XmsCKHZ8ULDBdWd4xuvFQ2Ji6jlo= Received: from BYAPR04MB5303.namprd04.prod.outlook.com (20.178.49.148) by BYAPR04MB6167.namprd04.prod.outlook.com (20.178.235.15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1537.26; Thu, 17 Jan 2019 10:38:44 +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; Thu, 17 Jan 2019 10:38:44 +0000 From: Anup Patel To: Rick Chen , Bin Meng , Joe Hershberger , Lukas Auer , Masahiro Yamada , Simon Glass Thread-Topic: [PATCH 05/11] net: macb: Fix GEM hardware detection Thread-Index: AQHUrlDSd+fDUX1m7UK0o69sUNPbeA== Date: Thu, 17 Jan 2019 10:38:44 +0000 Message-ID: <20190117103748.36613-6-anup.patel@wdc.com> References: <20190117103748.36613-1-anup.patel@wdc.com> In-Reply-To: <20190117103748.36613-1-anup.patel@wdc.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: MA1PR0101CA0069.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a00:20::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: [106.51.16.164] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; BYAPR04MB6167; 6:/7IWmjUKfx7GWTe2YOun5VQxXDLxCR3C5e8aPossXZR7SGWHd9a63wTXp0hDle9+M+66l3wky1OBawrpvz2Y33rdMX5DS3aXexbCRlWEaJpJUZlrCfruiHM2DbmHUWLomkeRHhV1TA0Zt96B9k8TUqNtvgEwrLvWMZBrRZTeiz2EwR13UUWJ+qgBFupo1TkuACbv0vfWBC8eVLot+Dmy0NsZoMiNOLAiJ/Cnosqv9CzcWLADxfu8vwA5qxBwZs1YVg7RSObPaxjFf/58hQVkUUv2G0WWFDEFgP3WZjli1M7eZOOnjb+Rnv6Kh+SSsCaSSeYZaCX4aNArCWA0lOgZf3CB3it19llEBlfkYsP6NJleVvwRIMkPN+su/XP8CDksDznNv8txvZ5ZdbRWqDNWwx+sU4hYiK5GvTbLLi9hnRfqdo+hSIBNXjKLD0do0SsymT5AytZ6+abtF8DIi6QN5A==; 5:PjmnfyaCDo5FhXgfu+VndyhGftdMRdiUhksVe7IHAkKzDf2dpK3SQHg15q++bq3QQqMD3pAol6o0Bny9mP0JTiAPlaRCB5bBWjGRFhHf+pDo6aTjf3BgzdG1uVDWbu9h6xiqOjG/zdhfzaKGqP2rwfmPmwpfmVH8UIuk8FBYDD7gVeDSSXzuWK1PgTKYt6g4aKHQbDzUrYGqUvYKOqMiGA==; 7:zi68byVGGWh90J+VkhAHXkGWbnJHpoj29B9B53mWW5qJxPfH3JK9Uk0U7kCFL22SXyIzJ/B3FYslYQSaihupdCzi3NHq6IywbvwNDXn5BZq6RMYZjYRL77bq2b/eqw7S/CY2wwREqgb2kGd4yEr0TQ== x-ms-office365-filtering-correlation-id: 51d3ea4d-b2aa-42a4-0444-08d67c67f436 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(5600109)(711020)(4618075)(4534185)(7168020)(4627221)(201703031133081)(201702281549075)(8990200)(2017052603328)(7153060)(7193020); SRVR:BYAPR04MB6167; x-ms-traffictypediagnostic: BYAPR04MB6167: wdcipoutbound: EOP-TRUE x-microsoft-antispam-prvs: x-forefront-prvs: 0920602B08 x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(346002)(376002)(366004)(136003)(39860400002)(396003)(199004)(189003)(78486014)(14454004)(256004)(14444005)(1076003)(72206003)(478600001)(66066001)(36756003)(86362001)(44832011)(6116002)(105586002)(7416002)(106356001)(3846002)(5660300001)(99286004)(476003)(2616005)(26005)(110136005)(11346002)(446003)(2906002)(316002)(25786009)(52116002)(305945005)(6486002)(6436002)(102836004)(53936002)(6506007)(486006)(54906003)(186003)(386003)(68736007)(39060400002)(9456002)(50226002)(4326008)(71190400001)(6512007)(97736004)(81156014)(81166006)(8936002)(76176011)(7736002)(4744005)(55236004)(8676002)(71200400001); DIR:OUT; SFP:1102; SCL:1; SRVR:BYAPR04MB6167; H:BYAPR04MB5303.namprd04.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: OAKULrm/UwGRtQc7kEcRHQ0lYecRVqCSY0uJkNx2fztmBYjyptL+8e0i5l7/uhNXe5Ov5Q3SiF9zooxYgGAb/oYIzjx3AW8Ek3j2qnLYKbMLvVBfsF9VS2Mjo3XD0Ie42oHPrWArM3HivN32Y8ibjlj5ItAaYaa0bWviSykKQlWsvJhEJEveqjyEMdv0zqGKZ1XFjNbRSyc3pBPEDpNqvHhO2/f05xsum2muOff6JKBpfaXBzTAxDC9jjJyOf2MRypbKcWdA1k1LFC7VSjokmmTuK9z47vxv8+7dHh0nTJ46X580G2/dAue8m9cjP8KP2epE437hu4nh721DTReHfyhGdl6w2TBKFnR88LruMOjgNv2qUX6jZQgc7Pq9bjYOqTda7YEC0Dmki+1zXLNTqBa4q/mxbm/xQBxpMAk/IyM= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: wdc.com X-MS-Exchange-CrossTenant-Network-Message-Id: 51d3ea4d-b2aa-42a4-0444-08d67c67f436 X-MS-Exchange-CrossTenant-originalarrivaltime: 17 Jan 2019 10:38:40.7034 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: b61c8803-16f3-4c35-9b17-6f65f441df86 X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR04MB6167 X-Mailman-Approved-At: Thu, 17 Jan 2019 12:20:42 +0000 Cc: Palmer Dabbelt , U-Boot Mailing List , Alexander Graf , Christoph Hellwig , Paul Walmsley Subject: [U-Boot] [PATCH 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 --- 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 Thu Jan 17 10:39:01 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anup Patel X-Patchwork-Id: 1026609 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="e1vDlb7q"; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=sharedspace.onmicrosoft.com header.i=@sharedspace.onmicrosoft.com header.b="i3qLAXWQ"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 43gNhY2ft6z9sBQ for ; Thu, 17 Jan 2019 23:30:37 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id D7238C220B2; Thu, 17 Jan 2019 12:24:31 +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 2491CC2211E; Thu, 17 Jan 2019 12:20:55 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id E3470C21D8A; Thu, 17 Jan 2019 10:39:08 +0000 (UTC) Received: from esa2.hgst.iphmx.com (esa2.hgst.iphmx.com [68.232.143.124]) by lists.denx.de (Postfix) with ESMTPS id 73DFDC21D4A for ; Thu, 17 Jan 2019 10:39:07 +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=1547721551; x=1579257551; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=zlNwMMD60yTBpxPOX/0Mv8BzpJaioGbhN1K9mWOGqYs=; b=e1vDlb7qgOdNalFHHTeXD6xq8/0V7Z00TI47nDyShNdO7/rjzAsojDV6 1UiN0eObbKlyktgYfIKzoYktOic/9Btibhhgo2M0de2uWnOd/6vG79gtm fbXxe3ZVIFWzuDAUNmWPY+7ljojAE0apggd2C8RCBE+dbFGFnW/HNk8WC XnXJ4Awv+1Xov/7akDY4gIg4YaMv/XWAl8T9cCPBAqpDtJj2db7JhLVsh bEuTTdZfdCuDPWOLUgeudbaaJ1/5NcQ4VsIb6jBpbhvz/+iT4BgdFq3Y1 j/kBWpwp+erFIqiDuJEIzrW8XzpcJ+v69JaTp5iRlo6huPWzcUpbTaYDB g==; X-IronPort-AV: E=Sophos;i="5.56,488,1539619200"; d="scan'208";a="197089616" Received: from mail-bn3nam01lp2055.outbound.protection.outlook.com (HELO NAM01-BN3-obe.outbound.protection.outlook.com) ([104.47.33.55]) by ob1.hgst.iphmx.com with ESMTP; 17 Jan 2019 18:39:06 +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=l7EICU5w4ajlRTkscaJvVBENjwXcdAxKoHU5Bk2IfY4=; b=i3qLAXWQexfduKkyU3W27OSrpiDVHX11iC+2kmru6ZjYJacj+6M8oXFblj/jxk3GtKe8zaX0dWdnMrjViim3I7kLiIPTMbQfqcSqoeSpPjIvb5JbuD4U2ivu4jzuriTtKR2b1eaBu+begvQ+PkX+ck2GEBo0OWxmZzDWsA+XNqk= Received: from BYAPR04MB5303.namprd04.prod.outlook.com (20.178.49.148) by BYAPR04MB6167.namprd04.prod.outlook.com (20.178.235.15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1537.26; Thu, 17 Jan 2019 10:39:01 +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; Thu, 17 Jan 2019 10:39:01 +0000 From: Anup Patel To: Rick Chen , Bin Meng , Joe Hershberger , Lukas Auer , Masahiro Yamada , Simon Glass Thread-Topic: [PATCH 06/11] clk: Add SiFive FU540 PRCI clock driver Thread-Index: AQHUrlDbQACWPgTppkKscTtz5kRkbw== Date: Thu, 17 Jan 2019 10:39:01 +0000 Message-ID: <20190117103748.36613-7-anup.patel@wdc.com> References: <20190117103748.36613-1-anup.patel@wdc.com> In-Reply-To: <20190117103748.36613-1-anup.patel@wdc.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: MA1PR0101CA0069.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a00:20::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: [106.51.16.164] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; BYAPR04MB6167; 6:AVeR1U3f8ZzWHcwqzIUIIUT0fiySzhOupdVyXKEgCS7ROFad9YxZ5sp85am04wxjYsNusW5EWbnkF/1WJJE8qOT8IFhQ6amd6WmeOv6qMnrQEjJBjR/aYQ4ZPC4AD2O0bn9yaAPLOKrHTBS/AptQavaY8c4lr3n1n9iA7UpkAg/+d7LUV2ZtwrrGNP7RunMN2Fj3wPIseHgklG3GG/PPdNlxEYDf3WdeC9RAhz1CaFV+NNbUbVB/FoMV6x0TUKvVX4NH7zG5HmvIN2wkz+WLrrvqnraBz9MA2gAhzMCMrYJwOABH5BNFxjoqvNNEitNWffdmAEjN6G6BVlW9xgTU65iKYMtLvj2SzUGvKJYlRZfza5f3+gFaTd0A9UUvpvTGvRYFOPNePVhpBn/wR5sLSASV0DNKSHC79Tcx+z1aKfwkYgdJsvV6W3E5dcDTix1tVQ/10Pvf2WE5FTP5alJG0w==; 5:ynnLaKaEuRqDnsoMvh6/nTcl8TLvcg4o5BFM1xI01EsDCEIeh1fbrWCnLbeX59PFujZa/+Mb1q2XFIQkKhhsU0U3ZcMu6wgJyQQR2pFEnh1Asqm5hEWcaNLkC7b190+7XGFmtnG4oJI/VJ5mxs9jzknJ6pLMw8b4lmkB4S1I9tKePqxorHq+4q6uBvfnOodk9WLsPRX9GUN8baYuw/v3ow==; 7:tkVZZliasYLuNr0+mli+Q3VlTq0cvCK3dvBHcvU5APybr9y5Rwta6aP1gPxlITnucrozpSOlTFX822BOiWaAh5i2Sgg5wJEHC9j4QlSaOQeltXxURra8Rt3IKWJX1X1Af5dpirKW//dtU/iHNme0wQ== x-ms-office365-filtering-correlation-id: a0e1508f-325f-403a-52e4-08d67c67fd3c x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(5600109)(711020)(4618075)(4534185)(7168020)(4627221)(201703031133081)(201702281549075)(8990200)(2017052603328)(7153060)(7193020); SRVR:BYAPR04MB6167; x-ms-traffictypediagnostic: BYAPR04MB6167: wdcipoutbound: EOP-TRUE x-microsoft-antispam-prvs: x-forefront-prvs: 0920602B08 x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(979002)(6029001)(346002)(376002)(366004)(136003)(39860400002)(396003)(199004)(189003)(78486014)(966005)(14454004)(256004)(14444005)(1076003)(72206003)(478600001)(66066001)(36756003)(86362001)(44832011)(6116002)(105586002)(7416002)(106356001)(3846002)(5660300001)(99286004)(476003)(2616005)(26005)(110136005)(11346002)(446003)(2906002)(316002)(25786009)(52116002)(305945005)(6486002)(6436002)(102836004)(53936002)(6506007)(486006)(54906003)(186003)(386003)(68736007)(39060400002)(9456002)(50226002)(4326008)(71190400001)(6512007)(97736004)(81156014)(81166006)(8936002)(76176011)(7736002)(6306002)(30864003)(53946003)(55236004)(8676002)(71200400001)(2004002)(959014)(569006); DIR:OUT; SFP:1102; SCL:1; SRVR:BYAPR04MB6167; H:BYAPR04MB5303.namprd04.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: XLxMZE0QXkZzAyOyN4QKt4aAu6Sgz/LvNSfJHjju2IKIuMq8b55Q3zWm04Cm4fBRorqHX0viWW5kLnX6x68lvxi+x+Hkyt/HishHoTHLjg+RSLsJ1gNqWHbYkxrMHV3QFmFmrp0BsB1v0/I+I70mI/kn6/th3vEWOePq7shLTv0z9QhTEtUho1Thda7QfXM0F/r+UDvPaBNkPjdfN65aDZ2GT49VQdFp8fbyG1n0mtpKgxDZtRwwD1MqZlaUMKXLkBlhDohxTQHGTko2DGI5silR1tkNmHLS/mYNTm0CAraIg+mxtoyjCxTlOjjXjzbXOsdqX5rsQzRF4REYG0oYmI9l8yfgg4Pg1+114bpEOpQW4tmuzKoVQpODY/iZidF38NpYDgNlHdoAvVMC/ZPyp9ad18Lc9/n+DJxO9+hZWvU= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: wdc.com X-MS-Exchange-CrossTenant-Network-Message-Id: a0e1508f-325f-403a-52e4-08d67c67fd3c X-MS-Exchange-CrossTenant-originalarrivaltime: 17 Jan 2019 10:38:46.1723 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: b61c8803-16f3-4c35-9b17-6f65f441df86 X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR04MB6167 X-Mailman-Approved-At: Thu, 17 Jan 2019 12:20:42 +0000 Cc: Palmer Dabbelt , U-Boot Mailing List , Alexander Graf , Christoph Hellwig , Paul Walmsley Subject: [U-Boot] [PATCH 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 Thu Jan 17 10:39: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: 1026611 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="qT26ayND"; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=sharedspace.onmicrosoft.com header.i=@sharedspace.onmicrosoft.com header.b="O9w8bZBS"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 43gNjX0j2Gz9sBQ for ; Thu, 17 Jan 2019 23:31:28 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id CD379C220BD; Thu, 17 Jan 2019 12:25:32 +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 15CC8C21E90; Thu, 17 Jan 2019 12:20:56 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id B26ECC21E75; Thu, 17 Jan 2019 10:39:12 +0000 (UTC) Received: from esa1.hgst.iphmx.com (esa1.hgst.iphmx.com [68.232.141.245]) by lists.denx.de (Postfix) with ESMTPS id EC284C21D4A for ; Thu, 17 Jan 2019 10:39:11 +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=1547721552; x=1579257552; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=KVHVSoT2s62rrJvsVTo3HgMsscbdr6/rhETrxHdY8FQ=; b=qT26ayNDE051CZqBoe4xtTqHNhuJL3vs8wUg/ZY/n5Z4YO9xcpd5Wj7k pbbvJgdHwAxHsL1VpGRV3pB82qT5BU64i5dWJkAHqTjsfYH3jZGsiDt9L l9lUZihKoLFeZ9jIfTA28/kYE8dNur/vJOAL584OfkoW6FsEbR+PaCL6y naFQyv0XbfH501si00Sk52Col8haEAgQaiGefL+RWY0NgeAlnogHcZ7po HPiU31jfPIQgfGPFWZtUh7O1tJOZQOZ3gp+UhJyTp92r9b8rdQYCavzQS FziuEzlz8Xaq1L50dOvIaKg/IknNXSIqOstVtUAGqsxBXLrnNdZ61wLti w==; X-IronPort-AV: E=Sophos;i="5.56,488,1539619200"; d="scan'208";a="203985207" Received: from mail-cys01nam02lp2052.outbound.protection.outlook.com (HELO NAM02-CY1-obe.outbound.protection.outlook.com) ([104.47.37.52]) by ob1.hgst.iphmx.com with ESMTP; 17 Jan 2019 18:39: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=xZieuhZLjcFVxcwD8tvfxh5sltDThYiX6kYTWkyOIFQ=; b=O9w8bZBSyqdWmNtvQcW22hsipT3iU9mJ722kY7QOEcJVWZtprAM5spNmINqgb1B5WYnImC+DsYgTC5TiH4s6Xj8JNmrlJmCAxmN+kqZ2w6OGTdAYpl4qc2Y+x7rub3zqZ3u+1DYhLiC6IULz3uQOdcoUIAeaCAm+BzDG8mzZeRA= Received: from BYAPR04MB5303.namprd04.prod.outlook.com (20.178.49.148) by BYAPR04MB4744.namprd04.prod.outlook.com (52.135.240.75) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1537.26; Thu, 17 Jan 2019 10:39:06 +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; Thu, 17 Jan 2019 10:39:06 +0000 From: Anup Patel To: Rick Chen , Bin Meng , Joe Hershberger , Lukas Auer , Masahiro Yamada , Simon Glass Thread-Topic: [PATCH 07/11] clk: Add fixed-factor clock driver Thread-Index: AQHUrlDfHGbAl9n9G0WjTvkNDkjqIg== Date: Thu, 17 Jan 2019 10:39:06 +0000 Message-ID: <20190117103748.36613-8-anup.patel@wdc.com> References: <20190117103748.36613-1-anup.patel@wdc.com> In-Reply-To: <20190117103748.36613-1-anup.patel@wdc.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: MA1PR0101CA0069.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a00:20::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: [106.51.16.164] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; BYAPR04MB4744; 6:ey4fnjpvLKguOtZvekTLpKkVMyCFUyjBq0Q70CO7FQ6dTk1K92WUBqvk5MONiDvE8dqMTzhjR+ZkABMG92GHNu3IVuJ1vjW3+0KN+p2dZ7SvmOx4JHX/512bVNxtzJMV3SyRr5rYlcX6s8Srel6CJDLtEph+9Q+dAwEbZe6N7BCdalLYx4ibSfWq83jRVAMTIa8/nWkORy9hoV+1p4rjYQirgVBDlLVEBRlZNe6OkHnDE3BWXCev6wjt3EuQy85ewd1KCfXVzBXcVwKVOkyMbIrjvCtSvHQoNJBCcZ/qh4U9cXbyO5z3tNFxoDMxC7BoWesJHiOTDu0wpKg4RPH6sxkxWFyPiSBPqUWBwqCMFap3KKSy7KGobgC//MgzLN0tb+RzSQ1PfsN5KdUTjpYrBT7l9k76OkrWs5nPPwPxojKfGy57sadhTzjYGVLqTK4imIiDj/hu0jkw7MgTUcvOwA==; 5:NzOkQnqF6z6YFqFiSZriSYMBBUbNvd+2UCOwi+TtcZwZVYSlBqozpD1WVf8ji07EU9O1pAGxlNQYS2MC54Yn/6iwIFgUrBQLH+0ZbH6XOGF3TbQ4BvKAUL5cGFE+l5/HS1d2bBeDLzlz249FY4xt4MXpiUM80c0LahnpKsT5F+J6yPq5rRjfa8RG9WPUI4w8kZ3cL0d18oTGCT42tsyzwg==; 7:1IvMYAxtXlC4u3hkpApplyF86QluVx0B1rhbbMtP9UhdxXPJD9rhUgbMa9fyoD4ZHT3wkBn8K1bJWGwOYUn9iT6e+4jyxzgGlBK8SE8w7N7RvBSeRnybKykSuG2b0Y2yWn1PZzgk7AnrpHKPLtdwGQ== x-ms-office365-filtering-correlation-id: 33e9fab2-90ba-4d23-fd58-08d67c680171 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:BYAPR04MB4744; x-ms-traffictypediagnostic: BYAPR04MB4744: wdcipoutbound: EOP-TRUE x-microsoft-antispam-prvs: x-forefront-prvs: 0920602B08 x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(346002)(366004)(396003)(39860400002)(376002)(136003)(189003)(199004)(9456002)(52116002)(186003)(11346002)(54906003)(6436002)(5660300001)(50226002)(8936002)(14444005)(316002)(81156014)(8676002)(486006)(71200400001)(97736004)(7416002)(71190400001)(2616005)(25786009)(66066001)(78486014)(476003)(446003)(256004)(44832011)(6116002)(3846002)(1076003)(6486002)(81166006)(4326008)(36756003)(86362001)(6512007)(6506007)(386003)(99286004)(478600001)(2906002)(53936002)(14454004)(110136005)(7736002)(305945005)(26005)(55236004)(106356001)(102836004)(68736007)(76176011)(72206003)(105586002)(39060400002); DIR:OUT; SFP:1102; SCL:1; SRVR:BYAPR04MB4744; 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: T/sH17waXmJw3Jkr68Jfdh9mT3Gb7L16221nOe/49lNjcMIdNbqgNKA5JbTm+GRYOJF3kw/tn1bIVfDWgcbN/tuaSvDh23IL7iUikgzfN/tlm0OvT5ry9GTLu9MwvaUd5LmiN6XIL8qiIguNUco8l3OxsYMF0kRZbjWfJDAdiFP74fRcsD8SGbabLRoKtLPHv861/Q05XVW4FwfM1vnQ4b9ulbb+ag4P6wOSEZZ0tmPs2PsEGSoWhfMoz4EVPmR4yZpM9tOEYJCSO8Vymj6zxWthKEKRqqZtyG7NYsp+II6UFggLktCFFe/B6zOzbbZtrFGaU+ORU+BJSJWy2LVyk2wC/4yhJpn8oi5tHfOCpVD9HQPitB23fu8Top1Q74qAJmKIWbZrry5Xs/uwLwLAHa5VS/Xr/GFMjdsF+pL0tYw= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: wdc.com X-MS-Exchange-CrossTenant-Network-Message-Id: 33e9fab2-90ba-4d23-fd58-08d67c680171 X-MS-Exchange-CrossTenant-originalarrivaltime: 17 Jan 2019 10:39:02.3756 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: b61c8803-16f3-4c35-9b17-6f65f441df86 X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR04MB4744 X-Mailman-Approved-At: Thu, 17 Jan 2019 12:20:43 +0000 Cc: Palmer Dabbelt , U-Boot Mailing List , Alexander Graf , Christoph Hellwig , Paul Walmsley Subject: [U-Boot] [PATCH 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: Anup Patel Signed-off-by: Atish Patra --- 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 Thu Jan 17 10:39: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: 1026606 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="nkIF9wuX"; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=sharedspace.onmicrosoft.com header.i=@sharedspace.onmicrosoft.com header.b="d4FKdEGt"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 43gNgN3F2qz9sBQ for ; Thu, 17 Jan 2019 23:29:36 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id EAB1FC220BA; Thu, 17 Jan 2019 12:25:48 +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 BC5DEC22123; Thu, 17 Jan 2019 12:20:56 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id A546AC21D4A; Thu, 17 Jan 2019 10:39:15 +0000 (UTC) Received: from esa1.hgst.iphmx.com (esa1.hgst.iphmx.com [68.232.141.245]) by lists.denx.de (Postfix) with ESMTPS id AF491C21D8A for ; Thu, 17 Jan 2019 10:39:14 +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=1547721554; x=1579257554; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=qvpnSxVZPtW1lKffhmkBk7kqLNEAjIN9QY8n+yhDKvE=; b=nkIF9wuXAyS+4d7KlBe7DTWxFKoOZi4FPk2G7HxjPssIQeLYFGTvPCSa pntLYCUDIRNXdAtUkAKYYc+JTuGReH41mYffao7eBttTb5QFDVhvACEOI qJ+1OCqml2SUgJGrLNZha99vgL2iuGyDqQlM6rb9DrYqukOSrNb/ggIuZ FAy5IRLMDZ/Oo0sZwu9c5/Ak1U2PMJzW7P0lGtyqypus3VXPTRfHgc9qR jg0XSlPIgvLLi11M/Vw7p5L4lcorCxTeg/oWE8xc1SnNnFjJNHa2qxS5Z PKbzBhyTABrHS7HlRB7XKW6dejbRvu+H+UIi2c252S/0V+JH4TEWry1og A==; X-IronPort-AV: E=Sophos;i="5.56,488,1539619200"; d="scan'208";a="203985211" Received: from mail-cys01nam02lp2059.outbound.protection.outlook.com (HELO NAM02-CY1-obe.outbound.protection.outlook.com) ([104.47.37.59]) by ob1.hgst.iphmx.com with ESMTP; 17 Jan 2019 18:39: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=mu8udMy7sSOxyQGKpMS57BRjytcsA1N/CxkU0RROJH0=; b=d4FKdEGtEng+Z8v+R+NYp6nPt0n302glkA9rhAKyTlwvUfby+DxpO7RaopZEczYwGLb6RqjlWNM6dyyEdlDNQgoswNhLYQeAFa/KKlNRm5GUZhUvYprWwIcVbh4Od7LRfYSEnz4dX8/cUe0N05Fq2QrM8VhOA7DYIYHO0twtXSg= Received: from BYAPR04MB5303.namprd04.prod.outlook.com (20.178.49.148) by BYAPR04MB4744.namprd04.prod.outlook.com (52.135.240.75) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1537.26; Thu, 17 Jan 2019 10:39: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; Thu, 17 Jan 2019 10:39:11 +0000 From: Anup Patel To: Rick Chen , Bin Meng , Joe Hershberger , Lukas Auer , Masahiro Yamada , Simon Glass Thread-Topic: [PATCH 08/11] drivers: serial_sifive: Fix baud rate calculation Thread-Index: AQHUrlDiOuKbmLtVmUStDw17uD2zzA== Date: Thu, 17 Jan 2019 10:39:11 +0000 Message-ID: <20190117103748.36613-9-anup.patel@wdc.com> References: <20190117103748.36613-1-anup.patel@wdc.com> In-Reply-To: <20190117103748.36613-1-anup.patel@wdc.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: MA1PR0101CA0069.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a00:20::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: [106.51.16.164] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; BYAPR04MB4744; 6:hKN+Jw44fWdM56FO8/92u8LZPXAaQ5dRO3BUuSdAmen1rJwif/A1IoNYyxm45nC9fOklL4BE5NGqlzmTdZZDOxfiUuCniL4VgPW0ojN58rJm3SozL7tRgnaR96RlY2n+aloNfBb91UeZKsKzyEEMkQxIQWgaLJIL9sxXXO2JVIz70nMPvExVsnPIFr/ZVhs1ZxhWFiXNKHeCd6z3los8V/ddUZXh4tFMytRI3+4OHLI71AbGh4s70DNfLWEwzT0YWli4zwT552quF09rDuYW41caeIP6Z8Gi/zU6kwttzn/FENUlGsPDKpHziNLTyZa0PzWj7/u4FqKq7BLQQvI9/ceSczcvvxFIkaosK9hLdJAo4RLWIzARrvgggmtAJsbmbS4PGAcyIgpuDSmsvz/AbEKVc4M5OL/Pa6pVuOUzyTssTTNvOBeaqXIuozk4JPUrcY0nKy9T9AJZTthN7zl9Jg==; 5:3drcvo1SjndYPEBK6zpSmjQ94vqYJGpn2lHBNQ40bybDP95R5igs80rbKOqO3bC25BkspDaSMMIZcg5Ax5ShKeGqTmpacXfOh0pBfLEJTrqCJarQFww1IXTP6xSeQYxz3J8a5yUH7FsJG/QwC3HO+Hqu+3PY9gvwsWxlpwaEqNwsGgnZDeK4JMsPMsQrV5jn+TbeCLvlNsh0M4OVs/pcZQ==; 7:mIzbxEPJKJgb+QQmn2aBS0u/RKrl3uxA9sVjzUs+cEnV9ppLSC843rJp8cpHlr2uBgnjYq6oEukQ8xzm8xshuUQ4DHjrTBWRqDf46IS7AKNZD9q+9qXVGPKEfi5SjzWSxMZndjIwM+sDWfnTTTwcSw== x-ms-office365-filtering-correlation-id: f3053cb0-7e3a-4057-6719-08d67c680463 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:BYAPR04MB4744; x-ms-traffictypediagnostic: BYAPR04MB4744: wdcipoutbound: EOP-TRUE x-microsoft-antispam-prvs: x-forefront-prvs: 0920602B08 x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(346002)(366004)(396003)(39860400002)(376002)(136003)(189003)(199004)(9456002)(52116002)(186003)(11346002)(54906003)(6436002)(5660300001)(50226002)(8936002)(14444005)(316002)(81156014)(8676002)(486006)(71200400001)(97736004)(7416002)(71190400001)(2616005)(25786009)(66066001)(78486014)(476003)(446003)(256004)(44832011)(6116002)(3846002)(1076003)(6486002)(81166006)(4326008)(36756003)(86362001)(6512007)(6506007)(386003)(99286004)(478600001)(2906002)(53936002)(14454004)(110136005)(7736002)(305945005)(26005)(55236004)(106356001)(102836004)(68736007)(76176011)(72206003)(105586002)(39060400002); DIR:OUT; SFP:1102; SCL:1; SRVR:BYAPR04MB4744; 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: rWa+XNMbrZIZ93MSlE6ctgchhBm0fWmfKsqxhzT+ppYttshqFQUYY50aYmCT3FwBFWarwh9+pexKsbLALKT7FM5Fl+x6FN3svLnJlYcIdTgK7bNotkKAP87L6MnC+fR6+exQghzEzRQ4c897OaDMkF3uyKRbNvRFXu2Xg7A7HwxCirFlVy1kd7FSN57tHlukYTzq6BbRlvtJV2OJR9wwrLp4eOcqunzl40FTVCruW1pC710Q2zx6oI5Z2RxuURC0W2PUyxR4Nmvn5IRoHX3DEaPUiAasCGqzdnOmOkhSJSYyioN34cOGWO3ZrrhI0WLtViKURvlfQS6SDxKGVU6SwKdXC+t0yC1R56447K0QTCzGEZzGG1LWgE4vKBGwRJ23mZfuSvyDQCD88U+wdRQoH7EqbiL6U19H1KDq5mK/dIY= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: wdc.com X-MS-Exchange-CrossTenant-Network-Message-Id: f3053cb0-7e3a-4057-6719-08d67c680463 X-MS-Exchange-CrossTenant-originalarrivaltime: 17 Jan 2019 10:39:07.8444 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: b61c8803-16f3-4c35-9b17-6f65f441df86 X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR04MB4744 X-Mailman-Approved-At: Thu, 17 Jan 2019 12:20:43 +0000 Cc: Palmer Dabbelt , U-Boot Mailing List , Alexander Graf , Christoph Hellwig , Paul Walmsley Subject: [U-Boot] [PATCH 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 --- 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 Thu Jan 17 10:39: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: 1026604 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="Tc032uqM"; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=sharedspace.onmicrosoft.com header.i=@sharedspace.onmicrosoft.com header.b="dlN42bIK"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 43gNfm1F7vz9sBn for ; Thu, 17 Jan 2019 23:29:04 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id CB815C220CC; Thu, 17 Jan 2019 12:26:04 +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 BDF40C220BD; Thu, 17 Jan 2019 12:20:57 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id D967DC21D8A; Thu, 17 Jan 2019 10:39:20 +0000 (UTC) Received: from esa2.hgst.iphmx.com (esa2.hgst.iphmx.com [68.232.143.124]) by lists.denx.de (Postfix) with ESMTPS id 29C95C21D4A for ; Thu, 17 Jan 2019 10:39:20 +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=1547721570; x=1579257570; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=B5j4bX8cEYGxShhi3AfG9mDq2ekprXX7IL04Lq41L44=; b=Tc032uqMoiwSIbKN+dIXlcbtdseJtL0ocD8zwPWp0uieyssKyBq7duh4 /wG2AMJBFJoF2cGSFEF1BbQ3VnT8iljKwZDSObpFcsle8yWKzxw9ntHUM 8ji5RCU0hIJr6XJV8zo2yC5/T6hWS1ebreCoChuoABsa1LZBM8M1eIMWZ H+q17VueMzE5KDFAQxOdT/sZPZ/ErE7SDuH+LvOscNG2mboMIsXCdxfCz aDlGfHnzpU8ZOSsAZdAde6Wf0Rm+vMGIHJPxbor/tvgtaB8G6P6d+f5KF BEY5zmyy6+7cNkgBNPXuMt4t/z4RSei4n/lk09dghmptocq6egNmo9LbY g==; X-IronPort-AV: E=Sophos;i="5.56,488,1539619200"; d="scan'208";a="197089628" Received: from mail-cys01nam02lp2054.outbound.protection.outlook.com (HELO NAM02-CY1-obe.outbound.protection.outlook.com) ([104.47.37.54]) by ob1.hgst.iphmx.com with ESMTP; 17 Jan 2019 18:39:26 +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=wdJUHtJoWdkfQhbYPHX4rcrWc1z9iuuPKMhx4B6l6rs=; b=dlN42bIKUxj1d56RC8d17EzABGYK44qHRBDcQHqxgXYLnCdmAImxPbfmxSOm7d8l3KJGlV9xEcGOzrmVB5g+smV8ePykJGoyC7K0V0E98cRYxwncSa1cMQaK8rYFHaPg1E4RmdiMw/MRjc5EqzeFqiaYcRhnoFSFnYwfFP1eVyA= Received: from BYAPR04MB5303.namprd04.prod.outlook.com (20.178.49.148) by BYAPR04MB4744.namprd04.prod.outlook.com (52.135.240.75) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1537.26; Thu, 17 Jan 2019 10:39: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; Thu, 17 Jan 2019 10:39:16 +0000 From: Anup Patel To: Rick Chen , Bin Meng , Joe Hershberger , Lukas Auer , Masahiro Yamada , Simon Glass Thread-Topic: [PATCH 09/11] drivers: serial: serial_sifive: Skip baudrate config if no input clock Thread-Index: AQHUrlDkAfFmIP0IRUqYFYF3LlLRmw== Date: Thu, 17 Jan 2019 10:39:16 +0000 Message-ID: <20190117103748.36613-10-anup.patel@wdc.com> References: <20190117103748.36613-1-anup.patel@wdc.com> In-Reply-To: <20190117103748.36613-1-anup.patel@wdc.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: MA1PR0101CA0069.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a00:20::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: [106.51.16.164] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; BYAPR04MB4744; 6:+ABYYtMyrabnxlzmHKcIbldiGCPBvJXP1PR2EfY5z9+NaDTFmrQI+pmaBrF4r6UjoiFzX0f/SZZUTnlPDSuBGn1ISMQvleDrt0noTyDuvwnR9scajAe/VYdLAbrjnwlm3PQIgYbRQHYaRA+zf0UbjMN48VF1DQ5M2lWSXkPXf6YuzOYpUTPdFGD8eC4kHR0o1TXxotf9azYsSOnJrVcDoccTY+KsnQa+dJIPd1fbutwbWetythWc072aDj1ZmMQCIlXCiQvNFsZWmNM5vm6IogdGvYo0ARE0cw5hohSGaHFD2CBzxDn3Srf2qXTLjh6e597Vx9SshNGJA8JwAwvRD3CYdAP44A5PsJq+ZzSM8EBTPBXSy4We3AL44yUMMdOz+ccDgfgX48P+YBbhJD4xMYkE3AorfBgiMC72r4EGijhEHCHoVR6hJuJri27olFtuoeIgb3EhpqbhH92oQRYt9g==; 5:KwQGZtzdMFIFiOuRv++R/eEn2ZV7tU1CMFtNH05RUzwuHslcqDWCs4ilGWTWEHhuJ/cHN5YP/3NpNy/ePOmArZW5LRSyZ0NNad5KBN2Hks7EEvoUhEaf45xTPuNNqRLZFbCONviXIr/UnbFQLAUtqKWECq4JzgdJcwOSWQ96P2KOVdXLM0QHdxtz4OBZdzIqo6irFcmARyVKmcS1jjB0SA==; 7:er0WjJIU/gIW9UpohPCjYQi/taajyLCxPoftRmPwj6XdYwOnsD6H91m1lbqIcUHCFHXmh0Rv1YrY4hpysnqNhZN888CZCH40EMgofuyUgDvwjXZbdPHqbbIH/EmMCQZQwqYUQsgls4fN19tDpqO1vg== x-ms-office365-filtering-correlation-id: ada70ac7-7495-452d-6e80-08d67c680752 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:BYAPR04MB4744; x-ms-traffictypediagnostic: BYAPR04MB4744: wdcipoutbound: EOP-TRUE x-microsoft-antispam-prvs: x-forefront-prvs: 0920602B08 x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(346002)(366004)(396003)(39860400002)(376002)(136003)(189003)(199004)(9456002)(52116002)(186003)(11346002)(54906003)(6436002)(5660300001)(50226002)(8936002)(316002)(81156014)(8676002)(486006)(71200400001)(97736004)(7416002)(71190400001)(2616005)(25786009)(66066001)(78486014)(476003)(446003)(256004)(44832011)(6116002)(3846002)(1076003)(6486002)(81166006)(4326008)(36756003)(86362001)(6512007)(6506007)(386003)(99286004)(478600001)(2906002)(53936002)(14454004)(110136005)(7736002)(305945005)(26005)(55236004)(106356001)(102836004)(68736007)(76176011)(72206003)(105586002)(39060400002); DIR:OUT; SFP:1102; SCL:1; SRVR:BYAPR04MB4744; 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: 3tyVNLp9Qmwbm7kpS2v7MFNdtHJ4Vvc3bLqNbyOqGzY32r2J4GYGmk2U1DcxC0Oj9hJQPd9eBo/2dNShyIhxIDIk6VIGPzxpzN2exICy7WXna025zfUHQu87ZIkXhIzOJelJeZB6Xagx1gsohqwZc1I68jkAqIvVGJjZ379xcGg+jBnMOTuAtvy/WNZNGKAqTMI/Tvpar/z0ebFVRcVrxUSfQh8ioykGapvMhqblcR0fl2Ke0gZSJ6U7JVUN8mspKQ3X83U5rhq0kE5BKS7sdk6ef/C5YxvVnrEXEiFYeY7cCqfPIZFN1QGEvnLW344MgRnnQzaPYUXoI0UMO7JBRSavmT42TbzpgJkrFtdhdnJoeoVuwzVUnZNa62VT3qgi3fTDs4ZKugE5qSmDxRSThNori0EM/ZhOmS1uG+7XWhE= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: wdc.com X-MS-Exchange-CrossTenant-Network-Message-Id: ada70ac7-7495-452d-6e80-08d67c680752 X-MS-Exchange-CrossTenant-originalarrivaltime: 17 Jan 2019 10:39:12.7664 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: b61c8803-16f3-4c35-9b17-6f65f441df86 X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR04MB4744 X-Mailman-Approved-At: Thu, 17 Jan 2019 12:20:43 +0000 Cc: Palmer Dabbelt , U-Boot Mailing List , Alexander Graf , Christoph Hellwig , Paul Walmsley Subject: [U-Boot] [PATCH 09/11] drivers: serial: 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 Thu Jan 17 10:39:21 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anup Patel X-Patchwork-Id: 1026602 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="rCIeKZts"; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=sharedspace.onmicrosoft.com header.i=@sharedspace.onmicrosoft.com header.b="f7ZLMk+j"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 43gNf8444nz9sBQ for ; Thu, 17 Jan 2019 23:28:32 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id 3B8C9C220AE; Thu, 17 Jan 2019 12:26:22 +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 AE91EC22133; Thu, 17 Jan 2019 12:20:58 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 2748EC21D8A; Thu, 17 Jan 2019 10:39:26 +0000 (UTC) Received: from esa4.hgst.iphmx.com (esa4.hgst.iphmx.com [216.71.154.42]) by lists.denx.de (Postfix) with ESMTPS id 66E90C21D4A for ; Thu, 17 Jan 2019 10:39:25 +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=1547721566; x=1579257566; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=zqH76OjTJb2cvw9fKb5zMlyocPprFmVcMRKH0SJ4elk=; b=rCIeKZts+4zueNofuzvYr77/fpvTSSq4Rys5mK7Zoeh5xw00yBD0URBG tO91Ln8w/KYw6iJaE8ztsuhA1aP5f7UEW3GKuVfJrL5SxtYvMOi1bKtWH IZKbmqYxpnpB1AvEZp4Rnb/XmmZjsoWpwV/6buMiLkYzwSZXNrtEtcTpm cCu0YoZVTPEVRs+mPNAX8V9dBnfcHXyA1fgQllHmiLFRUcwqmwbCSao7g q+rv1nAdCWTDK06oBuCn1DMiothz1VzHfApygb6nIOhZRrjx1x0wpUuXF 5GllH71VPCWCDNYAJDoVDxGseoyWbmu19UM0WhqXA74WFF542jDjBIqyj g==; X-IronPort-AV: E=Sophos;i="5.56,488,1539619200"; d="scan'208";a="99024064" Received: from mail-cys01nam02lp2057.outbound.protection.outlook.com (HELO NAM02-CY1-obe.outbound.protection.outlook.com) ([104.47.37.57]) by ob1.hgst.iphmx.com with ESMTP; 17 Jan 2019 18:39:23 +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=i0hC+JdrXbOno/M4+tEEw60mq0gcUdg1yXPiy1C/NfQ=; b=f7ZLMk+jUZiwSuq4vbXSFe4cki1TUAny6MbH0qXzqbmx/8R0NEIZBrfich+HA8fR+r9qytoPhMcaBKoSzfOKx5vjs0M8MB73hEltICdBuW3mg1tbYSacU+lGxxxEa3Efmgm7Jctm/FBIu0cDLfEJ3ZUDA3e+KVlP+aQ7gjpq8zI= Received: from BYAPR04MB5303.namprd04.prod.outlook.com (20.178.49.148) by BYAPR04MB4744.namprd04.prod.outlook.com (52.135.240.75) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1537.26; Thu, 17 Jan 2019 10:39: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; Thu, 17 Jan 2019 10:39:21 +0000 From: Anup Patel To: Rick Chen , Bin Meng , Joe Hershberger , Lukas Auer , Masahiro Yamada , Simon Glass Thread-Topic: [PATCH 10/11] cpu: Bind timer driver for boot hart Thread-Index: AQHUrlDorhk96hZLqEGkn14IlawYrA== Date: Thu, 17 Jan 2019 10:39:21 +0000 Message-ID: <20190117103748.36613-11-anup.patel@wdc.com> References: <20190117103748.36613-1-anup.patel@wdc.com> In-Reply-To: <20190117103748.36613-1-anup.patel@wdc.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: MA1PR0101CA0069.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a00:20::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: [106.51.16.164] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; BYAPR04MB4744; 6:zVSLdra+OgKwq0hhKSVNlplTkTPuHMkSbvZ9ZQNrmNdrCpPYwmabBql76GZ+PYi4u+NDwpDkI3GKFY9tvz+IxHcqj8OiFvn//yhD5Z2E3Th3duget7+BrIfgxDe4XEEV2kDc8mQUHtFfURShrl1F/AE75XBSfuWo3pJojSUy/ASS1aqQdih6dYu0qB/2RvNHjVAqh15QMyqZZ9egW04PP4X5X24MGkb5GUxBoscUJMFCPX67vTsfyWd/cwYVuuAiGgw3ovbhtjyll1MYXJ2cFFjFdqaKRJpaEVn6B4OjmDlRYFTp9+vaSGa1sP4pzkDd1MBSFvpOpPdiE5/En7cWbfW9pbkuPEO/9+cF6jsqHkMQzeNz2noS7EM7Ez5O/juVSJybsOyaPcyUy90A2DG3ZLR/n0ONQskUEEgfKU55ReVkxAC5RRiaoBJF7GLNypx6bPX/Wm109PayLef6IFb3lA==; 5:pBAW84M3nBLi77X/tDkt2rNL1VH8TIXN32/HOH71dnRjO8wQI38AD1vxaMyX1JGe32cWN/Vhp5lAkzar9II3zVE6coOYycFGZFWIGdSNT3h9H6ZxIX+Yc80anseFalYnZwTAbX2hp0lnyaZn97eP3W8HDcfkWWro/xfQ7wXySRWjJ+YzYcGdReqb3bqCi5CuSlWWN8jYsBaBZDqGbS+tmg==; 7:px2+sQHd7GgAYr4RG6qw9paaxp9Y8Bt3mWwH4gL/J3IyC373f5v+DKuBgYzKLZn/bImulv9+BikN41gh9gcg/8N2tXEN0mO7eTeesiYGq3oHO0ichmdoUc3uB+tlLFuPUy6lx0BD9pg1AIG5kCnejA== x-ms-office365-filtering-correlation-id: 27ad99d0-dd61-4ea6-75ae-08d67c680a41 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:BYAPR04MB4744; x-ms-traffictypediagnostic: BYAPR04MB4744: wdcipoutbound: EOP-TRUE x-microsoft-antispam-prvs: x-forefront-prvs: 0920602B08 x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(346002)(366004)(396003)(39860400002)(376002)(136003)(189003)(199004)(9456002)(52116002)(186003)(11346002)(54906003)(6436002)(5660300001)(50226002)(8936002)(316002)(81156014)(8676002)(486006)(71200400001)(97736004)(7416002)(71190400001)(2616005)(25786009)(66066001)(78486014)(476003)(446003)(256004)(44832011)(6116002)(3846002)(1076003)(6486002)(81166006)(4326008)(36756003)(86362001)(6512007)(6506007)(386003)(99286004)(478600001)(2906002)(53936002)(14454004)(110136005)(7736002)(305945005)(26005)(55236004)(106356001)(102836004)(68736007)(76176011)(72206003)(105586002)(39060400002); DIR:OUT; SFP:1102; SCL:1; SRVR:BYAPR04MB4744; 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: SpawcT0jjXqXkF4iPdqqAL1pZ3b8w/u6//pPAUhr5bR3S8m6FuAVriVWsf/itHus8bviV9UVomqiCtirI1r4nXe6xwthT1ZF5vW+5MHjS7G3y9fBqYAw7k7z9GizllE0oEWu3SI/JRG6OP62j2vmjsTlUDQnwpG3rZL95yPP3ieF9MWl9rra8zv+xhGAzD/p2S+K3IqN/VKV5fBQnqAsDWqfhLNk7W1nfxUTZ2QGDA9Mw9oFmFhA2iWlTjFaHepj55SGn2kw5ghk6AdRL5uCeMenFflxNHvbiSBIW7nmxGh2W8YjeqtinXp5CWmpBpzqiSE4sTKkIqeP1dY72tJMWmu/bsze+TUQmP7CIuzTOOsi6d/Us+rOqcVgeHa6DuUzE+o9E7lxt0zCcFL52xTfu1oOOlX5LqB01nTgKWSjFS8= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: wdc.com X-MS-Exchange-CrossTenant-Network-Message-Id: 27ad99d0-dd61-4ea6-75ae-08d67c680a41 X-MS-Exchange-CrossTenant-originalarrivaltime: 17 Jan 2019 10:39:17.6414 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: b61c8803-16f3-4c35-9b17-6f65f441df86 X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR04MB4744 X-Mailman-Approved-At: Thu, 17 Jan 2019 12:20:43 +0000 Cc: Palmer Dabbelt , U-Boot Mailing List , Alexander Graf , Christoph Hellwig , Paul Walmsley Subject: [U-Boot] [PATCH 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 --- 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 Thu Jan 17 10:39:27 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anup Patel X-Patchwork-Id: 1026612 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="Yr6KL3Kx"; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=sharedspace.onmicrosoft.com header.i=@sharedspace.onmicrosoft.com header.b="A95xj+bk"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 43gNjX5227z9sBn for ; Thu, 17 Jan 2019 23:31:28 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id 45C1BC220ED; Thu, 17 Jan 2019 12:26:38 +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 B1391C22129; Thu, 17 Jan 2019 12:20:59 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 8AE0CC21D8A; Thu, 17 Jan 2019 10:39:31 +0000 (UTC) Received: from esa4.hgst.iphmx.com (esa4.hgst.iphmx.com [216.71.154.42]) by lists.denx.de (Postfix) with ESMTPS id 901DFC21D4A for ; Thu, 17 Jan 2019 10:39: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=1547721571; x=1579257571; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=th1V6cTdtp4tRIIBORoZYAd3gmot2RU3h9e62bZVtqw=; b=Yr6KL3KxrUTY6UziHlNOVlZoVzbdXqu/6oX/fMyRO3b02DwA0kt7+WeS Pa/Fs1f24ababHsl0YFjJF/m69Rxw1nWG2W7GezPUMdg35pWV0E1S1G6n BS3n3PbbDDTibg2xjFj0Wk0C/QYoRM+LE5y4SZ1BCki3r5LuUcgTcEDzV PuQHF53l31LOLE6wndxg9bql3Jsw6h0klZaub3F0P+T8JmQI39qnUz+Jv wbi+/7RzdBNn7GOO7OCmWis1cYx4fjAHF9OeKnjYizvy5pzocRozQya1I sA0ShZrW/c4J6KgdpQzOsnPc9Pc5scnp6Bd1b8RrFYUrOJNlv3xROVYmd g==; X-IronPort-AV: E=Sophos;i="5.56,488,1539619200"; d="scan'208";a="99024072" Received: from mail-cys01nam02lp2052.outbound.protection.outlook.com (HELO NAM02-CY1-obe.outbound.protection.outlook.com) ([104.47.37.52]) by ob1.hgst.iphmx.com with ESMTP; 17 Jan 2019 18:39:29 +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=BiPkJQspVs+KpssqZX7Ch97uV6t1ySFb9Z+ig8bKhaQ=; b=A95xj+bkdEbC2VZqqrAk1R9adFiHjKvP8HoNq5KUjkmvrzCrFoBJvnuT+ouH1JqUyKJS/uXitcxfYaOvOF1RWvWTWiFyApFGXzCqwTk/GPFQDgdD9NVE36Q4snKiyD8N71psl0PA1KvzwkKCM3yZXtstGoKd9vASM3hV9rRe/ZU= Received: from BYAPR04MB5303.namprd04.prod.outlook.com (20.178.49.148) by BYAPR04MB4744.namprd04.prod.outlook.com (52.135.240.75) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1537.26; Thu, 17 Jan 2019 10:39:27 +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; Thu, 17 Jan 2019 10:39:27 +0000 From: Anup Patel To: Rick Chen , Bin Meng , Joe Hershberger , Lukas Auer , Masahiro Yamada , Simon Glass Thread-Topic: [PATCH 11/11] riscv: Add SiFive FU540 board support Thread-Index: AQHUrlDrZo+TUsloZUW4AbTLIfmR0g== Date: Thu, 17 Jan 2019 10:39:27 +0000 Message-ID: <20190117103748.36613-12-anup.patel@wdc.com> References: <20190117103748.36613-1-anup.patel@wdc.com> In-Reply-To: <20190117103748.36613-1-anup.patel@wdc.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: MA1PR0101CA0069.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a00:20::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: [106.51.16.164] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; BYAPR04MB4744; 6:aGznvpKqOBWXtPYhVI1a+vlqm8Lz/2JUOb6h+2s1WmuziU5z6X4LgrL0JIMgq+iK3eV52bd+wsS50nhOCnfxaX6cQgnIoVnc/s/s3B/AQqlxCqMMRPmwi5iHpdyb2cXo5nLqJrqM9U5HtbJEI3b+/nUUIlK/ijEpsS6Aq7wj5pc7S1EXmtwSIUPVq82fVDoP+TzdRUuOKS6aT6Wu0yWCCpdqq8s0WVNZsWUFYwWedsRAboQ01cuHrUxa1k5+Z5GHfEq4MKrlSG/D7QpUew/uNiMUb8O8TMEBVoQU5CB8SZWJJDLBr4defebPooiN81expDn6pAAGPt8RV7tvtkN2u2acoPWWCO5CwuJ50Qi33wlx2abdqi3ZUzG49s89S4mtQ+LOVF9zXh1dEUFgYHcO1VOcX4a+Apjz6w6x/BbPIrE3l/QFf9tVLCX8659j8xI+dmT/FMYJDQX2YZ/G5ja+Bw==; 5:BJGZr5JpS0sCZRBmQ7iZCbJzS6Qw0G/D0lx5cdgQJMFS3aaCa/LpcZjCnnzwjovHR/jkESH/wn8vg92QJ/nuNkvPZItqoY8Ek2syqkUwCgxWW6zSbi0AHZ3D9Ib8rYy6E4rvpBdnmMd0LKKhgotUhvaxKv8Fqtn+OjuoP03Y0LiiKjufBsRZuwsDg2b1vOBZs9DrBXrgFIawqlY+3Yf65g==; 7:OmpuNbJ96B6rLJ1V5uDcC2CRwNGsQ7/atG6SNEykZqqB5HefUBACtm+JpbRvVVBujXnWQlEwcfi8wqlQWlu41DmBLwt8EZRzLUTLUx4ro1KHK+eXQeRUZf6/adP3F30a2DKsosmmSqZZJPp2ouff8Q== x-ms-office365-filtering-correlation-id: 22ed9117-897e-400c-3c82-08d67c680db1 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:BYAPR04MB4744; x-ms-traffictypediagnostic: BYAPR04MB4744: wdcipoutbound: EOP-TRUE x-microsoft-antispam-prvs: x-forefront-prvs: 0920602B08 x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(6029001)(346002)(366004)(396003)(39860400002)(376002)(136003)(189003)(199004)(9456002)(52116002)(186003)(11346002)(54906003)(6436002)(5660300001)(50226002)(8936002)(316002)(81156014)(8676002)(486006)(71200400001)(97736004)(7416002)(71190400001)(2616005)(25786009)(66066001)(78486014)(476003)(446003)(256004)(44832011)(6116002)(3846002)(1076003)(6486002)(81166006)(4326008)(36756003)(86362001)(6512007)(6506007)(386003)(99286004)(478600001)(2906002)(53936002)(14454004)(110136005)(7736002)(305945005)(26005)(55236004)(106356001)(102836004)(68736007)(76176011)(72206003)(105586002)(39060400002); DIR:OUT; SFP:1102; SCL:1; SRVR:BYAPR04MB4744; 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: OvudRc7psP4ag7MH4PRXmP75lMZQERTQLmY4Gv/YT0Up/5aWNXf+Y4VoCO7fxX2Qon+R8GBzJiwCJ3nu27OS0WtT2VZN01/lRhjdEC8Y45/s4me+NNQGvJtKuUudXZFF8AshZVI/T1665HppYO9xbGvKVvOnBsdfIrN839xYUBE5p73dRRKdJWVQyXoNpvdZc3821Bw1UvS4z3+00VMqYxAoIlY2F5bTcKjwDZBCypWo6Q3SrKtX1FRPmDI3kziN+US6Gy0fh2a5eJZ66aoXcqgWtmWxdynjw95Yw+h8/kebFmZDqyQfEV9gkvGRAEYLxoLpuuEL3zXWaDXSXzKiu+5NKCreB5QozyGb2su0zpJfsNsyeOLEBKX7fZSzTD/N2G/WM2a0jZn8JrfegMG4huBVl2BbJAM7o88fy5kdshQ= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: wdc.com X-MS-Exchange-CrossTenant-Network-Message-Id: 22ed9117-897e-400c-3c82-08d67c680db1 X-MS-Exchange-CrossTenant-originalarrivaltime: 17 Jan 2019 10:39:22.8759 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: b61c8803-16f3-4c35-9b17-6f65f441df86 X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR04MB4744 X-Mailman-Approved-At: Thu, 17 Jan 2019 12:20:43 +0000 Cc: Palmer Dabbelt , U-Boot Mailing List , Alexander Graf , Christoph Hellwig , Paul Walmsley Subject: [U-Boot] [PATCH 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: Anup Patel Signed-off-by: Atish Patra Reviewed-by: Alexander Graf --- 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 */