Home | History | Annotate | Download | only in linux
      1 /*
      2  * Definitions for akm8976 compass chip.
      3  */
      4 #ifndef AKM8976_H
      5 #define AKM8976_H
      6 
      7 #include <linux/ioctl.h>
      8 
      9 /* Compass device dependent definition */
     10 #define AKECS_MODE_MEASURE	0x00	/* Starts measurement. Please use AKECS_MODE_MEASURE_SNG */
     11 					/* or AKECS_MODE_MEASURE_SEQ instead of this. */
     12 #define AKECS_MODE_PFFD		0x01	/* Start pedometer and free fall detect. */
     13 #define AKECS_MODE_E2P_READ	0x02	/* E2P access mode (read). */
     14 #define AKECS_MODE_POWERDOWN	0x03	/* Power down mode */
     15 
     16 #define AKECS_MODE_MEASURE_SNG	0x10	/* Starts single measurement */
     17 #define AKECS_MODE_MEASURE_SEQ	0x11	/* Starts sequential measurement */
     18 
     19 /* Default register settings */
     20 #define CSPEC_AINT		0x01	/* Amplification for acceleration sensor */
     21 #define CSPEC_SNG_NUM		0x01	/* Single measurement mode */
     22 #define CSPEC_SEQ_NUM		0x02	/* Sequential measurement mode */
     23 #define CSPEC_SFRQ_32		0x00	/* Measurement frequency: 32Hz */
     24 #define CSPEC_SFRQ_64		0x01	/* Measurement frequency: 64Hz */
     25 #define CSPEC_MCS		0x07	/* Clock frequency */
     26 #define CSPEC_MKS		0x01	/* Clock type: CMOS level */
     27 #define CSPEC_INTEN		0x01	/* Interruption pin enable: Enable */
     28 
     29 #define RBUFF_SIZE		31	/* Rx buffer size */
     30 #define MAX_CALI_SIZE	0x1000U	/* calibration buffer size */
     31 
     32 /* AK8976A register address */
     33 #define AKECS_REG_ST			0xC0
     34 #define AKECS_REG_TMPS			0xC1
     35 #define AKECS_REG_MS1			0xE0
     36 #define AKECS_REG_MS2			0xE1
     37 #define AKECS_REG_MS3			0xE2
     38 
     39 #define AKMIO				0xA1
     40 
     41 /* IOCTLs for AKM library */
     42 #define ECS_IOCTL_INIT                  _IO(AKMIO, 0x01)
     43 #define ECS_IOCTL_WRITE                 _IOW(AKMIO, 0x02, char[5])
     44 #define ECS_IOCTL_READ                  _IOWR(AKMIO, 0x03, char[5])
     45 #define ECS_IOCTL_RESET      	          _IO(AKMIO, 0x04)
     46 #define ECS_IOCTL_INT_STATUS            _IO(AKMIO, 0x05)
     47 #define ECS_IOCTL_FFD_STATUS            _IO(AKMIO, 0x06)
     48 #define ECS_IOCTL_SET_MODE              _IOW(AKMIO, 0x07, short)
     49 #define ECS_IOCTL_GETDATA               _IOR(AKMIO, 0x08, char[RBUFF_SIZE+1])
     50 #define ECS_IOCTL_GET_NUMFRQ            _IOR(AKMIO, 0x09, char[2])
     51 #define ECS_IOCTL_SET_PERST             _IO(AKMIO, 0x0A)
     52 #define ECS_IOCTL_SET_G0RST             _IO(AKMIO, 0x0B)
     53 #define ECS_IOCTL_SET_YPR               _IOW(AKMIO, 0x0C, short[12])
     54 #define ECS_IOCTL_GET_OPEN_STATUS       _IOR(AKMIO, 0x0D, int)
     55 #define ECS_IOCTL_GET_CLOSE_STATUS      _IOR(AKMIO, 0x0E, int)
     56 #define ECS_IOCTL_GET_CALI_DATA         _IOR(AKMIO, 0x0F, char[MAX_CALI_SIZE])
     57 #define ECS_IOCTL_GET_DELAY             _IOR(AKMIO, 0x30, short)
     58 
     59 /* IOCTLs for APPs */
     60 #define ECS_IOCTL_APP_SET_MODE		_IOW(AKMIO, 0x10, short)
     61 #define ECS_IOCTL_APP_SET_MFLAG		_IOW(AKMIO, 0x11, short)
     62 #define ECS_IOCTL_APP_GET_MFLAG		_IOW(AKMIO, 0x12, short)
     63 #define ECS_IOCTL_APP_SET_AFLAG		_IOW(AKMIO, 0x13, short)
     64 #define ECS_IOCTL_APP_GET_AFLAG		_IOR(AKMIO, 0x14, short)
     65 #define ECS_IOCTL_APP_SET_TFLAG		_IOR(AKMIO, 0x15, short)
     66 #define ECS_IOCTL_APP_GET_TFLAG		_IOR(AKMIO, 0x16, short)
     67 #define ECS_IOCTL_APP_RESET_PEDOMETER   _IO(AKMIO, 0x17)
     68 #define ECS_IOCTL_APP_SET_DELAY		_IOW(AKMIO, 0x18, short)
     69 #define ECS_IOCTL_APP_GET_DELAY		ECS_IOCTL_GET_DELAY
     70 #define ECS_IOCTL_APP_SET_MVFLAG	_IOW(AKMIO, 0x19, short) /* Set raw magnetic vector flag */
     71 #define ECS_IOCTL_APP_GET_MVFLAG	_IOR(AKMIO, 0x1A, short) /* Get raw magnetic vector flag */
     72 
     73 /* IOCTLs for pedometer */
     74 #define ECS_IOCTL_SET_STEP_CNT          _IOW(AKMIO, 0x20, short)
     75 
     76 /* Default GPIO setting */
     77 #define ECS_RST		146	/*MISC4, bit2 */
     78 #define ECS_CLK_ON	155	/*MISC5, bit3 */
     79 #define ECS_INTR	161	/*INT2, bit1 */
     80 
     81 struct akm8976_platform_data {
     82 	int reset;
     83 	int clk_on;
     84 	int intr;
     85 };
     86 extern char *get_akm_cal_ram(void);
     87 
     88 #endif
     89 
     90