Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
ad9834.h
Go to the documentation of this file.
1 /*
2  * AD9833/AD9834/AD9837/AD9838 SPI DDS driver
3  *
4  * Copyright 2010-2011 Analog Devices Inc.
5  *
6  * Licensed under the GPL-2.
7  */
8 #ifndef IIO_DDS_AD9834_H_
9 #define IIO_DDS_AD9834_H_
10 
11 /* Registers */
12 
13 #define AD9834_REG_CMD (0 << 14)
14 #define AD9834_REG_FREQ0 (1 << 14)
15 #define AD9834_REG_FREQ1 (2 << 14)
16 #define AD9834_REG_PHASE0 (6 << 13)
17 #define AD9834_REG_PHASE1 (7 << 13)
18 
19 /* Command Control Bits */
20 
21 #define AD9834_B28 (1 << 13)
22 #define AD9834_HLB (1 << 12)
23 #define AD9834_FSEL (1 << 11)
24 #define AD9834_PSEL (1 << 10)
25 #define AD9834_PIN_SW (1 << 9)
26 #define AD9834_RESET (1 << 8)
27 #define AD9834_SLEEP1 (1 << 7)
28 #define AD9834_SLEEP12 (1 << 6)
29 #define AD9834_OPBITEN (1 << 5)
30 #define AD9834_SIGN_PIB (1 << 4)
31 #define AD9834_DIV2 (1 << 3)
32 #define AD9834_MODE (1 << 1)
33 
34 #define AD9834_FREQ_BITS 28
35 #define AD9834_PHASE_BITS 12
36 
37 #define RES_MASK(bits) ((1 << (bits)) - 1)
38 
53 struct ad9834_state {
54  struct spi_device *spi;
55  struct regulator *reg;
56  unsigned int mclk;
57  unsigned short control;
58  unsigned short devid;
60  struct spi_message msg;
63 
64  /*
65  * DMA (thus cache coherency maintenance) requires the
66  * transfer buffers to live in their own cache lines.
67  */
68  unsigned short data ____cacheline_aligned;
69  unsigned short freq_data[2] ;
70 };
71 
72 
73 /*
74  * TODO: struct ad7887_platform_data needs to go into include/linux/iio
75  */
76 
92  unsigned int mclk;
93  unsigned int freq0;
94  unsigned int freq1;
95  unsigned short phase0;
96  unsigned short phase1;
97  bool en_div2;
99 };
100 
110 };
111 
112 #endif /* IIO_DDS_AD9834_H_ */