From patchwork Mon Dec 31 16:59:04 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jagan Teki X-Patchwork-Id: 118 Return-Path: X-Original-To: linux-amarula@patchwork.amarulasolutions.com Delivered-To: linux-amarula@patchwork.amarulasolutions.com Received: from mail-pg1-f200.google.com (cartago.priv [10.11.12.1]) by cassiopea.amarulasolutions.com (Postfix) with ESMTPS id 3C1C42E002E for ; Mon, 31 Dec 2018 18:00:37 +0100 (CET) Received: by mail-pg1-f200.google.com with SMTP id r16sf24547454pgr.15 for ; Mon, 31 Dec 2018 09:00:37 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1546275635; cv=pass; d=google.com; s=arc-20160816; b=izrv2XeaV6KLwAil8UI/DwvyPpR5IsAESgdOHTwJ/inMjxZaSQVhRL3W1f2W1f6K2I 4jv8t+Bei3SSKJR6DYzN274sTE80tARYTmVZo6CQSVQS7m4C73wvY3Jn1miClX7ubxM3 ndVAjV2RMlh3+cmgYjy2ltsZ5+PwobQCvCzm4aAslc+FaA7c1bfyW/KzvrcXe3PWbOJ9 mVMP2UpkMBsAanaQ9tLyAt7Mdmmh6PMeJWuMm05h9nXxBY6Ds2ymYdvucI15AaHzroA0 rFY6x6AFvLIIfk1ldSmRxeUnKMiqvC4LUbeWG3tqPVuJlyReAPx9LnwCnM/pu0nWBgOT 28vA== 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:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=tfBecW4K55CCu+/j7Q9NxzYQsaQLQEuqNBdy7dY4u3c=; b=m/+Z572RAriCTurSLJKxPJTdzSxHk4pNIfh8dLgZkCpgaQAgsfE590T00HAa1o4cLJ gqW1U4QhoOJir54FVcKKSFg4+sJatk4YpbJfHpMWQpNJKJ2/SomIK2vrGbINNEdXtx5l dVzMjvrNsb1ggdPpNCGcf2nqQjO0N+qnrTTU50op3DeW2sgP1o0dXOhA2joHbfhovMq9 KsXYs6WTIulSVQrFZ/NPX/HidpYrTpuHVkNMNPlT3z/jyVTxkQ3eUYjAVGGseZxdaLh1 WBISzKOXkKclVwx0GK0y8L3oe919zHGrojLOyrtUuqUb2jhBpYztKmzURm8S2jhp4xl3 Y1vA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=RJWEDFIx; 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:content-transfer-encoding:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :list-post:list-help:list-archive:list-unsubscribe; bh=tfBecW4K55CCu+/j7Q9NxzYQsaQLQEuqNBdy7dY4u3c=; b=hdA5QdAf1yISmZDXAtKHqIuN98DzPjWllRbB512sMmd7Wdm7PFqLGpxUGuylSpOCVv 5gFT9PhmHtBDxW332n8mkxn4Yv+xO/xjWXOzg5xPJ7tLU4MrQPN27mW3PyFgiVezeuw3 UUMfdu0wBjD1MHWGb0NtBjhvG1jP14ceTicyg= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding: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=tfBecW4K55CCu+/j7Q9NxzYQsaQLQEuqNBdy7dY4u3c=; b=lmuMQQogM1KQhSFuUQOVRl720hPWCRLlRhK0PT25nK9eBBdNiD3w28fuySBPyEGwnZ UqjFP0pZ5lxzP5wrvTZXP1s5/LTb3cjeFv8pb6kpbb3V5bco0PDMX2Oi5+ULkT8R2px/ IAdmbSsMOV4ZrbxC2eBSpabNfQmuWy1lzuQnCwmmQV1Rso5awS7t7Z1sPRYRObCvcIkC 4TsofdjNwsvMJeBGnALdW/vz7h7cKra++NAXCBME1lzMt4qnH7yQ2N979CfExJhSzDP5 rYz+f1gLeFiCHkltUPnrrEeHTFv8KG/Inz6O8024GLj0r++ZZaM3W58AfGMUWpFNidCz FMdA== X-Gm-Message-State: AJcUukc1vL1DJZCvlB6wsY0XYEGFoIVf2ukHlH0tLwio9x6zl9TiRDNG lQo6+qCgNQe0mEa55ScHQUY4sPo/ X-Google-Smtp-Source: ALg8bN7nBCLsFKwvTasKi5tWXtfpkRagMKA4+gFoa/gYhuW1GKEcAtpYeXhxYa1DDexgfZ5aot3A9Q== X-Received: by 2002:a17:902:7888:: with SMTP id q8mr14391177pll.130.1546275635846; Mon, 31 Dec 2018 09:00:35 -0800 (PST) X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:a63:151d:: with SMTP id v29ls6485759pgl.2.gmail; Mon, 31 Dec 2018 09:00:35 -0800 (PST) X-Received: by 2002:a62:1b50:: with SMTP id b77mr38873996pfb.36.1546275635551; Mon, 31 Dec 2018 09:00:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1546275635; cv=none; d=google.com; s=arc-20160816; b=mYHeC2KM9ZSbnmAADkTWYLNNNFtZs/JgnhoWZ1R9KzPVRsaB+HJHeqID8NSzAN8yEJ IWoTBZyZsClL5LYEIaDNt4Qspr4gQD6VwSusdY4OHbpg70ZxqlfsHuR1Cov3YQMdQ+41 cpjUnUJnqIhDvcGSeJBivtwv1wO3fBG8mdyJz4mZQniAPOwQLe04mPfYkt3yRtwunbBU 1mFoBDBc6DCz2D8ALJo5voOHkszA2LSK873przoSXZ3YmaddCmL3mZp1wF+Mk5U8vhF6 90Xgc0ECbkGNRVt2r+T+KwZnlEyXknLbxpaFB5Q4Ckf4xU/Mw+YY40+vbQzt3lHfU2eN UVyg== 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=tfBecW4K55CCu+/j7Q9NxzYQsaQLQEuqNBdy7dY4u3c=; b=ZDfuDM5zpAwo06W9EXhbp9fKv7pviLA6koxthF3IDBJTl/lqxvGJd494HcXlR/MntM +Ghk/250fRHmda09416AdM4xnBdpNget5DelISUYh/VGBnD5Yys1JQs6QZjt+TJNdfLT wUZejTIJe13MyozyqS3uNZ16A/Sd22s5kOHRIR5Zth7h2xceQNe9bDXAVQPBco6LSbB3 CBJoUMQzsDUAgXQOGUiJXNry8D11AwA/Oe+TGG5owoT7y3f29mo2aHIoPuFMNCFtpH+C 18nngZmQReAhsyhNTKsn5maMQ1Y0xksh6Cd5FZcprya960UnjDYn2sh9dufpFO5ppMTe HaCA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=RJWEDFIx; 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 u69sor13712114pgd.63.2018.12.31.09.00.35 for (Google Transport Security); Mon, 31 Dec 2018 09:00:35 -0800 (PST) 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:a63:2109:: with SMTP id h9mr8084319pgh.277.1546275635143; Mon, 31 Dec 2018 09:00:35 -0800 (PST) Received: from localhost.localdomain ([115.97.184.237]) by smtp.gmail.com with ESMTPSA id p7sm90692925pfj.72.2018.12.31.09.00.31 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 31 Dec 2018 09:00:34 -0800 (PST) From: Jagan Teki To: Maxime Ripard , Andre Przywara Cc: Chen-Yu Tsai , Simon Glass , Tom Rini , u-boot@lists.denx.de, linux-sunxi@googlegroups.com, Michael Trimarchi , linux-amarula@amarulasolutions.com, Jagan Teki Subject: [PATCH v5 03/26] clk: sunxi: Add Allwinner H3/H5 CLK driver Date: Mon, 31 Dec 2018 22:29:04 +0530 Message-Id: <20181231165927.13803-4-jagan@amarulasolutions.com> X-Mailer: git-send-email 2.18.0.321.gffc6fa0e3 In-Reply-To: <20181231165927.13803-1-jagan@amarulasolutions.com> References: <20181231165927.13803-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=RJWEDFIx; spf=pass (google.com: domain of jagan@amarulasolutions.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=jagan@amarulasolutions.com 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: , Add initial clock driver for Allwinner H3/H5. - Implement USB bus and USB clocks via ccu_clk_gate table for H3/H5, so it can accessed in common clk enable and disable functions from clk_sunxi.c - Implement USB bus and USB resets via ccu_reset table for H3/H5, so it can accessed in common reset deassert and assert functions from reset-sunxi.c Signed-off-by: Jagan Teki Acked-by: Maxime Ripard --- drivers/clk/sunxi/Kconfig | 7 ++++ drivers/clk/sunxi/Makefile | 1 + drivers/clk/sunxi/clk_h3.c | 79 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 87 insertions(+) create mode 100644 drivers/clk/sunxi/clk_h3.c diff --git a/drivers/clk/sunxi/Kconfig b/drivers/clk/sunxi/Kconfig index 041d711e58..c3713bbac2 100644 --- a/drivers/clk/sunxi/Kconfig +++ b/drivers/clk/sunxi/Kconfig @@ -9,6 +9,13 @@ config CLK_SUNXI if CLK_SUNXI +config CLK_SUN8I_H3 + bool "Clock driver for Allwinner H3/H5" + default MACH_SUNXI_H3_H5 + help + This enables common clock driver support for platforms based + on Allwinner H3/H5 SoC. + config CLK_SUN50I_A64 bool "Clock driver for Allwinner A64" default MACH_SUN50I diff --git a/drivers/clk/sunxi/Makefile b/drivers/clk/sunxi/Makefile index fb20d28333..dec49f27a1 100644 --- a/drivers/clk/sunxi/Makefile +++ b/drivers/clk/sunxi/Makefile @@ -6,4 +6,5 @@ obj-$(CONFIG_CLK_SUNXI) += clk_sunxi.o +obj-$(CONFIG_CLK_SUN8I_H3) += clk_h3.o obj-$(CONFIG_CLK_SUN50I_A64) += clk_a64.o diff --git a/drivers/clk/sunxi/clk_h3.c b/drivers/clk/sunxi/clk_h3.c new file mode 100644 index 0000000000..283fc31b01 --- /dev/null +++ b/drivers/clk/sunxi/clk_h3.c @@ -0,0 +1,79 @@ +// SPDX-License-Identifier: (GPL-2.0+ OR MIT) +/* + * Copyright (C) 2018 Amarula Solutions. + * Author: Jagan Teki + */ + +#include +#include +#include +#include +#include +#include +#include + +static struct ccu_clk_gate h3_gates[] = { + [CLK_BUS_OTG] = GATE(0x060, BIT(23)), + [CLK_BUS_EHCI0] = GATE(0x060, BIT(24)), + [CLK_BUS_EHCI1] = GATE(0x060, BIT(25)), + [CLK_BUS_EHCI2] = GATE(0x060, BIT(26)), + [CLK_BUS_EHCI3] = GATE(0x060, BIT(27)), + [CLK_BUS_OHCI0] = GATE(0x060, BIT(28)), + [CLK_BUS_OHCI1] = GATE(0x060, BIT(29)), + [CLK_BUS_OHCI2] = GATE(0x060, BIT(30)), + [CLK_BUS_OHCI3] = GATE(0x060, BIT(31)), + + [CLK_USB_PHY0] = GATE(0x0cc, BIT(8)), + [CLK_USB_PHY1] = GATE(0x0cc, BIT(9)), + [CLK_USB_PHY2] = GATE(0x0cc, BIT(10)), + [CLK_USB_PHY3] = GATE(0x0cc, BIT(11)), + [CLK_USB_OHCI0] = GATE(0x0cc, BIT(16)), + [CLK_USB_OHCI1] = GATE(0x0cc, BIT(17)), + [CLK_USB_OHCI2] = GATE(0x0cc, BIT(18)), + [CLK_USB_OHCI3] = GATE(0x0cc, BIT(19)), +}; + +static struct ccu_reset h3_resets[] = { + [RST_USB_PHY0] = RESET(0x0cc, BIT(0)), + [RST_USB_PHY1] = RESET(0x0cc, BIT(1)), + [RST_USB_PHY2] = RESET(0x0cc, BIT(2)), + [RST_USB_PHY3] = RESET(0x0cc, BIT(3)), + + [RST_BUS_OTG] = RESET(0x2c0, BIT(23)), + [RST_BUS_EHCI0] = RESET(0x2c0, BIT(24)), + [RST_BUS_EHCI1] = RESET(0x2c0, BIT(25)), + [RST_BUS_EHCI2] = RESET(0x2c0, BIT(26)), + [RST_BUS_EHCI3] = RESET(0x2c0, BIT(27)), + [RST_BUS_OHCI0] = RESET(0x2c0, BIT(28)), + [RST_BUS_OHCI1] = RESET(0x2c0, BIT(29)), + [RST_BUS_OHCI2] = RESET(0x2c0, BIT(30)), + [RST_BUS_OHCI3] = RESET(0x2c0, BIT(31)), +}; + +static const struct ccu_desc h3_ccu_desc = { + .gates = h3_gates, + .resets = h3_resets, +}; + +static int h3_clk_bind(struct udevice *dev) +{ + return sunxi_reset_bind(dev, 53); +} + +static const struct udevice_id h3_ccu_ids[] = { + { .compatible = "allwinner,sun8i-h3-ccu", + .data = (ulong)&h3_ccu_desc }, + { .compatible = "allwinner,sun50i-h5-ccu", + .data = (ulong)&h3_ccu_desc }, + { } +}; + +U_BOOT_DRIVER(clk_sun8i_h3) = { + .name = "sun8i_h3_ccu", + .id = UCLASS_CLK, + .of_match = h3_ccu_ids, + .priv_auto_alloc_size = sizeof(struct ccu_priv), + .ops = &sunxi_clk_ops, + .probe = sunxi_clk_probe, + .bind = h3_clk_bind, +};