Re: [PATCH v2] Documentation: can: flexcan: Add flexcan clocks' information

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 11/12/18 9:10 AM, Pankaj Bansal wrote:
> The property clock-frequency is optional for device tree probe.  When
> it's absent, the flexcan driver will try to get the frequency from clk
> system by calling clk_get_rate.
> 
> But, the clk_get_rate requires that clocks and clock-names properties
> to be present in the flexcan node.
> Document the usage of these properties.
> 
> Signed-off-by: Pankaj Bansal <pankaj.bansal@xxxxxxx>
> ---
> 
> Notes:
>     V2:
>      - Added notes that mentioning clocks' phandles is preferred method
>        over mentioning clock-frequency
> 
>  .../bindings/net/can/fsl-flexcan.txt         | 37 ++++++++++++++++--
>  1 file changed, 34 insertions(+), 3 deletions(-)
> 
> diff --git a/Documentation/devicetree/bindings/net/can/fsl-flexcan.txt b/Documentation/devicetree/bindings/net/can/fsl-flexcan.txt
> index bfc0c433654f..e1f9cc17d818 100644
> --- a/Documentation/devicetree/bindings/net/can/fsl-flexcan.txt
> +++ b/Documentation/devicetree/bindings/net/can/fsl-flexcan.txt
> @@ -12,10 +12,29 @@ Required properties:
>  - reg : Offset and length of the register set for this device
>  - interrupts : Interrupt tuple for this device
>  
> -Optional properties:
> +The input clock is the one fed to the prescaler to generate the serial clock

Actually the "per" clock is used as the input for the pre-scaler to
generate the serial clock to generate the waveform:

> 		clock_freq = clk_get_rate(clk_per);


> +(Sclock). Serial Clock (Sclock), whose period defines the 'time quantum'
> +used to compose the CAN waveform. The input clock information can be given
> +in two formats
> +

On modern fsl/nxp ARM cores you actually need both clocks, the ipg and
the per clock. IIRC the ipg is needed to access the register space,
while the per is used to generate the waveform.

> +- clocks: phandle to the clocks feeding the SPI controller. Two can be given:

"SPI controller" should be CAN controller I suppose.

"Two _must_ be given", for this method of configuration.

> +  - "ipg": Oscillator Clock
> +  - "per": Peripheral Clock
> +- clock-names: Must contain the clock names described just above
> +Note : This method is preferred method.
> +
> + or
> +
> +- clock-frequency : The oscillator/peripheral clock frequency
> +  driving the flexcan device.
> +Note : Only on platforms where you don't have your clocks in the Device Tree,
> +       use "clock-frequency" (as a fallback).
>  
> -- clock-frequency : The oscillator frequency driving the flexcan device
> +The oscillator clock should be selected whenever a tight tolerance (up to 0.1%)
> +is required in the CAN bus timing. The crystal oscillator clock has better
> +jitter performance than the peripheral clock.

Using the clock-frequency attribute is only useful if the kernel doesn't
support the generic clock framework for your SoC. Then it's up to
someone else (i.e. not the flexcan driver) to turn on _all_ needed
clocks for the CAN core to work, select whatever clock is preferred to
be the input clock for the pre-scaler and add exactly that clock's
frequency to the "clock-frequency" attribute in the device tree.

>  
> +Optional properties:
>  - xceiver-supply: Regulator that powers the CAN transceiver
>  
>  - big-endian: This means the registers of FlexCAN controller are big endian.
> @@ -25,11 +44,23 @@ Optional properties:
>                endian.
>  
>  Example:
> +	can0: can@2180000 {
> +		compatible = "fsl,lx2160ar1-flexcan";
> +		reg = <0x0 0x2180000 0x0 0x10000>;
> +		interrupts = <GIC_SPI 21 IRQ_TYPE_LEVEL_HIGH>;
> +		clocks = <&clockgen 4 7>, <&clockgen 4 7>; // preferred method
> +		clock-names = "ipg", "per";
> +		status = "disabled";
> +	};
>  
>  	can@1c000 {
>  		compatible = "fsl,p1010-flexcan";
>  		reg = <0x1c000 0x1000>;
>  		interrupts = <48 0x2>;
>  		interrupt-parent = <&mpic>;
> -		clock-frequency = <200000000>; // filled in by bootloader
> +		clock-frequency = <200000000>; // fallback method if no clocks
> +					       // in device tree. can be filled
> +					       // by bootloader
> +		big-endian;
>  	};
> +
> 

Marc

-- 
Pengutronix e.K.                  | Marc Kleine-Budde           |
Industrial Linux Solutions        | Phone: +49-231-2826-924     |
Vertretung West/Dortmund          | Fax:   +49-5121-206917-5555 |
Amtsgericht Hildesheim, HRA 2686  | http://www.pengutronix.de   |

Attachment: signature.asc
Description: OpenPGP digital signature


[Index of Archives]     [Automotive Discussions]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [eCos]     [Asterisk Internet PBX]     [Linux API]     [CAN Bus]

  Powered by Linux