This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revision | |||
resources:tools-software:linux-drivers:iio-dds:ad9834 [27 Apr 2016 17:14] – [Example platform device initialization] Fix typo Lars-Peter Clausen | resources:tools-software:linux-drivers:iio-dds:ad9834 [15 Mar 2019 08:14] (current) – change platform to DT Alexandru Ardelean | ||
---|---|---|---|
Line 37: | Line 37: | ||
| include | [[git.linux.org> | | include | [[git.linux.org> | ||
- | ====== Example | + | ====== Example device-tree ====== |
- | {{page> | + | In the example below, it's assumed that **spi0** is the SPI controller to which the AD983X is attached to. Typically, these are defined in the board device-tree where the AD983X is attached to. |
- | The reference voltage may vary between boards and models. The platform_data for the device' | + | <code c> |
- | <source trunk/ | + | & |
+ | #address-cells = < | ||
+ | # | ||
+ | status = " | ||
- | <code c> | + | ad9833@0{ |
- | /** | + | # |
- | * struct ad9834_platform_data - platform specific information | + | compatible = " |
- | | + | reg = <0>; |
- | * @freq0: | + | spi-max-frequency |
- | * @freq1: | + | spi-cpol; |
- | * @phase0: | + | clocks |
- | * @phase1: | + | vcc-supply |
- | * @en_div2: | + | }; |
- | * @en_signbit_msb_out: | + | }; |
- | * SIGN BIT OUT pin. en_div2 controls whether it is the MSB | + | |
- | * or MSB/2 that is output. if en_signbit_msb_out=false, | + | |
- | * the on-board comparator is connected to SIGN BIT OUT | + | |
- | */ | + | |
- | + | ||
- | struct ad9834_platform_data ad9834_pdata = { | + | |
- | .mclk = 75000000, | + | |
- | .freq0 | + | |
- | .freq1 = 5000000, | + | |
- | .phase0 | + | |
- | .phase1 | + | |
- | .en_div2 = false, | + | |
- | .en_signbit_msb_out = false, | + | |
- | }; | + | |
</ | </ | ||
- | {{page> | + | This example also references a regulator (vcc-supply) and a clock (osc). These can be left out, in which case it's assumed they are somehow hard-wired on the board to a proper voltage supply and clock source. |
- | Depending on the DDS IC used, you may need to set the modalias accordingly, matching your part name. | + | The **compabtible** string can be any of the following: |
- | It may also required to adjust max_speed_hz. Please consult the datasheet, for maximum spi clock supported by the device in question. | + | * adi,ad9833 |
+ | * adi,ad9834 | ||
+ | * adi,ad9837 | ||
+ | * adi,ad9838 | ||
- | <code c> | + | Note that, the *adi,* prefix can be omitted and this still works. It is preferred to be added to avoid any potential collisions with other drivers from other vendors. |
- | static struct spi_board_info board_spi_board_info[] __initdata = { | + | |
- | #if defined(CONFIG_AD9834) \ | + | However, the voltage supply |
- | || defined(CONFIG_AD9834_MODULE) | + | See example below: |
- | { | + | |
- | .modalias = " | + | |
- | .max_speed_hz = 1000000, /* max spi clock (SCK) speed in HZ */ | + | |
- | .bus_num = 0, | + | |
- | .chip_select = 3, /* CS, change it for your board */ | + | |
- | .platform_data = &ad9834_pdata, | + | |
- | .mode = SPI_MODE_2, | + | |
- | }, | + | |
- | #endif | + | |
- | }; | + | |
- | </ | + | |
<code c> | <code c> | ||
- | static int __init board_init(void) | + | / { |
- | { | + | vcc: fixedregulator@0 |
- | [--snip--] | + | compatible = " |
+ | regulator-name = "fixed-supply"; | ||
+ | regulator-min-microvolt = < | ||
+ | regulator-max-microvolt = < | ||
+ | regulator-boot-on; | ||
+ | }; | ||
- | spi_register_board_info(board_spi_board_info, | + | osc: oscillator { |
+ | # | ||
+ | compatible = " | ||
+ | clock-frequency = < | ||
+ | }; | ||
+ | }; | ||
+ | </ | ||
- | [--snip--] | + | This assumes that the board has the chips & drivers to generate voltages like this & clock frequencies. |
- | + | ||
- | return 0; | + | |
- | } | + | |
- | arch_initcall(board_init); | + | |
- | </ | + | |
====== Adding Linux driver support ====== | ====== Adding Linux driver support ====== |