public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: "Janusz Użycki" <j.uzycki@elproma.com.pl>
To: Philipp Zabel <p.zabel@pengutronix.de>
Cc: Mike Turquette <mturquette@linaro.org>,
	Thierry Reding <thierry.reding@gmail.com>,
	Rob Herring <robh+dt@kernel.org>, Pawel Moll <pawel.moll@arm.com>,
	Mark Rutland <mark.rutland@arm.com>,
	Ian Campbell <ijc+devicetree@hellion.org.uk>,
	Kumar Gala <galak@codeaurora.org>,
	devicetree@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-pwm@vger.kernel.org
Subject: Re: [PATCH v2] clk: Add PWM clock driver
Date: Tue, 09 Dec 2014 14:09:44 +0100	[thread overview]
Message-ID: <5486F498.30309@elproma.com.pl> (raw)
In-Reply-To: <1418116533.3107.1.camel@pengutronix.de>

Hi Philipp,

W dniu 2014-12-09 o 10:15, Philipp Zabel pisze:
> Hi Janusz,
>
> Am Montag, den 08.12.2014, 21:03 +0100 schrieb Janusz Użycki:
>> Hi,
>>
>> I've fixed my pwm driver and I can enable 12MHz 50% output using sysfs.
>> Then I rebased the pwm-clock to 3.14.
>> I have connected mcp2515 and it works with fixed clock. When I switch
>> the chip's clock to pwm clock in dt
>> I get "mcp251x: probe of spi1.2 failed with error -2". I've also added
>> clock-frequency property
>> but it didn't help.
>> When I set the mcp2515 clock to fixed clock again but the clock is not
>> applied to mcp2515 I get
>> "mcp251x spi1.2: MCP251x didn't enter in conf mode after reset".
>> So it looks this is indeed probe error caused likely by dt.
> Did pwm-clock fail to probe already? Could you check with the patch
> below?

Added. clk_pwm_probe() is never called. The pwm-clk driver is built-in. 
mcp251x is a module.
mcp251x doesn't trigger pwm-clock dt. I found fixed-clock uses 
CLK_OF_DECLARE().
How does it work for you? What is missing?

The pwm-clock driver set CLK_IS_ROOT and no parents.
I think it fail the clock on suspend/resume race but I can be wrong.

>> The fixed and pwm clock in DT:
>>           clocks {
>>                   #address-cells = <1>;
>>                   #size-cells = <1>;
>>                   ranges;
>>                   mcp251x_xtal_clk: mcp2515_xtal {
>>                           compatible = "fixed-clock";
>>                           #clock-cells = <0>;
>>                           clock-frequency = <12000000>;
>>                   };
>>
>>                   mcp251x_pwm_clk: mcp2515_pwm {
>>                           compatible = "pwm-clock";
>>                           #clock-cells = <0>;
>>                           clock-frequency = <12000000>;
>>                           clock-output-names = "can_clk";
>>                           pwms = <&pwm 3 83>;     /* 12MHz = 1 / ~83ns */
>>                   };
>>           };
>>
>> Also the mentioned frequency recalculation problem appears here.
>> In the case above recalc value is about 12.048MHz instead of 12.0MHz.
>> While PWM block is clocked 24MHz and the pwm generates exactly 12MHz
>> the pwm-clock driver returns drifted value. Using clock-frequency like
>> fixed-clock does could simply solve the binding problem.
> Yes, for this case it is very unfortunate that there's only nanosecond
> resolution for the duty cycle. Adding a clock-frequency property to
> indicate the real frequency would solve this problem.

Yes but the property also must be supported by pwm-clock driver.

best regards
Janusz

>
> ------8<------
> diff --git a/drivers/clk/clk-pwm.c b/drivers/clk/clk-pwm.c
> index 8f747b3..9c13856 100644
> --- a/drivers/clk/clk-pwm.c
> +++ b/drivers/clk/clk-pwm.c
> @@ -63,12 +63,16 @@ int clk_pwm_probe(struct platform_device *pdev)
>   		return -ENOMEM;
>   
>   	pwm = devm_pwm_get(&pdev->dev, NULL);
> -	if (IS_ERR(pwm))
> +	if (IS_ERR(pwm)) {
> +		dev_err(&pdev->dev, "failed to get pwm: %ld\n", PTR_ERR(pwm));
>   		return PTR_ERR(pwm);
> +	}
>   
>   	ret = pwm_config(pwm, (pwm->period + 1) >> 1, pwm->period);
> -	if (ret < 0)
> +	if (ret < 0) {
> +		dev_err(&pdev->dev, "failed to configure pwm: %d\n", ret);
>   		return ret;
> +	}
>   
>   	init.name = "pwm-clock";
>   	init.ops = &clk_pwm_ops;
> @@ -78,11 +82,18 @@ int clk_pwm_probe(struct platform_device *pdev)
>   	clk_pwm->pwm = pwm;
>   	clk_pwm->hw.init = &init;
>   	clk = devm_clk_register(&pdev->dev, &clk_pwm->hw);
> -	if (IS_ERR(clk))
> +	if (IS_ERR(clk)) {
> +		dev_err(&pdev->dev, "failed to register clock: %ld\n",
> +			PTR_ERR(clk));
>   		return PTR_ERR(clk);
> +	}
>   
> -	return of_clk_add_provider(pdev->dev.of_node,
> -				   of_clk_src_simple_get, clk);
> +	ret = of_clk_add_provider(pdev->dev.of_node,
> +				  of_clk_src_simple_get, clk);
> +	if (ret)
> +		dev_err(&pdev->dev, "failed to add clock provider: %d\n", ret);
> +
> +	return ret;
>   }
>   
>   int clk_pwm_remove(struct platform_device *pdev)
>
>


      reply	other threads:[~2014-12-09 13:09 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-11-03  9:31 [PATCH v2] clk: Add PWM clock driver Philipp Zabel
2014-11-25  7:07 ` Mike Turquette
2014-11-25  7:56   ` Philipp Zabel
2014-12-04 18:00 ` Janusz Użycki
2014-12-08 20:03   ` Janusz Użycki
2014-12-09  9:15     ` Philipp Zabel
2014-12-09 13:09       ` Janusz Użycki [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=5486F498.30309@elproma.com.pl \
    --to=j.uzycki@elproma.com.pl \
    --cc=devicetree@vger.kernel.org \
    --cc=galak@codeaurora.org \
    --cc=ijc+devicetree@hellion.org.uk \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pwm@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=mturquette@linaro.org \
    --cc=p.zabel@pengutronix.de \
    --cc=pawel.moll@arm.com \
    --cc=robh+dt@kernel.org \
    --cc=thierry.reding@gmail.com \
    /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