public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Benjamin Tietz <uboot@dresden.micronet24.de>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v2 07/22] clock-uclass: allow disabling a peripheral clock
Date: Fri, 29 Jul 2016 19:26:53 +0200	[thread overview]
Message-ID: <20160729172653.GF2991@micronet24.de> (raw)
In-Reply-To: <e7ee33c5-06db-4b03-db1e-a5edc91ab719@wwwdotorg.org>

Hello Stephen,

On Fri, Jul 29, 2016 at 10:04:56AM -0600, Stephen Warren wrote:
> On 07/28/2016 01:28 PM, Benjamin Tietz wrote:
> >Hello Vikas, hello Simon,
> >
> >the new clk-API leaves me with a problem. Previously there was a
> >seperate way to access the clock-device itself (using clk_[gs]et_rate) and
> >the peripherals connected (clk_[gs]et_periph_rate). The former case now isn't
> >available no more. But the system clock in STM32 doesn't have a separate ID.
> >According to the device-tree the kernel doesn't care about that - or
> >uses special logic.
> 
> I don't understand the issue here. The device tree model is that every clock
> has some provider (a node/phandle) and some ID (a sequence of integer
> values). There's no such thing as "the clock-device itself".

For the current STM32 DT exactly that is the problem. The phandle is
available and the set of IDs is defined. There is - at least at the
moment - no ID defined for the system clock itself, but only for the
derived clocks for the individual peripherals.

The existing peripherals IDs even start to count at 0, so the "intuitive"
solution to use that ID, doesn't work either.

> 
> The kernel is consistent with that model; each client executes clk_get(),
> which for a DT-based system parses the phandle+clock_specifier and returns a
> clock handle, and then the client just uses that handle. That's exactly how
> U-Boot works too.

I must admit, that I haven't had an in-depth look on the STM32 clocking
kernel sources yet. From other architectures I've seen, the system clock
is either accessed by a certain ID, based on the underlying hardware -
which isn't available on STM32 - or assumed to be "just there". On a
first glance, the kernel STM32 driver seems to fall into the second category.

> 
> Perhaps you can show the portion of DT that's causing the issue?

It is the not existing potion of the DT ;)

> 
> Is the issue that there are clocks that your code needs to use that haven't
> yet been assigned a clock ID (clock specifier value) for use in DT (i.e. you
> have SoC-specific code that's calling clk_get() and the mapping isn't via
> DT)? If so, you simply need to assign one and everything will work fine.
> High numbers work fine for this.
> 
> >Possible solutions:
> >
> >a) Using a magic ID. Unfortunately, the peripheral used in the current
> >device-tree are 0-based (and 0 is already in use), so this number isn't
> >available. Moving the IDs around would break compatibility to the linux
> >kernel.
> >
> >Negative numbers look like errors.
> >
> >Using a special high number looks unintuitive. And often result in
> >additional work-arounds in the future.
> 
> What specific issues are you thinking of? I haven't experienced any when
> assigning IDs on Tegra, and I haven't observed anyone having issues doing
> this on any platform within the Linux kernel, where the exact same thing
> would be required.

I'm no friend of magic numbers. Experience had shown, that - especially
those introduced as a work-around - generate complicate problems at a
later point of time.
The first thing I can think of is to run into a hardware, having more
peripheral clocks than expected. Nevertheless, in a follow-up mail I
made a suggestion interpreting part of the ID as a bit-field - with
enough room for bigger hardware.

