From patchwork Mon Dec 31 16:59:08 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jagan Teki X-Patchwork-Id: 122 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 B4FDA2E002E for ; Mon, 31 Dec 2018 18:01:01 +0100 (CET) Received: by mail-pf1-f199.google.com with SMTP id x67sf2981093pfk.16 for ; Mon, 31 Dec 2018 09:01:01 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1546275660; cv=pass; d=google.com; s=arc-20160816; b=zOPxVHFZJBVXbgBp6tJLFTPH4l/FWJ7LeUB/Dyhso0RyGOzJDbNLiLO1dZY8adkFFR gKWlwCjmyIoDSdKKjjw4wDOH8LXwHzkdZ/reqE/i1ZtqzNazqqpXG1LcpZjyyN4rSpPA KF9LtTp3ynDQqEruzDcO3u1UgSscM+DI+hfj9SYVceQ7gB8pMpNE3A8GNYVqY/RjwKIQ 5T9EG7GUVCeRyXwNwuyelewCGUYGS84kAOm7e+GZA15+Yddv2awWjCocATYwEduqT5JY AT8UlYR6DCngoGdOOJ4lmqCFIJbpzF9KaeyHLo3WJ8y4dyTg/Cd1CC7gMNBq8XXIKmDh cWCA== 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=ZOCtPZdbao3jV7plualGawW1O9gxwZ87z+pgUp1L+1k=; b=Fl1q32FgvQ1ru3x3WrFc+ILeJ+it8mtP8HzuNP3jHaPK2b4K4OwygvkroX6VYRjW9v OspFeoOYJ2/0K+crlIqlu8HNPujt+muGLEuPQ5xeWZMUkmyFOtJk+FYUfgSkTnfQsa5k /kxjPlGCNg9xGNX0iGcYBoxgy2lsVTj4+md13KqmeesCsEIQE24CWufduFV9La8iqBTN NlmIlJccA0bgrhe8C7bvypCzjdCnSy9KIeUmnhl9ysBWWFYEo0AYC4Z7APHWW5pSwUYm eWeQORovRfjktgV/mTmBIVv/vX+shbQrdFpB3yaqEgHWBLXCUHRbI/pWr0Jj/2G0dnwK wu3w== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=PeB6EhVl; 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=ZOCtPZdbao3jV7plualGawW1O9gxwZ87z+pgUp1L+1k=; b=bouSnugtupF00E8uP0A0DaxvknmpMjQmo3aiMifCdMtFcwDv3FhSMUlT8Y6grd9lGN 52jo1v/CT0Dtxr6BR1RCxYdOrSx1W+Ilv/qSlT/o28El4TYZOQajHVug7m3t2W5BSRDz Vo7mNedqCN+1NeWBEitfFGq9YhMRHy3W+Jm1A= 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=ZOCtPZdbao3jV7plualGawW1O9gxwZ87z+pgUp1L+1k=; b=dHqibqFLcONVzKIYlT315+v1zADQA4ZtXzwPTn0Gwqfugu3Yjcs+0R9f0NBR8BLHBS Y7vd9HsBI35aW03tOfQbrZlFzPmjtZU9LqSsAk8TX/grMOuFShkw3Nqfw8fyMViRkT3S 288D54Nph5dM2ZIZnOeuvSRp0kWPIpGmHqEBpx/PHbqvIZlnoFP+9dtd01ld/ZN/HFHh FFHm6768UEkZkRK9FhgS3vKAfVsvkc3NmEX5rpYG9zL+CX3zNuge2I7+ELx9rrlK8jcz XdagDOlkeeBkpA0mY88G+iw9HyIK/+QBuVesLaHJ/S2T+Xm8/+G/V1Gbr9QzPmVIdhXw P41A== X-Gm-Message-State: AJcUukfLGwhDo6qhXczGEMx4dBbRgnDFDlYGgmiCdvnSW3REzNyfMfx6 Q3a2EavyHX4LqbSQncHgRahqdO+V X-Google-Smtp-Source: ALg8bN5Ci4zuSb4V/7nUdOMXi6ANFawUrWHCnUMGZZ+PER7B6BERKij8MEq0K1lDh8wjIwmuj8cPZg== X-Received: by 2002:a65:45c6:: with SMTP id m6mr17608171pgr.103.1546275660384; Mon, 31 Dec 2018 09:01:00 -0800 (PST) X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:a65:41c7:: with SMTP id b7ls2388928pgq.11.gmail; Mon, 31 Dec 2018 09:01:00 -0800 (PST) X-Received: by 2002:a62:2606:: with SMTP id m6mr37833282pfm.133.1546275660001; Mon, 31 Dec 2018 09:01:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1546275659; cv=none; d=google.com; s=arc-20160816; b=soY1n+uH8Gl3MWmKKJfUIVbEfVQDPk3kl2S9DPkTdN0QewfLNwJnHnkB2R/dFKffaN JHhgJ3fpx0XSKvuDAxfaWqEzrpYInNTA4XR1HixioJwhlHLdc8O6CDnug/6nUt3r6C0C VTTyTqV4Tarl/vNPqdGOO2hNXZ3F8jhR0D1Xul0VrX4ziGzXotrOkf7UXQzSGH9hrauL 9Q73K91XK4isad19IdwctOfrNsYaC1YK+GIwqPu6vOyJ7wxXOMGoqusGTbwTVr/Pqskv XrNqUmopuG3Ejk+Qxrq33gx5lGLMuz7C6SDI/CjKOoTahuLOEuHj3oZlIQpIRjuXfH9O mr1w== 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=ZOCtPZdbao3jV7plualGawW1O9gxwZ87z+pgUp1L+1k=; b=nHpYhvXuNPwApy0c2wOssLqi3NJUa4xUwIyV4A9lyep8GlJ28qfWVxVdNNFN+b6c54 pFSMF9c77EVWNauOw05NvXUc7NvwlIGtBE5tWKbKDeC8M9YHfDGthDPDFUATd41Uwhqg Hc4R6Jhlff7PvFdosj9QwnRR7UgUyUs89el5Trq6tQybEueZPpNj0BTCfeFIEk/CDdct hvQfNmnz5iUvyXtCWCxwQ544rB1F28ijHvHqEgdZAZfk9t6Le4GYcNlf47w3VijwehBm ZuVdM5/k/DjPn7Rih7XYQI7S7di3x0hwSkvTACGGDLVqv32nAOWwVF7litkZfK8p71/Z XDfg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=PeB6EhVl; 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 j15sor14171735pgc.41.2018.12.31.09.00.59 for (Google Transport Security); Mon, 31 Dec 2018 09:00:59 -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:5455:: with SMTP id e21mr8155329pgm.316.1546275659656; Mon, 31 Dec 2018 09:00:59 -0800 (PST) Received: from localhost.localdomain ([115.97.184.237]) by smtp.gmail.com with ESMTPSA id p7sm90692925pfj.72.2018.12.31.09.00.53 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 31 Dec 2018 09:00:59 -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 07/26] clk: sunxi: Add Allwinner A23/A33 CLK driver Date: Mon, 31 Dec 2018 22:29:08 +0530 Message-Id: <20181231165927.13803-8-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=PeB6EhVl; 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 A23/A33. - Implement USB bus and USB clocks via ccu_clk_gate table for A23/A33, 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 A23/A33, 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_a23.c | 63 +++++++++++++++++++++++++++++++++++++ 3 files changed, 71 insertions(+) create mode 100644 drivers/clk/sunxi/clk_a23.c diff --git a/drivers/clk/sunxi/Kconfig b/drivers/clk/sunxi/Kconfig index 535b0dc02c..38ff99d345 100644 --- a/drivers/clk/sunxi/Kconfig +++ b/drivers/clk/sunxi/Kconfig @@ -30,6 +30,13 @@ config CLK_SUN6I_A31 This enables common clock driver support for platforms based on Allwinner A31/A31s SoC. +config CLK_SUN8I_A23 + bool "Clock driver for Allwinner A23/A33" + default MACH_SUN8I_A23 || MACH_SUN8I_A33 + help + This enables common clock driver support for platforms based + on Allwinner A23/A33 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 3cf0071b0c..6924897036 100644 --- a/drivers/clk/sunxi/Makefile +++ b/drivers/clk/sunxi/Makefile @@ -9,5 +9,6 @@ obj-$(CONFIG_CLK_SUNXI) += clk_sunxi.o obj-$(CONFIG_CLK_SUN4I_A10) += clk_a10.o 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_H3) += clk_h3.o obj-$(CONFIG_CLK_SUN50I_A64) += clk_a64.o diff --git a/drivers/clk/sunxi/clk_a23.c b/drivers/clk/sunxi/clk_a23.c new file mode 100644 index 0000000000..0fc8a5821c --- /dev/null +++ b/drivers/clk/sunxi/clk_a23.c @@ -0,0 +1,63 @@ +// SPDX-License-Identifier: (GPL-2.0+ OR MIT) +/* + * Copyright (C) 2018 Amarula Solutions B.V. + * Author: Jagan Teki + */ + +#include +#include +#include +#include +#include +#include +#include + +static struct ccu_clk_gate a23_gates[] = { + [CLK_BUS_OTG] = GATE(0x060, BIT(24)), + [CLK_BUS_EHCI] = GATE(0x060, BIT(26)), + [CLK_BUS_OHCI] = GATE(0x060, BIT(29)), + + [CLK_USB_PHY0] = GATE(0x0cc, BIT(8)), + [CLK_USB_PHY1] = GATE(0x0cc, BIT(9)), + [CLK_USB_HSIC] = GATE(0x0cc, BIT(10)), + [CLK_USB_HSIC_12M] = GATE(0x0cc, BIT(11)), + [CLK_USB_OHCI] = GATE(0x0cc, BIT(16)), +}; + +static struct ccu_reset a23_resets[] = { + [RST_USB_PHY0] = RESET(0x0cc, BIT(0)), + [RST_USB_PHY1] = RESET(0x0cc, BIT(1)), + [RST_USB_HSIC] = RESET(0x0cc, BIT(2)), + + [RST_BUS_OTG] = RESET(0x2c0, BIT(24)), + [RST_BUS_EHCI] = RESET(0x2c0, BIT(26)), + [RST_BUS_OHCI] = RESET(0x2c0, BIT(29)), +}; + +static const struct ccu_desc a23_ccu_desc = { + .gates = a23_gates, + .resets = a23_resets, +}; + +static int a23_clk_bind(struct udevice *dev) +{ + return sunxi_reset_bind(dev, 39); +} + +static const struct udevice_id a23_clk_ids[] = { + { .compatible = "allwinner,sun8i-a23-ccu", + .data = (ulong)&a23_ccu_desc }, + { .compatible = "allwinner,sun8i-a33-ccu", + .data = (ulong)&a23_ccu_desc }, + { } +}; + +U_BOOT_DRIVER(clk_sun8i_a23) = { + .name = "sun8i_a23_ccu", + .id = UCLASS_CLK, + .of_match = a23_clk_ids, + .priv_auto_alloc_size = sizeof(struct ccu_priv), + .ops = &sunxi_clk_ops, + .probe = sunxi_clk_probe, + .bind = a23_clk_bind, +};