All of lore.kernel.org
 help / color / mirror / Atom feed
From: Krzysztof Kozlowski <krzk@kernel.org>
To: Sakari Ailus <sakari.ailus@linux.intel.com>
Cc: devicetree@vger.kernel.org, Shawn Guo <shawnguo@kernel.org>,
	Sascha Hauer <s.hauer@pengutronix.de>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	Rob Herring <robh+dt@kernel.org>,
	NXP Linux Team <linux-imx@nxp.com>,
	Pengutronix Kernel Team <kernel@pengutronix.de>,
	Mauro Carvalho Chehab <mchehab@kernel.org>,
	Fabio Estevam <festevam@gmail.com>,
	linux-arm-kernel@lists.infradead.org,
	linux-media@vger.kernel.org
Subject: Re: [PATCH v4 1/4] dt-bindings: media: imx258: add bindings for IMX258 sensor
Date: Fri, 2 Oct 2020 14:15:11 +0200	[thread overview]
Message-ID: <20201002121511.GA7285@pi3> (raw)
In-Reply-To: <20200929110255.GJ26842@paasikivi.fi.intel.com>

On Tue, Sep 29, 2020 at 02:02:55PM +0300, Sakari Ailus wrote:
> On Tue, Sep 29, 2020 at 11:46:36AM +0200, Krzysztof Kozlowski wrote:
> > On Tue, Sep 29, 2020 at 12:40:46PM +0300, Sakari Ailus wrote:
> > > On Tue, Sep 29, 2020 at 11:18:46AM +0200, Krzysztof Kozlowski wrote:
> > > > On Tue, 29 Sep 2020 at 11:15, Sakari Ailus <sakari.ailus@linux.intel.com> wrote:
> > > > >
> > > > > Hi Krzysztof,
> > > > >
> > > > > On Wed, Sep 23, 2020 at 05:21:26PM +0200, Krzysztof Kozlowski wrote:
> > > > > > Add bindings for the IMX258 camera sensor.  The bindings, just like the
> > > > > > driver, are quite limited, e.g. do not support regulator supplies.
> > > > > >
> > > > > > Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>
> > > > > >
> > > > > > ---
> > > > > >
> > > > > > Changes since v3:
> > > > > > 1. Document also two lane setup.
> > > > > >
> > > > > > Changes since v2:
> > > > > > 1. Remove clock-frequency, add reset GPIOs, add supplies.
> > > > >
> > > > > Oops. I missed this one.
> > > > >
> > > > > How does the driver know the appropriate clock frequency for the platform
> > > > > if it's not in DT? The sensor supports a range of frequencies, not a single
> > > > > frequency.
> > > > >
> > > > > Could you add clock-frequency back?
> > > > 
> > > > Not really, it was removed on Rob's request. The bindings do not
> > > > describe driver's behavior so how the driver gets frequency should not
> > > > be part of the bindings. Also it's not a real problem - the driver
> > > > just calls clk_get_rate().
> > > 
> > > How is the rate determined? I mean, many ISPs or CSI-2 receivers that
> > > provide the clock are also capable of using a variety of frequencies. But
> > > only one can be used on the platform in general.
> > 
> > Having "clock-frequency" property in DTS did not solve that. It has no
> > effect on actual frequency.
> 
> It's up to the driver to do what's needed, yes.
> 
> Please see examples in e.g. drivers/media/i2c/ov8856.c and
> Documentation/devicetree/bindings/media/i2c/ov8856.yaml .

It seems the ov8856 driver uses this property in different way than
imx258 driver. It is more appropriate and quite similar to clock
providers and buses - to set the desired frequency on input clock.

Therefore what is the point of using this DT property comparing to
assigned-clock-rates?

It's the same. So let's use generic (already documented)
assigned-clock-rates.  

For your question (not related to the bindings but to driver
implementation): "How is the rate determined?", simple: clk_get_rate.
The driver then uses it like this:
	if (clk_get_rate() != only_working_configuration_hz)
		return -EINVAL;

From the bindings point of view, the clock can be anything within a
range of sensor's accepted values. The clock frequency is a property of
a clock, not of a sensor. Therefore for HW description it should be
described in the clock bindings, not in the sensor bindings.

To summarize, the "clock-frequency" property of sensor node:
1. As a way to configure the clock should be replaced with
   assigned-clock properties,
2. As a way to describe the hardware is simply invalid. It is not a HW
   description, because HW requires just a clock of frequency within
   given range, not a fixed frequency clock.

