From patchwork Mon Jun 24 13:50:34 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lukasz Majewski X-Patchwork-Id: 1121348 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=none (p=none dis=none) header.from=denx.de Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 45XWSd00dyz9sPS for ; Tue, 25 Jun 2019 00:12:00 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id 6266FC21FB0; Mon, 24 Jun 2019 14:11: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 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 66023C21F9A; Mon, 24 Jun 2019 14:11:38 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 1A901C21F6E; Mon, 24 Jun 2019 13:51:11 +0000 (UTC) Received: from mail-out.m-online.net (mail-out.m-online.net [212.18.0.10]) by lists.denx.de (Postfix) with ESMTPS id C1283C21F64 for ; Mon, 24 Jun 2019 13:51:10 +0000 (UTC) Received: from frontend01.mail.m-online.net (unknown [192.168.8.182]) by mail-out.m-online.net (Postfix) with ESMTP id 45XW0Z0k7xz1rp5w; Mon, 24 Jun 2019 15:51:10 +0200 (CEST) Received: from localhost (dynscan1.mnet-online.de [192.168.6.70]) by mail.m-online.net (Postfix) with ESMTP id 45XW0Y46hTz1qqkK; Mon, 24 Jun 2019 15:51:09 +0200 (CEST) X-Virus-Scanned: amavisd-new at mnet-online.de Received: from mail.mnet-online.de ([192.168.8.182]) by localhost (dynscan1.mail.m-online.net [192.168.6.70]) (amavisd-new, port 10024) with ESMTP id 3-U1zooqIz0B; Mon, 24 Jun 2019 15:51:05 +0200 (CEST) X-Auth-Info: nVTSf9SMuKgZTo4gr7mvlvoblxN8pHKxvqHhWithNlc= Received: from localhost.localdomain (85-222-111-42.dynamic.chello.pl [85.222.111.42]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.mnet-online.de (Postfix) with ESMTPSA; Mon, 24 Jun 2019 15:51:05 +0200 (CEST) From: Lukasz Majewski To: Stefano Babic , Fabio Estevam , Marek Vasut , Simon Glass , Tom Rini , u-boot@lists.denx.de, Jagan Teki , Peng Fan , Marcel Ziswiler , Adam Ford Date: Mon, 24 Jun 2019 15:50:34 +0200 Message-Id: <20190624135052.2699-1-lukma@denx.de> X-Mailer: git-send-email 2.11.0 X-Mailman-Approved-At: Mon, 24 Jun 2019 14:11:36 +0000 Cc: Michal Simek , Joe Hershberger , Krzysztof Kozlowski , Miquel Raynal , Stefan Roese , Ryder Lee , Heinrich Schuchardt , Alexander Graf Subject: [U-Boot] [PATCH v5 00/18] clk: Port Linux common clock framework [CCF] to U-boot (tag: v5.1.12) 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: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" This patch series brings the files from Linux kernel (SHA1: 5752b50477da Linux 5.1.12 to provide clocks support as it is used on the Linux kernel with Common Clock Framework [CCF] setup. This series also fixes several problems with current clocks and provides sandbox tests for functions added to clk-uclass.c file. CCF impact to U-Boot size: -------------------------- SPL U-Boot.img Without CCF: 51 KiB 358 KiB With CCF: 55 KiB 363 KiB Size increase: 1.3% 7.2% The SPL implementation is not yet optimized (no OF_PLATDATA, etc). Repository: https://github.com/lmajewski/u-boot-dfu/commits/CCF-v5 Applicable on top of u-boot/master: SHA1: 77f6e2dd0551d8a825bab391a1bd6b838874bcd4 Travis-CI: https://travis-ci.org/lmajewski/u-boot-dfu/builds/549603356 Changes in v6: - Use dev->uclass_priv pointer to store pointer to clk Changes in v5: - s/U-boot/U-Boot/g - Update Linux version to 5.1.12 - Add paragraph regarding sandbox CCF testing (common uclass code) - Use long long to store rate value (to avoid int overflow and also return errors correctly) - Use u32 to avoid checkpatch warning - s/U-boot/U-Boot/g - Replace dev->driver_data with dev_get_clk_ptr() wrapper on uclass_priv - Replace ulong with long long (to accommodate large freqs and return errors) - s/U-boot/U-Boot/g - Check if the relevant code has changed between Linux tag v5.0-rc3 and v5.1.12 (no changes - the version can be safely updated). - Use imply CLK_IMX6Q in Kconfig for (SPL_)CCF - Fix clk-fixed-factor implementation (kzalloc needed for correct Sandbox operation) - Fix gate2 implementation - Use dev->uclass_priv instead of dev->driver_data to store back pointer to the struct clk. - Split and introduce earlier the clk-provider.h header file Changes in v4: - New patch - Port some more Linux code to facilitate imx8 code porting (most notably flags) - Explicitly use container_of() based macro to provide struct clk in various places (e.g. gate2, mux, etc) Following patches has been squashed: http://patchwork.ozlabs.org/patch/1093141/ http://patchwork.ozlabs.org/patch/1093142/ http://patchwork.ozlabs.org/patch/1093146/ Changes in v3: - New patch - The rate information is now cached into struct clk field - The clk_get_parent() is used to get pointer to the parent struct clk - Replace -ENODEV with -ENOENT - Use **clkp instead of **c - Replace dev->driver_data with dev_get_clk_ptr() wrapper on uclas_priv Lukasz Majewski (18): clk: doc: Add documentation entry for Common Clock Framework [CCF] (i.MX) dm: Fix documentation entry as there is no UCLASS_CLOCK uclass clk: Remove clock ID check in .get_rate() of clk_fixed_* clk: Extend struct clk to provide information regarding clock rate clk: Extend struct clk to provide clock type agnostic flags clk: Provide struct clk for fixed rate clock (clk_fixed_rate.c) clk: Introduce clk-provider.h to store Common Clock Framework's internals dm: clk: Define clk_get_parent() for clk operations dm: clk: Define clk_get_parent_rate() for clk operations dm: clk: Define clk_get_by_id() for clk operations clk: Port Linux common clock framework [CCF] for imx6q to U-boot (tag: v5.1.12) dm: clk: Extend clk_get_parent_rate() to support CLK_GET_RATE_NOCACHE flag dts: sandbox: Add 'osc' clock for Common Clock Framework [CCF] testing clk: sandbox: Adjust clk-divider to emulate reading its value from HW clk: sandbox: Adjust clk-mux.c to emulate reading divider value from HW clk: sandbox: Add sandbox test code for Common Clock Framework [CCF] defconfig: sandbox: Enable SANDBOX_CLK_CCF to reuse generic CCF code clk: Add MAINTAINERS entry for clocks (./drivers/clk/) MAINTAINERS | 7 ++ arch/sandbox/dts/test.dts | 10 ++ configs/sandbox_defconfig | 1 + configs/sandbox_flattree_defconfig | 1 + doc/imx/clk/ccf.txt | 101 ++++++++++++++++++++ drivers/clk/Kconfig | 22 +++++ drivers/clk/Makefile | 3 + drivers/clk/clk-divider.c | 155 +++++++++++++++++++++++++++++++ drivers/clk/clk-fixed-factor.c | 80 ++++++++++++++++ drivers/clk/clk-mux.c | 172 ++++++++++++++++++++++++++++++++++ drivers/clk/clk-uclass.c | 60 ++++++++++++ drivers/clk/clk.c | 57 ++++++++++++ drivers/clk/clk_fixed_factor.c | 3 - drivers/clk/clk_fixed_rate.c | 8 +- drivers/clk/clk_sandbox_ccf.c | 185 +++++++++++++++++++++++++++++++++++++ drivers/clk/imx/Kconfig | 16 ++++ drivers/clk/imx/Makefile | 2 + drivers/clk/imx/clk-gate2.c | 103 +++++++++++++++++++++ drivers/clk/imx/clk-imx6q.c | 179 +++++++++++++++++++++++++++++++++++ drivers/clk/imx/clk-pfd.c | 90 ++++++++++++++++++ drivers/clk/imx/clk-pllv3.c | 82 ++++++++++++++++ drivers/clk/imx/clk.h | 69 ++++++++++++++ include/clk.h | 37 +++++++- include/linux/clk-provider.h | 132 ++++++++++++++++++++++++++ include/sandbox-clk.h | 76 +++++++++++++++ test/dm/Makefile | 2 +- test/dm/clk_ccf.c | 62 +++++++++++++ 27 files changed, 1707 insertions(+), 8 deletions(-) create mode 100644 doc/imx/clk/ccf.txt create mode 100644 drivers/clk/clk-divider.c create mode 100644 drivers/clk/clk-fixed-factor.c create mode 100644 drivers/clk/clk-mux.c create mode 100644 drivers/clk/clk.c create mode 100644 drivers/clk/clk_sandbox_ccf.c create mode 100644 drivers/clk/imx/clk-gate2.c create mode 100644 drivers/clk/imx/clk-imx6q.c create mode 100644 drivers/clk/imx/clk-pfd.c create mode 100644 drivers/clk/imx/clk-pllv3.c create mode 100644 drivers/clk/imx/clk.h create mode 100644 include/linux/clk-provider.h create mode 100644 include/sandbox-clk.h create mode 100644 test/dm/clk_ccf.c