public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Weijie Gao <weijie.gao@mediatek.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 12/26] clk: add clock gating driver for MediaTek MIPS platform
Date: Thu, 29 Aug 2019 11:25:07 +0800	[thread overview]
Message-ID: <1567049107.2874.121.camel@mcddlt001> (raw)
In-Reply-To: <2ad66e6c-15db-d8ea-73da-f741a76f917a@gmail.com>

On Wed, 2019-08-28 at 15:24 +0200, Daniel Schwierzeck wrote:
> 
> Am 28.08.19 um 08:37 schrieb Weijie Gao:
> > This patch adds clock gating driver for MediaTek MIPS platform
> > 
> > Signed-off-by: Weijie Gao <weijie.gao@mediatek.com>
> > ---
> >  drivers/clk/Kconfig                  |  8 ++++
> >  drivers/clk/Makefile                 |  1 +
> >  drivers/clk/clk-mtmips-cg.c          | 63 ++++++++++++++++++++++++++++
> >  include/dt-bindings/clk/mt7628-clk.h | 31 ++++++++++++++
> >  4 files changed, 103 insertions(+)
> >  create mode 100644 drivers/clk/clk-mtmips-cg.c
> >  create mode 100644 include/dt-bindings/clk/mt7628-clk.h
> > 
> > diff --git a/drivers/clk/Kconfig b/drivers/clk/Kconfig
> > index 95fe0aea2c..0762a42476 100644
> > --- a/drivers/clk/Kconfig
> > +++ b/drivers/clk/Kconfig
> > @@ -160,4 +160,12 @@ config SANDBOX_CLK_CCF
> >  	  Enable this option if you want to test the Linux kernel's Common
> >  	  Clock Framework [CCF] code in U-Boot's Sandbox clock driver.
> >  
> > +config CLK_MTMIPS_GATE
> > +	bool "Enable clock gating driver for MediaTek MIPS platform"
> > +	depends on CLK && ARCH_MTMIPS
> > +	default y
> > +	help
> > +	  Enable clock gating driver for MediaTek MIPS platform.
> > +	  This driver supports only clock enable and disable.
> > +
> >  endmenu
> > diff --git a/drivers/clk/Makefile b/drivers/clk/Makefile
> > index 68aabe1ca9..353974d784 100644
> > --- a/drivers/clk/Makefile
> > +++ b/drivers/clk/Makefile
> > @@ -26,6 +26,7 @@ obj-$(CONFIG_CLK_BOSTON) += clk_boston.o
> >  obj-$(CONFIG_CLK_EXYNOS) += exynos/
> >  obj-$(CONFIG_CLK_HSDK) += clk-hsdk-cgu.o
> >  obj-$(CONFIG_CLK_MPC83XX) += mpc83xx_clk.o
> > +obj-$(CONFIG_CLK_MTMIPS_GATE) += clk-mtmips-cg.o
> >  obj-$(CONFIG_CLK_OWL) += owl/
> >  obj-$(CONFIG_CLK_RENESAS) += renesas/
> >  obj-$(CONFIG_CLK_SIFIVE) += sifive/
> > diff --git a/drivers/clk/clk-mtmips-cg.c b/drivers/clk/clk-mtmips-cg.c
> > new file mode 100644
> > index 0000000000..0221d95aed
> > --- /dev/null
> > +++ b/drivers/clk/clk-mtmips-cg.c
> > @@ -0,0 +1,63 @@
> > +// SPDX-License-Identifier: GPL-2.0
> > +/*
> > + * Copyright (C) 2019 MediaTek Inc. All Rights Reserved.
> > + *
> > + * Author: Weijie Gao <weijie.gao@mediatek.com>
> > + */
> > +
> > +#include <common.h>
> > +#include <clk-uclass.h>
> > +#include <dm.h>
> > +#include <asm/io.h>
> > +
> > +struct mtmips_clk_gate_priv {
> > +	void __iomem *base;
> > +};
> > +
> > +static int mtmips_clk_gate_enable(struct clk *clk)
> > +{
> > +	struct mtmips_clk_gate_priv *priv = dev_get_priv(clk->dev);
> > +
> > +	setbits_32(priv->base, BIT(clk->id));
> > +
> > +	return 0;
> > +}
> > +
> > +static int mtmips_clk_gate_disable(struct clk *clk)
> > +{
> > +	struct mtmips_clk_gate_priv *priv = dev_get_priv(clk->dev);
> > +
> > +	clrbits_32(priv->base, BIT(clk->id));
> > +
> > +	return 0;
> > +}
> > +
> > +const struct clk_ops mtmips_clk_gate_ops = {
> > +	.enable = mtmips_clk_gate_enable,
> > +	.disable = mtmips_clk_gate_disable,
> > +};
> 
> the generic clk-gate.c driver already supports this simple register bit
> toggling. Why don't you use that one?
> 
> > +
> > +static int mtmips_clk_gate_probe(struct udevice *dev)
> > +{
> > +	struct mtmips_clk_gate_priv *priv = dev_get_priv(dev);
> > +
> > +	priv->base = (void __iomem *)dev_remap_addr_index(dev, 0);
> > +	if (!priv->base)
> > +		return -EINVAL;
> > +
> > +	return 0;
> > +}
> > +
> > +static const struct udevice_id mtmips_clk_gate_ids[] = {
> > +	{ .compatible = "mediatek,mtmips-clk-gate" },
> > +	{ }
> > +};
> > +
> > +U_BOOT_DRIVER(mtmips_clk_gate) = {
> > +	.name = "mtmips-clk-gate",
> > +	.id = UCLASS_CLK,
> > +	.of_match = mtmips_clk_gate_ids,
> > +	.probe = mtmips_clk_gate_probe,
> > +	.priv_auto_alloc_size = sizeof(struct mtmips_clk_gate_priv),
> > +	.ops = &mtmips_clk_gate_ops,
> > +};
> > diff --git a/include/dt-bindings/clk/mt7628-clk.h b/include/dt-bindings/clk/mt7628-clk.h
> > new file mode 100644
> > index 0000000000..6784d6e50b
> > --- /dev/null
> > +++ b/include/dt-bindings/clk/mt7628-clk.h
> > @@ -0,0 +1,31 @@
> > +/* SPDX-License-Identifier: GPL-2.0 */
> > +/*
> > + * Copyright (C) 2019 MediaTek Inc.
> > + *
> > + * Author:  Weijie Gao <weijie.gao@mediatek.com>
> > + */
> > +
> > +#ifndef _DT_BINDINGS_MT7628_CLK_H_
> > +#define _DT_BINDINGS_MT7628_CLK_H_
> > +
> > +#define MT7628_PWM_CLK			31
> > +#define MT7628_SDXC_CLK			30
> > +#define MT7628_CRYPTO_CLK		29
> > +#define MT7628_MIPS_CNT_CLK		28
> > +#define MT7628_PCIE_CLK			26
> > +#define MT7628_UPHY_CLK			25
> > +#define MT7628_ETH_CLK			23
> > +#define MT7628_UART2_CLK		20
> > +#define MT7628_UART1_CLK		19
> > +#define MT7628_SPI_CLK			18
> > +#define MT7628_I2S_CLK			17
> > +#define MT7628_I2C_CLK			16
> > +#define MT7628_GDMA_CLK			14
> > +#define MT7628_PIO_CLK			13
> > +#define MT7628_UART0_CLK		12
> > +#define MT7628_PCM_CLK			11
> > +#define MT7628_MC_CLK			10
> > +#define MT7628_INT_CLK			9
> > +#define MT7628_TIMER_CLK		8
> > +
> > +#endif /* _DT_BINDINGS_MT7628_CLK_H_ */
> > 
> 


