mbox series

[RFC,0/3] Extend lan966x clock driver for clock gating support

Message ID 20211019084449.1411060-1-horatiu.vultur@microchip.com
Headers show
Series Extend lan966x clock driver for clock gating support | expand

Message

Horatiu Vultur Oct. 19, 2021, 8:44 a.m. UTC
This patch series depends on the following series, therefor keep it as RFC.
https://www.spinics.net/lists/linux-clk/msg62237.html

This patch series extend the clock driver to support also clock gating.

Horatiu Vultur (3):
  dt-bindings: clock: lan966x: Extend for clock gate support
  dt-bindings: clock: lan966x: Extend includes with clock gates
  clk: lan966x: Extend lan966x clock driver for clock gating support

 .../bindings/clock/microchip,lan966x-gck.yaml | 13 +++-
 drivers/clk/clk-lan966x.c                     | 72 +++++++++++++++++--
 include/dt-bindings/clock/microchip,lan966x.h |  8 ++-
 3 files changed, 86 insertions(+), 7 deletions(-)

Comments

Stephen Boyd Oct. 29, 2021, 6:41 a.m. UTC | #1
Quoting Horatiu Vultur (2021-10-19 01:44:49)
> diff --git a/drivers/clk/clk-lan966x.c b/drivers/clk/clk-lan966x.c
> index 19bec94e1551..40be47092a31 100644
> --- a/drivers/clk/clk-lan966x.c
> +++ b/drivers/clk/clk-lan966x.c
> @@ -188,26 +202,64 @@ static struct clk_hw *lan966x_gck_clk_register(struct device *dev, int i)
>         return &priv->hw;
>  };
>  
> +static int lan966x_gate_clk_register(struct device *dev,
> +                                    struct clk_hw_onecell_data *hw_data,
> +                                    void __iomem *gate_base)
> +{
> +       int i;
> +
> +       for (i = GCK_GATE_UHPHS; i < N_CLOCKS; ++i) {
> +               int idx = i - GCK_GATE_UHPHS;
> +
> +               hw_data->hws[i] =
> +                       clk_hw_register_gate(dev, clk_gate_desc[idx].name,

Use devm?

> +                                            "lan966x", 0, base,
> +                                            clk_gate_desc[idx].bit_idx,
> +                                            0, &clk_gate_lock);
> +
> +               if (IS_ERR(hw_data->hws[i]))
> +                       return dev_err_probe(dev, PTR_ERR(hw_data->hws[i]),
> +                                            "failed to register %s clock\n",
> +                                            clk_gate_desc[idx].name);
> +       }
> +
> +       return 0;
> +}
> +
> +static void lan966x_gate_clk_unregister(struct clk_hw_onecell_data *hw_data)
> +{
> +       int i;
> +
> +       for (i = GCK_GATE_UHPHS; i < N_CLOCKS; ++i)

for (int i = 

should suffice

> +               if (!IS_ERR(hw_data->hws[i]))
> +                       clk_hw_unregister(hw_data->hws[i]);
> +}
> +
Horatiu Vultur Oct. 29, 2021, 9:35 a.m. UTC | #2
The 10/28/2021 23:41, Stephen Boyd wrote:

Hi Stephen,

> 
> Quoting Horatiu Vultur (2021-10-19 01:44:49)
> > diff --git a/drivers/clk/clk-lan966x.c b/drivers/clk/clk-lan966x.c
> > index 19bec94e1551..40be47092a31 100644
> > --- a/drivers/clk/clk-lan966x.c
> > +++ b/drivers/clk/clk-lan966x.c
> > @@ -188,26 +202,64 @@ static struct clk_hw *lan966x_gck_clk_register(struct device *dev, int i)
> >         return &priv->hw;
> >  };
> >
> > +static int lan966x_gate_clk_register(struct device *dev,
> > +                                    struct clk_hw_onecell_data *hw_data,
> > +                                    void __iomem *gate_base)
> > +{
> > +       int i;
> > +
> > +       for (i = GCK_GATE_UHPHS; i < N_CLOCKS; ++i) {
> > +               int idx = i - GCK_GATE_UHPHS;
> > +
> > +               hw_data->hws[i] =
> > +                       clk_hw_register_gate(dev, clk_gate_desc[idx].name,
> 
> Use devm?

I couldn't find any devm_clk_hw_register_gate or something similar for
the gate.

> 
> > +                                            "lan966x", 0, base,
> > +                                            clk_gate_desc[idx].bit_idx,
> > +                                            0, &clk_gate_lock);
> > +
> > +               if (IS_ERR(hw_data->hws[i]))
> > +                       return dev_err_probe(dev, PTR_ERR(hw_data->hws[i]),
> > +                                            "failed to register %s clock\n",
> > +                                            clk_gate_desc[idx].name);
> > +       }
> > +
> > +       return 0;
> > +}
> > +
> > +static void lan966x_gate_clk_unregister(struct clk_hw_onecell_data *hw_data)
> > +{
> > +       int i;
> > +
> > +       for (i = GCK_GATE_UHPHS; i < N_CLOCKS; ++i)
> 
> for (int i =
> 
> should suffice

That would not work. I will get the error:
error: ‘for’ loop initial declarations are only allowed in C99 or C11 mode

> 
> > +               if (!IS_ERR(hw_data->hws[i]))
> > +                       clk_hw_unregister(hw_data->hws[i]);
> > +}
> > +
Stephen Boyd Oct. 29, 2021, 11:32 p.m. UTC | #3
Quoting Horatiu Vultur (2021-10-29 02:35:56)
> The 10/28/2021 23:41, Stephen Boyd wrote:
> 
> Hi Stephen,
> 
> > 
> > Quoting Horatiu Vultur (2021-10-19 01:44:49)
> > > diff --git a/drivers/clk/clk-lan966x.c b/drivers/clk/clk-lan966x.c
> > > index 19bec94e1551..40be47092a31 100644
> > > --- a/drivers/clk/clk-lan966x.c
> > > +++ b/drivers/clk/clk-lan966x.c
> > > @@ -188,26 +202,64 @@ static struct clk_hw *lan966x_gck_clk_register(struct device *dev, int i)
> > >         return &priv->hw;
> > >  };
> > >
> > > +static int lan966x_gate_clk_register(struct device *dev,
> > > +                                    struct clk_hw_onecell_data *hw_data,
> > > +                                    void __iomem *gate_base)
> > > +{
> > > +       int i;
> > > +
> > > +       for (i = GCK_GATE_UHPHS; i < N_CLOCKS; ++i) {
> > > +               int idx = i - GCK_GATE_UHPHS;
> > > +
> > > +               hw_data->hws[i] =
> > > +                       clk_hw_register_gate(dev, clk_gate_desc[idx].name,
> > 
> > Use devm?
> 
> I couldn't find any devm_clk_hw_register_gate or something similar for
> the gate.

Add one?

> 
> > 
> > > +                                            "lan966x", 0, base,
> > > +                                            clk_gate_desc[idx].bit_idx,
> > > +                                            0, &clk_gate_lock);
> > > +
> > > +               if (IS_ERR(hw_data->hws[i]))
> > > +                       return dev_err_probe(dev, PTR_ERR(hw_data->hws[i]),
> > > +                                            "failed to register %s clock\n",
> > > +                                            clk_gate_desc[idx].name);
> > > +       }
> > > +
> > > +       return 0;
> > > +}
> > > +
> > > +static void lan966x_gate_clk_unregister(struct clk_hw_onecell_data *hw_data)
> > > +{
> > > +       int i;
> > > +
> > > +       for (i = GCK_GATE_UHPHS; i < N_CLOCKS; ++i)
> > 
> > for (int i =
> > 
> > should suffice
> 
> That would not work. I will get the error:
> error: ‘for’ loop initial declarations are only allowed in C99 or C11 mode

Ah ok
Horatiu Vultur Oct. 31, 2021, 9:03 a.m. UTC | #4
The 10/29/2021 16:32, Stephen Boyd wrote:
> 
> Quoting Horatiu Vultur (2021-10-29 02:35:56)
> > The 10/28/2021 23:41, Stephen Boyd wrote:
> >
> > Hi Stephen,
> >
> > >
> > > Quoting Horatiu Vultur (2021-10-19 01:44:49)
> > > > diff --git a/drivers/clk/clk-lan966x.c b/drivers/clk/clk-lan966x.c
> > > > index 19bec94e1551..40be47092a31 100644
> > > > --- a/drivers/clk/clk-lan966x.c
> > > > +++ b/drivers/clk/clk-lan966x.c
> > > > @@ -188,26 +202,64 @@ static struct clk_hw *lan966x_gck_clk_register(struct device *dev, int i)
> > > >         return &priv->hw;
> > > >  };
> > > >
> > > > +static int lan966x_gate_clk_register(struct device *dev,
> > > > +                                    struct clk_hw_onecell_data *hw_data,
> > > > +                                    void __iomem *gate_base)
> > > > +{
> > > > +       int i;
> > > > +
> > > > +       for (i = GCK_GATE_UHPHS; i < N_CLOCKS; ++i) {
> > > > +               int idx = i - GCK_GATE_UHPHS;
> > > > +
> > > > +               hw_data->hws[i] =
> > > > +                       clk_hw_register_gate(dev, clk_gate_desc[idx].name,
> > >
> > > Use devm?
> >
> > I couldn't find any devm_clk_hw_register_gate or something similar for
> > the gate.
> 
> Add one?

Yes, I will do that.

> 
> >
> > >
> > > > +                                            "lan966x", 0, base,
> > > > +                                            clk_gate_desc[idx].bit_idx,
> > > > +                                            0, &clk_gate_lock);
> > > > +
> > > > +               if (IS_ERR(hw_data->hws[i]))
> > > > +                       return dev_err_probe(dev, PTR_ERR(hw_data->hws[i]),
> > > > +                                            "failed to register %s clock\n",
> > > > +                                            clk_gate_desc[idx].name);
> > > > +       }
> > > > +
> > > > +       return 0;
> > > > +}
> > > > +
> > > > +static void lan966x_gate_clk_unregister(struct clk_hw_onecell_data *hw_data)
> > > > +{
> > > > +       int i;
> > > > +
> > > > +       for (i = GCK_GATE_UHPHS; i < N_CLOCKS; ++i)
> > >
> > > for (int i =
> > >
> > > should suffice
> >
> > That would not work. I will get the error:
> > error: ‘for’ loop initial declarations are only allowed in C99 or C11 mode
> 
> Ah ok