public inbox for devicetree@vger.kernel.org
 help / color / mirror / Atom feed
From: "Jernej Škrabec" <jernej.skrabec-gGgVlfcn5nU@public.gmane.org>
To: linux-sunxi-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org,
	icenowy-ymACFijhrKM@public.gmane.org
Cc: Maxime Ripard
	<maxime.ripard-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>,
	David Airlie <airlied-cv59FeDIM0c@public.gmane.org>,
	Jean-Francois Moine <moinejf-GANU6spQydw@public.gmane.org>,
	Rob Herring <robh+dt-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	linux-clk-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org,
	Chen-Yu Tsai <wens-jdAy2FN1RRM@public.gmane.org>,
	dri-devel-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org
Subject: Re: Re: [PATCH 2/8] clk: sunxi-ng: add support for DE2 CCU
Date: Wed, 22 Feb 2017 23:11:49 +0100	[thread overview]
Message-ID: <2861790.WmLcjTgm5a@jernej-laptop> (raw)
In-Reply-To: <20170222231754.Hm6O1qAk-fU7thrOZ3Cs0PDqKvflMoHmW9unr2Ajn@public.gmane.org>

Hi,

Dne sreda, 22. februar 2017 ob 21:17:29 CET je Icenowy Zheng napisal(a):
> 2017年2月23日 03:09于 Maxime Ripard <maxime.ripard-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>写道:
> 
> > Hi,
> > 
> > On Wed, Feb 22, 2017 at 11:18:48PM +0800, Icenowy Zheng wrote:
> > > +config SUNXI_DE2_CCU
> > > + bool "Support for the Allwinner SoCs DE2 CCU"
> > > + select SUNXI_CCU_DIV
> > > + select SUNXI_CCU_GATE
> > > + default n
> > 
> > This is already the default.
> 
> P.S. I in fact want it default DRM_SUN4I_DE2.
> 
> > > +
> > >
> > >  endif
> > >
> > > diff --git a/drivers/clk/sunxi-ng/Makefile
> > > b/drivers/clk/sunxi-ng/Makefile
> > > index 6feaac0c5600..1d36c40384a6 100644
> > > --- a/drivers/clk/sunxi-ng/Makefile
> > > +++ b/drivers/clk/sunxi-ng/Makefile
> > > @@ -28,3 +28,4 @@ obj-$(CONFIG_SUN8I_V3S_CCU) += ccu-sun8i-v3s.o
> > >
> > >  obj-$(CONFIG_SUN9I_A80_CCU) += ccu-sun9i-a80.o
> > >  obj-$(CONFIG_SUN9I_A80_CCU) += ccu-sun9i-a80-de.o
> > >  obj-$(CONFIG_SUN9I_A80_CCU) += ccu-sun9i-a80-usb.o
> > >
> > > +obj-$(CONFIG_SUNXI_DE2_CCU) += ccu-sunxi-de2.o
> > 
> > sun8i-de2 please
> 
> It also exists in sun50is.

Usual approach is to name it after the family where the IP block first 
appeared.

Regards,
Jernej