I've written this driver in the early July, before clk-gate was added.
I didn't notice this driver yesterday.
I will try to switch to clk-gate.

  reply	other threads:[~2019-08-29  3:25 UTC|newest]

Thread overview: 60+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-08-28  6:37 [U-Boot] [PATCH 00/26] Add and update drivers for MediaTek MT76x8 SoCs Weijie Gao
2019-08-28  6:37 ` [U-Boot] [PATCH 01/26] serial: serial_mtk: enable FIFO and disable flow control Weijie Gao
2019-08-28  6:37 ` [U-Boot] [PATCH 02/26] serial: serial_mtk: add non-DM version for SPL Weijie Gao
2019-08-28  6:37 ` [U-Boot] [PATCH 03/26] dts: mtmips: move uart property clock-frequency into mt7628an.dtsi Weijie Gao
2019-08-28  7:13   ` Stefan Roese
2019-08-28  6:37 ` [U-Boot] [PATCH 04/26] dts: mtmips: enable high-speed UART support for mt7628 Weijie Gao
2019-08-28  7:14   ` Stefan Roese
2019-08-28  6:37 ` [U-Boot] [PATCH 05/26] spi: mt7621-spi: remove data cache and rewrite its xfer function Weijie Gao
2019-08-28  7:55   ` Stefan Roese
2019-08-28  6:37 ` [U-Boot] [PATCH 06/26] spi: mt7621-spi: restore default register value after each xfer Weijie Gao
2019-08-28  8:01   ` Stefan Roese
2019-08-28  6:37 ` [U-Boot] [PATCH 07/26] pinctrl: add support for MediaTek MT7628 Weijie Gao
2019-08-28 12:26   ` Stefan Roese
2019-08-28 12:37     ` Stefan Roese
2019-08-29  3:04       ` Weijie Gao
2019-08-28  6:37 ` [U-Boot] [PATCH 08/26] dts: mtmips: add pinctrl node for mt7628 Weijie Gao
2019-08-28  6:37 ` [U-Boot] [PATCH 09/26] dts: mtmips: add default pinctrl for uart nodes Weijie Gao
2019-08-28  6:37 ` [U-Boot] [PATCH 10/26] reset: add reset controller driver for MediaTek MIPS platform Weijie Gao
2019-08-28  6:37 ` [U-Boot] [PATCH 11/26] dts: mtmips: update reset controller node for mt7628 Weijie Gao
2019-08-28 13:18   ` Stefan Roese
2019-08-29  3:18     ` Weijie Gao
2019-12-30  9:19   ` Mauro Condarelli
2019-12-30 10:22     ` Daniel Schwierzeck
2019-12-30 11:09       ` Mauro Condarelli
2019-12-30 12:14       ` Mauro Condarelli
2020-01-02 12:30         ` Stefan Roese
2020-01-02 13:36           ` Mauro Condarelli
2019-08-28  6:37 ` [U-Boot] [PATCH 12/26] clk: add clock gating driver for MediaTek MIPS platform Weijie Gao
2019-08-28 13:24   ` Daniel Schwierzeck
2019-08-29  3:25     ` Weijie Gao [this message]
2019-08-28  6:37 ` [U-Boot] [PATCH 13/26] dts: mtmips: add gate clock node for mt7628 Weijie Gao
2019-08-28  6:37 ` [U-Boot] [PATCH 14/26] phy: mt76x8-usb-phy: add slew rate calibration and remove non-mt7628 part Weijie Gao
2019-08-28  6:38 ` [U-Boot] [PATCH 15/26] net: mt7628-eth: remove hardcoded gpio settings and regmap-based phy reset Weijie Gao
2019-08-28 13:32   ` Stefan Roese
2019-08-28  6:38 ` [U-Boot] [PATCH 16/26] net: mt7628-eth: remove phy link up detection Weijie Gao
2019-08-28 13:37   ` Stefan Roese
2019-08-29  3:32     ` Weijie Gao
2019-08-28  6:38 ` [U-Boot] [PATCH 17/26] net: mt7628-eth: free rx descriptor on receiving failure Weijie Gao
2019-08-28 13:42   ` Stefan Roese
2019-08-28  6:38 ` [U-Boot] [PATCH 18/26] net: mt7628-eth: add support to isolate LAN/WAN ports Weijie Gao
2019-08-28 13:46   ` Stefan Roese
2019-08-29  4:27     ` Weijie Gao
2019-08-28  6:38 ` [U-Boot] [PATCH 19/26] dts: mtmips: enable eth port0 led function for all boards Weijie Gao
2019-08-28 13:47   ` Stefan Roese
2019-08-28  6:38 ` [U-Boot] [PATCH 20/26] mmc: mtk-sd: add support for MediaTek MT7620/MT7628 SoCs Weijie Gao
2019-08-28 13:50   ` Stefan Roese
2019-08-29  4:28     ` Weijie Gao
2019-08-28  6:38 ` [U-Boot] [PATCH 21/26] mmc: mtk-sd: add a dts property cd-active-high for builtin-cd mode Weijie Gao
2019-08-28  6:38 ` [U-Boot] [PATCH 22/26] dts: mtmips: add mmc related nodes for mt7628an.dtsi Weijie Gao
2019-08-28  6:38 ` [U-Boot] [PATCH 23/26] dts: mtmips: add default pinctrl for gardena-smart-gateway-mt7688 Weijie Gao
2019-08-28 13:52   ` Stefan Roese
2019-08-28  6:38 ` [U-Boot] [PATCH 24/26] dts: mtmips: add default pinctrl to eth nodes for all boards Weijie Gao
2019-08-28 13:55   ` Stefan Roese
2019-08-28  6:38 ` [U-Boot] [PATCH 25/26] configs: mtmips: change all boards to use mtk high-speed uart driver Weijie Gao
2019-08-28 13:57   ` Stefan Roese
2019-08-29  4:30     ` Weijie Gao
2019-08-28  6:38 ` [U-Boot] [PATCH 26/26] configs: mtmips: add necessary drivers for mtmips boards Weijie Gao
2019-08-28 13:35   ` Daniel Schwierzeck
2019-08-28 13:40     ` Stefan Roese
2019-08-29  3:34       ` Weijie Gao

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1567049107.2874.121.camel@mcddlt001 \
    --to=weijie.gao@mediatek.com \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox