All of lore.kernel.org
 help / color / mirror / Atom feed
From: Sean Anderson <seanga2@gmail.com>
To: u-boot@lists.denx.de
Subject: [PATCH v9 18/21] riscv: Enable cpu clock if it is present
Date: Sat, 2 May 2020 22:34:18 -0400	[thread overview]
Message-ID: <69b53491-abcb-128f-f00b-357051529b3d@gmail.com> (raw)
In-Reply-To: <MWHPR13MB0944956E9B8675DED3448D2CE5D10@MWHPR13MB0944.namprd13.prod.outlook.com>

On 4/25/20 3:54 AM, Pragnesh Patel wrote:
> Hi Sean,
> 
>> -----Original Message-----
>> From: U-Boot <u-boot-bounces@lists.denx.de> On Behalf Of Sean Anderson
>> Sent: 23 April 2020 08:03
>> To: u-boot at lists.denx.de
>> Cc: Rick Chen <rickchen36@gmail.com>; Bin Meng <bmeng.cn@gmail.com>;
>> Sean Anderson <seanga2@gmail.com>
>> Subject: [PATCH v9 18/21] riscv: Enable cpu clock if it is present
>>
>> [External Email] Do not click links or attachments unless you recognize the
>> sender and know the content is safe
>>
>> The cpu clock is probably already enabled if we are executing code (though we
>> could be executing from a different core). This patch prevents the cpu clock or
>> its parents from being disabled.
>>
>> Signed-off-by: Sean Anderson <seanga2@gmail.com>
>> Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
>> ---
>> This patch was previously submitted on its own as
>> https://patchwork.ozlabs.org/patch/1232420/
>>
>> Changes in v4:
>> - New
>>
>> drivers/cpu/riscv_cpu.c | 20 ++++++++++++++++++++
>> 1 file changed, 20 insertions(+)
>>
>> diff --git a/drivers/cpu/riscv_cpu.c b/drivers/cpu/riscv_cpu.c index
>> c6ed060abc..9ce58695aa 100644
>> --- a/drivers/cpu/riscv_cpu.c
>> +++ b/drivers/cpu/riscv_cpu.c
>> @@ -1,6 +1,7 @@
>> // SPDX-License-Identifier: GPL-2.0+
>> /*
>>  * Copyright (C) 2018, Bin Meng <bmeng.cn@gmail.com>
>> + * Copyright (C) 2020, Sean Anderson <seanga2@gmail.com>
>>  */
>>
>> #include <clk.h>
>> @@ -117,6 +118,24 @@ static int riscv_cpu_bind(struct udevice *dev)
>>        return 0;
>> }
>>
>> +static int riscv_cpu_probe(struct udevice *dev) {
>> +       int ret = 0;
>> +       struct clk clk;
>> +
>> +       /* Get a clock if it exists */
>> +       ret = clk_get_by_index(dev, 0, &clk);
>> +       if (ret)
>> +               return 0;
>> +
>> +       ret = clk_enable(&clk);
>> +       clk_free(&clk);
>> +       if (ret == -ENOSYS || ret == -ENOTSUPP)
>> +               return 0;
>> +       else
>> +               return ret;
>> +}
> 
> can we add clk_set_rate() if clock-frequency is present in cpus node of dts ?

I already commented on this in your patch series, but I want to have a
record of it here as well.

I think this is better done with assigned-clock-frequency. If just the
clock-frequency property is present (but not the clocks property), we
can't set the frequency, so we need to assume the CPU is already running
at that frequency. If we use the clock-frequency property to denote the
desired frequency when there is a clocks property present, that changes
the semantics when the clocks property is not present. If the clocks
property is present, we should use the existing apis to configure the
clock.

--Sean

  reply	other threads:[~2020-05-03  2:34 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-23  2:32 [PATCH v9 00/21] riscv: Add Sipeed Maix support Sean Anderson
2020-04-23  2:33 ` [PATCH v9 01/21] clk: Always use the supplied struct clk Sean Anderson
2020-04-23  2:33 ` [PATCH v9 02/21] clk: Check that ops of composite clock components exist before calling Sean Anderson
2020-04-23  2:33 ` [PATCH v9 03/21] clk: Unconditionally recursively en-/dis-able clocks Sean Anderson
2020-04-23  2:33 ` [PATCH v9 04/21] clk: Fix clk_get_by_* handling of index Sean Anderson
2020-04-23  2:33 ` [PATCH v9 05/21] clk: Add K210 pll support Sean Anderson
2020-04-23  2:33 ` [PATCH v9 06/21] clk: Add a bypass clock for K210 Sean Anderson
2020-04-23  2:33 ` [PATCH v9 07/21] clk: Add K210 clock support Sean Anderson
2020-04-23  2:33 ` [PATCH v9 08/21] dm: Add support for simple-pm-bus Sean Anderson
2020-04-23  2:33 ` [PATCH v9 09/21] dm: Fix error handling for dev_read_addr_ptr Sean Anderson
2020-04-23  2:33 ` [PATCH v9 10/21] reset: Add generic reset driver Sean Anderson
2020-04-23  2:33 ` [PATCH v9 11/21] lib: Always set errno in hcreate_r Sean Anderson
2020-04-23  2:33 ` [PATCH v9 12/21] riscv: Add headers for asm/global_data.h Sean Anderson
2020-04-23  2:33 ` [PATCH v9 13/21] riscv: Clear pending interrupts before enabling IPIs Sean Anderson
2020-04-23  2:33 ` [PATCH v9 14/21] riscv: Clean up IPI initialization code Sean Anderson
2020-04-23  2:33 ` [PATCH v9 15/21] riscv: Add option to support RISC-V privileged spec 1.9 Sean Anderson
2020-04-23  2:33 ` [PATCH v9 16/21] riscv: Allow use of reset drivers Sean Anderson
2020-04-23  2:33 ` [PATCH v9 17/21] riscv: Try to get cpu frequency from a "clocks" node if it exists Sean Anderson
2020-04-23  2:33 ` [PATCH v9 18/21] riscv: Enable cpu clock if it is present Sean Anderson
2020-04-25  7:54   ` Pragnesh Patel
2020-05-03  2:34     ` Sean Anderson [this message]
2020-04-23  2:33 ` [PATCH v9 19/21] riscv: Add device tree for K210 and Sipeed Maix BitM Sean Anderson
2020-04-23  2:33 ` [PATCH v9 20/21] doc: riscv: Add documentation for Sipeed Maix Bit Sean Anderson
2020-04-23  2:33 ` [PATCH v9 21/21] riscv: Add Sipeed Maix support Sean Anderson
2020-05-03  2:35 [PATCH v9 00/21] " Sean Anderson
2020-05-03  2:35 ` [PATCH v9 18/21] riscv: Enable cpu clock if it is present Sean Anderson

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=69b53491-abcb-128f-f00b-357051529b3d@gmail.com \
    --to=seanga2@gmail.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.