From patchwork Mon Dec 31 16:59:10 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jagan Teki X-Patchwork-Id: 124 Return-Path: X-Original-To: linux-amarula@patchwork.amarulasolutions.com Delivered-To: linux-amarula@patchwork.amarulasolutions.com Received: from mail-pl1-f199.google.com (cartago.priv [10.11.12.1]) by cassiopea.amarulasolutions.com (Postfix) with ESMTPS id D1D862E002E for ; Mon, 31 Dec 2018 18:01:13 +0100 (CET) Received: by mail-pl1-f199.google.com with SMTP id v12sf21963327plp.16 for ; Mon, 31 Dec 2018 09:01:13 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1546275672; cv=pass; d=google.com; s=arc-20160816; b=ZDnSDee0wGIXLINlhpTx5mbXNmabna/0uTimYkYcNpV9h5xaPke39WT0EobxMJH/O+ jMtU69Jtm/dM5FTf7SvHyJz4+7EEiXvPziX129SaeU7x4wfp2tzLp8HfcRZDtS93/gKo WO5OoU3+l9yeZUNQp7bibjyn3YISSB0DOgAgsYwk/1JYqtWuCGHVp3GMdeWlQFNmj1jP qvtDkpq5+680NKWuC+ewtBQ9JB+Qqb+ydXGLWFffqovvLd5czlJXrd/uymnHVEFKvt29 tDU58tnJU0hxUmOheuZAAZzdf5tH+gK6WW6FbxcMIThmZJVi8TYKnDMWHKalaYpASlem kqaA== 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=XMWHnHjlI9SU1Ey/mjiyFCP12XhI50YU9PmO5axz3T0=; b=BxiMAQoAb9BNnZtawAi+DvT/KdmL2iooWoN7XtC0OYfIw3SsHcCiNEcq07yex6qFqj YpbgUdjix78MCXWUXFO7u0XAP5lQHHNKtNPgSuJ9w+bLrdjrdGHRZy2POYOMPQF9Q95i 0csqsdf5S0JEuNd4BKcCWb9WEXHwZ7unkZwq/nkDie+K/hQz2OK5pI5bZZvDp7rxk04f FrOue41BGH04uZObayNUmyWOcy9nXZs0mJRzLvFbtyj5dnsy3FYNlWEsEiGxVwjtSE+3 i8LfNKZLUwkBxEnr182Uouv3oGb1G7Imh+KSRaTrCG09nAROL1glC+1BDxAlNvO3c3J7 4ofQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=NkNjCAIo; 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=XMWHnHjlI9SU1Ey/mjiyFCP12XhI50YU9PmO5axz3T0=; b=KkF3OSnsXtjGFGfUsBuS42AOHlE3X2oezlgSbhzz+POrG380JuzhTGiVEL89TBWp7Z nj9a6UWdgxFs2A+9qSKUu6ZrYyu3v1m3eKQtFy4+XQxvrytkP/cQcfmTVI8s+sjiEfkk RC1tXd3ZnLNWa2wmZso79s+NijMts5lfjbPmE= 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=XMWHnHjlI9SU1Ey/mjiyFCP12XhI50YU9PmO5axz3T0=; b=QhJxLMN7uyZ/H9nfzNshB7z5imVh71mP9EcyYK2BsVwlV4YiEUVQiYgFp41TRVgAOC 24JGlTWS3HIcqIzuh8FNtIesoEMOkq0ViNSs5hGakXrJH4q8Wuf60UlwJnDfNUOnqR6t y0UNf8kJxq7eGgq1L8pgYetT909X5lIoWQjXHoOVMj4XSySF+3RNWlX5pH9JMDBku2h5 hnsooqu6Qnld6OAiYc1apDmV9vgNrep4YE2LlgrjFS/srMa32FiIoVTmNkJhwQclDGrh bToxcvr3acW8pR5KlzbUi+cTGA3LPnjd4ucSBS0Sw7SmuyKv8cRzvAcCZJkTACfpWyut +h1A== X-Gm-Message-State: AJcUukeiNKY19OwJkndEzEyyV5q7f4Yh4L4IOEhLdlk5tIJRsrO+d3Pb ZyuIcsdgeOBMrhPjifzoy843OCBN X-Google-Smtp-Source: ALg8bN7fkU1cXS26UUpGoWRrj9IE15r26Y/5QPatUlZE/PSY+4f6R99/9IUfUpWgl8X4BFEiJpVm2g== X-Received: by 2002:a63:1962:: with SMTP id 34mr17288555pgz.135.1546275672473; Mon, 31 Dec 2018 09:01:12 -0800 (PST) X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:a63:b946:: with SMTP id v6ls10295728pgo.9.gmail; Mon, 31 Dec 2018 09:01:12 -0800 (PST) X-Received: by 2002:a63:9e19:: with SMTP id s25mr8130417pgd.203.1546275672102; Mon, 31 Dec 2018 09:01:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1546275672; cv=none; d=google.com; s=arc-20160816; b=UJqChfyqFpWzxjYxXBckOaNxvJdrr4gjKvLUeZRBjAgKDY8opZjfxQ3cImyak34DBM bAWZXpjhb03KU/hhIbHqaED6TEtJ4LUqCJ54ztwwTKg5gyQC5H6qdrjdbyMKOIkf6Erl dBPaybDj+fP5VdUMnPNdfYsQx+S5J7dvw0Ozi8clHjhihb8/v/SY4D7NuY/dgj0DaFRT 0n7dv9owelD/Jc0YCRLLPo0ePKNRfF86AO6xFjPmeQqZFKggdxgfQsZnPrrsa4uT7JIB WY268KWhhK+X+MqDhXrg/UJ5r6HyEwBR3dXV7j2/ZDANBE+LGq7/yAC2twaCVOTn3ktS wmqA== 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=XMWHnHjlI9SU1Ey/mjiyFCP12XhI50YU9PmO5axz3T0=; b=Q+ar6UA+onUljSIDYSu8r2bImBWi7La0HBnNzfeVetEjJxMQR1bNSjjvxGpZl3u3JA 2rgll5LPZIpFTAjOmgzNOl4Ik56i9kqkuI8yYpxu/y38F3mJSYbOeXVr+LBfh4WIWW8E 46K+5N+W1sW12W+Vu8IdoO734/3iepBeO32bddxJ7c7vKZaT4poLnYOzz2+Q1jWu4lbz G2AnNPogqRtvPxP+v9vDIIlkxcc25RvJoLtletUxVr5ur6QbZfj4QYwSAUB4qxNIB9Ef JAQa07ZtochHOVyDEAarKSI9u/UOBSIxid0wK+V6w7cxUrGEanu2oPXHMUTFwwowcsm5 2Edg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=NkNjCAIo; 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 d71sor13780820pga.73.2018.12.31.09.01.12 for (Google Transport Security); Mon, 31 Dec 2018 09:01:12 -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:5122:: with SMTP id f34mr7791412pgb.218.1546275671746; Mon, 31 Dec 2018 09:01:11 -0800 (PST) Received: from localhost.localdomain ([115.97.184.237]) by smtp.gmail.com with ESMTPSA id p7sm90692925pfj.72.2018.12.31.09.01.06 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 31 Dec 2018 09:01:11 -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 09/26] clk: sunxi: Add Allwinner R40 CLK driver Date: Mon, 31 Dec 2018 22:29:10 +0530 Message-Id: <20181231165927.13803-10-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=NkNjCAIo; 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 R40. - Implement USB bus and USB clocks via ccu_clk_gate for R40, 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 R40, 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_r40.c | 70 +++++++++++++++++++++++++++++++++++++ 3 files changed, 78 insertions(+) create mode 100644 drivers/clk/sunxi/clk_r40.c diff --git a/drivers/clk/sunxi/Kconfig b/drivers/clk/sunxi/Kconfig index 90af70d171..c45a4ba378 100644 --- a/drivers/clk/sunxi/Kconfig +++ b/drivers/clk/sunxi/Kconfig @@ -44,6 +44,13 @@ config CLK_SUN8I_A83T This enables common clock driver support for platforms based on Allwinner A83T SoC. +config CLK_SUN8I_R40 + bool "Clock driver for Allwinner R40" + default MACH_SUN8I_R40 + help + This enables common clock driver support for platforms based + on Allwinner R40 SoC. + config CLK_SUN8I_H3 bool "Clock driver for Allwinner H3/H5" default MACH_SUNXI_H3_H5 diff --git a/drivers/clk/sunxi/Makefile b/drivers/clk/sunxi/Makefile index 4a254c8671..61f8b87396 100644 --- a/drivers/clk/sunxi/Makefile +++ b/drivers/clk/sunxi/Makefile @@ -11,5 +11,6 @@ obj-$(CONFIG_CLK_SUN5I_A10S) += clk_a10s.o obj-$(CONFIG_CLK_SUN6I_A31) += clk_a31.o obj-$(CONFIG_CLK_SUN8I_A23) += clk_a23.o obj-$(CONFIG_CLK_SUN8I_A83T) += clk_a83t.o +obj-$(CONFIG_CLK_SUN8I_R40) += clk_r40.o obj-$(CONFIG_CLK_SUN8I_H3) += clk_h3.o obj-$(CONFIG_CLK_SUN50I_A64) += clk_a64.o diff --git a/drivers/clk/sunxi/clk_r40.c b/drivers/clk/sunxi/clk_r40.c new file mode 100644 index 0000000000..2a6000f4dc --- /dev/null +++ b/drivers/clk/sunxi/clk_r40.c @@ -0,0 +1,70 @@ +// 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 r40_gates[] = { + [CLK_BUS_OTG] = GATE(0x060, BIT(25)), + [CLK_BUS_EHCI0] = GATE(0x060, BIT(26)), + [CLK_BUS_EHCI1] = GATE(0x060, BIT(27)), + [CLK_BUS_EHCI2] = GATE(0x060, BIT(28)), + [CLK_BUS_OHCI0] = GATE(0x060, BIT(29)), + [CLK_BUS_OHCI1] = GATE(0x060, BIT(30)), + [CLK_BUS_OHCI2] = 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_OHCI0] = GATE(0x0cc, BIT(16)), + [CLK_USB_OHCI1] = GATE(0x0cc, BIT(17)), + [CLK_USB_OHCI2] = GATE(0x0cc, BIT(18)), +}; + +static struct ccu_reset r40_resets[] = { + [RST_USB_PHY0] = RESET(0x0cc, BIT(0)), + [RST_USB_PHY1] = RESET(0x0cc, BIT(1)), + [RST_USB_PHY2] = RESET(0x0cc, BIT(2)), + + [RST_BUS_OTG] = RESET(0x2c0, BIT(25)), + [RST_BUS_EHCI0] = RESET(0x2c0, BIT(26)), + [RST_BUS_EHCI1] = RESET(0x2c0, BIT(27)), + [RST_BUS_EHCI2] = RESET(0x2c0, BIT(28)), + [RST_BUS_OHCI0] = RESET(0x2c0, BIT(29)), + [RST_BUS_OHCI1] = RESET(0x2c0, BIT(30)), + [RST_BUS_OHCI2] = RESET(0x2c0, BIT(31)), +}; + +static const struct ccu_desc r40_ccu_desc = { + .gates = r40_gates, + .resets = r40_resets, +}; + +static int r40_clk_bind(struct udevice *dev) +{ + return sunxi_reset_bind(dev, 80); +} + +static const struct udevice_id r40_clk_ids[] = { + { .compatible = "allwinner,sun8i-r40-ccu", + .data = (ulong)&r40_ccu_desc }, + { } +}; + +U_BOOT_DRIVER(clk_sun8i_r40) = { + .name = "sun8i_r40_ccu", + .id = UCLASS_CLK, + .of_match = r40_clk_ids, + .priv_auto_alloc_size = sizeof(struct ccu_priv), + .ops = &sunxi_clk_ops, + .probe = sunxi_clk_probe, + .bind = r40_clk_bind, +};