regards
Benjamin

  reply	other threads:[~2016-07-29 17:26 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-06-20 18:26 [U-Boot] [PATCH 2 00/22] DM: Cmd: GPIO/LED/STM32/CLK: provide command-line support for device-tree configured gpios and leds Benjamin Tietz
2016-06-20 18:26 ` [U-Boot] [PATCH v2 01/22] stm32: gpio: fix otype access Benjamin Tietz
2016-06-20 18:26 ` [U-Boot] [PATCH v2 02/22] stm32: gpio_direction_output: make sure, output is set to push-pull Benjamin Tietz
2016-06-20 18:26 ` [U-Boot] [PATCH v2 03/22] stm32: gpio_get_value: always return 0 or 1 Benjamin Tietz
2016-06-20 18:26 ` [U-Boot] [PATCH v2 04/22] stm32f429-discovery: config: enable status leds Benjamin Tietz
2016-06-20 18:26 ` [U-Boot] [PATCH v2 05/22] Cmd: led: provide a selector in kconfig Benjamin Tietz
2016-06-20 18:26 ` [U-Boot] [PATCH v2 06/22] DTS: stm32f429: provide device-tree files (from linux kernel) Benjamin Tietz
2016-06-20 18:26 ` [U-Boot] [PATCH v2 07/22] clock-uclass: allow disabling a peripheral clock Benjamin Tietz
2016-07-12 16:02   ` Simon Glass
2016-07-12 16:08     ` Stephen Warren
2016-07-28 16:50     ` Benjamin Tietz
2016-07-28 19:28     ` Benjamin Tietz
2016-07-29  5:22       ` Benjamin Tietz
2016-07-29 16:04       ` Stephen Warren
2016-07-29 17:26         ` Benjamin Tietz [this message]
2016-07-29 18:02           ` Stephen Warren
2016-07-29 18:34             ` Benjamin Tietz
2016-08-01  1:03               ` Simon Glass
2016-06-20 18:26 ` [U-Boot] [PATCH v2 08/22] STM32: clock: provide dts-accessible clock driver Benjamin Tietz
2016-06-20 18:26 ` [U-Boot] [PATCH v2 09/22] DTS: STM32f429: add gpio-banks Benjamin Tietz
2016-06-20 18:26 ` [U-Boot] [PATCH v2 10/22] STM32: gpio: group SOC-specific code to one ifdef/elif construct Benjamin Tietz
2016-06-20 18:26 ` [U-Boot] [PATCH v2 11/22] GPIO: STM32: make DTS-aware Benjamin Tietz
2016-06-20 18:27 ` [U-Boot] [PATCH v2 12/22] STM32F429-discovery: led: disable board-specific code, if DM is selected Benjamin Tietz
2016-06-20 18:27 ` [U-Boot] [PATCH v2 13/22] GPIO/LED: make more robust, if STATUS_LED isn't selected Benjamin Tietz
2016-06-20 18:27 ` [U-Boot] [PATCH v2 14/22] Cmd: LED: rewrite to prepare non-static access Benjamin Tietz
2016-06-20 18:27 ` [U-Boot] [PATCH v2 15/22] DTS: STM32F429-disco: add board leds and enable rcc Benjamin Tietz
2016-06-20 18:27 ` [U-Boot] [PATCH v2 16/22] LED: add function to retrieve a device's label Benjamin Tietz
2016-06-20 18:27 ` [U-Boot] [PATCH v2 17/22] LED: provide function to count and get all (DM-)LEDs Benjamin Tietz
2016-06-20 18:27 ` [U-Boot] [PATCH v2 18/22] cmd: LED: be aware of DTS-configured leds Benjamin Tietz
2016-06-20 18:27 ` [U-Boot] [PATCH v2 19/22] LED: provide functionality to get led status Benjamin Tietz
2016-06-20 18:27 ` [U-Boot] [PATCH v2 20/22] LED: GPIO: provide get_on() op Benjamin Tietz
2016-06-20 18:27 ` [U-Boot] [PATCH v2 21/22] LED: provide toggling interface Benjamin Tietz
2016-06-20 18:27 ` [U-Boot] [PATCH v2 22/22] Cmd: LED: make DM-leds toggle Benjamin Tietz
2016-07-01 23:35 ` [U-Boot] [PATCH 2 00/22] DM: Cmd: GPIO/LED/STM32/CLK: provide command-line support for device-tree configured gpios and leds Vikas MANOCHA
2016-07-20 22:32 ` Vikas MANOCHA
2016-07-28 16:30   ` Benjamin Tietz

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=20160729172653.GF2991@micronet24.de \
    --to=uboot@dresden.micronet24.de \
    --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