From patchwork Tue Apr 2 11:28:39 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jagan Teki X-Patchwork-Id: 195 Return-Path: X-Original-To: linux-amarula@patchwork.amarulasolutions.com Delivered-To: linux-amarula@patchwork.amarulasolutions.com Received: from mail-pg1-f200.google.com (mail-pg1-f200.google.com [209.85.215.200]) by ganimede.amarulasolutions.com (Postfix) with ESMTPS id 1DFD83F078 for ; Tue, 2 Apr 2019 13:29:34 +0200 (CEST) Received: by mail-pg1-f200.google.com with SMTP id 18sf9729943pgx.11 for ; Tue, 02 Apr 2019 04:29:34 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1554204573; cv=pass; d=google.com; s=arc-20160816; b=K10RNIlb7h/DfqwB63ignem5D7xXKTSrupsvxClp97bpaDPBgTeGcQoyuJSgBXJMaD 2KrymHeSIKvvupRTIMtwjsOQA38ZMYpyRbxkPZh84ZXO7heouSXkqdg6H8Amv9vx6ZNU BBpJKlorL6VFf6xZxlCw0saktDLYq9w8WdHlabFUsX0HzcXNMhZXnCxMZEVtedLa/ofk vLu5PN8BRp9fkwZqoIJuYmqmqbuuNfHC38qsYs8gDBqtw8hf886PPVrTfPJrmqpJk7nR yptiUFIX8Ja+8VWaNV6uJfKowCjvgk6Bwg2DKdvy4NQb621ftZOZ1VXA7larmFoaJB3p cAoQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-archive:list-help:list-post:list-id :mailing-list:precedence:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=SdPu0NdP6VBWOY79D156W7TvLsJEkGHoqkG19nUSC5I=; b=dtgwNal5qABc7m6hbg+B85bjDNy8I1z4cAyhVKf/JGF4mdWDOodvwJIoKj7tn15cVM W1rxG2l8dILhDE23QqT3yrrRvnNGx+yTOR3+1VFKPraXDcTvdU9ORDAP8DbgLxMkkseG RtnD6OB+iHsd/ppMfQJ/qV+ODGrfOaDj8k39ErQdf4IPTDnktFOr/SWpCpg1emlX77qB A5lt1upcggkKylClXBB9eThrA2qjL/VeGM/0BludtFXDV3JQTteW/nD18B8xlMaJizhT wfYUP8b7jmkLClP+ohNaPt8HCANRA6DrPcgYPxXZrjDdcm50xr3fk8sk6OVNDoDW+hJr Y67g== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=WKx8vO7v; spf=pass (google.com: domain of jagan@amarulasolutions.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=jagan@amarulasolutions.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amarulasolutions.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:x-original-sender:x-original-authentication-results :precedence:mailing-list:list-id:list-post:list-help:list-archive :list-unsubscribe; bh=SdPu0NdP6VBWOY79D156W7TvLsJEkGHoqkG19nUSC5I=; b=S9zm3LUwEnDybSvPWuSeHJ1oorWyAeCbd2ZBKdLiNNdQjt3bTW8IpjozrlvKAfvWK0 /R7T97uw2DIXzjaM0QnkvEnJWuQ6aK2GiKMDpHL9NuDDBDBljAV3TzhALJdBRN3Rb7tx Y/P4pIVEdf4QErcTACtwg7NZDUX4967XTq59U= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :x-spam-checked-in-group:list-post:list-help:list-archive :list-unsubscribe; bh=SdPu0NdP6VBWOY79D156W7TvLsJEkGHoqkG19nUSC5I=; b=F9hrpYte4sic6bxJeqvZobKzh7Ckk7z+di1f4vrNHpBUfxSLqQByoG1fG33YmMBlpC w7TfITrnJ/JaIPbjHlXeyuZ0vFQMT8djf+qF7OYVaWN4fDtBG8x4AtJmkB5xjcPuTZSf w8J5KkgTPhL0zKHDAfi02UCS4UqYY0qommV6XvMlS2KnOTn7ovHA82iSVKgLaZtSlTiR Xrf5lJw5hIPszOKBOGgAFA/yAfqRmRfDVwuy4ZFmndIJQa+fcwmPobgAOj84BXVyvP7x TOrDQAcouCfOOLxyT2+unexo04FI7GjYG6AobEgRv4MwB0FNOW3AQyOWHHjSjs/rz4w+ BSFQ== X-Gm-Message-State: APjAAAVpwIW6HayYhQBnv2gzcL3jdtxzX5+HdZGNl+7pkgQJwZVLVK4p Vn0dXHgtdjvN4H5w1gkSdduJiBD7 X-Google-Smtp-Source: APXvYqymy6qzTcyoSimHD331Q/jGLx40gPpKvObNc/5YsN+5o726iuMDmVL4m40aOjx5xj7G2LgCLw== X-Received: by 2002:aa7:93a8:: with SMTP id x8mr1168235pff.87.1554204572896; Tue, 02 Apr 2019 04:29:32 -0700 (PDT) X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:a17:902:227:: with SMTP id 36ls6321514plc.8.gmail; Tue, 02 Apr 2019 04:29:32 -0700 (PDT) X-Received: by 2002:a17:902:9a09:: with SMTP id v9mr68634491plp.225.1554204572466; Tue, 02 Apr 2019 04:29:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1554204572; cv=none; d=google.com; s=arc-20160816; b=Eg3K3Fp9D6WIlxdnFuAAbXULSK9sJ4JLBYD9slYkfPQXcdq6btOywKbg1rrK9o0ShH h54+rkR5CpwbUFtKvJLuLLpZSViSiCTZYtgUQjAB5yowPkmAwpnOK2uPF8R652dfClEp mLgWfZDQar4ezCPgXIFAyBGq5LhrmoXywUmDs7K8V3hVUpeuFmOrhwNh/VXRcY0DM3bu BpHQa6hxFtSe2/9WN6Y8v+URCpnUsNHhcuRhcrmibVr0igLoG4x3Z9X/qZV60kHA8ejS rj01oZAetVeIc1NqfwrHVRWz5jzPuoCZVdS+Oroc/nY1Tnh/fM9Lp6B3ckISm28u4tUh MaYg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=WO35GqKvUQJDjEEk6ZGRPqU7zDrVzdtDRzq4IB+StZ8=; b=uVFWII9BriOwLpr+jd3HYp/xwjXh8pBMl719lgfNt/BdvaOFx0attPV74oRGbvaKGb LXxyHtjsuIGP+m5QkTKoOdv8ncrnq5gII9LCFjUNEtZ1+TciU0HklrDrJOiS//UMu0a3 u5OZa+i3Qw377ZkYKu7UwLTdU7p3iDzG3wWgxUAkW3XYYcCOsYWVa/4zwvP7HkUTaYKs tAPwyOlOT9ilIQ9evUPKSig2hLMDYsiennjKRSB+lY1tZUIsM9ncEqCjQTeI/n3Zyb+X aJWs9TPStd7XLDyiCzanCyupEQUXvGeUPB0NnCSm3Nbimtnxh4BNnZF9g0hj2Y0o/mKy BPHA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=WKx8vO7v; spf=pass (google.com: domain of jagan@amarulasolutions.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=jagan@amarulasolutions.com Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id o9sor16602301plk.9.2019.04.02.04.29.32 for (Google Transport Security); Tue, 02 Apr 2019 04:29:32 -0700 (PDT) Received-SPF: pass (google.com: domain of jagan@amarulasolutions.com designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; X-Received: by 2002:a17:902:9b83:: with SMTP id y3mr23654838plp.165.1554204572157; Tue, 02 Apr 2019 04:29:32 -0700 (PDT) Received: from jagan-XPS-13-9350.imgcgcw.net ([147.50.13.10]) by smtp.gmail.com with ESMTPSA id u62sm23992715pfa.124.2019.04.02.04.29.27 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 02 Apr 2019 04:29:31 -0700 (PDT) From: Jagan Teki To: Simon Glass , Tom Rini , Neil Armstrong , Philipp Tomsich , Marek Vasut , Stefano Babic , Fabio Estevam , Peng Fan , Maxime Ripard , Michael Trimarchi , Andre Przywara Cc: u-boot@lists.denx.de, uboot-imx@nxp.com, Shyam Saini , linux-amarula@amarulasolutions.com, Jagan Teki Subject: [PATCH v2 06/10] clk: imx6: Add imx6ul clock tree support Date: Tue, 2 Apr 2019 16:58:39 +0530 Message-Id: <20190402112843.992-7-jagan@amarulasolutions.com> X-Mailer: git-send-email 2.18.0.321.gffc6fa0e3 In-Reply-To: <20190402112843.992-1-jagan@amarulasolutions.com> References: <20190402112843.992-1-jagan@amarulasolutions.com> MIME-Version: 1.0 X-Original-Sender: jagan@amarulasolutions.com X-Original-Authentication-Results: mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=WKx8vO7v; spf=pass (google.com: domain of jagan@amarulasolutions.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=jagan@amarulasolutions.com Content-Type: text/plain; charset="UTF-8" Precedence: list Mailing-list: list linux-amarula@amarulasolutions.com; contact linux-amarula+owners@amarulasolutions.com List-ID: X-Spam-Checked-In-Group: linux-amarula@amarulasolutions.com X-Google-Group-Id: 476853432473 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , i.MX6 clock control module comprise of parent clocks, gates, multiplexers, dividers, PODF, PLL, fixed rate and etc. So, the U-Boot implementation of ccm has divided into gates and tree. 1) gate clocks are generic clock configuration of enable/disable bit management which can be handle via imx6_clock_gate. 2) tree clocks are handle via tree clock management where it link the clocks based on the parent clock which usually required to get and set the clock rates. This patch add tree clock management for imx6ul USDHC clocks, so the mmc driver from imx6 can eventually use this so getting the USDHC clock rates. Unlike Linux, U-Boot implementation may not require to maintain exact clock tree due to various constrains and use cases. So here is how the clock tree differs between them. usdhc clock tree in Linux: ------------------------- USDHC1 => USDHC1_PODF => USDHC1_SEL => PLL2_PFD2 => PLL2_BUS => PLL2_BYPASS => PLL2 => OSC usdhc clock tree in U-Boot: --------------------------- USDHC1 => USDHC1_PODF => USDHC1_SEL => PLL2_PFD2 => PLL2_BUS => OSC Signed-off-by: Jagan Teki --- drivers/clk/imx/clk-imx6ul.c | 48 ++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/drivers/clk/imx/clk-imx6ul.c b/drivers/clk/imx/clk-imx6ul.c index f5250e8b72..8528176eec 100644 --- a/drivers/clk/imx/clk-imx6ul.c +++ b/drivers/clk/imx/clk-imx6ul.c @@ -10,6 +10,53 @@ #include #include +static const unsigned long pll2_bus[] = { + IMX6UL_CLK_OSC, +}; + +static const unsigned long pfd_352m[] = { + IMX6UL_CLK_PLL2_BUS, +}; + +static const unsigned long usdhc_sel[] = { + IMX6UL_CLK_PLL2_PFD2, + IMX6UL_CLK_PLL2_PFD0, +}; + +static const unsigned long usdhc1_podf[] = { + IMX6UL_CLK_USDHC1_SEL, +}; + +static const unsigned long usdhc2_podf[] = { + IMX6UL_CLK_USDHC2_SEL, +}; + +static const unsigned long usdhc1[] = { + IMX6UL_CLK_USDHC1_PODF, +}; + +static const unsigned long usdhc2[] = { + IMX6UL_CLK_USDHC2_PODF, +}; + +static const struct imx6_clk_tree imx6ul_tree[] = { + [IMX6UL_CLK_OSC] = FIXED(OSC_24M_ULL), + + [IMX6UL_CLK_PLL2_BUS] = PLL_DIV(pll2_bus, 0x30, 13, 1), + + [IMX6UL_CLK_PLL2_PFD0] = PLL_PFD(pfd_352m, 0x100, 6, 0), + [IMX6UL_CLK_PLL2_PFD2] = PLL_PFD(pfd_352m, 0x100, 6, 2), + + [IMX6UL_CLK_USDHC2_SEL] = MUX(usdhc_sel, 0x01c, 17, 1), + [IMX6UL_CLK_USDHC1_SEL] = MUX(usdhc_sel, 0x01c, 16, 1), + + [IMX6UL_CLK_USDHC2_PODF] = DIV(usdhc2_podf, 0x024, 16, 3), + [IMX6UL_CLK_USDHC1_PODF] = DIV(usdhc1_podf, 0x024, 11, 3), + + [IMX6UL_CLK_USDHC2] = SIMPLE(usdhc2), + [IMX6UL_CLK_USDHC1] = SIMPLE(usdhc1), +}; + static const struct imx6_clk_gate imx6ul_gates[] = { [IMX6UL_CLK_USDHC1] = GATE(0x080, GENMASK(3, 2)), [IMX6UL_CLK_USDHC2] = GATE(0x080, GENMASK(5, 4)), @@ -17,6 +64,7 @@ static const struct imx6_clk_gate imx6ul_gates[] = { static const struct imx6_clk_desc imx6ul_clk_desc = { .gates = imx6ul_gates, + .tree = imx6ul_tree, }; static const struct udevice_id clk_imx6ul_ids[] = {