From patchwork Mon Dec 31 16:59:05 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jagan Teki X-Patchwork-Id: 119 Return-Path: X-Original-To: linux-amarula@patchwork.amarulasolutions.com Delivered-To: linux-amarula@patchwork.amarulasolutions.com Received: from mail-pf1-f199.google.com (cartago.priv [10.11.12.1]) by cassiopea.amarulasolutions.com (Postfix) with ESMTPS id 3EBF02E002E for ; Mon, 31 Dec 2018 18:00:42 +0100 (CET) Received: by mail-pf1-f199.google.com with SMTP id e89sf29304356pfb.17 for ; Mon, 31 Dec 2018 09:00:42 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1546275641; cv=pass; d=google.com; s=arc-20160816; b=SebBkL+t9sfApGu15sofGwA6Q/5xrKm/nxrjAXUe+mN8qPS6zMCsmLUBiSRezvm76J 7KfKKxgh7qaiDVfbxIfH9Ho1pDUd5LRKvZa6ZimAW+AnmUyGLvdE2qqKto+KqmFUi+VI 9Am2p1BaayQ4sAiXeXdybyW+XQr3fxqz9VYt91T9yWE+tpKInXm+X5dDgqPPhBhTrSOh N/q1Y09mMFDb3pH3cGok/pxLF/VPcGaNkvD094dimR+wEDSY4XUuw/1p7vn19TwfAfT4 yhnTIbjI9WXz1pTy5knQxQdSQs2BUSpzN4mWN2wr5IahmVpUbZv0VWhG47YppEMktJ/O dXaA== 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=lIFuQ3hhWOdcHFZRLbNrEwvRChvZpp/CbAdZrKhr8Zo=; b=z5fnMqsbU/XZ24crqNf/jx2mH/7fgbIY3hucNDM4tTOpwvBqC7HUhsKKksZ4gp94zA 0PbDgp3BEyTV0++o4TVPxMzW81sdXB0wuwZim0PnYHcnygE3WBCsBoPKL/WVWd8ThNN7 NErwLWMMHDhZ4Izgyg3i88SOe+fa+KOSGQFUnCn8zzw7vS3y57asfNCNl7i20OvX9EGb ZpRAzzCv1Fw1seJVbSOWdjxCQAZT9X4CBMlq9VPbUwNkmnx9r+SGCI3kPDLkswHnJ6AX y6xZIvtudr3SvqCbIg3+hpiwfiGjHxXBercyVVrmOUYFeRAXtRBbW0okGHE01n34gmwl N04g== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=K7ZHCNFn; 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=lIFuQ3hhWOdcHFZRLbNrEwvRChvZpp/CbAdZrKhr8Zo=; b=KCyFJlsuw9RVNBdrt30oRS0i5sMFhlM1JAlkSTK4k+du/rq01Nwd/QfW907hEcLeoB m+xtUCqvtrHZXB3EL0bXdTTWGgyeP4E2yC+jfu6L8Wijey6jcSP1+seldhwBhGlWwzWb gw4FueunMawGRUeRRzerujrRG0X/0H4sAyUfI= 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=lIFuQ3hhWOdcHFZRLbNrEwvRChvZpp/CbAdZrKhr8Zo=; b=KHhnw5stYOPb3reu7yct08gHx9+8MrEf/pDfsHlKhnoHcxoYL3PFaSgHvR5p62kGn7 fIlFoNHkErukQKf3ZwRQCYHtRf/HVE0S3Hg09gkfxghvwtdE6A2ik6vR1SQN4GN8eqm3 fnwCbb/lGuGbuct64FDWKZfrTWQ4VvUO0jwUWSgFdeX1OtkA8EarI7s2yf63vmZ68wW/ IK+Bv3ZdWf8Uap+ZaP3oNvc/ln0WX5P0l47IwjfT2cup/wGK4BYP81ltOrAFKZUXM3rG Cz5xnf329MBqbc4uzG5Wju6m2VbT5DgYM0b4EaG0Lqk28wfHkrIisso64fcSU6DFslVi Wfrw== X-Gm-Message-State: AJcUukfFSKRwwp5HibynebIk5nockK30nglykIIg/kU3DoHYaPZtzjWQ bl0t9LZJM3FBIOdBy6nakBBk9IRo X-Google-Smtp-Source: ALg8bN74BqeJP4X6iCOD+nT0uDVqsgCD2SLSVe0af9ilED2NW500rbDkciCMzkpuLYWSuXXidKrUJQ== X-Received: by 2002:a17:902:8206:: with SMTP id x6mr14241202pln.114.1546275640881; Mon, 31 Dec 2018 09:00:40 -0800 (PST) X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:a63:6942:: with SMTP id e63ls10291409pgc.12.gmail; Mon, 31 Dec 2018 09:00:40 -0800 (PST) X-Received: by 2002:a62:26c7:: with SMTP id m190mr39218701pfm.79.1546275640542; Mon, 31 Dec 2018 09:00:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1546275640; cv=none; d=google.com; s=arc-20160816; b=Tz99cW2lp10itHfkz3S+M//t8xDzxxvC6i/+M4It7mCJgx7YMeYyTDWdiYrZr56Hih MEtb2gjfNmHE96odAPVDhaDuY7WdtIkIqVFDo2ukLlwqXbg/WiGEAf35RHtQOo+7/vGY WnKlM+rSscHWPY5Dbybu9HJunLG4z8y/ywKaoLsjChIhCGNjIp0MTzQw4zbzoQczSJV1 whkaJoC1Ow68X2wRE2Yh0+oZ4uNDQHr8JDqcBoTaPMQnY1nqZF1VqZkVVG56hOuAPziS 2CcKtBsIJW3VPPIYsjNP58FupKpYT3a2HIQENdVpJtB5fDDnxRlrWmgNEa9jMRYfSBPI vb0A== 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=lIFuQ3hhWOdcHFZRLbNrEwvRChvZpp/CbAdZrKhr8Zo=; b=NiFjt6NIiMxc+2gIzalS0JKooJE2JRULHgfEr9OmXb2z7WkCEENr6nClS8jfutMG8M Hg5yz7FBfRsS0WLG07DgWNU0t6+D/hZpqsdV9tg0vktM35oFtE96E6NAm1W3L36BSpEC METXiUW2NcL0NjOkOmeXOaWahGqiQ93db+jaDG+9LGOqI2piDObRaUBhZJdrjvCmW3bt zffIvY3IeiIefZt/bW+sbdz0AryYW/QIpNb8gH7LIOtLUOwZH5RE0+oORq5ciQnOHKo9 GQmmcavuD9Tf+QK1m69w3z9TVdfnr/9yblRn8fjJ7cjqjoHckm8NN3/9cERaOs404T2s Gp4Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=K7ZHCNFn; 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 i37sor13212785plb.45.2018.12.31.09.00.40 for (Google Transport Security); Mon, 31 Dec 2018 09:00:40 -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:a17:902:8f83:: with SMTP id z3mr33892619plo.328.1546275640186; Mon, 31 Dec 2018 09:00:40 -0800 (PST) Received: from localhost.localdomain ([115.97.184.237]) by smtp.gmail.com with ESMTPSA id p7sm90692925pfj.72.2018.12.31.09.00.35 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 31 Dec 2018 09:00:39 -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 04/26] clk: sunxi: Add Allwinner A10/A20 CLK driver Date: Mon, 31 Dec 2018 22:29:05 +0530 Message-Id: <20181231165927.13803-5-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=K7ZHCNFn; 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 A10/A20. - Implement USB ahb and USB clocks via ccu_clk_gate table for A10/A20, so it can accessed in common clk enable and disable functions from clk_sunxi.c - Implement USB resets via ccu_reset table for A10/A20, 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_a10.c | 59 +++++++++++++++++++++++++++++++++++++ 3 files changed, 67 insertions(+) create mode 100644 drivers/clk/sunxi/clk_a10.c diff --git a/drivers/clk/sunxi/Kconfig b/drivers/clk/sunxi/Kconfig index c3713bbac2..fbbf94ef55 100644 --- a/drivers/clk/sunxi/Kconfig +++ b/drivers/clk/sunxi/Kconfig @@ -9,6 +9,13 @@ config CLK_SUNXI if CLK_SUNXI +config CLK_SUN4I_A10 + bool "Clock driver for Allwinner A10/A20" + default MACH_SUN4I || MACH_SUN7I + help + This enables common clock driver support for platforms based + on Allwinner A10/A20 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 dec49f27a1..bba830922f 100644 --- a/drivers/clk/sunxi/Makefile +++ b/drivers/clk/sunxi/Makefile @@ -6,5 +6,6 @@ obj-$(CONFIG_CLK_SUNXI) += clk_sunxi.o +obj-$(CONFIG_CLK_SUN4I_A10) += clk_a10.o obj-$(CONFIG_CLK_SUN8I_H3) += clk_h3.o obj-$(CONFIG_CLK_SUN50I_A64) += clk_a64.o diff --git a/drivers/clk/sunxi/clk_a10.c b/drivers/clk/sunxi/clk_a10.c new file mode 100644 index 0000000000..59d9d90a19 --- /dev/null +++ b/drivers/clk/sunxi/clk_a10.c @@ -0,0 +1,59 @@ +// 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 a10_gates[] = { + [CLK_AHB_OTG] = GATE(0x060, BIT(0)), + [CLK_AHB_EHCI0] = GATE(0x060, BIT(1)), + [CLK_AHB_OHCI0] = GATE(0x060, BIT(2)), + [CLK_AHB_EHCI1] = GATE(0x060, BIT(3)), + [CLK_AHB_OHCI1] = GATE(0x060, BIT(4)), + + [CLK_USB_OHCI0] = GATE(0x0cc, BIT(6)), + [CLK_USB_OHCI1] = GATE(0x0cc, BIT(7)), + [CLK_USB_PHY] = GATE(0x0cc, BIT(8)), +}; + +static struct ccu_reset a10_resets[] = { + [RST_USB_PHY0] = RESET(0x0cc, BIT(0)), + [RST_USB_PHY1] = RESET(0x0cc, BIT(1)), + [RST_USB_PHY2] = RESET(0x0cc, BIT(2)), +}; + +static const struct ccu_desc a10_ccu_desc = { + .gates = a10_gates, + .resets = a10_resets, +}; + +static int a10_clk_bind(struct udevice *dev) +{ + return sunxi_reset_bind(dev, 22); +} + +static const struct udevice_id a10_ccu_ids[] = { + { .compatible = "allwinner,sun4i-a10-ccu", + .data = (ulong)&a10_ccu_desc }, + { .compatible = "allwinner,sun7i-a20-ccu", + .data = (ulong)&a10_ccu_desc }, + { } +}; + +U_BOOT_DRIVER(clk_sun4i_a10) = { + .name = "sun4i_a10_ccu", + .id = UCLASS_CLK, + .of_match = a10_ccu_ids, + .priv_auto_alloc_size = sizeof(struct ccu_priv), + .ops = &sunxi_clk_ops, + .probe = sunxi_clk_probe, + .bind = a10_clk_bind, +};