> 
> > > diff --git a/drivers/clk/sunxi-ng/ccu-sunxi-de2.c
> > > b/drivers/clk/sunxi-ng/ccu-sunxi-de2.c new file mode 100644
> > > index 000000000000..4259c145d5da
> > > --- /dev/null
> > > +++ b/drivers/clk/sunxi-ng/ccu-sunxi-de2.c
> > > @@ -0,0 +1,204 @@
> > > +/*
> > > + * Copyright (c) 2016 Chen-Yu Tsai. All rights reserved.
> > 
> > Wrong author?
> 
> Oh I copied ccu-sun9i-a80-de.c...
> 
> > > + *
> > > + * This software is licensed under the terms of the GNU General Public
> > > + * License version 2, as published by the Free Software Foundation, and
> > > + * may be copied, distributed, and modified under those terms.
> > > + *
> > > + * This program is distributed in the hope that it will be useful,
> > > + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> > > + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> > > + * GNU General Public License for more details.
> > > + */
> > > +
> > > +#include <linux/clk.h>
> > > +#include <linux/clk-provider.h>
> > > +#include <linux/of_address.h>
> > > +#include <linux/of_platform.h>
> > > +#include <linux/platform_device.h>
> > > +#include <linux/reset.h>
> > > +
> > > +#include "ccu_common.h"
> > > +#include "ccu_div.h"
> > > +#include "ccu_gate.h"
> > > +#include "ccu_reset.h"
> > > +
> > > +#include "ccu-sunxi-de2.h"
> > > +
> > > +static SUNXI_CCU_GATE(bus_mixer0_clk, "bus-mixer0", "bus-de",
> > > +       0x04, BIT(0), 0);
> > > +static SUNXI_CCU_GATE(bus_mixer1_clk, "bus-mixer1", "bus-de",
> > > +       0x04, BIT(1), 0);
> > > +static SUNXI_CCU_GATE(bus_wb_clk, "bus-wb", "bus-de",
> > > +       0x04, BIT(2), 0);
> > > +
> > > +static SUNXI_CCU_GATE(mixer0_clk, "mixer0", "mixer0-div",
> > > +       0x00, BIT(0), CLK_SET_RATE_PARENT);
> > > +static SUNXI_CCU_GATE(mixer1_clk, "mixer1", "mixer1-div",
> > > +       0x00, BIT(1), CLK_SET_RATE_PARENT);
> > > +static SUNXI_CCU_GATE(wb_clk, "wb", "wb-div",
> > > +       0x00, BIT(2), CLK_SET_RATE_PARENT);
> > > +
> > > +static SUNXI_CCU_M(mixer0_div_clk, "mixer0-div", "de", 0x0c, 0, 4,
> > > +    CLK_SET_RATE_PARENT);
> > > +static SUNXI_CCU_M(mixer1_div_clk, "mixer1-div", "de", 0x0c, 4, 4,
> > > +    CLK_SET_RATE_PARENT);
> > > +static SUNXI_CCU_M(wb_div_clk, "wb-div", "de", 0x0c, 8, 4,
> > > +    CLK_SET_RATE_PARENT);
> > > +
> > > +static struct ccu_common *sunxi_de2_clks[] = {
> > > + &mixer0_clk.common,
> > > + &mixer1_clk.common,
> > > + &wb_clk.common,
> > > +
> > > + &bus_mixer0_clk.common,
> > > + &bus_mixer1_clk.common,
> > > + &bus_wb_clk.common,
> > > +
> > > + &mixer0_div_clk.common,
> > > + &mixer1_div_clk.common,
> > > + &wb_div_clk.common,
> > > +};
> > > +
> > > +static struct clk_hw_onecell_data sunxi_de2_hw_clks = {
> > > + .hws = {
> > > + [CLK_MIXER0] = &mixer0_clk.common.hw,
> > > + [CLK_MIXER1] = &mixer1_clk.common.hw,
> > > + [CLK_WB] = &wb_clk.common.hw,
> > > +
> > > + [CLK_BUS_MIXER0] = &bus_mixer0_clk.common.hw,
> > > + [CLK_BUS_MIXER1] = &bus_mixer1_clk.common.hw,
> > > + [CLK_BUS_WB] = &bus_wb_clk.common.hw,
> > > +
> > > + [CLK_MIXER0_DIV] = &mixer1_div_clk.common.hw,
> > > + [CLK_MIXER1_DIV] = &mixer0_div_clk.common.hw,
> > > + [CLK_WB_DIV] = &wb_div_clk.common.hw,
> > > + },
> > > + .num = CLK_NUMBER,
> > > +};
> > > +
> > > +static struct ccu_reset_map sun8i_a83t_de2_resets[] = {
> > > + [RST_MIXER0] = { 0x08, BIT(0) },
> > > + /*
> > > + * For A83T, H3 and R40, mixer1 reset line is shared with wb, so
> > > + * only RST_WB is exported here.
> > > + */
> > > + [RST_WB] = { 0x08, BIT(2) },
> > > +};
> > > +
> > > +static struct ccu_reset_map sun50i_a64_de2_resets[] = {
> > > + [RST_MIXER0] = { 0x08, BIT(0) },
> > > + [RST_MIXER1] = { 0x08, BIT(1) },
> > > + [RST_WB] = { 0x08, BIT(2) },
> > > +};
> > > +
> > > +static const struct sunxi_ccu_desc sun8i_a83t_de2_clk_desc = {
> > > + .ccu_clks = sunxi_de2_clks,
> > > + .num_ccu_clks = ARRAY_SIZE(sunxi_de2_clks),
> > > +
> > > + .hw_clks = &sunxi_de2_hw_clks,
> > > +
> > > + .resets = sun8i_a83t_de2_resets,
> > > + .num_resets = ARRAY_SIZE(sun8i_a83t_de2_resets),
> > > +};
> > > +
> > > +static const struct sunxi_ccu_desc sun50i_a64_de2_clk_desc = {
> > > + .ccu_clks = sunxi_de2_clks,
> > > + .num_ccu_clks = ARRAY_SIZE(sunxi_de2_clks),
> > > +
> > > + .hw_clks = &sunxi_de2_hw_clks,
> > > +
> > > + .resets = sun50i_a64_de2_resets,
> > > + .num_resets = ARRAY_SIZE(sun50i_a64_de2_resets),
> > > +};
> > > +
> > > +static int sunxi_de2_clk_probe(struct platform_device *pdev)
> > > +{
> > > + struct resource *res;
> > > + struct clk *bus_clk;
> > > + struct reset_control *rstc;
> > > + void __iomem *reg;
> > > + const struct sunxi_ccu_desc *ccu_desc;
> > > + int ret;
> > > +
> > > + ccu_desc = of_device_get_match_data(&pdev->dev);
> > > + if (!ccu_desc)
> > > + return -EINVAL;
> > > +
> > > + res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> > > + reg = devm_ioremap_resource(&pdev->dev, res);
> > > + if (IS_ERR(reg))
> > > + return PTR_ERR(reg);
> > > +
> > > + bus_clk = devm_clk_get(&pdev->dev, "bus");
> > > + if (IS_ERR(bus_clk)) {
> > > + ret = PTR_ERR(bus_clk);
> > > + if (ret != -EPROBE_DEFER)
> > > + dev_err(&pdev->dev, "Couldn't get bus clk: %d\n", ret);
> > > + return ret;
> > > + }
> > > +
> > > + rstc = devm_reset_control_get_exclusive(&pdev->dev, NULL);
> > > + if (IS_ERR(rstc)) {
> > > + ret = PTR_ERR(bus_clk);
> > > + if (ret != -EPROBE_DEFER)
> > > + dev_err(&pdev->dev,
> > > + "Couldn't get reset control: %d\n", ret);
> > > + return ret;
> > > + }
> > > +
> > > + /* The bus clock needs to be enabled for us to access the registers */
> > > + ret = clk_prepare_enable(bus_clk);
> > > + if (ret) {
> > > + dev_err(&pdev->dev, "Couldn't enable bus clk: %d\n", ret);
> > > + return ret;
> > > + }
> > 
> > That looks inefficient if none of the clocks are enabled. Maybe you
> > can use CLK_OPS_PARENT_ENABLE?
> 
> Don't know about it... it's a simplified version of this func of A80 de ccu.
> > Thanks,
> > Maxime
> > 
> > --
> > Maxime Ripard, Free Electrons
> > Embedded Linux and Kernel engineering
> > http://free-electrons.com
> > 
> > --
> > You received this message because you are subscribed to the Google Groups
> > "linux-sunxi" group. To unsubscribe from this group and stop receiving
> > emails from it, send an email to
> > linux-sunxi+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit
> > https://groups.google.com/d/optout.
> 
> --
> You received this message because you are subscribed to the Google Groups
> "linux-sunxi" group. To unsubscribe from this group and stop receiving
> emails from it, send an email to linux-sunxi+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org.
> For more options, visit https://groups.google.com/d/optout.


-- 
You received this message because you are subscribed to the Google Groups "linux-sunxi" group.
To unsubscribe from this group and stop receiving emails from it, send an email to linux-sunxi+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
For more options, visit https://groups.google.com/d/optout.

      parent reply	other threads:[~2017-02-22 22:11 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-02-22 20:17 Re: [PATCH 2/8] clk: sunxi-ng: add support for DE2 CCU Icenowy Zheng
     [not found] ` <20170222231754.Hm6O1qAk-fU7thrOZ3Cs0PDqKvflMoHmW9unr2Ajn@public.gmane.org>
2017-02-22 22:11   ` Jernej Škrabec [this message]

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=2861790.WmLcjTgm5a@jernej-laptop \
    --to=jernej.skrabec-gggvlfcn5nu@public.gmane.org \
    --cc=airlied-cv59FeDIM0c@public.gmane.org \
    --cc=devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=dri-devel-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org \
    --cc=icenowy-ymACFijhrKM@public.gmane.org \
    --cc=linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org \
    --cc=linux-clk-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=linux-sunxi-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org \
    --cc=maxime.ripard-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org \
    --cc=moinejf-GANU6spQydw@public.gmane.org \
    --cc=robh+dt-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org \
    --cc=wens-jdAy2FN1RRM@public.gmane.org \
    /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