Consider the example:
        camera@1a {
                compatible = "sony,imx258";
                reg = <0x1a>;

                clocks = <&imx258_clk>;
                clock-names = "clk";

                /* Oscillator on camera board */
                imx258_clk: clk {
                        compatible = "fixed-clock";
                        #clock-cells = <0>;
                        clock-frequency = <19200000>;
                };

                port {
			...
                };
        };

What is the point to add "clock-frequency" property to the camera
itself, since it is already clearly defined by the clock?

Or another example:

        camera@1a {
                compatible = "sony,imx258";
                reg = <0x1a>;

                clocks = <&iclk 0>;
                clock-names = "clk";
		assigned-clocks = <&clk 0>;
		assigned-clock-rates = <19200000>;

                port {
			...
                };
        };

Again, no reason for artificial clock-frequency property. It is not part
of HW description of the sensor.

Best regards,
Krzysztof


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

WARNING: multiple messages have this Message-ID (diff)
From: Krzysztof Kozlowski <krzk@kernel.org>
To: Sakari Ailus <sakari.ailus@linux.intel.com>
Cc: Mauro Carvalho Chehab <mchehab@kernel.org>,
	Rob Herring <robh+dt@kernel.org>, Shawn Guo <shawnguo@kernel.org>,
	Sascha Hauer <s.hauer@pengutronix.de>,
	Pengutronix Kernel Team <kernel@pengutronix.de>,
	Fabio Estevam <festevam@gmail.com>,
	NXP Linux Team <linux-imx@nxp.com>,
	linux-media@vger.kernel.org, devicetree@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v4 1/4] dt-bindings: media: imx258: add bindings for IMX258 sensor
Date: Fri, 2 Oct 2020 14:15:11 +0200	[thread overview]
Message-ID: <20201002121511.GA7285@pi3> (raw)
In-Reply-To: <20200929110255.GJ26842@paasikivi.fi.intel.com>

On Tue, Sep 29, 2020 at 02:02:55PM +0300, Sakari Ailus wrote:
> On Tue, Sep 29, 2020 at 11:46:36AM +0200, Krzysztof Kozlowski wrote:
> > On Tue, Sep 29, 2020 at 12:40:46PM +0300, Sakari Ailus wrote:
> > > On Tue, Sep 29, 2020 at 11:18:46AM +0200, Krzysztof Kozlowski wrote:
> > > > On Tue, 29 Sep 2020 at 11:15, Sakari Ailus <sakari.ailus@linux.intel.com> wrote:
> > > > >
> > > > > Hi Krzysztof,
> > > > >
> > > > > On Wed, Sep 23, 2020 at 05:21:26PM +0200, Krzysztof Kozlowski wrote:
> > > > > > Add bindings for the IMX258 camera sensor.  The bindings, just like the
> > > > > > driver, are quite limited, e.g. do not support regulator supplies.
> > > > > >
> > > > > > Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>
> > > > > >
> > > > > > ---
> > > > > >
> > > > > > Changes since v3:
> > > > > > 1. Document also two lane setup.
> > > > > >
> > > > > > Changes since v2:
> > > > > > 1. Remove clock-frequency, add reset GPIOs, add supplies.
> > > > >
> > > > > Oops. I missed this one.
> > > > >
> > > > > How does the driver know the appropriate clock frequency for the platform
> > > > > if it's not in DT? The sensor supports a range of frequencies, not a single
> > > > > frequency.
> > > > >
> > > > > Could you add clock-frequency back?
> > > > 
> > > > Not really, it was removed on Rob's request. The bindings do not
> > > > describe driver's behavior so how the driver gets frequency should not
> > > > be part of the bindings. Also it's not a real problem - the driver
> > > > just calls clk_get_rate().
> > > 
> > > How is the rate determined? I mean, many ISPs or CSI-2 receivers that
> > > provide the clock are also capable of using a variety of frequencies. But
> > > only one can be used on the platform in general.
> > 
> > Having "clock-frequency" property in DTS did not solve that. It has no
> > effect on actual frequency.
> 
> It's up to the driver to do what's needed, yes.
> 
> Please see examples in e.g. drivers/media/i2c/ov8856.c and
> Documentation/devicetree/bindings/media/i2c/ov8856.yaml .

It seems the ov8856 driver uses this property in different way than
imx258 driver. It is more appropriate and quite similar to clock
providers and buses - to set the desired frequency on input clock.

