This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

AM5718: am5718idk and ad4350 interfacing over spi2

Part Number: AM5718


Hi,

I want to cntrol ad4350 through user space in linux. I am having processor sdk linux for am5718idk board version 06.03.00.

The driver information provided by analof devices is asking us to do.

platform device initialization

struct adf4350_platform_data {
	unsigned long		clkin;
	unsigned long		channel_spacing;
	unsigned long long	power_up_frequency;
 
	unsigned short		ref_div_factor; /* 10-bit R counter */
	bool			ref_doubler_en;
	bool			ref_div2_en;
 
	unsigned		r2_user_settings;
	unsigned		r3_user_settings;
	unsigned		r4_user_settings;
	int			gpio_lock_detect;
};


Declaring SPI slave devices

static struct spi_board_info board_spi_board_info[] __initdata = {
#if defined(CONFIG_ADF4350) || defined(CONFIG_ADF4350_MODULE)
	{
		.modalias = "adf4350",
		.max_speed_hz = 1000000,     /* max spi clock (SCK) speed in HZ */
		.bus_num = 0,
		.chip_select = GPIO_PF10 + MAX_CTRL_CS,	/* GPIO controlled SSEL */
		.platform_data = NULL, /* No spi_driver specific config */
		.mode = SPI_MODE_0,
	},
#endif
};

static int __init board_init(void)
{
	[--snip--]
 
	spi_register_board_info(board_spi_board_info, ARRAY_SIZE(board_spi_board_info));
 
	[--snip--]
 
	return 0;
}
arch_initcall(board_init);

Devicetree bindings

Example:
		lo_pll0_rx_adf4351: adf4351-rx-lpc@4 {
			compatible = "adi,adf4351";
			reg = <4>;
			spi-max-frequency = <10000000>;
			clocks = <&clk0_ad9523 9>;
			clock-names = "clkin";
			adi,channel-spacing = <10000>;
			adi,power-up-frequency = <2400000000>;
			adi,phase-detector-polarity-positive-enable;
			adi,charge-pump-current = <2500>;
			adi,output-power = <3>;
			adi,mute-till-lock-enable;
		};

Adding Linux driver support

Linux Kernel Configuration
	Device Drivers  --->
		<*>     Industrial I/O support --->
		    --- Industrial I/O support
		    -*-   Enable ring buffer support within IIO
		    -*-     Industrial I/O lock free software ring
		    -*-   Enable triggered sampling support

			          *** Phase-Locked Loop (PLL) frequency synthesizers ***

		    [--snip--]
			    <*>   Analog Devices ADF4350/ADF4351 Wideband Synthesizers
		    [--snip--]




B
ut in AM5718idk where to do that. I am not able to get where to do all above modifications. Kindly help me out.
I think I need to modify the am57xx-idk-commom.dtsi file by adding a node mcspi2. What should be the parameters for Mcspi2 node to control ad4350 synthesizer.
The option is not coming in menuconfig to select AD4350 synthesizer.

  • Hi Khushboo,

      │ Symbol: ADF4350 [=m]                                                                                                                                                                                │  
      │ Type  : tristate                                                                                                                                                                                    │  
      │ Prompt: Analog Devices ADF4350/ADF4351 Wideband Synthesizers                                                                                                                                        │  
      │   Location:                                                                                                                                                                                         │  
      │     -> Device Drivers                                                                                                                                                                               │  
      │       -> Industrial I/O support (IIO [=m])                                                                                                                                                          │  
      │         -> Frequency Synthesizers DDS/PLL                                                                                                                                                           │  
      │ (1)       -> Phase-Locked Loop (PLL) frequency synthesizers                                                                                                                                         │  
      │   Defined at drivers/iio/frequency/Kconfig:31                                                                                                                                                       │  
      │   Depends on: IIO [=m] && SPI [=y]

    Just try a make menuconfig in the ti-processor-sdk-linux-am57xx-evm-06.03.00.106/board-support/linux-4.19.94+gitAUTOINC+be5389fd85-gbe5389fd85
    directory.

    You can search for ADF4350.

    We will need more information on the Device tree from Analog Devices. Can they suggest
    some dts file example where it has been used on other evms? The example mentioned above
    is from documentation but a concrete working device tree entry in a dts example will be more helpful.

    Regards,
    Keerthy

  • Thanku for your reply. I will contact them and get back to you.

  • Hi, 

    / {

                clocks {

                            adf4351_clkin: clock@1 {

                                        compatible = "fixed-clock";

                                        clock-frequency = <25000000>;

                                        clock-output-names = "refclk";

                                        #clock-cells = <0>;

                            };

                };

    };

    &pmod_spi {

                            lo_pll0_tx_adf4351: adf4351-udc-tx-pmod@0 {

                                        compatible = "adi,adf4351";

                                        reg = <0>;

                                        spi-max-frequency = <10000000>;

                                        clocks = <&adf4351_clkin>;

                                        clock-names = "clkin";

                                        adi,channel-spacing = <1000000>;

                                        adi,power-up-frequency = <370000000>;

                                        adi,phase-detector-polarity-positive-enable;

                                        adi,charge-pump-current = <2500>;

                                        adi,output-power = <3>;

                                        adi,mute-till-lock-enable;

                                        adi,muxout-select = <6>;

                            };

    This is the working code they provided. Kindly help me out to integrate with AM5718 IDK board

  • Hi Khushboo,

    Our recommendation is to try with McSPI.

    Check the McSPI device tree bindings document: 
    Documentation/devicetree/bindings/spi/omap-spi.txt

    ADF4350:

    Driver is at: drivers/iio/frequency/adf4350.c
    Doc at: Documentation/devicetree/bindings/iio/frequency/adf4350.txt

    For device tree example please look at:

    https://software-dl.ti.com/processor-sdk-linux/esd/docs/06_03_00_106/linux/Foundational_Components/Kernel/Kernel_Drivers/SPI.html

    &spi1 {
            status = "okay";
            pinctrl-names = "default";
            pinctrl-0 = <&spi1_pins_s0>;
            spidev@1 {
                    spi-max-frequency = <24000000>;
                    reg = <0>;
                    compatible = "rohm,dh2228fv";
            };
    };


    So spidev is an example node that needs to replaced with adf node like in the above example you have mentioned from ADI.


    Make sure that pinctrl is setup for the right spi instance that you plan to use.

    Best Regards,
    Keerthy