Therefore what is the point of using this DT property comparing to
assigned-clock-rates?

It's the same. So let's use generic (already documented)
assigned-clock-rates.  

For your question (not related to the bindings but to driver
implementation): "How is the rate determined?", simple: clk_get_rate.
The driver then uses it like this:
	if (clk_get_rate() != only_working_configuration_hz)
		return -EINVAL;

From the bindings point of view, the clock can be anything within a
range of sensor's accepted values. The clock frequency is a property of
a clock, not of a sensor. Therefore for HW description it should be
described in the clock bindings, not in the sensor bindings.

To summarize, the "clock-frequency" property of sensor node:
1. As a way to configure the clock should be replaced with
   assigned-clock properties,
2. As a way to describe the hardware is simply invalid. It is not a HW
   description, because HW requires just a clock of frequency within
   given range, not a fixed frequency clock.

Consider the example:
        camera@1a {
                compatible = "sony,imx258";
                reg = <0x1a>;

                clocks = <&imx258_clk>;
                clock-names = "clk";

                /* Oscillator on camera board */
                imx258_clk: clk {
                        compatible = "fixed-clock";
                        #clock-cells = <0>;
                        clock-frequency = <19200000>;
                };

                port {
			...
                };
        };

What is the point to add "clock-frequency" property to the camera
itself, since it is already clearly defined by the clock?

Or another example:

        camera@1a {
                compatible = "sony,imx258";
                reg = <0x1a>;

                clocks = <&iclk 0>;
                clock-names = "clk";
		assigned-clocks = <&clk 0>;
		assigned-clock-rates = <19200000>;

                port {
			...
                };
        };

Again, no reason for artificial clock-frequency property. It is not part
of HW description of the sensor.

Best regards,
Krzysztof


  reply	other threads:[~2020-10-02 12:17 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-23 15:21 [PATCH v4 1/4] dt-bindings: media: imx258: add bindings for IMX258 sensor Krzysztof Kozlowski
2020-09-23 15:21 ` Krzysztof Kozlowski
2020-09-23 15:21 ` [PATCH v4 2/4] media: i2c: imx258: add support for binding via device tree Krzysztof Kozlowski
2020-09-23 15:21   ` Krzysztof Kozlowski
2020-09-23 15:21 ` [PATCH v4 3/4] media: i2c: imx258: simplify getting state container Krzysztof Kozlowski
2020-09-23 15:21   ` Krzysztof Kozlowski
2020-09-23 15:21 ` [PATCH v4 4/4] media: i2c: imx258: get clock from device properties and enable it via runtime PM Krzysztof Kozlowski
2020-09-23 15:21   ` Krzysztof Kozlowski
2020-09-29  9:17   ` Sakari Ailus
2020-09-29  9:17     ` Sakari Ailus
2020-09-29  9:24     ` Krzysztof Kozlowski
2020-09-29  9:24       ` Krzysztof Kozlowski
2020-09-28 18:46 ` [PATCH v4 1/4] dt-bindings: media: imx258: add bindings for IMX258 sensor Rob Herring
2020-09-28 18:46   ` Rob Herring
2020-09-29  9:15 ` Sakari Ailus
2020-09-29  9:15   ` Sakari Ailus
2020-09-29  9:18   ` Krzysztof Kozlowski
2020-09-29  9:18     ` Krzysztof Kozlowski
2020-09-29  9:40     ` Sakari Ailus
2020-09-29  9:40       ` Sakari Ailus
2020-09-29  9:46       ` Krzysztof Kozlowski
2020-09-29  9:46         ` Krzysztof Kozlowski
2020-09-29 11:02         ` Sakari Ailus
2020-09-29 11:02           ` Sakari Ailus
2020-10-02 12:15           ` Krzysztof Kozlowski [this message]
2020-10-02 12:15             ` Krzysztof Kozlowski
2020-09-29  9:43     ` Sakari Ailus
2020-09-29  9:43       ` Sakari Ailus

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=20201002121511.GA7285@pi3 \
    --to=krzk@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=festevam@gmail.com \
    --cc=kernel@pengutronix.de \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-imx@nxp.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=mchehab@kernel.org \
    --cc=robh+dt@kernel.org \
    --cc=s.hauer@pengutronix.de \
    --cc=sakari.ailus@linux.intel.com \
    --cc=shawnguo@kernel.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 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.